mirror of https://github.com/M66B/FairEmail.git
Added option to launch adjacent portrait/landscape
This commit is contained in:
parent
fbb9dab83e
commit
c34e23ef48
|
@ -248,7 +248,8 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
private SwitchCompat swThreadByRef;
|
||||
private SwitchCompat swMdn;
|
||||
private SwitchCompat swAppChooser;
|
||||
private SwitchCompat swAdjacent;
|
||||
private SwitchCompat swAdjacentPortrait;
|
||||
private SwitchCompat swAdjacentLandscape;
|
||||
private SwitchCompat swDeleteConfirmation;
|
||||
private SwitchCompat swDmarcViewer;
|
||||
private EditText etKeywords;
|
||||
|
@ -314,7 +315,7 @@ 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", "delete_confirmation", "global_keywords", "test_iab"
|
||||
"app_chooser", "adjacent_portrait", "adjacent_landscape", "delete_confirmation", "global_keywords", "test_iab"
|
||||
};
|
||||
|
||||
private final static String[] RESET_QUESTIONS = new String[]{
|
||||
|
@ -511,7 +512,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);
|
||||
swAdjacent = view.findViewById(R.id.swAdjacent);
|
||||
swAdjacentPortrait = view.findViewById(R.id.swAdjacentPortrait);
|
||||
swAdjacentLandscape = view.findViewById(R.id.swAdjacentLandscape);
|
||||
swDeleteConfirmation = view.findViewById(R.id.swDeleteConfirmation);
|
||||
swDmarcViewer = view.findViewById(R.id.swDmarcViewer);
|
||||
etKeywords = view.findViewById(R.id.etKeywords);
|
||||
|
@ -1944,10 +1946,17 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
|
|||
}
|
||||
});
|
||||
|
||||
swAdjacent.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
swAdjacentPortrait.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("adjacent", checked).apply();
|
||||
prefs.edit().putBoolean("adjacent_portrait", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
swAdjacentLandscape.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("adjacent_landscape", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -2733,7 +2742,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));
|
||||
swAdjacent.setChecked(prefs.getBoolean("adjacent", false));
|
||||
swAdjacentPortrait.setChecked(prefs.getBoolean("adjacent_portrait", false));
|
||||
swAdjacentLandscape.setChecked(prefs.getBoolean("adjacent_landscape", false));
|
||||
swDeleteConfirmation.setChecked(prefs.getBoolean("delete_confirmation", true));
|
||||
swDmarcViewer.setChecked(Helper.isComponentEnabled(getContext(), ActivityDmarc.class));
|
||||
etKeywords.setText(prefs.getString("global_keywords", null));
|
||||
|
|
|
@ -1008,12 +1008,7 @@ public class Helper {
|
|||
intent.setDataAndTypeAndNormalize(uri, type);
|
||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
|
||||
// https://developer.android.com/guide/topics/large-screens/multi-window-support#launch_adjacent
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean adjacent = prefs.getBoolean("adjacent", false);
|
||||
if (adjacent &&
|
||||
context instanceof ActivityView &&
|
||||
!((ActivityView) context).isSplit())
|
||||
if (launchAdjacent(context))
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
if (!TextUtils.isEmpty(name))
|
||||
|
@ -1127,11 +1122,7 @@ public class Helper {
|
|||
if (task)
|
||||
view.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
// https://developer.android.com/guide/topics/large-screens/multi-window-support#launch_adjacent
|
||||
boolean adjacent = prefs.getBoolean("adjacent", false);
|
||||
if (adjacent &&
|
||||
context instanceof ActivityView &&
|
||||
!((ActivityView) context).isSplit())
|
||||
if (launchAdjacent(context))
|
||||
view.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
if ("chooser".equals(open_with_pkg) && !open_with_tabs) {
|
||||
|
@ -1212,6 +1203,14 @@ public class Helper {
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean launchAdjacent(Context context) {
|
||||
// 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);
|
||||
}
|
||||
|
||||
static boolean customTabsWarmup(Context context) {
|
||||
if (context == null)
|
||||
return false;
|
||||
|
|
|
@ -2380,16 +2380,39 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/swMdn"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swAdjacent"
|
||||
<TextView
|
||||
android:id="@+id/tvSideBySide"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:checked="true"
|
||||
android:text="@string/title_advanced_adjacent"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swAppChooser"
|
||||
app:layout_constraintTop_toBottomOf="@id/swAppChooser" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swAdjacentPortrait"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_portrait_mode"
|
||||
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/swAdjacentLandscape"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_landscape_mode"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swAdjacentPortrait"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
|
@ -2400,7 +2423,7 @@
|
|||
android:text="@string/title_advanced_delete_confirmation"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swAdjacent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swAdjacentLandscape"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<TextView
|
||||
|
|
|
@ -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_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>
|
||||
<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_dmarc_viewer" translatable="false">DMARC viewer</string>
|
||||
|
|
Loading…
Reference in New Issue