Loading packages/SystemUI/res/layout/activity_rear_display_education_opened.xml +4 −4 Original line number Diff line number Diff line Loading @@ -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" Loading @@ -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" /> Loading packages/SystemUI/res/values-land/dimens.xml +6 −0 Original line number Diff line number Diff line Loading @@ -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> Loading packages/SystemUI/res/values/dimens.xml +4 −0 Original line number Diff line number Diff line Loading @@ -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> Loading packages/SystemUI/src/com/android/systemui/reardisplay/RearDisplayDialogController.java +38 −7 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -70,6 +74,7 @@ public class RearDisplayDialogController implements CoreStartable, CommandQueue. @VisibleForTesting SystemUIDialog mRearDisplayEducationDialog; @Nullable LinearLayout mDialogViewContainer; @Inject public RearDisplayDialogController(Context context, CommandQueue commandQueue, Loading @@ -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; } /** Loading Loading @@ -164,6 +194,7 @@ public class RearDisplayDialogController implements CoreStartable, CommandQueue. mServiceNotified = true; mDeviceStateManagerGlobal.unregisterDeviceStateCallback(mDeviceStateManagerCallback); mDeviceStateManagerGlobal.onStateRequestOverlayDismissed(shouldCancelRequest); mDialogViewContainer = null; } /** Loading packages/SystemUI/tests/src/com/android/systemui/reardisplay/RearDisplayDialogControllerTest.java +23 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -67,6 +69,27 @@ public class RearDisplayDialogControllerTest extends SysuiTestCase { R.string.rear_display_folded_bottom_sheet_title)); } @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, Loading Loading
packages/SystemUI/res/layout/activity_rear_display_education_opened.xml +4 −4 Original line number Diff line number Diff line Loading @@ -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" Loading @@ -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" /> Loading
packages/SystemUI/res/values-land/dimens.xml +6 −0 Original line number Diff line number Diff line Loading @@ -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> Loading
packages/SystemUI/res/values/dimens.xml +4 −0 Original line number Diff line number Diff line Loading @@ -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> Loading
packages/SystemUI/src/com/android/systemui/reardisplay/RearDisplayDialogController.java +38 −7 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -70,6 +74,7 @@ public class RearDisplayDialogController implements CoreStartable, CommandQueue. @VisibleForTesting SystemUIDialog mRearDisplayEducationDialog; @Nullable LinearLayout mDialogViewContainer; @Inject public RearDisplayDialogController(Context context, CommandQueue commandQueue, Loading @@ -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; } /** Loading Loading @@ -164,6 +194,7 @@ public class RearDisplayDialogController implements CoreStartable, CommandQueue. mServiceNotified = true; mDeviceStateManagerGlobal.unregisterDeviceStateCallback(mDeviceStateManagerCallback); mDeviceStateManagerGlobal.onStateRequestOverlayDismissed(shouldCancelRequest); mDialogViewContainer = null; } /** Loading
packages/SystemUI/tests/src/com/android/systemui/reardisplay/RearDisplayDialogControllerTest.java +23 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -67,6 +69,27 @@ public class RearDisplayDialogControllerTest extends SysuiTestCase { R.string.rear_display_folded_bottom_sheet_title)); } @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, Loading