Skip to content

Commit

Permalink
android:fitsSystemWindows="true"
Browse files Browse the repository at this point in the history
  • Loading branch information
m5r committed Jun 6, 2024
1 parent f5f32bf commit 20b4b64
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,9 @@ private void displayServerSelectList() {

// TODO: replace `UPSIDE_DOWN_CAKE` with `VANILLA_ICE_CREAM` when SDK 35 comes out of preview
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
trace(this, "***************");
// https://developer.android.com/about/versions/15/behavior-changes-15#window-insets
View layout = findViewById(R.id.serverSelectListLayout);
ViewCompat.setOnApplyWindowInsetsListener(layout, (v, windowInsets) -> {
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
mlp.topMargin = insets.top;
mlp.rightMargin = insets.right;
mlp.bottomMargin = insets.bottom;
mlp.leftMargin = insets.left;
v.setLayoutParams(mlp);

return WindowInsetsCompat.CONSUMED;
});
View view = findViewById(R.id.serverSelectListLayout);
ViewCompat.requestApplyInsets(view.getRootView());
// ((View) view.getParent()).requestApplyInsets();
}

List<ServerMetadata> servers = serverRepo.getServers();
Expand All @@ -105,20 +94,8 @@ private void displayCustomServerForm() {

// TODO: replace `UPSIDE_DOWN_CAKE` with `VANILLA_ICE_CREAM` when SDK 35 comes out of preview
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
trace(this, "ddddddddddddd");
// https://developer.android.com/about/versions/15/behavior-changes-15#window-insets
View layout = findViewById(R.id.customServerFormLayout);
ViewCompat.setOnApplyWindowInsetsListener(layout, (v, windowInsets) -> {
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) v.getLayoutParams();
mlp.topMargin = insets.top;
mlp.rightMargin = insets.right;
mlp.bottomMargin = insets.bottom;
mlp.leftMargin = insets.left;
v.setLayoutParams(mlp);

return WindowInsetsCompat.CONSUMED;
});
View view = findViewById(R.id.customServerFormLayout);
ViewCompat.requestApplyInsets(view.getRootView());
}

if(!this.settings.hasWebappSettings()) {
Expand Down
1 change: 1 addition & 0 deletions src/main/res/layout/custom_server_form.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
android:id="@+id/customServerFormLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fitsSystemWindows="true"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">
Expand Down
1 change: 1 addition & 0 deletions src/main/res/layout/server_select_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
android:id="@+id/serverSelectListLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fitsSystemWindows="true"
android:orientation="vertical">

<EditText
Expand Down

0 comments on commit 20b4b64

Please sign in to comment.