From 103ef7dadf707c801640224f588bf5a8ce8a3040 Mon Sep 17 00:00:00 2001 From: James O'Leary Date: Tue, 26 Apr 2022 22:49:35 +0000 Subject: [PATCH] Add color scheme constructor that takes WallpaperColors & Style objects Pairs with, and needed for, a CL that enables Widgets to use the user-selected theme variant. Bug: 213314628 Test: visual inspection at runtime: use different wallpapers and widgets in different locations, change to different theme variants, observe changes and verify they're in line with expectations (ex. if a widget is blue in the default theme variant, in the expressive theme variant it rotates hue just like a blue theme color does in expressive hue) Change-Id: I288a4faeba06042037b468c8345414ef5547325c --- .../src/com/android/systemui/monet/ColorScheme.kt | 9 +++++++-- .../com/android/systemui/monet/ColorSchemeTest.java | 10 ++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/monet/src/com/android/systemui/monet/ColorScheme.kt b/packages/SystemUI/monet/src/com/android/systemui/monet/ColorScheme.kt index 9ea1e7410de3c..dd45b6f39bddc 100644 --- a/packages/SystemUI/monet/src/com/android/systemui/monet/ColorScheme.kt +++ b/packages/SystemUI/monet/src/com/android/systemui/monet/ColorScheme.kt @@ -225,8 +225,13 @@ class ColorScheme( constructor(@ColorInt seed: Int, darkTheme: Boolean): this(seed, darkTheme, Style.TONAL_SPOT) - constructor(wallpaperColors: WallpaperColors, darkTheme: Boolean): - this(getSeedColor(wallpaperColors), darkTheme) + @JvmOverloads + constructor( + wallpaperColors: WallpaperColors, + darkTheme: Boolean, + style: Style = Style.TONAL_SPOT + ): + this(getSeedColor(wallpaperColors), darkTheme, style) val allAccentColors: List get() { diff --git a/packages/SystemUI/tests/src/com/android/systemui/monet/ColorSchemeTest.java b/packages/SystemUI/tests/src/com/android/systemui/monet/ColorSchemeTest.java index 05e83d2d05135..863484b62a004 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/monet/ColorSchemeTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/monet/ColorSchemeTest.java @@ -62,6 +62,16 @@ public class ColorSchemeTest extends SysuiTestCase { Assert.assertEquals(rankedSeedColors, List.of(0xffaec00a)); } + @Test + public void testStyleApplied() { + WallpaperColors wallpaperColors = new WallpaperColors(Color.valueOf(0xffaec00a), + null, null); + // Expressive applies hue rotations to the theme color. The input theme color has hue + // 117, ensuring the hue changed significantly is a strong signal styles are being applied. + ColorScheme colorScheme = new ColorScheme(wallpaperColors, false, Style.EXPRESSIVE); + Assert.assertEquals(Cam.fromInt(colorScheme.getAccent1().get(6)).getHue(), 357.46, 0.1); + } + @Test public void testFiltersInvalidColors() {