From 04b02c9d44989c4010fde107df68c5b42f4e4c96 Mon Sep 17 00:00:00 2001 From: Lucas Dupin Date: Tue, 16 Feb 2021 11:48:26 -0800 Subject: [PATCH] Add neutral palette, rename main and accent Added new netrual colors palette, and renamed main and accent palettes to primary and secondary respectively. This was done to align with the new color spec. Test: atest SystemPalette Test: atest ColorTest Test: atest ThemeOverlayControllerTest Bug: 171916625 Change-Id: Ia56eb1e96a01c3ff8a64de0e1d632d4436bc9048 --- core/api/current.txt | 60 ++++---- core/res/res/values/colors.xml | 133 +++++++++++------- .../res/res/values/colors_device_defaults.xml | 34 ++--- core/res/res/values/public.xml | 65 +++++---- .../systemui/theme/ThemeOverlayApplier.java | 2 + .../theme/ThemeOverlayController.java | 44 +++--- .../theme/ThemeOverlayControllerTest.java | 3 + 7 files changed, 209 insertions(+), 132 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index 2f09ce11aeff0..fd03a70a0492e 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -1708,30 +1708,42 @@ package android { field @Deprecated public static final int secondary_text_dark_nodisable = 17170438; // 0x1060006 field @Deprecated public static final int secondary_text_light = 17170439; // 0x1060007 field @Deprecated public static final int secondary_text_light_nodisable = 17170440; // 0x1060008 - field public static final int system_accent_0 = 17170473; // 0x1060029 - field public static final int system_accent_100 = 17170475; // 0x106002b - field public static final int system_accent_1000 = 17170484; // 0x1060034 - field public static final int system_accent_200 = 17170476; // 0x106002c - field public static final int system_accent_300 = 17170477; // 0x106002d - field public static final int system_accent_400 = 17170478; // 0x106002e - field public static final int system_accent_50 = 17170474; // 0x106002a - field public static final int system_accent_500 = 17170479; // 0x106002f - field public static final int system_accent_600 = 17170480; // 0x1060030 - field public static final int system_accent_700 = 17170481; // 0x1060031 - field public static final int system_accent_800 = 17170482; // 0x1060032 - field public static final int system_accent_900 = 17170483; // 0x1060033 - field public static final int system_main_0 = 17170461; // 0x106001d - field public static final int system_main_100 = 17170463; // 0x106001f - field public static final int system_main_1000 = 17170472; // 0x1060028 - field public static final int system_main_200 = 17170464; // 0x1060020 - field public static final int system_main_300 = 17170465; // 0x1060021 - field public static final int system_main_400 = 17170466; // 0x1060022 - field public static final int system_main_50 = 17170462; // 0x106001e - field public static final int system_main_500 = 17170467; // 0x1060023 - field public static final int system_main_600 = 17170468; // 0x1060024 - field public static final int system_main_700 = 17170469; // 0x1060025 - field public static final int system_main_800 = 17170470; // 0x1060026 - field public static final int system_main_900 = 17170471; // 0x1060027 + field public static final int system_neutral_0 = 17170485; // 0x1060035 + field public static final int system_neutral_100 = 17170487; // 0x1060037 + field public static final int system_neutral_1000 = 17170496; // 0x1060040 + field public static final int system_neutral_200 = 17170488; // 0x1060038 + field public static final int system_neutral_300 = 17170489; // 0x1060039 + field public static final int system_neutral_400 = 17170490; // 0x106003a + field public static final int system_neutral_50 = 17170486; // 0x1060036 + field public static final int system_neutral_500 = 17170491; // 0x106003b + field public static final int system_neutral_600 = 17170492; // 0x106003c + field public static final int system_neutral_700 = 17170493; // 0x106003d + field public static final int system_neutral_800 = 17170494; // 0x106003e + field public static final int system_neutral_900 = 17170495; // 0x106003f + field public static final int system_primary_0 = 17170461; // 0x106001d + field public static final int system_primary_100 = 17170463; // 0x106001f + field public static final int system_primary_1000 = 17170472; // 0x1060028 + field public static final int system_primary_200 = 17170464; // 0x1060020 + field public static final int system_primary_300 = 17170465; // 0x1060021 + field public static final int system_primary_400 = 17170466; // 0x1060022 + field public static final int system_primary_50 = 17170462; // 0x106001e + field public static final int system_primary_500 = 17170467; // 0x1060023 + field public static final int system_primary_600 = 17170468; // 0x1060024 + field public static final int system_primary_700 = 17170469; // 0x1060025 + field public static final int system_primary_800 = 17170470; // 0x1060026 + field public static final int system_primary_900 = 17170471; // 0x1060027 + field public static final int system_secondary_0 = 17170473; // 0x1060029 + field public static final int system_secondary_100 = 17170475; // 0x106002b + field public static final int system_secondary_1000 = 17170484; // 0x1060034 + field public static final int system_secondary_200 = 17170476; // 0x106002c + field public static final int system_secondary_300 = 17170477; // 0x106002d + field public static final int system_secondary_400 = 17170478; // 0x106002e + field public static final int system_secondary_50 = 17170474; // 0x106002a + field public static final int system_secondary_500 = 17170479; // 0x106002f + field public static final int system_secondary_600 = 17170480; // 0x1060030 + field public static final int system_secondary_700 = 17170481; // 0x1060031 + field public static final int system_secondary_800 = 17170482; // 0x1060032 + field public static final int system_secondary_900 = 17170483; // 0x1060033 field public static final int tab_indicator_text = 17170441; // 0x1060009 field @Deprecated public static final int tertiary_text_dark = 17170448; // 0x1060010 field @Deprecated public static final int tertiary_text_light = 17170449; // 0x1060011 diff --git a/core/res/res/values/colors.xml b/core/res/res/values/colors.xml index e7c4947bed5fb..59c260cecfbf0 100644 --- a/core/res/res/values/colors.xml +++ b/core/res/res/values/colors.xml @@ -240,77 +240,114 @@ #F9AB00 - - #ffffff - - #f2f2f2 - - #e3e3e3 - - #c7c7c7 - - #ababab - - #8f8f8f - - #757575 - - #5e5e5e - - #474747 - - #303030 - - #1f1f1f - - #000000 + #000000 - - #ffffff - - #91fff4 - - #83f6e5 - - #65d9c9 - - #45bdae - - #1fa293 - - #008377 - - #006d61 - - #005449 - - #003c33 - - #00271e - - #000000 + #000000 + + + #ffffff + + #f0f0f0 + + #e2e2e2 + + #c6c6c6 + + #ababab + + #909090 + + #757575 + + #5e5e5e + + #464646 + + #303030 + + #1b1b1b + + #000000 diff --git a/core/res/res/values/colors_device_defaults.xml b/core/res/res/values/colors_device_defaults.xml index f7234269f227b..1020c14ef6654 100644 --- a/core/res/res/values/colors_device_defaults.xml +++ b/core/res/res/values/colors_device_defaults.xml @@ -17,9 +17,9 @@ - @color/system_main_800 - @color/system_main_50 - @color/system_main_800 + @color/system_primary_800 + @color/system_primary_50 + @color/system_primary_800 @color/primary_device_default_light @color/primary_device_default_dark @color/primary_device_default_light @@ -33,21 +33,21 @@ @color/tertiary_material_settings @color/quaternary_material_settings - @color/system_accent_600 - @color/system_accent_200 + @color/system_secondary_600 + @color/system_secondary_200 @color/accent_device_default_light - @color/system_main_800 - @color/system_main_50 - @color/system_main_900 - @color/system_main_100 + @color/system_primary_800 + @color/system_primary_50 + @color/system_primary_900 + @color/system_primary_100 - @color/system_main_900 - @color/system_main_50 - @color/system_main_700 - @color/system_main_200 - @color/system_main_500 - @color/system_main_400 + @color/system_primary_900 + @color/system_primary_50 + @color/system_primary_700 + @color/system_primary_200 + @color/system_primary_500 + @color/system_primary_400 @color/text_color_primary_device_default_light @color/text_color_primary_device_default_dark @@ -55,8 +55,8 @@ @color/error_color_material_dark @color/error_color_material_light - @color/system_main_500 - @color/system_main_400 + @color/system_primary_500 + @color/system_primary_400 @android:color/white @android:color/white diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index fdef08bc5faab..0399afd20e969 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -3082,32 +3082,45 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayApplier.java b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayApplier.java index 9e78a664d35f7..0a3e83326e013 100644 --- a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayApplier.java +++ b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayApplier.java @@ -65,6 +65,8 @@ public class ThemeOverlayApplier implements Dumpable { "android.theme.customization.accent_color"; static final String OVERLAY_CATEGORY_SYSTEM_PALETTE = "android.theme.customization.system_palette"; + static final String OVERLAY_CATEGORY_NEUTRAL_PALETTE = + "android.theme.customization.neutral_palette"; @VisibleForTesting static final String OVERLAY_CATEGORY_FONT = "android.theme.customization.font"; @VisibleForTesting diff --git a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java index 522a42b8d4b47..1f222d80f014b 100644 --- a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java +++ b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java @@ -16,6 +16,7 @@ package com.android.systemui.theme; import static com.android.systemui.theme.ThemeOverlayApplier.OVERLAY_CATEGORY_ACCENT_COLOR; +import static com.android.systemui.theme.ThemeOverlayApplier.OVERLAY_CATEGORY_NEUTRAL_PALETTE; import static com.android.systemui.theme.ThemeOverlayApplier.OVERLAY_CATEGORY_SYSTEM_PALETTE; import android.annotation.Nullable; @@ -83,8 +84,9 @@ public class ThemeOverlayController extends SystemUI implements Dumpable { protected static final String TAG = "ThemeOverlayController"; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); - protected static final int MAIN = 0; - protected static final int ACCENT = 1; + protected static final int PRIMARY = 0; + protected static final int SECONDARY = 1; + protected static final int NEUTRAL = 1; // If lock screen wallpaper colors should also be considered when selecting the theme. // Doing this has performance impact, given that overlays would need to be swapped when @@ -111,9 +113,11 @@ public class ThemeOverlayController extends SystemUI implements Dumpable { // Accent color extracted from wallpaper, NOT the color used on the overlay protected int mWallpaperAccentColor = Color.TRANSPARENT; // System colors overlay - private FabricatedOverlay mSystemOverlay; + private FabricatedOverlay mPrimaryOverlay; // Accent colors overlay - private FabricatedOverlay mAccentOverlay; + private FabricatedOverlay mSecondaryOverlay; + // Neutral system colors overlay + private FabricatedOverlay mNeutralOverlay; @Inject public ThemeOverlayController(Context context, BroadcastDispatcher broadcastDispatcher, @@ -232,12 +236,13 @@ public class ThemeOverlayController extends SystemUI implements Dumpable { mWallpaperAccentColor = accentCandidate; if (mIsMonetEnabled) { - mSystemOverlay = getOverlay(mMainWallpaperColor, MAIN); - mAccentOverlay = getOverlay(mWallpaperAccentColor, ACCENT); + mPrimaryOverlay = getOverlay(mMainWallpaperColor, PRIMARY); + mSecondaryOverlay = getOverlay(mWallpaperAccentColor, SECONDARY); + mNeutralOverlay = getOverlay(mMainWallpaperColor, NEUTRAL); mNeedsOverlayCreation = true; if (DEBUG) { - Log.d(TAG, "fetched overlays. system: " + mSystemOverlay + " accent: " - + mAccentOverlay); + Log.d(TAG, "fetched overlays. primary: " + mPrimaryOverlay + " secondary: " + + mSecondaryOverlay + " neutral: " + mNeutralOverlay); } } @@ -296,7 +301,9 @@ public class ThemeOverlayController extends SystemUI implements Dumpable { if (mIsMonetEnabled && systemPalette != null && systemPalette.getPackageName() != null) { try { int color = Integer.parseInt(systemPalette.getPackageName().toLowerCase(), 16); - mSystemOverlay = getOverlay(color, MAIN); + mPrimaryOverlay = getOverlay(color, PRIMARY); + // Neutral palette is always derived from primary color. + mNeutralOverlay = getOverlay(color, NEUTRAL); mNeedsOverlayCreation = true; categoryToPackage.remove(OVERLAY_CATEGORY_SYSTEM_PALETTE); } catch (NumberFormatException e) { @@ -309,7 +316,7 @@ public class ThemeOverlayController extends SystemUI implements Dumpable { if (mIsMonetEnabled && accentPalette != null && accentPalette.getPackageName() != null) { try { int color = Integer.parseInt(accentPalette.getPackageName().toLowerCase(), 16); - mAccentOverlay = getOverlay(color, ACCENT); + mSecondaryOverlay = getOverlay(color, SECONDARY); mNeedsOverlayCreation = true; categoryToPackage.remove(OVERLAY_CATEGORY_ACCENT_COLOR); } catch (NumberFormatException e) { @@ -320,12 +327,14 @@ public class ThemeOverlayController extends SystemUI implements Dumpable { // Compatibility with legacy themes, where full packages were defined, instead of just // colors. if (!categoryToPackage.containsKey(OVERLAY_CATEGORY_SYSTEM_PALETTE) - && mSystemOverlay != null) { - categoryToPackage.put(OVERLAY_CATEGORY_SYSTEM_PALETTE, mSystemOverlay.getIdentifier()); + && mPrimaryOverlay != null) { + categoryToPackage.put(OVERLAY_CATEGORY_SYSTEM_PALETTE, mPrimaryOverlay.getIdentifier()); + categoryToPackage.put(OVERLAY_CATEGORY_NEUTRAL_PALETTE, + mNeutralOverlay.getIdentifier()); } if (!categoryToPackage.containsKey(OVERLAY_CATEGORY_ACCENT_COLOR) - && mAccentOverlay != null) { - categoryToPackage.put(OVERLAY_CATEGORY_ACCENT_COLOR, mAccentOverlay.getIdentifier()); + && mSecondaryOverlay != null) { + categoryToPackage.put(OVERLAY_CATEGORY_ACCENT_COLOR, mSecondaryOverlay.getIdentifier()); } Set userHandles = Sets.newHashSet(UserHandle.of(currentUser)); @@ -342,7 +351,7 @@ public class ThemeOverlayController extends SystemUI implements Dumpable { if (mNeedsOverlayCreation) { mNeedsOverlayCreation = false; mThemeManager.applyCurrentUserOverlays(categoryToPackage, new FabricatedOverlay[] { - mSystemOverlay, mAccentOverlay + mPrimaryOverlay, mSecondaryOverlay, mNeutralOverlay }, userHandles); } else { mThemeManager.applyCurrentUserOverlays(categoryToPackage, null, userHandles); @@ -356,8 +365,9 @@ public class ThemeOverlayController extends SystemUI implements Dumpable { pw.println("mSystemColors=" + mSystemColors); pw.println("mMainWallpaperColor=" + Integer.toHexString(mMainWallpaperColor)); pw.println("mWallpaperAccentColor=" + Integer.toHexString(mWallpaperAccentColor)); - pw.println("mSystemOverlayColor=" + mSystemOverlay); - pw.println("mAccentOverlayColor=" + mAccentOverlay); + pw.println("mPrimaryOverlay=" + mPrimaryOverlay); + pw.println("mSecondaryOverlay=" + mSecondaryOverlay); + pw.println("mNeutralOverlay=" + mNeutralOverlay); pw.println("mIsMonetEnabled=" + mIsMonetEnabled); pw.println("mNeedsOverlayCreation=" + mNeedsOverlayCreation); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java index f7f8d03da1c2b..aa385effa931d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java @@ -17,6 +17,7 @@ package com.android.systemui.theme; import static com.android.systemui.theme.ThemeOverlayApplier.OVERLAY_CATEGORY_ACCENT_COLOR; +import static com.android.systemui.theme.ThemeOverlayApplier.OVERLAY_CATEGORY_NEUTRAL_PALETTE; import static com.android.systemui.theme.ThemeOverlayApplier.OVERLAY_CATEGORY_SYSTEM_PALETTE; import static com.android.systemui.theme.ThemeOverlayController.USE_LOCK_SCREEN_WALLPAPER; @@ -147,6 +148,8 @@ public class ThemeOverlayControllerTest extends SysuiTestCase { // Assert that we received the colors that we were expecting assertThat(themeOverlays.getValue().get(OVERLAY_CATEGORY_SYSTEM_PALETTE)) .isEqualTo(new OverlayIdentifier("ffff0000")); + assertThat(themeOverlays.getValue().get(OVERLAY_CATEGORY_NEUTRAL_PALETTE)) + .isEqualTo(new OverlayIdentifier("ffff0000")); assertThat(themeOverlays.getValue().get(OVERLAY_CATEGORY_ACCENT_COLOR)) .isEqualTo(new OverlayIdentifier("ff0000ff"));