From c03f0464c1f834c2f4d8642cbfad322033d368b7 Mon Sep 17 00:00:00 2001 From: Lena Date: Wed, 1 Jul 2026 00:00:00 +0000 Subject: app: pad Main and Settings for system bar insets targetSdk 35 makes every window edge-to-edge on Android 15. Neither activity handled insets, so Main drew its header under the status bar and the Settings ScrollView started at window y=0: the framework action bar covered its first 80dp and the navigation bar covered the last rows. Pad both roots by the system bar insets. Main adds the IME inset as well, since an edge-to-edge window is not resized when the keyboard opens. Settings drops the framework action bar and draws its own title like Main already does, which removes the action-bar-versus-inset interaction entirely. Reported on the F-Droid submission (fdroiddata!41394). --- app/src/main/java/invalid/lena/scrcpy/Ui.java | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app/src/main/java/invalid/lena/scrcpy/Ui.java (limited to 'app/src/main/java/invalid/lena/scrcpy/Ui.java') 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(); + } +} -- cgit v1.2.3