summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/WindowManager/Shell/res/drawable/letterbox_education_dialog_background.xml3
-rw-r--r--libs/WindowManager/Shell/res/drawable/letterbox_education_dismiss_button_background_ripple.xml3
-rw-r--r--libs/WindowManager/Shell/res/drawable/letterbox_education_ic_light_bulb.xml3
-rw-r--r--libs/WindowManager/Shell/res/layout/letterbox_education_dialog_action_layout.xml3
-rw-r--r--libs/WindowManager/Shell/res/layout/letterbox_education_dialog_layout.xml5
-rw-r--r--libs/WindowManager/Shell/res/values/colors.xml1
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java18
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/compatui/LetterboxEduWindowManager.java7
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/LetterboxEduWindowManagerTest.java21
9 files changed, 48 insertions, 16 deletions
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 3e1a2bce2393..e7c89d1f9c76 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.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:shape="rectangle">
- <solid android:color="@color/compat_controls_background"/>
+ <solid android:color="?androidprv:attr/colorSurface"/>
<corners android:radius="@dimen/letterbox_education_dialog_corner_radius"/>
</shape> \ 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 a2699681e656..72ebef625ffc 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.
-->
<inset xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:insetTop="@dimen/letterbox_education_dialog_vertical_inset"
android:insetBottom="@dimen/letterbox_education_dialog_vertical_inset">
<ripple android:color="@color/letterbox_education_dismiss_button_background_ripple">
@@ -31,7 +32,7 @@
</item>
<item>
<shape android:shape="rectangle">
- <solid android:color="@color/letterbox_education_accent_primary"/>
+ <solid android:color="?androidprv:attr/colorAccentPrimaryVariant"/>
<corners android:radius="@dimen/letterbox_education_dialog_button_radius"/>
<padding android:left="@dimen/letterbox_education_dialog_horizontal_padding"
android:top="@dimen/letterbox_education_dialog_vertical_padding"
diff --git a/libs/WindowManager/Shell/res/drawable/letterbox_education_ic_light_bulb.xml b/libs/WindowManager/Shell/res/drawable/letterbox_education_ic_light_bulb.xml
index ddfb5c27e701..4a1e7485ed19 100644
--- a/libs/WindowManager/Shell/res/drawable/letterbox_education_ic_light_bulb.xml
+++ b/libs/WindowManager/Shell/res/drawable/letterbox_education_ic_light_bulb.xml
@@ -15,12 +15,13 @@
~ limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:width="@dimen/letterbox_education_dialog_title_icon_width"
android:height="@dimen/letterbox_education_dialog_title_icon_height"
android:viewportWidth="45"
android:viewportHeight="44">
<path
- android:fillColor="@color/letterbox_education_accent_primary"
+ android:fillColor="?androidprv:attr/colorAccentPrimaryVariant"
android:pathData="M11 40H19C19 42.2 17.2 44 15 44C12.8 44 11 42.2 11 40ZM7 38L23 38V34L7 34L7 38ZM30 19C30 26.64 24.68 30.72 22.46 32L7.54 32C5.32 30.72 0 26.64 0 19C0 10.72 6.72 4 15 4C23.28 4 30 10.72 30 19ZM26 19C26 12.94 21.06 8 15 8C8.94 8 4 12.94 4 19C4 23.94 6.98 26.78 8.7 28L21.3 28C23.02 26.78 26 23.94 26 19ZM39.74 14.74L37 16L39.74 17.26L41 20L42.26 17.26L45 16L42.26 14.74L41 12L39.74 14.74ZM35 12L36.88 7.88L41 6L36.88 4.12L35 0L33.12 4.12L29 6L33.12 7.88L35 12Z" />
</vector> \ 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 095576b581df..c77a4fdcfa79 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 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:layout_width="@dimen/letterbox_education_dialog_action_width"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
@@ -36,7 +37,7 @@
android:layout_height="wrap_content"
android:lineSpacingExtra="4sp"
android:textAlignment="center"
- android:textColor="@color/compat_controls_text"
+ android:textColor="?android:attr/textColorSecondary"
android:textSize="14sp"/>
</LinearLayout> \ 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 a993469aaccf..4d5256777018 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 @@
-->
<com.android.wm.shell.compatui.LetterboxEduDialogLayout
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/LetterboxDialog">
@@ -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 33861485d6f7..171a6b2fe5fb 100644
--- a/libs/WindowManager/Shell/res/values/colors.xml
+++ b/libs/WindowManager/Shell/res/values/colors.xml
@@ -39,7 +39,6 @@
<color name="compat_controls_text">@android:color/system_neutral1_50</color>
<!-- Letterbox Education -->
- <color name="letterbox_education_accent_primary">@android:color/system_accent1_100</color>
<color name="letterbox_education_text_secondary">@android:color/system_neutral2_200</color>
<!-- Letterbox Dialog -->
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 2bbd870f024d..62b0799618ac 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 9a67258ded2e..fce1a39399d0 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;
}
@@ -211,6 +210,12 @@ class LetterboxEduWindowManager extends CompatUIWindowManagerAbstract {
}
@Override
+ boolean needsToBeRecreated(TaskInfo taskInfo, ShellTaskOrganizer.TaskListener taskListener) {
+ return super.needsToBeRecreated(taskInfo, taskListener)
+ && !mCompatUIConfiguration.getHasSeenLetterboxEducation(mUserId);
+ }
+
+ @Override
protected void onParentBoundsChanged() {
if (mLayout == null) {
return;
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 12ceb0a9a9ba..9200b3c90f0d 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) {