From 3693693fdc0b99babb87909f54931a181b7b3943 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 25 Sep 2024 15:19:23 +0200 Subject: [PATCH] Can fold --- app/src/main/java/eu/faircode/email/ActivityView.java | 6 +++--- app/src/main/java/eu/faircode/email/DebugHelper.java | 1 + app/src/main/java/eu/faircode/email/Helper.java | 10 ++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java index 417e6bdea3..de0bd8dfa0 100644 --- a/app/src/main/java/eu/faircode/email/ActivityView.java +++ b/app/src/main/java/eu/faircode/email/ActivityView.java @@ -252,8 +252,8 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB " portrait rows=" + portrait2 + " cols=" + portrait2c + " min=" + portrait_min_size + " landscape cols=" + landscape + " min=" + landscape_min_size); boolean duo = Helper.isSurfaceDuo(); - boolean fold6 = Helper.isFold6(); - boolean close_pane = prefs.getBoolean("close_pane", !duo && !fold6); + boolean canFold = Helper.canFold(this); + boolean close_pane = prefs.getBoolean("close_pane", !duo && !canFold); boolean nav_categories = prefs.getBoolean("nav_categories", false); // 1=small, 2=normal, 3=large, 4=xlarge @@ -279,7 +279,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB if (content_pane != null) { // Special: Surface Duo - if (duo || fold6) { + if (duo || canFold) { View content_frame = findViewById(R.id.content_frame); ViewGroup.LayoutParams lparam = content_frame.getLayoutParams(); if (lparam instanceof LinearLayout.LayoutParams) { diff --git a/app/src/main/java/eu/faircode/email/DebugHelper.java b/app/src/main/java/eu/faircode/email/DebugHelper.java index fcabc3d195..d54b2f0fdf 100644 --- a/app/src/main/java/eu/faircode/email/DebugHelper.java +++ b/app/src/main/java/eu/faircode/email/DebugHelper.java @@ -493,6 +493,7 @@ public class DebugHelper { sb.append(String.format("Density 1dp=%f\r\n", density)); sb.append(String.format("Resolution: %.2f x %.2f dp\r\n", dim.x / density, dim.y / density)); //sb.append(String.format("Max. texture: %d px\r\n", Helper.getMaxTextureSize())); + sb.append(String.format("Foldable: %b\r\n", Helper.canFold(context))); Configuration config = context.getResources().getConfiguration(); diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java index ac593742c5..7759316532 100644 --- a/app/src/main/java/eu/faircode/email/Helper.java +++ b/app/src/main/java/eu/faircode/email/Helper.java @@ -1728,6 +1728,16 @@ public class Helper { return (Build.DEVICE != null) && Build.DEVICE.matches(".+_cheets|cheets_.+"); } + static boolean canFold(Context context) { + try { + PackageManager pm = context.getPackageManager(); + return pm.hasSystemFeature(PackageManager.FEATURE_SENSOR_HINGE_ANGLE); + } catch (Throwable ex) { + Log.e(ex); + return false; + } + } + static boolean isWatch(Context context) { if (isSmartwatch == null) isSmartwatch = _isWatch(context);