Added option for fixed nav menu in portrait mode

pull/203/head
M66B 3 years ago
parent 2e77bc34d3
commit 0dcbe6430d

@ -177,9 +177,12 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
Configuration config = getResources().getConfiguration(); Configuration config = getResources().getConfiguration();
final boolean normal = config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL); final boolean normal = config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL);
final boolean portrait2 = prefs.getBoolean("portrait2", false); final boolean portrait2 = prefs.getBoolean("portrait2", false);
final boolean portrait3 = prefs.getBoolean("portrait3", false);
final boolean landscape = prefs.getBoolean("landscape", true); final boolean landscape = prefs.getBoolean("landscape", true);
final boolean landscape3 = prefs.getBoolean("landscape3", true); final boolean landscape3 = prefs.getBoolean("landscape3", true);
Log.i("Orientation=" + config.orientation + " normal=" + normal + Log.i("Orientation=" + config.orientation +
" normal=" + normal +
" portrait=" + portrait2 + "/" + portrait3 +
" landscape=" + landscape + "/" + landscape3); " landscape=" + landscape + "/" + landscape3);
int viewId; int viewId;
@ -230,8 +233,9 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
Log.i("Drawer opened"); Log.i("Drawer opened");
owner.start(); owner.start();
if (normal && landscape3 && if (normal &&
config.orientation == Configuration.ORIENTATION_LANDSCAPE) { ((portrait3 && config.orientation == Configuration.ORIENTATION_PORTRAIT) ||
(landscape3 && config.orientation == Configuration.ORIENTATION_LANDSCAPE))) {
drawerLayout.setDrawerLockMode(LOCK_MODE_LOCKED_OPEN); drawerLayout.setDrawerLockMode(LOCK_MODE_LOCKED_OPEN);
childContent.setPaddingRelative(childDrawer.getLayoutParams().width, 0, 0, 0); childContent.setPaddingRelative(childDrawer.getLayoutParams().width, 0, 0, 0);
} }
@ -246,8 +250,9 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
else else
owner.stop(); owner.stop();
if (normal && landscape3 && if (normal &&
config.orientation == Configuration.ORIENTATION_LANDSCAPE) ((portrait3 && config.orientation == Configuration.ORIENTATION_PORTRAIT) ||
(landscape3 && config.orientation == Configuration.ORIENTATION_LANDSCAPE)))
childContent.setPaddingRelative( childContent.setPaddingRelative(
Math.round(slideOffset * childDrawer.getLayoutParams().width), 0, 0, 0); Math.round(slideOffset * childDrawer.getLayoutParams().width), 0, 0, 0);
} }
@ -258,7 +263,11 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
int drawerWidth; int drawerWidth;
DisplayMetrics dm = getResources().getDisplayMetrics(); DisplayMetrics dm = getResources().getDisplayMetrics();
if (viewId != R.layout.activity_view_landscape_split || !landscape3) { if (viewId == R.layout.activity_view_landscape_split && landscape3)
drawerWidth = Helper.dp2pixels(this, 300);
else if (viewId != R.layout.activity_view_landscape_split && portrait3)
drawerWidth = Math.min(Helper.dp2pixels(this, 300), dm.widthPixels / 2);
else {
int actionBarHeight; int actionBarHeight;
TypedValue tv = new TypedValue(); TypedValue tv = new TypedValue();
if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true))
@ -269,8 +278,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
int screenWidth = Math.min(dm.widthPixels, dm.heightPixels); int screenWidth = Math.min(dm.widthPixels, dm.heightPixels);
int dp320 = Helper.dp2pixels(this, 320); int dp320 = Helper.dp2pixels(this, 320);
drawerWidth = Math.min(screenWidth - actionBarHeight, dp320); drawerWidth = Math.min(screenWidth - actionBarHeight, dp320);
} else }
drawerWidth = Helper.dp2pixels(this, 300);
ViewGroup.LayoutParams lparam = drawerContainer.getLayoutParams(); ViewGroup.LayoutParams lparam = drawerContainer.getLayoutParams();
lparam.width = drawerWidth; lparam.width = drawerWidth;

@ -51,10 +51,12 @@ public class DrawerLayoutEx extends DrawerLayout {
void setup(Configuration config, View drawerContainer, ActionBarDrawerToggle drawerToggle) { void setup(Configuration config, View drawerContainer, ActionBarDrawerToggle drawerToggle) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean normal = config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL); boolean normal = config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL);
boolean portrait3 = prefs.getBoolean("portrait3", false);
boolean landscape3 = prefs.getBoolean("landscape3", true); boolean landscape3 = prefs.getBoolean("landscape3", true);
if (normal && landscape3 && if (normal &&
config.orientation == Configuration.ORIENTATION_LANDSCAPE) { ((portrait3 && config.orientation == Configuration.ORIENTATION_PORTRAIT) ||
(landscape3 && config.orientation == Configuration.ORIENTATION_LANDSCAPE))) {
setScrimColor(Color.TRANSPARENT); setScrimColor(Color.TRANSPARENT);
openDrawer(drawerContainer, false); openDrawer(drawerContainer, false);
drawerToggle.onDrawerOpened(drawerContainer); drawerToggle.onDrawerOpened(drawerContainer);

@ -108,7 +108,7 @@ public class FragmentOptions extends FragmentBase {
"subscriptions", "subscriptions",
"check_authentication", "check_reply_domain", "check_mx", "check_blocklist", "check_authentication", "check_reply_domain", "check_mx", "check_blocklist",
"send_pending", "send_pending",
"portrait2", "landscape", "landscape3", "nav_count", "startup", "portrait2", "portrait3", "landscape", "landscape3", "nav_count", "startup",
"cards", "beige", "tabular_card_bg", "shadow_unread", "cards", "beige", "tabular_card_bg", "shadow_unread",
"indentation", "date", "date_bold", "threading", "threading_unread", "indentation", "date", "date_bold", "threading", "threading_unread",
"highlight_unread", "highlight_color", "color_stripe", "highlight_unread", "highlight_color", "color_stripe",

@ -68,6 +68,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swDateBold; private SwitchCompat swDateBold;
private SwitchCompat swNavBarColorize; private SwitchCompat swNavBarColorize;
private SwitchCompat swPortrait2; private SwitchCompat swPortrait2;
private SwitchCompat swPortrait3;
private SwitchCompat swLandscape; private SwitchCompat swLandscape;
private SwitchCompat swLandscape3; private SwitchCompat swLandscape3;
private SwitchCompat swNavMessageCount; private SwitchCompat swNavMessageCount;
@ -154,7 +155,8 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private final static String[] RESET_OPTIONS = new String[]{ private final static String[] RESET_OPTIONS = new String[]{
"theme", "startup", "cards", "beige", "tabular_card_bg", "shadow_unread", "theme", "startup", "cards", "beige", "tabular_card_bg", "shadow_unread",
"date", "date_bold", "navbar_colorize", "portrait2", "landscape", "landscape3", "nav_count", "date", "date_bold", "navbar_colorize",
"portrait2", "portrait3", "landscape", "landscape3", "nav_count",
"threading", "threading_unread", "indentation", "seekbar", "actionbar", "actionbar_color", "threading", "threading_unread", "indentation", "seekbar", "actionbar", "actionbar_color",
"highlight_unread", "highlight_color", "color_stripe", "highlight_unread", "highlight_color", "color_stripe",
"avatars", "bimi", "gravatars", "favicons", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold", "avatars", "bimi", "gravatars", "favicons", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold",
@ -190,6 +192,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swDateBold = view.findViewById(R.id.swDateBold); swDateBold = view.findViewById(R.id.swDateBold);
swNavBarColorize = view.findViewById(R.id.swNavBarColorize); swNavBarColorize = view.findViewById(R.id.swNavBarColorize);
swPortrait2 = view.findViewById(R.id.swPortrait2); swPortrait2 = view.findViewById(R.id.swPortrait2);
swPortrait3 = view.findViewById(R.id.swPortrait3);
swLandscape = view.findViewById(R.id.swLandscape); swLandscape = view.findViewById(R.id.swLandscape);
swLandscape3 = view.findViewById(R.id.swLandscape3); swLandscape3 = view.findViewById(R.id.swLandscape3);
swNavMessageCount = view.findViewById(R.id.swNavMessageCount); swNavMessageCount = view.findViewById(R.id.swNavMessageCount);
@ -359,6 +362,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
} }
}); });
swPortrait3.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("portrait3", checked).apply();
}
});
swLandscape.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swLandscape.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -1023,6 +1033,8 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swDateBold.setEnabled(swDate.isChecked()); swDateBold.setEnabled(swDate.isChecked());
swNavBarColorize.setChecked(prefs.getBoolean("navbar_colorize", false)); swNavBarColorize.setChecked(prefs.getBoolean("navbar_colorize", false));
swPortrait2.setChecked(prefs.getBoolean("portrait2", false)); swPortrait2.setChecked(prefs.getBoolean("portrait2", false));
swPortrait3.setChecked(prefs.getBoolean("portrait3", false));
swPortrait3.setEnabled(normal);
swLandscape.setChecked(prefs.getBoolean("landscape", true)); swLandscape.setChecked(prefs.getBoolean("landscape", true));
swLandscape.setEnabled(normal); swLandscape.setEnabled(normal);
swLandscape3.setChecked(prefs.getBoolean("landscape3", true)); swLandscape3.setChecked(prefs.getBoolean("landscape3", true));

@ -254,6 +254,17 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swPortrait2" /> app:layout_constraintTop_toBottomOf="@id/swPortrait2" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swPortrait3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_portrait3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvPortrait2Hint"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swLandscape" android:id="@+id/swLandscape"
android:layout_width="0dp" android:layout_width="0dp"
@ -263,7 +274,7 @@
android:text="@string/title_advanced_landscape" android:text="@string/title_advanced_landscape"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvPortrait2Hint" app:layout_constraintTop_toBottomOf="@id/swPortrait3"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView <eu.faircode.email.FixedTextView

@ -396,6 +396,7 @@
<string name="title_advanced_caption_debug" translatable="false">Debug</string> <string name="title_advanced_caption_debug" translatable="false">Debug</string>
<string name="title_advanced_portrait2">Use two rows in portrait mode</string> <string name="title_advanced_portrait2">Use two rows in portrait mode</string>
<string name="title_advanced_portrait3">Show navigation menu in portrait mode by default</string>
<string name="title_advanced_landscape">Use two columns in landscape mode</string> <string name="title_advanced_landscape">Use two columns in landscape mode</string>
<string name="title_advanced_landscape3">Show navigation menu in landscape mode by default</string> <string name="title_advanced_landscape3">Show navigation menu in landscape mode by default</string>
<string name="title_advanced_nav_message_count">Show number of locally stored messages in the navigation menu</string> <string name="title_advanced_nav_message_count">Show number of locally stored messages in the navigation menu</string>

Loading…
Cancel
Save