From f1e09b3385d176ab5acb00f81f1a5e610c5baac8 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 2 Jan 2020 22:00:52 +0100 Subject: [PATCH] Added setting for fixed nav menu landscape mode --- .../java/eu/faircode/email/DrawerLayoutEx.java | 6 +++++- .../java/eu/faircode/email/FragmentOptions.java | 2 +- .../eu/faircode/email/FragmentOptionsDisplay.java | 14 +++++++++++++- .../main/res/layout/fragment_options_display.xml | 14 +++++++++++++- app/src/main/res/values/strings.xml | 1 + 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/DrawerLayoutEx.java b/app/src/main/java/eu/faircode/email/DrawerLayoutEx.java index 5248a747cd..3553f4a417 100644 --- a/app/src/main/java/eu/faircode/email/DrawerLayoutEx.java +++ b/app/src/main/java/eu/faircode/email/DrawerLayoutEx.java @@ -20,6 +20,7 @@ package eu.faircode.email; */ import android.content.Context; +import android.content.SharedPreferences; import android.content.res.Configuration; import android.graphics.Color; import android.os.Parcelable; @@ -32,6 +33,7 @@ import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.drawerlayout.widget.DrawerLayout; +import androidx.preference.PreferenceManager; public class DrawerLayoutEx extends DrawerLayout { private boolean locked = false; @@ -51,7 +53,9 @@ public class DrawerLayoutEx extends DrawerLayout { void setup(Configuration config, View drawerContainer) { setScrimColor(Helper.resolveColor(getContext(), R.attr.colorDrawerScrim)); - if (BuildConfig.DEBUG) { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + boolean landscape3 = prefs.getBoolean("landscape3", false); + if (landscape3) { ViewGroup childContent = (ViewGroup) getChildAt(0); ViewGroup childDrawer = (ViewGroup) getChildAt(1); if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) { diff --git a/app/src/main/java/eu/faircode/email/FragmentOptions.java b/app/src/main/java/eu/faircode/email/FragmentOptions.java index d0f20a78f7..c9b238b56c 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptions.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptions.java @@ -39,7 +39,7 @@ public class FragmentOptions extends FragmentBase { static String[] OPTIONS_RESTART = new String[]{ "subscriptions", - "landscape", "startup", "cards", "indentation", "date", "threading", "highlight_unread", "color_stripe", + "landscape", "landscape3", "startup", "cards", "indentation", "date", "threading", "highlight_unread", "color_stripe", "avatars", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold", "name_email", "distinguish_contacts", "authentication", "subject_top", "font_size_sender", "font_size_subject", "subject_italic", "subject_ellipsize", diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java index 8df41a4db0..76f6ddfa81 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsDisplay.java @@ -53,6 +53,7 @@ import androidx.preference.PreferenceManager; public class FragmentOptionsDisplay extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener { private Button btnTheme; private SwitchCompat swLandscape; + private SwitchCompat swLandscape3; private Spinner spStartup; private SwitchCompat swCards; private SwitchCompat swDate; @@ -95,7 +96,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer private SwitchCompat swActionbar; private final static String[] RESET_OPTIONS = new String[]{ - "theme", "landscape", "startup", "cards", "indentation", "date", "threading", "highlight_unread", "color_stripe", + "theme", "landscape", "landscape3", "startup", "cards", "indentation", "date", "threading", "highlight_unread", "color_stripe", "avatars", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold", "name_email", "distinguish_contacts", "authentication", "subject_top", "font_size_sender", "font_size_subject", "subject_italic", "subject_ellipsize", @@ -116,6 +117,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer btnTheme = view.findViewById(R.id.btnTheme); swLandscape = view.findViewById(R.id.swLandscape); + swLandscape3 = view.findViewById(R.id.swLandscape3); spStartup = view.findViewById(R.id.spStartup); swCards = view.findViewById(R.id.swCards); swIndentation = view.findViewById(R.id.swIndentation); @@ -173,6 +175,14 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { prefs.edit().putBoolean("landscape", checked).apply(); + swLandscape3.setEnabled(checked); + } + }); + + swLandscape3.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("landscape3", checked).apply(); } }); @@ -559,6 +569,8 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer swLandscape.setChecked(prefs.getBoolean("landscape", true)); swLandscape.setEnabled(normal); + swLandscape3.setChecked(prefs.getBoolean("landscape3", false)); + swLandscape3.setEnabled(normal && swLandscape.isChecked()); String startup = prefs.getString("startup", "unified"); String[] startupValues = getResources().getStringArray(R.array.startupValues); diff --git a/app/src/main/res/layout/fragment_options_display.xml b/app/src/main/res/layout/fragment_options_display.xml index ddfb5119b0..a48d237a3e 100644 --- a/app/src/main/res/layout/fragment_options_display.xml +++ b/app/src/main/res/layout/fragment_options_display.xml @@ -60,6 +60,18 @@ app:layout_constraintTop_toBottomOf="@id/btnTheme" app:switchPadding="12dp" /> + + + app:layout_constraintTop_toBottomOf="@id/swLandscape3" /> Manage connectivity Use two columns in landscape mode + Always show navigation menu in landscape mode Show on start screen Show cards Group by date