Enable compact view on narrow screens

pull/153/head
M66B 6 years ago
parent e7ea4ca015
commit b2d420339b

@ -22,8 +22,10 @@ package eu.faircode.email;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Point;
import android.os.Build;
import android.os.Bundle;
import android.view.Display;
import java.util.List;
@ -73,6 +75,13 @@ 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)
prefs.edit().putBoolean("compact", true).apply();
setTheme(R.style.AppThemeLight);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

@ -33,6 +33,7 @@ import android.content.pm.ResolveInfo;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Point;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkCapabilities;
@ -42,9 +43,11 @@ import android.os.Build;
import android.os.Bundle;
import android.os.PowerManager;
import android.text.TextUtils;
import android.view.Display;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.CheckBox;
@ -461,6 +464,12 @@ public class Helper {
sb.append(String.format("Id: %s\r\n", Build.ID));
sb.append("\r\n");
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Point size = new Point();
display.getSize(size);
sb.append(String.format("Resolution: %dx%d\r\n", size.x, size.y));
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
boolean ignoring = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)

Loading…
Cancel
Save