Added options to enable opening links/documents adjacent

pull/214/head
M66B 1 year ago
parent c34e23ef48
commit 2e59220e0e

@ -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));

@ -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) {

@ -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" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swAdjacentLinks"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_adjacent_links"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSideBySide"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swAdjacentDocuments"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_adjacent_documents"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAdjacentLinks"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swAdjacentPortrait"
android:layout_width="0dp"
@ -2400,7 +2426,7 @@
android:text="@string/title_advanced_portrait_mode"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSideBySide"
app:layout_constraintTop_toBottomOf="@id/swAdjacentDocuments"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

@ -920,6 +920,8 @@
<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_adjacent" translatable="false">Open side-by-side</string>
<string name="title_advanced_adjacent_links" translatable="false">Links</string>
<string name="title_advanced_adjacent_documents" translatable="false">Documents</string>
<string name="title_advanced_portrait_mode" translatable="false">Portrait mode</string>
<string name="title_advanced_landscape_mode" translatable="false">Landscape mode</string>
<string name="title_advanced_delete_confirmation" translatable="false">Permanent deletion confirmation</string>

Loading…
Cancel
Save