From fabe8a0eb3d44edfacc6d50a1f1ade19aeaed0ad Mon Sep 17 00:00:00 2001 From: James O'Leary Date: Tue, 31 Jan 2023 11:53:16 -0500 Subject: [PATCH] Add key color roles, rename surfaces, adjust spec. Done per chat and commentary on ag/21127519. - Key colors are a new concept. A key color for a palette is found by taking the palette's hue and chroma, and searching for the first tone from T50 that reaches that chroma. Colors made using relativeLstar in XML will now reach spec. - Surface names changed after the code landed in the internal source repo. This CL updates their names. - Monet Gallery matches Android 2021's output. libmonet Java did not match. Double-checked that Monet Gallery matched Android, updated variant specs to match. Bug: 266731167 Test: atest com.android.systemui.monet, all 389 pass. Change-Id: I09a8ec9bd8883d124804db31369c595a6aca6a1b --- .../dynamiccolor/MaterialDynamicColors.java | 29 +++++++-- .../systemui/monet/palettes/TonalPalette.java | 51 ++++++++++++++- .../monet/scheme/SchemeExpressive.java | 8 ++- .../monet/scheme/SchemeTonalSpot.java | 4 +- .../systemui/monet/scheme/SchemeVibrant.java | 2 +- .../systemui/monet/SchemeContentTest.java | 16 +++++ .../systemui/monet/SchemeExpressiveTest.java | 64 ++++++++++++------- .../systemui/monet/SchemeFidelityTest.java | 16 ++++- .../systemui/monet/SchemeFruitSaladTest.java | 16 +++++ .../systemui/monet/SchemeMonochromeTest.java | 16 +++++ .../systemui/monet/SchemeNeutralTest.java | 16 +++++ .../systemui/monet/SchemeRainbowTest.java | 17 ++++- .../systemui/monet/SchemeTonalSpotTest.java | 62 +++++++++++------- .../systemui/monet/SchemeVibrantTest.java | 22 ++++++- 14 files changed, 274 insertions(+), 65 deletions(-) diff --git a/packages/SystemUI/monet/src/com/android/systemui/monet/dynamiccolor/MaterialDynamicColors.java b/packages/SystemUI/monet/src/com/android/systemui/monet/dynamiccolor/MaterialDynamicColors.java index 813b22a411a63..91f33092fe745 100644 --- a/packages/SystemUI/monet/src/com/android/systemui/monet/dynamiccolor/MaterialDynamicColors.java +++ b/packages/SystemUI/monet/src/com/android/systemui/monet/dynamiccolor/MaterialDynamicColors.java @@ -57,19 +57,19 @@ public final class MaterialDynamicColors { public static final DynamicColor surfaceDim = DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 6.0 : 87.0); - public static final DynamicColor surfaceSub2 = + public static final DynamicColor surfaceContainerLowest = DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 4.0 : 100.0); - public static final DynamicColor surfaceSub1 = + public static final DynamicColor surfaceContainerLow = DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 10.0 : 96.0); public static final DynamicColor surfaceContainer = DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 12.0 : 94.0); - public static final DynamicColor surfaceAdd1 = + public static final DynamicColor surfaceContainerHigh = DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 17.0 : 92.0); - public static final DynamicColor surfaceAdd2 = + public static final DynamicColor surfaceContainerHighest = DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 22.0 : 90.0); public static final DynamicColor onSurface = @@ -366,6 +366,27 @@ public final class MaterialDynamicColors { public static final DynamicColor textHintInverse = DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 10.0 : 90.0); + public static final DynamicColor primaryPaletteKeyColor = + DynamicColor.fromPalette( + (s) -> s.primaryPalette, (s) -> s.primaryPalette.getKeyColor().getTone()); + + public static final DynamicColor secondaryPaletteKeyColor = + DynamicColor.fromPalette( + (s) -> s.secondaryPalette, (s) -> s.secondaryPalette.getKeyColor().getTone()); + + public static final DynamicColor tertiaryPaletteKeyColor = + DynamicColor.fromPalette( + (s) -> s.tertiaryPalette, (s) -> s.tertiaryPalette.getKeyColor().getTone()); + + public static final DynamicColor neutralPaletteKeyColor = + DynamicColor.fromPalette( + (s) -> s.neutralPalette, (s) -> s.neutralPalette.getKeyColor().getTone()); + + public static final DynamicColor neutralVariantPaletteKeyColor = + DynamicColor.fromPalette( + (s) -> s.neutralVariantPalette, + (s) -> s.neutralVariantPalette.getKeyColor().getTone()); + private static ViewingConditions viewingConditionsForAlbers(DynamicScheme scheme) { return ViewingConditions.defaultWithBackgroundLstar(scheme.isDark ? 30.0 : 80.0); } diff --git a/packages/SystemUI/monet/src/com/android/systemui/monet/palettes/TonalPalette.java b/packages/SystemUI/monet/src/com/android/systemui/monet/palettes/TonalPalette.java index 6911666bce551..8e905ea2c33e8 100644 --- a/packages/SystemUI/monet/src/com/android/systemui/monet/palettes/TonalPalette.java +++ b/packages/SystemUI/monet/src/com/android/systemui/monet/palettes/TonalPalette.java @@ -26,6 +26,7 @@ import java.util.Map; */ public final class TonalPalette { Map cache; + Hct keyColor; double hue; double chroma; @@ -46,7 +47,7 @@ public final class TonalPalette { * @return Tones matching that color's hue and chroma. */ public static TonalPalette fromHct(Hct hct) { - return TonalPalette.fromHueAndChroma(hct.getHue(), hct.getChroma()); + return new TonalPalette(hct.getHue(), hct.getChroma(), hct); } /** @@ -57,13 +58,52 @@ public final class TonalPalette { * @return Tones matching hue and chroma. */ public static TonalPalette fromHueAndChroma(double hue, double chroma) { - return new TonalPalette(hue, chroma); + return new TonalPalette(hue, chroma, createKeyColor(hue, chroma)); } - private TonalPalette(double hue, double chroma) { + private TonalPalette(double hue, double chroma, Hct keyColor) { cache = new HashMap<>(); this.hue = hue; this.chroma = chroma; + this.keyColor = keyColor; + } + + /** The key color is the first tone, starting from T50, matching the given hue and chroma. */ + private static Hct createKeyColor(double hue, double chroma) { + double startTone = 50.0; + Hct smallestDeltaHct = Hct.from(hue, chroma, startTone); + double smallestDelta = Math.abs(smallestDeltaHct.getChroma() - chroma); + // Starting from T50, check T+/-delta to see if they match the requested + // chroma. + // + // Starts from T50 because T50 has the most chroma available, on + // average. Thus it is most likely to have a direct answer and minimize + // iteration. + for (double delta = 1.0; delta < 50.0; delta += 1.0) { + // Termination condition rounding instead of minimizing delta to avoid + // case where requested chroma is 16.51, and the closest chroma is 16.49. + // Error is minimized, but when rounded and displayed, requested chroma + // is 17, key color's chroma is 16. + if (Math.round(chroma) == Math.round(smallestDeltaHct.getChroma())) { + return smallestDeltaHct; + } + + final Hct hctAdd = Hct.from(hue, chroma, startTone + delta); + final double hctAddDelta = Math.abs(hctAdd.getChroma() - chroma); + if (hctAddDelta < smallestDelta) { + smallestDelta = hctAddDelta; + smallestDeltaHct = hctAdd; + } + + final Hct hctSubtract = Hct.from(hue, chroma, startTone - delta); + final double hctSubtractDelta = Math.abs(hctSubtract.getChroma() - chroma); + if (hctSubtractDelta < smallestDelta) { + smallestDelta = hctSubtractDelta; + smallestDeltaHct = hctSubtract; + } + } + + return smallestDeltaHct; } /** @@ -98,4 +138,9 @@ public final class TonalPalette { public double getHue() { return this.hue; } + + /** The key color is the first tone, starting from T50, that matches the palette's chroma. */ + public Hct getKeyColor() { + return this.keyColor; + } } diff --git a/packages/SystemUI/monet/src/com/android/systemui/monet/scheme/SchemeExpressive.java b/packages/SystemUI/monet/src/com/android/systemui/monet/scheme/SchemeExpressive.java index e7c6f79021e8b..234826e2fcde2 100644 --- a/packages/SystemUI/monet/src/com/android/systemui/monet/scheme/SchemeExpressive.java +++ b/packages/SystemUI/monet/src/com/android/systemui/monet/scheme/SchemeExpressive.java @@ -34,14 +34,16 @@ public class SchemeExpressive extends DynamicScheme { isDark, contrastLevel, TonalPalette.fromHueAndChroma( - MathUtils.sanitizeDegreesDouble(sourceColorHct.getHue() + 120.0), 40.0), + MathUtils.sanitizeDegreesDouble(sourceColorHct.getHue() + 240.0), 40.0), TonalPalette.fromHueAndChroma( DynamicScheme.getRotatedHue(sourceColorHct, HUES, SECONDARY_ROTATIONS), 24.0), TonalPalette.fromHueAndChroma( DynamicScheme.getRotatedHue(sourceColorHct, HUES, TERTIARY_ROTATIONS), 32.0), - TonalPalette.fromHueAndChroma(sourceColorHct.getHue(), 8.0), - TonalPalette.fromHueAndChroma(sourceColorHct.getHue(), 12.0)); + TonalPalette.fromHueAndChroma( + MathUtils.sanitizeDegreesDouble(sourceColorHct.getHue() + 15.0), 8.0), + TonalPalette.fromHueAndChroma( + MathUtils.sanitizeDegreesDouble(sourceColorHct.getHue() + 15.0), 12.0)); } } diff --git a/packages/SystemUI/monet/src/com/android/systemui/monet/scheme/SchemeTonalSpot.java b/packages/SystemUI/monet/src/com/android/systemui/monet/scheme/SchemeTonalSpot.java index cd74ac382c91c..8480684043dcf 100644 --- a/packages/SystemUI/monet/src/com/android/systemui/monet/scheme/SchemeTonalSpot.java +++ b/packages/SystemUI/monet/src/com/android/systemui/monet/scheme/SchemeTonalSpot.java @@ -28,11 +28,11 @@ public class SchemeTonalSpot extends DynamicScheme { Variant.TONAL_SPOT, isDark, contrastLevel, - TonalPalette.fromHueAndChroma(sourceColorHct.getHue(), 40.0), + TonalPalette.fromHueAndChroma(sourceColorHct.getHue(), 36.0), TonalPalette.fromHueAndChroma(sourceColorHct.getHue(), 16.0), TonalPalette.fromHueAndChroma( MathUtils.sanitizeDegreesDouble(sourceColorHct.getHue() + 60.0), 24.0), - TonalPalette.fromHueAndChroma(sourceColorHct.getHue(), 6.0), + TonalPalette.fromHueAndChroma(sourceColorHct.getHue(), 4.0), TonalPalette.fromHueAndChroma(sourceColorHct.getHue(), 8.0)); } } diff --git a/packages/SystemUI/monet/src/com/android/systemui/monet/scheme/SchemeVibrant.java b/packages/SystemUI/monet/src/com/android/systemui/monet/scheme/SchemeVibrant.java index 89337cac771a9..160fab77a6c3a 100644 --- a/packages/SystemUI/monet/src/com/android/systemui/monet/scheme/SchemeVibrant.java +++ b/packages/SystemUI/monet/src/com/android/systemui/monet/scheme/SchemeVibrant.java @@ -38,7 +38,7 @@ public class SchemeVibrant extends DynamicScheme { TonalPalette.fromHueAndChroma( DynamicScheme.getRotatedHue(sourceColorHct, HUES, TERTIARY_ROTATIONS), 32.0), - TonalPalette.fromHueAndChroma(sourceColorHct.getHue(), 8.0), + TonalPalette.fromHueAndChroma(sourceColorHct.getHue(), 10.0), TonalPalette.fromHueAndChroma(sourceColorHct.getHue(), 12.0)); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeContentTest.java b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeContentTest.java index 9de55b176f2a0..1ddfc4d4af5b0 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeContentTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeContentTest.java @@ -33,6 +33,22 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) public final class SchemeContentTest extends SysuiTestCase { + @Test + public void testKeyColors() { + SchemeContent scheme = new SchemeContent(Hct.fromInt(0xff0000ff), false, 0.0); + + assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff080CFF); + assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff656DD3); + assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff81009F); + assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff767684); + assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff757589); + } + @Test public void lightTheme_minContrast_primary() { SchemeContent scheme = new SchemeContent(Hct.fromInt(0xFF0000ff), false, -1.0); diff --git a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeExpressiveTest.java b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeExpressiveTest.java index 3ef92804cb837..31e8711c6d8c9 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeExpressiveTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeExpressiveTest.java @@ -33,159 +33,175 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) public final class SchemeExpressiveTest extends SysuiTestCase { + @Test + public void testKeyColors() { + SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 0.0); + + assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff35855F); + assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff8C6D8C); + assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff806EA1); + assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff79757F); + assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff7A7585); + } + @Test public void lightTheme_minContrast_primary() { SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, -1.0); - assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xffad603c); + assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff32835D); } @Test public void lightTheme_standardContrast_primary() { SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 0.0); - assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff924b28); + assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff146C48); } @Test public void lightTheme_maxContrast_primary() { SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 1.0); - assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff401400); + assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff002818); } @Test public void lightTheme_minContrast_primaryContainer() { SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, -1.0); assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( - 0xffffdbcc); + 0xffA2F4C6); } @Test public void lightTheme_standardContrast_primaryContainer() { SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 0.0); assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( - 0xffffdbcc); + 0xffA2F4C6); } @Test public void lightTheme_maxContrast_primaryContainer() { SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 1.0); assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( - 0xff6f3010); + 0xff004D31); } @Test public void lightTheme_minContrast_onPrimaryContainer() { SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, -1.0); assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( - 0xff99512e); + 0xff1e724e); } @Test public void lightTheme_standardContrast_onPrimaryContainer() { SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 0.0); assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( - 0xff351000); + 0xff002112); } @Test public void lightTheme_maxContrast_onPrimaryContainer() { SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 1.0); assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( - 0xffffd0bc); + 0xff9aebbe); } @Test public void lightTheme_minContrast_surface() { SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, -1.0); - assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffbf8ff); + assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffdf7ff); } @Test public void lightTheme_standardContrast_surface() { SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 0.0); - assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffbf8ff); + assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffdf7ff); } @Test public void lightTheme_maxContrast_surface() { SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), false, 1.0); - assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffbf8ff); + assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffdf7ff); } @Test public void darkTheme_minContrast_primary() { SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, -1.0); - assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xffad603c); + assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff32835d); } @Test public void darkTheme_standardContrast_primary() { SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 0.0); - assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xffffb595); + assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff87d7ab); } @Test public void darkTheme_maxContrast_primary() { SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 1.0); - assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xfffff3ee); + assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xffd5ffe4); } @Test public void darkTheme_minContrast_primaryContainer() { SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, -1.0); assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( - 0xff743413); + 0xff005234); } @Test public void darkTheme_standardContrast_primaryContainer() { SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 0.0); assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( - 0xff743413); + 0xff005234); } @Test public void darkTheme_maxContrast_primaryContainer() { SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 1.0); assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( - 0xffffbb9e); + 0xff8bdbaf); } @Test public void darkTheme_minContrast_onPrimaryContainer() { SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, -1.0); assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( - 0xfff99f75); + 0xff76c59b); } @Test public void darkTheme_standardContrast_onPrimaryContainer() { SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 0.0); assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( - 0xffffdbcc); + 0xffa2f4c6); } @Test public void darkTheme_maxContrast_onPrimaryContainer() { SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 1.0); assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( - 0xff622706); + 0xff004229); } @Test public void darkTheme_minContrast_surface() { SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, -1.0); - assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12131a); + assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff14121a); } @Test public void darkTheme_standardContrast_surface() { SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 0.0); - assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12131a); + assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff14121a); } @Test public void darkTheme_maxContrast_surface() { SchemeExpressive scheme = new SchemeExpressive(Hct.fromInt(0xff0000ff), true, 1.0); - assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12131a); + assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff14121a); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeFidelityTest.java b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeFidelityTest.java index cfd05184b8184..511f83bb01407 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeFidelityTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeFidelityTest.java @@ -32,6 +32,21 @@ import org.junit.runners.JUnit4; @SmallTest @RunWith(JUnit4.class) public final class SchemeFidelityTest extends SysuiTestCase { + @Test + public void testKeyColors() { + SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), false, 0.0); + + assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff080CFF); + assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff656DD3); + assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff9D0002); + assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff767684); + assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff757589); + } @Test public void lightTheme_minContrast_primary() { @@ -251,5 +266,4 @@ public final class SchemeFidelityTest extends SysuiTestCase { SchemeFidelity scheme = new SchemeFidelity(Hct.fromInt(0xff0000ff), true, 1.0); assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12121d); } - } diff --git a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeFruitSaladTest.java b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeFruitSaladTest.java index ce6f6d96a1a55..4cf14d5455d3e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeFruitSaladTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeFruitSaladTest.java @@ -33,6 +33,22 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) public final class SchemeFruitSaladTest extends SysuiTestCase { + @Test + public void testKeyColors() { + SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, 0.0); + + assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff0091C0); + assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff3A7E9E); + assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff6E72AC); + assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff777682); + assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff75758B); + } + @Test public void lightTheme_minContrast_primary() { SchemeFruitSalad scheme = new SchemeFruitSalad(Hct.fromInt(0xff0000ff), false, -1.0); diff --git a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeMonochromeTest.java b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeMonochromeTest.java index 9ffc52384e64a..3eca4dcf7baa7 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeMonochromeTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeMonochromeTest.java @@ -33,6 +33,22 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) public final class SchemeMonochromeTest extends SysuiTestCase { + @Test + public void testKeyColors() { + SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, 0.0); + + assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff070707); + assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff070707); + assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff070707); + assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff070707); + assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff070707); + } + @Test public void lightTheme_minContrast_primary() { SchemeMonochrome scheme = new SchemeMonochrome(Hct.fromInt(0xff0000ff), false, -1.0); diff --git a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeNeutralTest.java b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeNeutralTest.java index c6892f948a17f..71e9f4da79cb0 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeNeutralTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeNeutralTest.java @@ -33,6 +33,22 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) public final class SchemeNeutralTest extends SysuiTestCase { + @Test + public void testKeyColors() { + SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, 0.0); + + assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff767685); + assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff777680); + assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff75758B); + assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff787678); + assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff787678); + } + @Test public void lightTheme_minContrast_primary() { SchemeNeutral scheme = new SchemeNeutral(Hct.fromInt(0xff0000ff), false, -1.0); diff --git a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeRainbowTest.java b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeRainbowTest.java index a0836220da975..cc6f044eb09c9 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeRainbowTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeRainbowTest.java @@ -33,6 +33,22 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) public final class SchemeRainbowTest extends SysuiTestCase { + @Test + public void testKeyColors() { + SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, 0.0); + + assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff696FC4); + assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff75758B); + assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff936B84); + assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff070707); + assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff070707); + } + @Test public void lightTheme_minContrast_primary() { SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), false, -1.0); @@ -230,5 +246,4 @@ public final class SchemeRainbowTest extends SysuiTestCase { SchemeRainbow scheme = new SchemeRainbow(Hct.fromInt(0xff0000ff), true, 1.0); assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131313); } - } diff --git a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeTonalSpotTest.java b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeTonalSpotTest.java index b0c7f10496bfb..e4880d9df858c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeTonalSpotTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeTonalSpotTest.java @@ -33,22 +33,38 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) public final class SchemeTonalSpotTest extends SysuiTestCase { + @Test + public void testKeyColors() { + SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0); + + assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff6E72AC); + assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff75758B); + assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff936B84); + assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff78767A); + assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff777680); + } + @Test public void lightTheme_minContrast_primary() { SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0); - assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff6a6fb1); + assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff6c70aa); } @Test public void lightTheme_standardContrast_primary() { SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0); - assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff545999); + assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff555992); } @Test public void lightTheme_maxContrast_primary() { SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0); - assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff161a59); + assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff181c51); } @Test @@ -69,21 +85,21 @@ public final class SchemeTonalSpotTest extends SysuiTestCase { public void lightTheme_maxContrast_primaryContainer() { SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0); assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( - 0xff383c7c); + 0xff3a3e74); } @Test public void lightTheme_minContrast_onPrimaryContainer() { SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0); assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( - 0xff5a5fa0); + 0xff5C5F98); } @Test public void lightTheme_standardContrast_onPrimaryContainer() { SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0); assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( - 0xff0e1253); + 0xff11144B); } @Test @@ -96,37 +112,37 @@ public final class SchemeTonalSpotTest extends SysuiTestCase { @Test public void lightTheme_minContrast_surface() { SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0); - assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffbf8ff); + assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xffFCF8FD); } @Test public void lightTheme_standardContrast_surface() { SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0); - assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffbf8ff); + assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xffFCF8FD); } @Test public void lightTheme_maxContrast_surface() { SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0); - assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xfffbf8ff); + assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xffFCF8FD); } @Test public void lightTheme_minContrast_onSurface() { SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, -1.0); - assertThat(MaterialDynamicColors.onSurface.getArgb(scheme)).isSameColorAs(0xff5f5e65); + assertThat(MaterialDynamicColors.onSurface.getArgb(scheme)).isSameColorAs(0xff605E62); } @Test public void lightTheme_standardContrast_onSurface() { SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 0.0); - assertThat(MaterialDynamicColors.onSurface.getArgb(scheme)).isSameColorAs(0xff1b1b21); + assertThat(MaterialDynamicColors.onSurface.getArgb(scheme)).isSameColorAs(0xff1B1B1F); } @Test public void lightTheme_maxContrast_onSurface() { SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), false, 1.0); - assertThat(MaterialDynamicColors.onSurface.getArgb(scheme)).isSameColorAs(0xff1a1a20); + assertThat(MaterialDynamicColors.onSurface.getArgb(scheme)).isSameColorAs(0xff1B1A1E); } @Test @@ -186,7 +202,7 @@ public final class SchemeTonalSpotTest extends SysuiTestCase { @Test public void darkTheme_minContrast_primary() { SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0); - assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff6a6fb1); + assertThat(MaterialDynamicColors.primary.getArgb(scheme)).isSameColorAs(0xff6C70AA); } @Test @@ -205,14 +221,14 @@ public final class SchemeTonalSpotTest extends SysuiTestCase { public void darkTheme_minContrast_primaryContainer() { SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0); assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( - 0xff3c4180); + 0xff3E4278); } @Test public void darkTheme_standardContrast_primaryContainer() { SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0); assertThat(MaterialDynamicColors.primaryContainer.getArgb(scheme)).isSameColorAs( - 0xff3c4180); + 0xff3E4278); } @Test @@ -226,7 +242,7 @@ public final class SchemeTonalSpotTest extends SysuiTestCase { public void darkTheme_minContrast_onPrimaryContainer() { SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0); assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( - 0xffabaff7); + 0xffadb0ef); } @Test @@ -240,7 +256,7 @@ public final class SchemeTonalSpotTest extends SysuiTestCase { public void darkTheme_maxContrast_onPrimaryContainer() { SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0); assertThat(MaterialDynamicColors.onPrimaryContainer.getArgb(scheme)).isSameColorAs( - 0xff2e3271); + 0xff30346A); } @Test @@ -321,36 +337,36 @@ public final class SchemeTonalSpotTest extends SysuiTestCase { @Test public void darkTheme_minContrast_surface() { SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0); - assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131318); + assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131316); } @Test public void darkTheme_standardContrast_surface() { SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0); - assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131318); + assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131316); } @Test public void darkTheme_maxContrast_surface() { SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0); - assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131318); + assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff131316); } @Test public void darkTheme_minContrast_onSurface() { SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, -1.0); - assertThat(MaterialDynamicColors.onSurface.getArgb(scheme)).isSameColorAs(0xffa4a2a9); + assertThat(MaterialDynamicColors.onSurface.getArgb(scheme)).isSameColorAs(0xffa4a2a6); } @Test public void darkTheme_standardContrast_onSurface() { SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 0.0); - assertThat(MaterialDynamicColors.onSurface.getArgb(scheme)).isSameColorAs(0xffe4e1e9); + assertThat(MaterialDynamicColors.onSurface.getArgb(scheme)).isSameColorAs(0xffe5e1e6); } @Test public void darkTheme_maxContrast_onSurface() { SchemeTonalSpot scheme = new SchemeTonalSpot(Hct.fromInt(0xff0000ff), true, 1.0); - assertThat(MaterialDynamicColors.onSurface.getArgb(scheme)).isSameColorAs(0xffe5e2ea); + assertThat(MaterialDynamicColors.onSurface.getArgb(scheme)).isSameColorAs(0xffe6e2e7); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeVibrantTest.java b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeVibrantTest.java index f056a16717665..e5963a2f39fe3 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeVibrantTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/monet/SchemeVibrantTest.java @@ -33,6 +33,22 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) public final class SchemeVibrantTest extends SysuiTestCase { + @Test + public void testKeyColors() { + SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, 0.0); + + assertThat(MaterialDynamicColors.primaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff080CFF); + assertThat(MaterialDynamicColors.secondaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff7B7296); + assertThat(MaterialDynamicColors.tertiaryPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff886C9D); + assertThat(MaterialDynamicColors.neutralPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff777682); + assertThat(MaterialDynamicColors.neutralVariantPaletteKeyColor.getArgb(scheme)) + .isSameColorAs(0xff767685); + } + @Test public void lightTheme_minContrast_primary() { SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), false, -1.0); @@ -195,18 +211,18 @@ public final class SchemeVibrantTest extends SysuiTestCase { @Test public void darkTheme_minContrast_surface() { SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, -1.0); - assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12131a); + assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12131C); } @Test public void darkTheme_standardContrast_surface() { SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 0.0); - assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12131a); + assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12131C); } @Test public void darkTheme_maxContrast_surface() { SchemeVibrant scheme = new SchemeVibrant(Hct.fromInt(0xff0000ff), true, 1.0); - assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12131a); + assertThat(MaterialDynamicColors.surface.getArgb(scheme)).isSameColorAs(0xff12131C); } }