diff --git a/libs/WindowManager/Shell/res/drawable/letterbox_education_dialog_background.xml b/libs/WindowManager/Shell/res/drawable/letterbox_education_dialog_background.xml index 3e1a2bce23932..e7c89d1f9c763 100644 --- a/libs/WindowManager/Shell/res/drawable/letterbox_education_dialog_background.xml +++ b/libs/WindowManager/Shell/res/drawable/letterbox_education_dialog_background.xml @@ -15,7 +15,8 @@ ~ limitations under the License. --> - + \ No newline at end of file diff --git a/libs/WindowManager/Shell/res/drawable/letterbox_education_dismiss_button_background_ripple.xml b/libs/WindowManager/Shell/res/drawable/letterbox_education_dismiss_button_background_ripple.xml index a2699681e6564..72ebef625ffc0 100644 --- a/libs/WindowManager/Shell/res/drawable/letterbox_education_dismiss_button_background_ripple.xml +++ b/libs/WindowManager/Shell/res/drawable/letterbox_education_dismiss_button_background_ripple.xml @@ -15,6 +15,7 @@ ~ limitations under the License. --> @@ -31,7 +32,7 @@ - + \ No newline at end of file diff --git a/libs/WindowManager/Shell/res/layout/letterbox_education_dialog_action_layout.xml b/libs/WindowManager/Shell/res/layout/letterbox_education_dialog_action_layout.xml index 095576b581df0..c77a4fdcfa79d 100644 --- a/libs/WindowManager/Shell/res/layout/letterbox_education_dialog_action_layout.xml +++ b/libs/WindowManager/Shell/res/layout/letterbox_education_dialog_action_layout.xml @@ -16,6 +16,7 @@ \ No newline at end of file diff --git a/libs/WindowManager/Shell/res/layout/letterbox_education_dialog_layout.xml b/libs/WindowManager/Shell/res/layout/letterbox_education_dialog_layout.xml index a993469aaccf5..4d52567770189 100644 --- a/libs/WindowManager/Shell/res/layout/letterbox_education_dialog_layout.xml +++ b/libs/WindowManager/Shell/res/layout/letterbox_education_dialog_layout.xml @@ -15,6 +15,7 @@ --> @@ -66,7 +67,7 @@ android:lineSpacingExtra="4sp" android:text="@string/letterbox_education_dialog_title" android:textAlignment="center" - android:textColor="@color/compat_controls_text" + android:textColor="?android:attr/textColorPrimary" android:fontFamily="@*android:string/config_bodyFontFamilyMedium" android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Headline" android:textSize="24sp"/> @@ -108,7 +109,7 @@ android:background= "@drawable/letterbox_education_dismiss_button_background_ripple" android:text="@string/letterbox_education_got_it" - android:textColor="@android:color/system_neutral1_900" + android:textColor="?android:attr/textColorPrimaryInverse" android:textAlignment="center" android:contentDescription="@string/letterbox_education_got_it"/> diff --git a/libs/WindowManager/Shell/res/values/colors.xml b/libs/WindowManager/Shell/res/values/colors.xml index 33861485d6f7d..171a6b2fe5fb1 100644 --- a/libs/WindowManager/Shell/res/values/colors.xml +++ b/libs/WindowManager/Shell/res/values/colors.xml @@ -39,7 +39,6 @@ @android:color/system_neutral1_50 - @android:color/system_accent1_100 @android:color/system_neutral2_200 diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java index 2bbd870f024d3..62b0799618acf 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java @@ -334,17 +334,19 @@ public class CompatUIController implements OnDisplaysChangedListener, private void createOrUpdateLetterboxEduLayout(TaskInfo taskInfo, ShellTaskOrganizer.TaskListener taskListener) { - if (mActiveLetterboxEduLayout != null - && mActiveLetterboxEduLayout.getTaskId() == taskInfo.taskId) { - // UI already exists, update the UI layout. - if (!mActiveLetterboxEduLayout.updateCompatInfo(taskInfo, taskListener, - showOnDisplay(mActiveLetterboxEduLayout.getDisplayId()))) { - // The layout is no longer eligible to be shown, clear active layout. + if (mActiveLetterboxEduLayout != null) { + if (mActiveLetterboxEduLayout.needsToBeRecreated(taskInfo, taskListener)) { + mActiveLetterboxEduLayout.release(); mActiveLetterboxEduLayout = null; + } else { + if (!mActiveLetterboxEduLayout.updateCompatInfo(taskInfo, taskListener, + showOnDisplay(mActiveLetterboxEduLayout.getDisplayId()))) { + // The layout is no longer eligible to be shown, clear active layout. + mActiveLetterboxEduLayout = null; + } + return; } - return; } - // Create a new UI layout. final Context context = getOrCreateDisplayContext(taskInfo.displayId); if (context == null) { diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/LetterboxEduWindowManager.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/LetterboxEduWindowManager.java index 9a67258ded2ea..fce1a39399d0d 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/LetterboxEduWindowManager.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/LetterboxEduWindowManager.java @@ -141,7 +141,6 @@ class LetterboxEduWindowManager extends CompatUIWindowManagerAbstract { // startEnterAnimation will be called immediately if shell-transitions are disabled. mTransitions.runOnIdle(this::startEnterAnimation); - return mLayout; } @@ -210,6 +209,12 @@ class LetterboxEduWindowManager extends CompatUIWindowManagerAbstract { return super.updateCompatInfo(taskInfo, taskListener, canShow); } + @Override + boolean needsToBeRecreated(TaskInfo taskInfo, ShellTaskOrganizer.TaskListener taskListener) { + return super.needsToBeRecreated(taskInfo, taskListener) + && !mCompatUIConfiguration.getHasSeenLetterboxEducation(mUserId); + } + @Override protected void onParentBoundsChanged() { if (mLayout == null) { diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/LetterboxEduWindowManagerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/LetterboxEduWindowManagerTest.java index 12ceb0a9a9ba9..9200b3c90f0d6 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/LetterboxEduWindowManagerTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/LetterboxEduWindowManagerTest.java @@ -16,6 +16,8 @@ package com.android.wm.shell.compatui; +import static android.content.res.Configuration.UI_MODE_NIGHT_YES; + import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; import static com.google.common.truth.Truth.assertThat; @@ -371,6 +373,25 @@ public class LetterboxEduWindowManagerTest extends ShellTestCase { verify(mAnimationController).cancelAnimation(); } + @Test + public void testDeviceThemeChange_educationDialogUnseen_recreated() { + LetterboxEduWindowManager windowManager = createWindowManager(/* eligible= */ true); + ActivityManager.RunningTaskInfo newTaskInfo = new ActivityManager.RunningTaskInfo(); + newTaskInfo.configuration.uiMode |= UI_MODE_NIGHT_YES; + + assertTrue(windowManager.needsToBeRecreated(newTaskInfo, mTaskListener)); + } + + @Test + public void testDeviceThemeHasChanged_educationDialogSeen_notRecreated() { + LetterboxEduWindowManager windowManager = createWindowManager(/* eligible= */ true); + mCompatUIConfiguration.setSeenLetterboxEducation(USER_ID_1); + ActivityManager.RunningTaskInfo newTaskInfo = new ActivityManager.RunningTaskInfo(); + newTaskInfo.configuration.uiMode |= UI_MODE_NIGHT_YES; + + assertFalse(windowManager.needsToBeRecreated(newTaskInfo, mTaskListener)); + } + private void verifyLayout(LetterboxEduDialogLayout layout, ViewGroup.LayoutParams params, int expectedWidth, int expectedHeight, int expectedExtraTopMargin, int expectedExtraBottomMargin) {