diff options
| author | Lena <lena@omega> | 2026-07-01 00:00:00 +0000 |
|---|---|---|
| committer | Lena <lena@omega> | 2026-07-01 00:00:00 +0000 |
| commit | c03f0464c1f834c2f4d8642cbfad322033d368b7 (patch) | |
| tree | 9b591265ba9800d520d3ea07c2d484879191e4c3 /app/src/main/java/invalid/lena/scrcpy/Ui.java | |
| parent | be7a012517905f0a36b2e68f0df7a311ca191fff (diff) | |
| download | scrcpy-android-c03f0464c1f834c2f4d8642cbfad322033d368b7.tar.gz | |
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).
Diffstat (limited to 'app/src/main/java/invalid/lena/scrcpy/Ui.java')
| -rw-r--r-- | app/src/main/java/invalid/lena/scrcpy/Ui.java | 34 |
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(); + } +} |