diff options
author | 2024-11-18 19:38:03 +0000 | |
---|---|---|
committer | 2024-11-18 20:03:12 +0000 | |
commit | da2a07a8b68e110a88a1e70d159eb65288949823 (patch) | |
tree | 988744babc020fb4bfde419fff6d97881462b230 /packages/BackupRestoreConfirmation | |
parent | b95e6688dfda7e8131d34dd9dff1d75b688b0657 (diff) |
Handle insets (status bar, navigation bar, etc) properly in adb
backup/restore confirmation dialog.
This flow is deprecated / a developer tool, so we arent investing in
making it look any nicer, but this way, we wont break our CTS tests!
(b/333130113)
After removing opt-out: http://screen/McdceDpYCHczgRk http://screen/37Zi4N3FvL9n7s4
With fix: http://screen/3qhjsdKyi5KuKzq http://screen/9ZjJJrP5KzjMGSp
Test: manual + https://android-build.corp.google.com/builds/abtd/run/L46300030007841260
Fix: 378652636
Flag: EXEMPT bugfix
Change-Id: I34944e937c10b5cd2536d3f15220cda381c73e6c
Diffstat (limited to 'packages/BackupRestoreConfirmation')
6 files changed, 47 insertions, 33 deletions
diff --git a/packages/BackupRestoreConfirmation/Android.bp b/packages/BackupRestoreConfirmation/Android.bp index ad3f4c12dfb1..a7d16a1cb0d0 100644 --- a/packages/BackupRestoreConfirmation/Android.bp +++ b/packages/BackupRestoreConfirmation/Android.bp @@ -27,6 +27,7 @@ android_app { name: "BackupRestoreConfirmation", defaults: ["platform_app_defaults"], srcs: ["src/**/*.java"], + static_libs: ["androidx.core_core"], platform_apis: true, certificate: "platform", privileged: true, diff --git a/packages/BackupRestoreConfirmation/AndroidManifest.xml b/packages/BackupRestoreConfirmation/AndroidManifest.xml index 44aa1b1b8747..fee46576d588 100644 --- a/packages/BackupRestoreConfirmation/AndroidManifest.xml +++ b/packages/BackupRestoreConfirmation/AndroidManifest.xml @@ -27,7 +27,6 @@ android:permission="android.permission.CONFIRM_FULL_BACKUP" > <activity android:name=".BackupRestoreConfirmation" - android:theme="@style/OptOutEdgeToEdgeEnforcement" android:title="" android:windowSoftInputMode="stateAlwaysHidden" android:excludeFromRecents="true" diff --git a/packages/BackupRestoreConfirmation/res/layout/confirm_backup.xml b/packages/BackupRestoreConfirmation/res/layout/confirm_backup.xml index 6504435fada3..16e4706e6bb0 100644 --- a/packages/BackupRestoreConfirmation/res/layout/confirm_backup.xml +++ b/packages/BackupRestoreConfirmation/res/layout/confirm_backup.xml @@ -24,6 +24,7 @@ android:orientation="vertical" > <ScrollView + android:id="@+id/scroll_view" android:layout_height="0dp" android:layout_weight="1" android:layout_width="match_parent" @@ -84,11 +85,11 @@ android:layout_width="match_parent" /> <!-- button bar --> - <LinearLayout android:orientation="horizontal" - style="?android:attr/buttonBarStyle" + <LinearLayout android:id="@+id/button_bar" + android:orientation="horizontal" + style="?android:attr/buttonBarStyle" android:layout_height="wrap_content" - android:layout_width="match_parent" - android:layout_gravity="bottom"> + android:layout_width="match_parent"> <Button android:id="@+id/button_deny" style="?android:attr/buttonBarButtonStyle" diff --git a/packages/BackupRestoreConfirmation/res/layout/confirm_restore.xml b/packages/BackupRestoreConfirmation/res/layout/confirm_restore.xml index 2ee74fe4519b..55efe4a44c19 100644 --- a/packages/BackupRestoreConfirmation/res/layout/confirm_restore.xml +++ b/packages/BackupRestoreConfirmation/res/layout/confirm_restore.xml @@ -23,11 +23,13 @@ android:layout_height="match_parent" android:orientation="vertical"> - <ScrollView + <ScrollView + android:id="@+id/scroll_view" android:padding="16dp" android:layout_height="0dp" android:layout_weight="1" - android:layout_width="match_parent"> + android:layout_width="match_parent" + android:clipToPadding="false" > <LinearLayout android:orientation="vertical" android:layout_height="wrap_content" @@ -82,8 +84,9 @@ android:layout_width="match_parent" /> <!-- button bar --> - <LinearLayout android:orientation="horizontal" - style="?android:attr/buttonBarStyle" + <LinearLayout android:id="@+id/button_bar" + android:orientation="horizontal" + style="?android:attr/buttonBarStyle" android:layout_height="wrap_content" android:layout_width="match_parent" android:layout_gravity="bottom"> diff --git a/packages/BackupRestoreConfirmation/res/values/styles.xml b/packages/BackupRestoreConfirmation/res/values/styles.xml deleted file mode 100644 index ce54568ed6d6..000000000000 --- a/packages/BackupRestoreConfirmation/res/values/styles.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2024 The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> - -<resources xmlns:android="http://schemas.android.com/apk/res/android"> - <!-- - TODO(b/309578419): Make activities handle insets properly and then remove this. - --> - <style name="OptOutEdgeToEdgeEnforcement"> - <item name="android:windowOptOutEdgeToEdgeEnforcement">true</item> - </style> -</resources> diff --git a/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java b/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java index 3c790f0e24ee..bc06bdbd29af 100644 --- a/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java +++ b/packages/BackupRestoreConfirmation/src/com/android/backupconfirm/BackupRestoreConfirmation.java @@ -31,10 +31,17 @@ import android.text.Editable; import android.text.TextWatcher; import android.util.Slog; import android.view.View; +import android.view.ViewGroup.MarginLayoutParams; import android.widget.Button; +import android.widget.LinearLayout; +import android.widget.ScrollView; import android.widget.TextView; import android.widget.Toast; +import androidx.core.graphics.Insets; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowInsetsCompat; + /** * Confirm with the user that a requested full backup/restore operation is legitimate. * Any attempt to perform a full backup/restore will launch this UI and wait for a @@ -208,6 +215,8 @@ public class BackupRestoreConfirmation extends Activity { setTitle(titleId); setContentView(layoutId); + handleInsets(); + // Same resource IDs for each layout variant (backup / restore) mStatusView = findViewById(R.id.package_name); mAllowButton = findViewById(R.id.button_allow); @@ -254,6 +263,31 @@ public class BackupRestoreConfirmation extends Activity { } } + // Handle insets so that UI components are not covered by navigation and status bars + private void handleInsets() { + LinearLayout buttonBar = findViewById(R.id.button_bar); + ViewCompat.setOnApplyWindowInsetsListener(buttonBar, (v, windowInsets) -> { + Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + MarginLayoutParams mlp = (MarginLayoutParams) v.getLayoutParams(); + mlp.leftMargin = insets.left; + mlp.bottomMargin = insets.bottom; + mlp.rightMargin = insets.right; + v.setLayoutParams(mlp); + return WindowInsetsCompat.CONSUMED; + }); + + ScrollView scrollView = findViewById(R.id.scroll_view); + ViewCompat.setOnApplyWindowInsetsListener(scrollView, (v, windowInsets) -> { + Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + MarginLayoutParams mlp = (MarginLayoutParams) v.getLayoutParams(); + mlp.leftMargin = insets.left; + mlp.topMargin = insets.top; + mlp.rightMargin = insets.right; + v.setLayoutParams(mlp); + return WindowInsetsCompat.CONSUMED; + }); + } + private void monitorEncryptionPassword() { mAllowButton.setEnabled(false); mEncPassword.addTextChangedListener(new TextWatcher() { |