diff options
5 files changed, 75 insertions, 11 deletions
diff --git a/packages/SystemUI/res/layout/activity_rear_display_education_opened.xml b/packages/SystemUI/res/layout/activity_rear_display_education_opened.xml index c12bfcca4eff..0e6b2812a8a9 100644 --- a/packages/SystemUI/res/layout/activity_rear_display_education_opened.xml +++ b/packages/SystemUI/res/layout/activity_rear_display_education_opened.xml @@ -32,8 +32,8 @@ <com.airbnb.lottie.LottieAnimationView android:id="@+id/rear_display_folded_animation" android:importantForAccessibility="no" - android:layout_width="@dimen/rear_display_animation_width" - android:layout_height="@dimen/rear_display_animation_height" + android:layout_width="@dimen/rear_display_animation_width_opened" + android:layout_height="@dimen/rear_display_animation_height_opened" android:layout_gravity="center" android:contentDescription="@string/rear_display_accessibility_unfolded_animation" android:scaleType="fitXY" @@ -49,8 +49,8 @@ android:text="@string/rear_display_unfolded_bottom_sheet_title" android:textAppearance="@style/TextAppearance.Dialog.Title" android:lineSpacingExtra="2sp" - android:paddingTop="@dimen/rear_display_title_top_padding" - android:paddingBottom="@dimen/rear_display_title_bottom_padding" + android:paddingTop="@dimen/rear_display_title_top_padding_opened" + android:paddingBottom="@dimen/rear_display_title_bottom_padding_opened" android:gravity="center_horizontal|center_vertical" /> diff --git a/packages/SystemUI/res/values-land/dimens.xml b/packages/SystemUI/res/values-land/dimens.xml index 908aac4a7b7f..f277e8a6f02f 100644 --- a/packages/SystemUI/res/values-land/dimens.xml +++ b/packages/SystemUI/res/values-land/dimens.xml @@ -67,6 +67,12 @@ <dimen name="controls_header_horizontal_padding">12dp</dimen> <dimen name="controls_content_margin_horizontal">16dp</dimen> + <!-- Rear Display Education dimens --> + <dimen name="rear_display_animation_width">246dp</dimen> + <dimen name="rear_display_animation_height">180dp</dimen> + <dimen name="rear_display_title_top_padding">4dp</dimen> + <dimen name="rear_display_title_bottom_padding">0dp</dimen> + <!-- Bouncer user switcher margins --> <dimen name="bouncer_user_switcher_view_mode_user_switcher_bottom_margin">0dp</dimen> <dimen name="bouncer_user_switcher_view_mode_view_flipper_bottom_margin">0dp</dimen> diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index c82d0544e739..2024daefbdff 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -1772,8 +1772,12 @@ <!-- Rear Display Education dimens --> <dimen name="rear_display_animation_width">273dp</dimen> <dimen name="rear_display_animation_height">200dp</dimen> + <dimen name="rear_display_animation_width_opened">273dp</dimen> + <dimen name="rear_display_animation_height_opened">200dp</dimen> <dimen name="rear_display_title_top_padding">24dp</dimen> <dimen name="rear_display_title_bottom_padding">16dp</dimen> + <dimen name="rear_display_title_top_padding_opened">24dp</dimen> + <dimen name="rear_display_title_bottom_padding_opened">16dp</dimen> <!-- Bouncer user switcher margins --> <dimen name="bouncer_user_switcher_view_mode_user_switcher_bottom_margin">0dp</dimen> diff --git a/packages/SystemUI/src/com/android/systemui/reardisplay/RearDisplayDialogController.java b/packages/SystemUI/src/com/android/systemui/reardisplay/RearDisplayDialogController.java index dc3c8203d1a2..6912114140b0 100644 --- a/packages/SystemUI/src/com/android/systemui/reardisplay/RearDisplayDialogController.java +++ b/packages/SystemUI/src/com/android/systemui/reardisplay/RearDisplayDialogController.java @@ -16,12 +16,16 @@ package com.android.systemui.reardisplay; +import android.annotation.Nullable; import android.annotation.SuppressLint; import android.annotation.TestApi; import android.content.Context; +import android.content.res.Configuration; import android.hardware.devicestate.DeviceStateManager; import android.hardware.devicestate.DeviceStateManagerGlobal; import android.view.View; +import android.view.ViewGroup.LayoutParams; +import android.widget.LinearLayout; import com.android.internal.annotations.VisibleForTesting; import com.android.systemui.CoreStartable; @@ -70,6 +74,7 @@ public class RearDisplayDialogController implements CoreStartable, CommandQueue. @VisibleForTesting SystemUIDialog mRearDisplayEducationDialog; + @Nullable LinearLayout mDialogViewContainer; @Inject public RearDisplayDialogController(Context context, CommandQueue commandQueue, @@ -90,26 +95,51 @@ public class RearDisplayDialogController implements CoreStartable, CommandQueue. createAndShowDialog(); } + @Override + public void onConfigurationChanged(Configuration newConfig) { + if (mRearDisplayEducationDialog != null && mRearDisplayEducationDialog.isShowing() + && mDialogViewContainer != null) { + // Refresh the dialog view when configuration is changed. + Context dialogContext = mRearDisplayEducationDialog.getContext(); + View dialogView = createDialogView(dialogContext); + mDialogViewContainer.removeAllViews(); + mDialogViewContainer.addView(dialogView); + } + } + private void createAndShowDialog() { mServiceNotified = false; Context dialogContext = mRearDisplayEducationDialog.getContext(); + View dialogView = createDialogView(dialogContext); + + mDialogViewContainer = new LinearLayout(dialogContext); + mDialogViewContainer.setLayoutParams( + new LinearLayout.LayoutParams( + LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); + mDialogViewContainer.setOrientation(LinearLayout.VERTICAL); + mDialogViewContainer.addView(dialogView); + + mRearDisplayEducationDialog.setView(mDialogViewContainer); + + configureDialogButtons(); + + mRearDisplayEducationDialog.show(); + } + + private View createDialogView(Context context) { View dialogView; if (mStartedFolded) { - dialogView = View.inflate(dialogContext, + dialogView = View.inflate(context, R.layout.activity_rear_display_education, null); } else { - dialogView = View.inflate(dialogContext, + dialogView = View.inflate(context, R.layout.activity_rear_display_education_opened, null); } LottieAnimationView animationView = dialogView.findViewById( R.id.rear_display_folded_animation); animationView.setRepeatCount(mAnimationRepeatCount); - mRearDisplayEducationDialog.setView(dialogView); - - configureDialogButtons(); - - mRearDisplayEducationDialog.show(); + return dialogView; } /** @@ -164,6 +194,7 @@ public class RearDisplayDialogController implements CoreStartable, CommandQueue. mServiceNotified = true; mDeviceStateManagerGlobal.unregisterDeviceStateCallback(mDeviceStateManagerCallback); mDeviceStateManagerGlobal.onStateRequestOverlayDismissed(shouldCancelRequest); + mDialogViewContainer = null; } /** diff --git a/packages/SystemUI/tests/src/com/android/systemui/reardisplay/RearDisplayDialogControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/reardisplay/RearDisplayDialogControllerTest.java index 9acd47e4378f..55813f60aecd 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/reardisplay/RearDisplayDialogControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/reardisplay/RearDisplayDialogControllerTest.java @@ -17,8 +17,10 @@ package com.android.systemui.reardisplay; import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotSame; import static junit.framework.Assert.assertTrue; +import android.content.res.Configuration; import android.hardware.devicestate.DeviceStateManager; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; @@ -68,6 +70,27 @@ public class RearDisplayDialogControllerTest extends SysuiTestCase { } @Test + public void testClosedDialogIsRefreshedOnConfigurationChange() { + RearDisplayDialogController controller = new RearDisplayDialogController(mContext, + mCommandQueue, mFakeExecutor); + controller.setDeviceStateManagerCallback(new TestDeviceStateManagerCallback()); + controller.setFoldedStates(new int[]{0}); + controller.setAnimationRepeatCount(0); + + controller.showRearDisplayDialog(CLOSED_BASE_STATE); + assertTrue(controller.mRearDisplayEducationDialog.isShowing()); + TextView deviceClosedTitleTextView = controller.mRearDisplayEducationDialog.findViewById( + R.id.rear_display_title_text_view); + + controller.onConfigurationChanged(new Configuration()); + assertTrue(controller.mRearDisplayEducationDialog.isShowing()); + TextView deviceClosedTitleTextView2 = controller.mRearDisplayEducationDialog.findViewById( + R.id.rear_display_title_text_view); + + assertNotSame(deviceClosedTitleTextView, deviceClosedTitleTextView2); + } + + @Test public void testOpenDialogIsShown() { RearDisplayDialogController controller = new RearDisplayDialogController(mContext, mCommandQueue, mFakeExecutor); |