Make letterbox education dialog react to dark/light themes
Update letterbox education dialog to use colours assigned based on the system theme. Force letterbox education dialog component to be recreated if the system theme has been change or device is docked while the dialoge is visible Fixes: 270936761 Test: atest WMShellUnitTests:LetterboxEduWindowManagerTest Change-Id: I3422c4ca7d7abdc085b28b341f7d539bc1447f66
This commit is contained in:
@@ -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>
|
||||
@@ -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"
|
||||
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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"/>
|
||||
|
||||
|
||||
@@ -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 -->
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user