Added debug option to disable app chooser

pull/213/head
M66B 1 year ago
parent bacc3b634e
commit 261445ac4a

@ -240,6 +240,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private SwitchCompat swDupMsgId; private SwitchCompat swDupMsgId;
private SwitchCompat swThreadByRef; private SwitchCompat swThreadByRef;
private SwitchCompat swMdn; private SwitchCompat swMdn;
private SwitchCompat swAppChooser;
private SwitchCompat swDeleteConfirmation; private SwitchCompat swDeleteConfirmation;
private EditText etKeywords; private EditText etKeywords;
private SwitchCompat swTestIab; private SwitchCompat swTestIab;
@ -303,7 +304,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
"max_backoff_power", "logarithmic_backoff", "max_backoff_power", "logarithmic_backoff",
"exact_alarms", "exact_alarms",
"native_dkim", "native_arc", "native_arc_whitelist", "native_dkim", "native_arc", "native_arc_whitelist",
"infra", "tld_flags", "dup_msgids", "thread_byref", "mdn", "delete_confirmation", "global_keywords", "test_iab" "infra", "tld_flags", "dup_msgids", "thread_byref", "mdn", "app_chooser", "delete_confirmation", "global_keywords", "test_iab"
}; };
private final static String[] RESET_QUESTIONS = new String[]{ private final static String[] RESET_QUESTIONS = new String[]{
@ -492,6 +493,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swDupMsgId = view.findViewById(R.id.swDupMsgId); swDupMsgId = view.findViewById(R.id.swDupMsgId);
swThreadByRef = view.findViewById(R.id.swThreadByRef); swThreadByRef = view.findViewById(R.id.swThreadByRef);
swMdn = view.findViewById(R.id.swMdn); swMdn = view.findViewById(R.id.swMdn);
swAppChooser = view.findViewById(R.id.swAppChooser);
swDeleteConfirmation = view.findViewById(R.id.swDeleteConfirmation); swDeleteConfirmation = view.findViewById(R.id.swDeleteConfirmation);
etKeywords = view.findViewById(R.id.etKeywords); etKeywords = view.findViewById(R.id.etKeywords);
swTestIab = view.findViewById(R.id.swTestIab); swTestIab = view.findViewById(R.id.swTestIab);
@ -1859,6 +1861,13 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
} }
}); });
swAppChooser.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("app_chooser", checked).apply();
}
});
swDeleteConfirmation.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swDeleteConfirmation.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -2612,6 +2621,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swDupMsgId.setChecked(prefs.getBoolean("dup_msgids", false)); swDupMsgId.setChecked(prefs.getBoolean("dup_msgids", false));
swThreadByRef.setChecked(prefs.getBoolean("thread_byref", true)); swThreadByRef.setChecked(prefs.getBoolean("thread_byref", true));
swMdn.setChecked(prefs.getBoolean("mdn", swExperiments.isChecked())); swMdn.setChecked(prefs.getBoolean("mdn", swExperiments.isChecked()));
swAppChooser.setChecked(prefs.getBoolean("app_chooser", true));
swDeleteConfirmation.setChecked(prefs.getBoolean("delete_confirmation", true)); swDeleteConfirmation.setChecked(prefs.getBoolean("delete_confirmation", true));
etKeywords.setText(prefs.getString("global_keywords", null)); etKeywords.setText(prefs.getString("global_keywords", null));
swTestIab.setChecked(prefs.getBoolean("test_iab", false)); swTestIab.setChecked(prefs.getBoolean("test_iab", false));

@ -940,14 +940,18 @@ public class Helper {
} }
static Intent getChooser(Context context, Intent intent) { static Intent getChooser(Context context, Intent intent) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean app_chooser = prefs.getBoolean("app_chooser", true);
if (!app_chooser)
return intent;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
PackageManager pm = context.getPackageManager(); PackageManager pm = context.getPackageManager();
if (pm.queryIntentActivities(intent, 0).size() == 1) if (pm.queryIntentActivities(intent, 0).size() == 1)
return intent; return intent;
else }
return Intent.createChooser(intent, context.getString(R.string.title_select_app));
} else return Intent.createChooser(intent, context.getString(R.string.title_select_app));
return Intent.createChooser(intent, context.getString(R.string.title_select_app));
} }
static void share(Context context, File file, String type, String name) { static void share(Context context, File file, String type, String name) {

@ -2283,6 +2283,18 @@
app:layout_constraintTop_toBottomOf="@id/swThreadByRef" app:layout_constraintTop_toBottomOf="@id/swThreadByRef"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swAppChooser"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_app_chooser"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swMdn"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swDeleteConfirmation" android:id="@+id/swDeleteConfirmation"
android:layout_width="0dp" android:layout_width="0dp"
@ -2291,7 +2303,7 @@
android:text="@string/title_advanced_delete_confirmation" android:text="@string/title_advanced_delete_confirmation"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swMdn" app:layout_constraintTop_toBottomOf="@id/swAppChooser"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<TextView <TextView

@ -902,6 +902,7 @@
<string name="title_advanced_dup_msgid" translatable="false">Duplicates by message ID</string> <string name="title_advanced_dup_msgid" translatable="false">Duplicates by message ID</string>
<string name="title_advanced_thread_by_ref" translatable="false">Thread by common reference</string> <string name="title_advanced_thread_by_ref" translatable="false">Thread by common reference</string>
<string name="title_advanced_mdn" translatable="false">Process MDNs</string> <string name="title_advanced_mdn" translatable="false">Process MDNs</string>
<string name="title_advanced_app_chooser" translatable="false">Use Android app chooser</string>
<string name="title_advanced_delete_confirmation" translatable="false">Permanent deletion confirmation</string> <string name="title_advanced_delete_confirmation" translatable="false">Permanent deletion confirmation</string>
<string name="title_advanced_deletion_confirmation_hint" translatable="false">If you turn this off, please do not complain if you accidentally delete messages irreversibly</string> <string name="title_advanced_deletion_confirmation_hint" translatable="false">If you turn this off, please do not complain if you accidentally delete messages irreversibly</string>
<string name="title_advanced_global_keywords" translatable="false">Global keywords</string> <string name="title_advanced_global_keywords" translatable="false">Global keywords</string>

Loading…
Cancel
Save