diff --git a/app/build.gradle b/app/build.gradle index 4aacedae87..398c38c79d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -330,6 +330,7 @@ dependencies { def emoji_version = "1.2.0-alpha04" def activity_version = "1.4.0" // 1.5.0-beta01 / 1.6.0-alpha01 def fragment_version = "1.4.1" // 1.5.0-beta01 + def windows_version = "1.0.0" // 1.1.0-alpha01 def webkit_version = "1.4.0" def recyclerview_version = "1.2.1" // 1.3.0-alpha02 def coordinatorlayout_version = "1.2.0" @@ -390,10 +391,12 @@ dependencies { // https://mvnrepository.com/artifact/androidx.emoji2/emoji2 // https://mvnrepository.com/artifact/androidx.activity/activity // https://mvnrepository.com/artifact/androidx.fragment/fragment + // https://mvnrepository.com/artifact/androidx.window/window-java implementation "androidx.appcompat:appcompat:$appcompat_version" implementation "androidx.emoji2:emoji2:$emoji_version" implementation "androidx.activity:activity:$activity_version" implementation "androidx.fragment:fragment:$fragment_version" + implementation "androidx.window:window-java:$windows_version" // https://developer.android.com/jetpack/androidx/releases/webkit // https://mvnrepository.com/artifact/androidx.webkit/webkit diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java index f82b5d84f1..df99c8eca0 100644 --- a/app/src/main/java/eu/faircode/email/ActivityView.java +++ b/app/src/main/java/eu/faircode/email/ActivityView.java @@ -61,6 +61,7 @@ import androidx.appcompat.app.AlertDialog; import androidx.appcompat.widget.PopupMenu; import androidx.constraintlayout.widget.Group; import androidx.core.app.NotificationCompat; +import androidx.core.util.Consumer; import androidx.core.widget.NestedScrollView; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; @@ -74,6 +75,10 @@ import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import androidx.window.java.layout.WindowInfoTrackerCallbackAdapter; +import androidx.window.layout.DisplayFeature; +import androidx.window.layout.WindowInfoTracker; +import androidx.window.layout.WindowLayoutInfo; import com.google.android.material.snackbar.Snackbar; @@ -103,6 +108,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB private boolean nav_options; private int colorDrawerScrim; + private WindowInfoTrackerCallbackAdapter infoTracker; private int layoutId; private View view; @@ -218,6 +224,8 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB if (nav_expanded && nav_pinned && !canExpandAndPin()) nav_pinned = false; + infoTracker = new WindowInfoTrackerCallbackAdapter(WindowInfoTracker.getOrCreate(this)); + Configuration config = getResources().getConfiguration(); boolean portrait2 = prefs.getBoolean("portrait2", false); boolean portrait2c = prefs.getBoolean("portrait2c", false); @@ -1022,6 +1030,18 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB setIntent(intent); } + @Override + protected void onStart() { + super.onStart(); + infoTracker.addWindowLayoutInfoListener(this, Runnable::run, layoutStateChangeCallback); + } + + @Override + protected void onStop() { + super.onStop(); + infoTracker.removeWindowLayoutInfoListener(layoutStateChangeCallback); + } + @Override protected void onResume() { super.onResume(); @@ -2234,4 +2254,14 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB .create(); } } + + private final Consumer layoutStateChangeCallback = new Consumer() { + @Override + public void accept(WindowLayoutInfo info) { + List features = info.getDisplayFeatures(); + Log.i("Display features=" + features.size()); + for (DisplayFeature feature : features) + EntityLog.log(ActivityView.this, "Display feature bounds=" + feature.getBounds()); + } + }; }