Improve LogAccessDialogActivity's rotation handling

1. Do not dismiss the dialog on configuration change, such as rotation.

When the device was rotated, the dialog was automatically dismissed as
the activity was destroyed & recreated in the new configuration.

2. Wrap the dialog content view in a ScrolLView

In landscape orientation (and smaller phone screens), the dialog content
may not fit entirely on the screen. By wrapping it in a ScrollView, all
the dialog text and buttons can still be accessed in landscape / smaller
screens.

Bug: 231436416
Test: Manual, on adt3
Test: On phone emulator in light/dark mode & different orientations
Change-Id: Ibf3ecf93a237783ce4909a24a959c3ea243ab766
This commit is contained in:
Robert Horvath
2022-05-04 17:17:43 +02:00
parent 3c8ff4712f
commit bd9cf8f9d2
2 changed files with 77 additions and 68 deletions

View File

@@ -16,77 +16,86 @@
** limitations under the License.
*/
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="380dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:paddingLeft="24dp"
android:paddingRight="24dp"
android:paddingTop="24dp"
android:paddingBottom="24dp">
<ImageView
android:id="@+id/log_access_image_view"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginBottom="16dp"
android:src="@drawable/ic_doc_document"
tools:layout_editor_absoluteX="148dp"
tools:layout_editor_absoluteY="35dp"
android:gravity="center" />
<TextView
android:id="@+id/log_access_dialog_title"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginBottom="32dp"
android:text="@string/log_access_confirmation_title"
android:textAppearance="@style/AllowLogAccess"
android:textColor="?android:attr/textColorPrimary"
android:gravity="center" />
<TextView
android:id="@+id/log_access_dialog_body"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginBottom="40dp"
android:text="@string/log_access_confirmation_body"
android:textAppearance="@style/PrimaryAllowLogAccess"
android:textColor="?android:attr/textColorPrimary"
android:gravity="center" />
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="380dp"
android:layout_height="match_parent"
android:clipToPadding="false">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/log_access_dialog_allow_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/log_access_confirmation_allow"
style="@style/PermissionGrantButtonTop"
android:textAppearance="@style/PermissionGrantButtonTextAppearance"
android:layout_marginBottom="5dp"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:clipToOutline="true"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:paddingLeft="24dp"
android:paddingRight="24dp"
android:paddingTop="24dp"
android:paddingBottom="24dp">
<ImageView
android:id="@+id/log_access_image_view"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginBottom="16dp"
android:src="@drawable/ic_doc_document"
tools:layout_editor_absoluteX="148dp"
tools:layout_editor_absoluteY="35dp"
android:gravity="center" />
<Button
android:id="@+id/log_access_dialog_deny_button"
android:layout_width="match_parent"
<TextView
android:id="@+id/log_access_dialog_title"
android:layout_height="wrap_content"
android:text="@string/log_access_confirmation_deny"
style="@style/PermissionGrantButtonBottom"
android:textAppearance="@style/PermissionGrantButtonTextAppearance"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:clipToOutline="true"
android:layout_width="wrap_content"
android:layout_marginBottom="32dp"
android:text="@string/log_access_confirmation_title"
android:textAppearance="@style/AllowLogAccess"
android:textColor="?android:attr/textColorPrimary"
android:gravity="center" />
<TextView
android:id="@+id/log_access_dialog_body"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginBottom="40dp"
android:text="@string/log_access_confirmation_body"
android:textAppearance="@style/PrimaryAllowLogAccess"
android:textColor="?android:attr/textColorPrimary"
android:gravity="center" />
<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/log_access_dialog_allow_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/log_access_confirmation_allow"
style="@style/PermissionGrantButtonTop"
android:textAppearance="@style/PermissionGrantButtonTextAppearance"
android:layout_marginBottom="5dp"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:clipToOutline="true"
android:gravity="center" />
<Button
android:id="@+id/log_access_dialog_deny_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/log_access_confirmation_deny"
style="@style/PermissionGrantButtonBottom"
android:textAppearance="@style/PermissionGrantButtonTextAppearance"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:clipToOutline="true"
android:gravity="center" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>

View File

@@ -105,7 +105,7 @@ public class LogAccessDialogActivity extends Activity implements
@Override
protected void onDestroy() {
super.onDestroy();
if (mAlert != null && mAlert.isShowing()) {
if (!isChangingConfigurations() && mAlert != null && mAlert.isShowing()) {
mAlert.dismiss();
}
mAlert = null;