Added options to enable opening links/documents adjacent

This commit is contained in:
M66B
2023-10-23 10:06:50 +02:00
parent c34e23ef48
commit 2e59220e0e
4 changed files with 57 additions and 7 deletions

View File

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