Removed normal screen limitations

pull/203/head
M66B 4 years ago
parent 73e824c3ec
commit cbb39fa46f

@ -239,11 +239,20 @@ public class ActivityMain extends ActivityBase implements FragmentManager.OnBack
else else
boot.execute(this, new Bundle(), "main:accounts"); boot.execute(this, new Bundle(), "main:accounts");
} else { } else {
// Enable 3-col mode on large screen / compact view on small screens SharedPreferences.Editor editor = prefs.edit();
if (getResources().getConfiguration().isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE)) Configuration config = getResources().getConfiguration();
prefs.edit().putBoolean("landscape3", true).apply();
else // Default enable compact mode for smaller screens
prefs.edit().putBoolean("compact", true).apply(); if (!config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE))
editor.putBoolean("compact", true);
// Default disable landscape columns for small screens
if (!config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL)) {
editor.putBoolean("landscape", false);
editor.putBoolean("landscape3", false);
}
editor.apply();
if (Helper.isNight(this)) if (Helper.isNight(this))
setTheme(R.style.AppThemeBlueOrangeDark); setTheme(R.style.AppThemeBlueOrangeDark);

@ -175,20 +175,19 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
startup = prefs.getString("startup", "unified"); startup = prefs.getString("startup", "unified");
Configuration config = getResources().getConfiguration(); Configuration config = getResources().getConfiguration();
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 portrait2c = prefs.getBoolean("portrait2c", false); final boolean portrait2c = prefs.getBoolean("portrait2c", false);
final boolean portrait3 = prefs.getBoolean("portrait3", 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 +
" portrait 2=" + portrait2 + " 2c=" + portrait2c + " nav=" + portrait3 + " portrait 2=" + portrait2 + " 2c=" + portrait2c + " nav=" + portrait3 +
" landscape 2=" + landscape + " nav=" + landscape3); " landscape 2=" + landscape + " nav=" + landscape3);
int viewId; int viewId;
if (config.orientation == ORIENTATION_PORTRAIT && portrait2c) if (config.orientation == ORIENTATION_PORTRAIT && portrait2c)
viewId = R.layout.activity_view_landscape_split; viewId = R.layout.activity_view_landscape_split;
else if (config.orientation == ORIENTATION_PORTRAIT || !(normal && landscape)) else if (config.orientation == ORIENTATION_PORTRAIT || !landscape)
viewId = (portrait2 ? R.layout.activity_view_portrait_split : R.layout.activity_view_portrait); viewId = (portrait2 ? R.layout.activity_view_portrait_split : R.layout.activity_view_portrait);
else else
viewId = R.layout.activity_view_landscape_split; viewId = R.layout.activity_view_landscape_split;
@ -235,9 +234,8 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
Log.i("Drawer opened"); Log.i("Drawer opened");
owner.start(); owner.start();
if (normal && if (((portrait3 && config.orientation == Configuration.ORIENTATION_PORTRAIT) ||
((portrait3 && config.orientation == Configuration.ORIENTATION_PORTRAIT) || (landscape3 && config.orientation == Configuration.ORIENTATION_LANDSCAPE))) {
(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);
} }
@ -252,9 +250,8 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
else else
owner.stop(); owner.stop();
if (normal && if (((portrait3 && config.orientation == Configuration.ORIENTATION_PORTRAIT) ||
((portrait3 && config.orientation == Configuration.ORIENTATION_PORTRAIT) || (landscape3 && config.orientation == Configuration.ORIENTATION_LANDSCAPE)))
(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);
} }

@ -505,6 +505,15 @@ public class ApplicationEx extends Application
boolean experiments = prefs.getBoolean("experiments", false); boolean experiments = prefs.getBoolean("experiments", false);
if (experiments) if (experiments)
editor.putBoolean("deepl_enabled", true); editor.putBoolean("deepl_enabled", true);
} else if (version < 1678) {
Configuration config = context.getResources().getConfiguration();
boolean normal = config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL);
if (!normal) {
if (!prefs.contains("landscape"))
editor.putBoolean("landscape", false);
if (!prefs.contains("landscape3"))
editor.putBoolean("landscape3", false);
}
} }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !BuildConfig.DEBUG) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !BuildConfig.DEBUG)

@ -50,13 +50,11 @@ 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 portrait3 = prefs.getBoolean("portrait3", false); boolean portrait3 = prefs.getBoolean("portrait3", false);
boolean landscape3 = prefs.getBoolean("landscape3", true); boolean landscape3 = prefs.getBoolean("landscape3", true);
if (normal && if (((portrait3 && config.orientation == Configuration.ORIENTATION_PORTRAIT) ||
((portrait3 && config.orientation == Configuration.ORIENTATION_PORTRAIT) || (landscape3 && config.orientation == Configuration.ORIENTATION_LANDSCAPE))) {
(landscape3 && config.orientation == Configuration.ORIENTATION_LANDSCAPE))) {
setScrimColor(Color.TRANSPARENT); setScrimColor(Color.TRANSPARENT);
openDrawer(drawerContainer, false); openDrawer(drawerContainer, false);
drawerToggle.onDrawerOpened(drawerContainer); drawerToggle.onDrawerOpened(drawerContainer);

@ -1023,9 +1023,6 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private void setOptions() { private void setOptions() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean normal = getResources().getConfiguration()
.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL);
String startup = prefs.getString("startup", "unified"); String startup = prefs.getString("startup", "unified");
String[] startupValues = getResources().getStringArray(R.array.startupValues); String[] startupValues = getResources().getStringArray(R.array.startupValues);
for (int pos = 0; pos < startupValues.length; pos++) for (int pos = 0; pos < startupValues.length; pos++)
@ -1048,11 +1045,8 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swPortrait2.setChecked(prefs.getBoolean("portrait2", false)); swPortrait2.setChecked(prefs.getBoolean("portrait2", false));
swPortrait2c.setChecked(prefs.getBoolean("portrait2c", false) && !swPortrait2.isChecked()); swPortrait2c.setChecked(prefs.getBoolean("portrait2c", false) && !swPortrait2.isChecked());
swPortrait3.setChecked(prefs.getBoolean("portrait3", 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);
swLandscape3.setChecked(prefs.getBoolean("landscape3", true)); swLandscape3.setChecked(prefs.getBoolean("landscape3", true));
swLandscape3.setEnabled(normal);
swNavMessageCount.setChecked(prefs.getBoolean("nav_count", false)); swNavMessageCount.setChecked(prefs.getBoolean("nav_count", false));
swThreading.setChecked(prefs.getBoolean("threading", true)); swThreading.setChecked(prefs.getBoolean("threading", true));

@ -1712,15 +1712,25 @@ public class Log {
long nheap = Debug.getNativeHeapAllocatedSize() / 1024L; long nheap = Debug.getNativeHeapAllocatedSize() / 1024L;
sb.append(String.format("Heap usage: %s/%s KiB native: %s KiB\r\n", hused, hmax, nheap)); sb.append(String.format("Heap usage: %s/%s KiB native: %s KiB\r\n", hused, hmax, nheap));
Configuration config = context.getResources().getConfiguration();
String size;
if (config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_XLARGE))
size = "XL";
else if (config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE))
size = "L";
else if (config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL))
size = "M";
else if (config.isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_SMALL))
size = "M";
else
size = "?";
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay(); Display display = wm.getDefaultDisplay();
Point size = new Point(); Point dim = new Point();
display.getSize(size); display.getSize(dim);
float density = context.getResources().getDisplayMetrics().density; float density = context.getResources().getDisplayMetrics().density;
sb.append(String.format("Density %f resolution: %.2f x %.2f dp %b\r\n", sb.append(String.format("Density %f resolution: %.2f x %.2f dp %s\r\n",
density, density, dim.x / density, dim.y / density, size));
size.x / density, size.y / density,
context.getResources().getConfiguration().isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL)));
int uiMode = context.getResources().getConfiguration().uiMode; int uiMode = context.getResources().getConfiguration().uiMode;
sb.append(String.format("UI mode: 0x")) sb.append(String.format("UI mode: 0x"))
@ -1773,6 +1783,8 @@ public class Log {
sb.append(String.format("UUID: %s\r\n", uuid == null ? "-" : uuid)); sb.append(String.format("UUID: %s\r\n", uuid == null ? "-" : uuid));
} }
sb.append(String.format("Configuration: %s\r\n", config.toString()));
sb.append("\r\n"); sb.append("\r\n");
try { try {

Loading…
Cancel
Save