aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/AndroidManifest.xml3
-rw-r--r--app/src/main/java/invalid/lena/scrcpy/Main.java7
-rw-r--r--app/src/main/java/invalid/lena/scrcpy/SettingsActivity.java3
-rw-r--r--app/src/main/java/invalid/lena/scrcpy/Ui.java34
-rw-r--r--app/src/main/res/layout/main.xml3
-rw-r--r--app/src/main/res/layout/settings.xml13
6 files changed, 61 insertions, 2 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 540a499..91e3725 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -37,7 +37,8 @@
<activity
android:name=".SettingsActivity"
android:exported="false"
- android:label="@string/settings"/>
+ android:label="@string/settings"
+ android:theme="@style/Theme.Scrcpy.NoActionBar"/>
<service
android:name=".Sessions"
diff --git a/app/src/main/java/invalid/lena/scrcpy/Main.java b/app/src/main/java/invalid/lena/scrcpy/Main.java
index 2f95375..eb8d400 100644
--- a/app/src/main/java/invalid/lena/scrcpy/Main.java
+++ b/app/src/main/java/invalid/lena/scrcpy/Main.java
@@ -6,6 +6,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
+import android.view.WindowInsets;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
@@ -34,6 +35,12 @@ public final class Main extends Activity {
super.onCreate(saved);
setContentView(R.layout.main);
+ // The IME inset is in the mask too: the window is edge-to-edge, so
+ // nothing resizes it when the keyboard opens. Padding the root
+ // shrinks the weighted device list and keeps the form reachable.
+ Ui.padForInsets(findViewById(R.id.root),
+ WindowInsets.Type.systemBars() | WindowInsets.Type.ime());
+
EditText host = findViewById(R.id.host);
EditText pairPort = findViewById(R.id.pair_port);
EditText pairCode = findViewById(R.id.pair_code);
diff --git a/app/src/main/java/invalid/lena/scrcpy/SettingsActivity.java b/app/src/main/java/invalid/lena/scrcpy/SettingsActivity.java
index d95ecba..43b0954 100644
--- a/app/src/main/java/invalid/lena/scrcpy/SettingsActivity.java
+++ b/app/src/main/java/invalid/lena/scrcpy/SettingsActivity.java
@@ -2,6 +2,7 @@ package invalid.lena.scrcpy;
import android.app.Activity;
import android.os.Bundle;
+import android.view.WindowInsets;
import android.widget.CheckBox;
import android.widget.RadioButton;
import android.widget.RadioGroup;
@@ -15,7 +16,7 @@ public final class SettingsActivity extends Activity {
protected void onCreate(Bundle saved) {
super.onCreate(saved);
setContentView(R.layout.settings);
- setTitle(R.string.settings);
+ Ui.padForInsets(findViewById(R.id.root), WindowInsets.Type.systemBars());
RadioGroup videoGroup = findViewById(R.id.video_codec);
RadioGroup audioGroup = findViewById(R.id.audio_codec);
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();
+ }
+}
diff --git a/app/src/main/res/layout/main.xml b/app/src/main/res/layout/main.xml
index acd4a3c..2e722b0 100644
--- a/app/src/main/res/layout/main.xml
+++ b/app/src/main/res/layout/main.xml
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
+<!-- Root padding is the base; Ui.padForInsets() adds the system bar and
+ IME insets to it at runtime (the window is edge-to-edge). -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
diff --git a/app/src/main/res/layout/settings.xml b/app/src/main/res/layout/settings.xml
index 5d4e450..76f706b 100644
--- a/app/src/main/res/layout/settings.xml
+++ b/app/src/main/res/layout/settings.xml
@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
+<!-- Title lives in the layout, not in an action bar: the window is
+ edge-to-edge, so Ui.padForInsets() on this root is what keeps the
+ content clear of the system bars. -->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent">
@@ -10,6 +14,15 @@
android:padding="@dimen/space_lg">
<TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/space_lg"
+ android:text="@string/settings"
+ android:textColor="@color/on_surface"
+ android:textSize="22sp"
+ android:textStyle="bold"/>
+
+ <TextView
style="@style/Note"
android:layout_width="match_parent"
android:layout_height="wrap_content"