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();
final boolean normal = config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL);
final boolean portrait2 = prefs.getBoolean("portrait2", false);
final boolean portrait3 = prefs.getBoolean("portrait3", false);
final boolean landscape = prefs.getBoolean("landscape", 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);
int viewId;
@ -230,8 +233,9 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
Log.i("Drawer opened");
owner.start();
if (normal && landscape3 &&
config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
if (normal &&
((portrait3 && config.orientation == Configuration.ORIENTATION_PORTRAIT) ||
(landscape3 && config.orientation == Configuration.ORIENTATION_LANDSCAPE))) {
drawerLayout.setDrawerLockMode(LOCK_MODE_LOCKED_OPEN);
childContent.setPaddingRelative(childDrawer.getLayoutParams().width, 0, 0, 0);
}
@ -246,8 +250,9 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
else
owner.stop();
if (normal && landscape3 &&
config.orientation == Configuration.ORIENTATION_LANDSCAPE)
if (normal &&
((portrait3 && config.orientation == Configuration.ORIENTATION_PORTRAIT) ||
(landscape3 && config.orientation == Configuration.ORIENTATION_LANDSCAPE)))
childContent.setPaddingRelative(
Math.round(slideOffset * childDrawer.getLayoutParams().width), 0, 0, 0);
}
@ -258,7 +263,11 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
int drawerWidth;
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;
TypedValue tv = new TypedValue();
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 dp320 = Helper.dp2pixels(this, 320);
drawerWidth = Math.min(screenWidth - actionBarHeight, dp320);
} else
drawerWidth = Helper.dp2pixels(this, 300);
}
ViewGroup.LayoutParams lparam = drawerContainer.getLayoutParams();
lparam.width = drawerWidth;

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

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

@ -68,6 +68,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swDateBold;
private SwitchCompat swNavBarColorize;
private SwitchCompat swPortrait2;
private SwitchCompat swPortrait3;
private SwitchCompat swLandscape;
private SwitchCompat swLandscape3;
private SwitchCompat swNavMessageCount;
@ -154,7 +155,8 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private final static String[] RESET_OPTIONS = new String[]{
"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",
"highlight_unread", "highlight_color", "color_stripe",
"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);
swNavBarColorize = view.findViewById(R.id.swNavBarColorize);
swPortrait2 = view.findViewById(R.id.swPortrait2);
swPortrait3 = view.findViewById(R.id.swPortrait3);
swLandscape = view.findViewById(R.id.swLandscape);
swLandscape3 = view.findViewById(R.id.swLandscape3);
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() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -1023,6 +1033,8 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swDateBold.setEnabled(swDate.isChecked());
swNavBarColorize.setChecked(prefs.getBoolean("navbar_colorize", false));
swPortrait2.setChecked(prefs.getBoolean("portrait2", false));
swPortrait3.setChecked(prefs.getBoolean("portrait3", false));
swPortrait3.setEnabled(normal);
swLandscape.setChecked(prefs.getBoolean("landscape", true));
swLandscape.setEnabled(normal);
swLandscape3.setChecked(prefs.getBoolean("landscape3", true));

@ -254,6 +254,17 @@
app:layout_constraintStart_toStartOf="parent"
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
android:id="@+id/swLandscape"
android:layout_width="0dp"
@ -263,7 +274,7 @@
android:text="@string/title_advanced_landscape"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvPortrait2Hint"
app:layout_constraintTop_toBottomOf="@id/swPortrait3"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView

@ -396,6 +396,7 @@
<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_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_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>

Loading…
Cancel
Save