diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java index 4f8f38108d..752ed6f3fb 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java @@ -248,6 +248,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc private SwitchCompat swThreadByRef; private SwitchCompat swMdn; private SwitchCompat swAppChooser; + private SwitchCompat swAdjacentLinks; + private SwitchCompat swAdjacentDocuments; private SwitchCompat swAdjacentPortrait; private SwitchCompat swAdjacentLandscape; private SwitchCompat swDeleteConfirmation; @@ -315,7 +317,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc "exact_alarms", "native_dkim", "native_arc", "native_arc_whitelist", "webp", "easy_correct", "infra", "tld_flags", "dup_msgids", "thread_byref", "mdn", - "app_chooser", "adjacent_portrait", "adjacent_landscape", "delete_confirmation", "global_keywords", "test_iab" + "app_chooser", "adjacent_links", "adjacent_documents", "adjacent_portrait", "adjacent_landscape", + "delete_confirmation", "global_keywords", "test_iab" }; private final static String[] RESET_QUESTIONS = new String[]{ @@ -512,6 +515,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc swThreadByRef = view.findViewById(R.id.swThreadByRef); swMdn = view.findViewById(R.id.swMdn); swAppChooser = view.findViewById(R.id.swAppChooser); + swAdjacentLinks = view.findViewById(R.id.swAdjacentLinks); + swAdjacentDocuments = view.findViewById(R.id.swAdjacentDocuments); swAdjacentPortrait = view.findViewById(R.id.swAdjacentPortrait); swAdjacentLandscape = view.findViewById(R.id.swAdjacentLandscape); swDeleteConfirmation = view.findViewById(R.id.swDeleteConfirmation); @@ -1946,6 +1951,20 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc } }); + swAdjacentLinks.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("adjacent_links", checked).apply(); + } + }); + + swAdjacentDocuments.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("adjacent_documents", checked).apply(); + } + }); + swAdjacentPortrait.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -2742,6 +2761,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc swThreadByRef.setChecked(prefs.getBoolean("thread_byref", true)); swMdn.setChecked(prefs.getBoolean("mdn", swExperiments.isChecked())); swAppChooser.setChecked(prefs.getBoolean("app_chooser", false)); + swAdjacentLinks.setChecked(prefs.getBoolean("adjacent_links", false)); + swAdjacentDocuments.setChecked(prefs.getBoolean("adjacent_documents", true)); swAdjacentPortrait.setChecked(prefs.getBoolean("adjacent_portrait", false)); swAdjacentLandscape.setChecked(prefs.getBoolean("adjacent_landscape", false)); swDeleteConfirmation.setChecked(prefs.getBoolean("delete_confirmation", true)); diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java index 6ba4c351de..e97cbfeb80 100644 --- a/app/src/main/java/eu/faircode/email/Helper.java +++ b/app/src/main/java/eu/faircode/email/Helper.java @@ -1008,7 +1008,7 @@ public class Helper { intent.setDataAndTypeAndNormalize(uri, type); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); - if (launchAdjacent(context)) + if (launchAdjacent(context, true)) intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT | Intent.FLAG_ACTIVITY_NEW_TASK); if (!TextUtils.isEmpty(name)) @@ -1122,7 +1122,7 @@ public class Helper { if (task) view.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - if (launchAdjacent(context)) + if (launchAdjacent(context, false)) view.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT | Intent.FLAG_ACTIVITY_NEW_TASK); if ("chooser".equals(open_with_pkg) && !open_with_tabs) { @@ -1203,12 +1203,13 @@ public class Helper { } } - private static boolean launchAdjacent(Context context) { + private static boolean launchAdjacent(Context context, boolean document) { // https://developer.android.com/guide/topics/large-screens/multi-window-support#launch_adjacent Configuration config = context.getResources().getConfiguration(); boolean portrait = (config.orientation == Configuration.ORIENTATION_PORTRAIT); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); - return prefs.getBoolean("adjacent_" + (portrait ? "portrait" : "landscape"), false); + return (prefs.getBoolean("adjacent_" + (portrait ? "portrait" : "landscape"), false) && + prefs.getBoolean("adjacent_" + (document ? "documents" : "links"), document)); } static boolean customTabsWarmup(Context context) { diff --git a/app/src/main/res/layout/fragment_options_misc.xml b/app/src/main/res/layout/fragment_options_misc.xml index 89d9ae2728..eaa101f50b 100644 --- a/app/src/main/res/layout/fragment_options_misc.xml +++ b/app/src/main/res/layout/fragment_options_misc.xml @@ -2386,11 +2386,37 @@ android:layout_height="wrap_content" android:layout_marginTop="12dp" android:text="@string/title_advanced_adjacent" - android:textAppearance="@style/TextAppearance.AppCompat.Medium" + android:textAppearance="@style/TextAppearance.AppCompat.Small" + android:textColor="?android:attr/textColorPrimary" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/swAppChooser" /> + + + + Process MDNs Use Android app chooser Open side-by-side + Links + Documents Portrait mode Landscape mode Permanent deletion confirmation