Added button to go to Android app settings

pull/180/head
M66B 4 years ago
parent 54b184d3b4
commit 500d52c89f

@ -28,7 +28,9 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.graphics.Paint; import android.graphics.Paint;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.provider.Settings;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -82,6 +84,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private SwitchCompat swCleanupAttachments; private SwitchCompat swCleanupAttachments;
private Button btnCleanup; private Button btnCleanup;
private TextView tvLastCleanup; private TextView tvLastCleanup;
private Button btnApp;
private Button btnMore; private Button btnMore;
private TextView tvProcessors; private TextView tvProcessors;
@ -137,6 +140,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swCleanupAttachments = view.findViewById(R.id.swCleanupAttachments); swCleanupAttachments = view.findViewById(R.id.swCleanupAttachments);
btnCleanup = view.findViewById(R.id.btnCleanup); btnCleanup = view.findViewById(R.id.btnCleanup);
tvLastCleanup = view.findViewById(R.id.tvLastCleanup); tvLastCleanup = view.findViewById(R.id.tvLastCleanup);
btnApp = view.findViewById(R.id.btnApp);
btnMore = view.findViewById(R.id.btnMore); btnMore = view.findViewById(R.id.btnMore);
tvProcessors = view.findViewById(R.id.tvProcessors); tvProcessors = view.findViewById(R.id.tvProcessors);
@ -308,6 +312,20 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
} }
}); });
final Intent app = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
app.setData(Uri.parse("package:" + getContext().getPackageName()));
btnApp.setEnabled(app.resolveActivity(getContext().getPackageManager()) != null);
btnApp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
getContext().startActivity(app);
} catch (Throwable ex) {
ToastEx.makeText(getContext(), getString(R.string.title_no_viewer, app.getAction()), Toast.LENGTH_LONG).show();
}
}
});
btnMore.setOnClickListener(new View.OnClickListener() { btnMore.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {

@ -331,6 +331,16 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvCleanupHint" /> app:layout_constraintTop_toBottomOf="@id/tvCleanupHint" />
<Button
android:id="@+id/btnApp"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_app"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvLastCleanup" />
<Button <Button
android:id="@+id/btnMore" android:id="@+id/btnMore"
style="?android:attr/buttonStyleSmall" style="?android:attr/buttonStyleSmall"
@ -339,7 +349,7 @@
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:text="@string/title_advanced_more" android:text="@string/title_advanced_more"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvLastCleanup" /> app:layout_constraintTop_toBottomOf="@id/btnApp" />
<eu.faircode.email.FixedTextView <eu.faircode.email.FixedTextView
android:id="@+id/tvProcessors" android:id="@+id/tvProcessors"

@ -461,6 +461,7 @@
<string name="title_advanced_cleanup_attachments">Delete attachments of old messages</string> <string name="title_advanced_cleanup_attachments">Delete attachments of old messages</string>
<string name="title_advanced_cleanup">Cleanup</string> <string name="title_advanced_cleanup">Cleanup</string>
<string name="title_advanced_last_cleanup">Last cleanup: %1$s</string> <string name="title_advanced_last_cleanup">Last cleanup: %1$s</string>
<string name="title_advanced_app">App settings</string>
<string name="title_advanced_more">More options</string> <string name="title_advanced_more">More options</string>
<string name="title_advanced_processors" translatable="false">Processors: %1$d</string> <string name="title_advanced_processors" translatable="false">Processors: %1$d</string>
<string name="title_advanced_memory_class" translatable="false">Memory class: %1$s</string> <string name="title_advanced_memory_class" translatable="false">Memory class: %1$s</string>

Loading…
Cancel
Save