Better check for small screens

pull/153/head
M66B 6 years ago
parent 8633c59e52
commit 05f4c7497e

@ -22,10 +22,9 @@ package eu.faircode.email;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Point;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.view.Display;
import java.util.List;
@ -75,11 +74,8 @@ public class ActivityMain extends AppCompatActivity implements FragmentManager.O
}
}.execute(this, new Bundle(), "main:accounts");
} else {
// Enable compact view on narrow screens
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
if (size.x < 1080)
// Enable compact view on small screens
if (!getResources().getConfiguration().isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL))
prefs.edit().putBoolean("compact", true).apply();
setTheme(R.style.AppThemeLight);

@ -30,6 +30,7 @@ import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@ -468,7 +469,10 @@ public class Helper {
Display display = wm.getDefaultDisplay();
Point size = new Point();
display.getSize(size);
sb.append(String.format("Resolution: %dx%d\r\n", size.x, size.y));
float density = context.getResources().getDisplayMetrics().density;
sb.append(String.format("Resolution: %.2f x %.2f dp %b\r\n",
size.x / density, size.y / density,
context.getResources().getConfiguration().isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_NORMAL)));
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
boolean ignoring = true;

Loading…
Cancel
Save