Log windows features

pull/207/head
M66B 3 years ago
parent 17c8ce1e94
commit c10a763ff6

@ -330,6 +330,7 @@ dependencies {
def emoji_version = "1.2.0-alpha04" def emoji_version = "1.2.0-alpha04"
def activity_version = "1.4.0" // 1.5.0-beta01 / 1.6.0-alpha01 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 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 webkit_version = "1.4.0"
def recyclerview_version = "1.2.1" // 1.3.0-alpha02 def recyclerview_version = "1.2.1" // 1.3.0-alpha02
def coordinatorlayout_version = "1.2.0" def coordinatorlayout_version = "1.2.0"
@ -390,10 +391,12 @@ dependencies {
// https://mvnrepository.com/artifact/androidx.emoji2/emoji2 // https://mvnrepository.com/artifact/androidx.emoji2/emoji2
// https://mvnrepository.com/artifact/androidx.activity/activity // https://mvnrepository.com/artifact/androidx.activity/activity
// https://mvnrepository.com/artifact/androidx.fragment/fragment // https://mvnrepository.com/artifact/androidx.fragment/fragment
// https://mvnrepository.com/artifact/androidx.window/window-java
implementation "androidx.appcompat:appcompat:$appcompat_version" implementation "androidx.appcompat:appcompat:$appcompat_version"
implementation "androidx.emoji2:emoji2:$emoji_version" implementation "androidx.emoji2:emoji2:$emoji_version"
implementation "androidx.activity:activity:$activity_version" implementation "androidx.activity:activity:$activity_version"
implementation "androidx.fragment:fragment:$fragment_version" implementation "androidx.fragment:fragment:$fragment_version"
implementation "androidx.window:window-java:$windows_version"
// https://developer.android.com/jetpack/androidx/releases/webkit // https://developer.android.com/jetpack/androidx/releases/webkit
// https://mvnrepository.com/artifact/androidx.webkit/webkit // https://mvnrepository.com/artifact/androidx.webkit/webkit

@ -61,6 +61,7 @@ import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.PopupMenu; import androidx.appcompat.widget.PopupMenu;
import androidx.constraintlayout.widget.Group; import androidx.constraintlayout.widget.Group;
import androidx.core.app.NotificationCompat; import androidx.core.app.NotificationCompat;
import androidx.core.util.Consumer;
import androidx.core.widget.NestedScrollView; import androidx.core.widget.NestedScrollView;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
@ -74,6 +75,10 @@ import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; 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; import com.google.android.material.snackbar.Snackbar;
@ -103,6 +108,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
private boolean nav_options; private boolean nav_options;
private int colorDrawerScrim; private int colorDrawerScrim;
private WindowInfoTrackerCallbackAdapter infoTracker;
private int layoutId; private int layoutId;
private View view; private View view;
@ -218,6 +224,8 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
if (nav_expanded && nav_pinned && !canExpandAndPin()) if (nav_expanded && nav_pinned && !canExpandAndPin())
nav_pinned = false; nav_pinned = false;
infoTracker = new WindowInfoTrackerCallbackAdapter(WindowInfoTracker.getOrCreate(this));
Configuration config = getResources().getConfiguration(); Configuration config = getResources().getConfiguration();
boolean portrait2 = prefs.getBoolean("portrait2", false); boolean portrait2 = prefs.getBoolean("portrait2", false);
boolean portrait2c = prefs.getBoolean("portrait2c", false); boolean portrait2c = prefs.getBoolean("portrait2c", false);
@ -1022,6 +1030,18 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
setIntent(intent); setIntent(intent);
} }
@Override
protected void onStart() {
super.onStart();
infoTracker.addWindowLayoutInfoListener(this, Runnable::run, layoutStateChangeCallback);
}
@Override
protected void onStop() {
super.onStop();
infoTracker.removeWindowLayoutInfoListener(layoutStateChangeCallback);
}
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
@ -2234,4 +2254,14 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
.create(); .create();
} }
} }
private final Consumer<WindowLayoutInfo> layoutStateChangeCallback = new Consumer<WindowLayoutInfo>() {
@Override
public void accept(WindowLayoutInfo info) {
List<DisplayFeature> features = info.getDisplayFeatures();
Log.i("Display features=" + features.size());
for (DisplayFeature feature : features)
EntityLog.log(ActivityView.this, "Display feature bounds=" + feature.getBounds());
}
};
} }

Loading…
Cancel
Save