aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/invalid/lena/scrcpy/Ui.java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/invalid/lena/scrcpy/Ui.java')
-rw-r--r--app/src/main/java/invalid/lena/scrcpy/Ui.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/app/src/main/java/invalid/lena/scrcpy/Ui.java b/app/src/main/java/invalid/lena/scrcpy/Ui.java
new file mode 100644
index 0000000..91b8b66
--- /dev/null
+++ b/app/src/main/java/invalid/lena/scrcpy/Ui.java
@@ -0,0 +1,34 @@
+package invalid.lena.scrcpy;
+
+import android.graphics.Insets;
+import android.view.View;
+
+// Window inset plumbing for the non-fullscreen activities.
+//
+// targetSdk 35 makes every window edge-to-edge on Android 15: the system
+// no longer insets the content view, so an unhandled layout draws under
+// the status and navigation bars. Mirror wants that and opts in itself;
+// Main and Settings do not, so they pad their root by the bar sizes.
+public final class Ui {
+
+ private Ui() {}
+
+ // Add the insets of the given WindowInsets.Type mask to whatever
+ // padding the layout already declares. Applied on top of the XML
+ // padding, not instead of it, so the layout stays the source of the
+ // base spacing.
+ public static void padForInsets(View root, int types) {
+ int left = root.getPaddingLeft();
+ int top = root.getPaddingTop();
+ int right = root.getPaddingRight();
+ int bottom = root.getPaddingBottom();
+
+ root.setOnApplyWindowInsetsListener((v, insets) -> {
+ Insets in = insets.getInsets(types);
+ v.setPadding(left + in.left, top + in.top,
+ right + in.right, bottom + in.bottom);
+ return insets;
+ });
+ root.requestApplyInsets();
+ }
+}