Open nav menu by default when enabled

This commit is contained in:
M66B
2020-01-03 17:33:17 +01:00
parent f78954119a
commit 59027f63ae
2 changed files with 27 additions and 17 deletions

View File

@@ -20,7 +20,9 @@ package eu.faircode.email;
*/
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.MotionEvent;
@@ -28,7 +30,9 @@ import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.preference.PreferenceManager;
public class DrawerLayoutEx extends DrawerLayout {
public DrawerLayoutEx(@NonNull Context context) {
@@ -43,11 +47,21 @@ public class DrawerLayoutEx extends DrawerLayout {
super(context, attrs, defStyle);
}
void setup(Configuration config, View drawerContainer) {
setScrimColor(Helper.resolveColor(getContext(), R.attr.colorDrawerScrim));
if (config.orientation != Configuration.ORIENTATION_LANDSCAPE) {
setDrawerLockMode(LOCK_MODE_UNLOCKED);
void setup(Configuration config, View drawerContainer, ActionBarDrawerToggle drawerToggle) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean normal = config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL);
boolean landscape = prefs.getBoolean("landscape", true);
boolean landscape3 = prefs.getBoolean("landscape3", true);
if (normal && landscape && landscape3 &&
config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
setScrimColor(Color.TRANSPARENT);
openDrawer(drawerContainer, false);
drawerToggle.onDrawerOpened(drawerContainer);
} else {
setScrimColor(Helper.resolveColor(getContext(), R.attr.colorDrawerScrim));
closeDrawer(drawerContainer, false);
drawerToggle.onDrawerClosed(drawerContainer);
}
}