Loading monet/src/com/android/systemui/monet/ColorScheme.java +19 −15 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.monet; import android.annotation.ColorInt; import android.app.WallpaperColors; import android.graphics.Color; Loading Loading @@ -52,7 +53,8 @@ public class ColorScheme { @ColorInt private final int mSeed; private final boolean mIsDark; private final Style mStyle; @Style.Type private final int mStyle; private final DynamicScheme mMaterialScheme; private final TonalPalette mAccent1; private final TonalPalette mAccent2; Loading @@ -63,7 +65,8 @@ public class ColorScheme { private final Hct mProposedSeedHct; public ColorScheme(@ColorInt int seed, boolean isDark, Style style, double contrastLevel) { public ColorScheme(@ColorInt int seed, boolean isDark, @Style.Type int style, double contrastLevel) { this.mSeed = seed; this.mIsDark = isDark; this.mStyle = style; Loading @@ -78,17 +81,17 @@ public class ColorScheme { : seed)); mMaterialScheme = switch (style) { case SPRITZ -> new SchemeNeutral(seedHct, isDark, contrastLevel); case TONAL_SPOT -> new SchemeTonalSpot(seedHct, isDark, contrastLevel); case VIBRANT -> new SchemeVibrant(seedHct, isDark, contrastLevel); case EXPRESSIVE -> new SchemeExpressive(seedHct, isDark, contrastLevel); case RAINBOW -> new SchemeRainbow(seedHct, isDark, contrastLevel); case FRUIT_SALAD -> new SchemeFruitSalad(seedHct, isDark, contrastLevel); case CONTENT -> new SchemeContent(seedHct, isDark, contrastLevel); case MONOCHROMATIC -> new SchemeMonochrome(seedHct, isDark, contrastLevel); case Style.SPRITZ -> new SchemeNeutral(seedHct, isDark, contrastLevel); case Style.TONAL_SPOT -> new SchemeTonalSpot(seedHct, isDark, contrastLevel); case Style.VIBRANT -> new SchemeVibrant(seedHct, isDark, contrastLevel); case Style.EXPRESSIVE -> new SchemeExpressive(seedHct, isDark, contrastLevel); case Style.RAINBOW -> new SchemeRainbow(seedHct, isDark, contrastLevel); case Style.FRUIT_SALAD -> new SchemeFruitSalad(seedHct, isDark, contrastLevel); case Style.CONTENT -> new SchemeContent(seedHct, isDark, contrastLevel); case Style.MONOCHROMATIC -> new SchemeMonochrome(seedHct, isDark, contrastLevel); // SystemUI Schemes case CLOCK -> new SchemeClock(seedHct, isDark, contrastLevel); case CLOCK_VIBRANT -> new SchemeClockVibrant(seedHct, isDark, contrastLevel); case Style.CLOCK -> new SchemeClock(seedHct, isDark, contrastLevel); case Style.CLOCK_VIBRANT -> new SchemeClockVibrant(seedHct, isDark, contrastLevel); default -> throw new IllegalArgumentException("Unknown style: " + style); }; Loading @@ -104,11 +107,11 @@ public class ColorScheme { this(seed, darkTheme, Style.TONAL_SPOT); } public ColorScheme(@ColorInt int seed, boolean darkTheme, Style style) { public ColorScheme(@ColorInt int seed, boolean darkTheme, @Style.Type int style) { this(seed, darkTheme, style, 0.0); } public ColorScheme(WallpaperColors wallpaperColors, boolean darkTheme, Style style) { public ColorScheme(WallpaperColors wallpaperColors, boolean darkTheme, @Style.Type int style) { this(getSeedColor(wallpaperColors, style != Style.CONTENT), darkTheme, style); } Loading Loading @@ -136,7 +139,8 @@ public class ColorScheme { return mSeed; } public Style getStyle() { @Style.Type public int getStyle() { return mStyle; } Loading monet/src/com/android/systemui/monet/Style.java +166 −12 Original line number Diff line number Diff line Loading @@ -15,7 +15,158 @@ */ package com.android.systemui.monet; public enum Style { import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * A class defining the different styles available for theming. * This class replaces the previous enum implementation for improved performance and compatibility. */ public final class Style { private Style() { } /** * @hide */ @IntDef({ SPRITZ, TONAL_SPOT, VIBRANT, EXPRESSIVE, RAINBOW, FRUIT_SALAD, CONTENT, MONOCHROMATIC, CLOCK, CLOCK_VIBRANT }) @Retention(RetentionPolicy.SOURCE) public @interface Type { } /** * Represents the SPRITZ style. */ public static final int SPRITZ = 0; /** * Represents the TONAL_SPOT style. */ public static final int TONAL_SPOT = 1; /** * Represents the VIBRANT style. */ public static final int VIBRANT = 2; /** * Represents the EXPRESSIVE style. */ public static final int EXPRESSIVE = 3; /** * Represents the RAINBOW style. */ public static final int RAINBOW = 4; /** * Represents the FRUIT_SALAD style. */ public static final int FRUIT_SALAD = 5; /** * Represents the CONTENT style. */ public static final int CONTENT = 6; /** * Represents the MONOCHROMATIC style. */ public static final int MONOCHROMATIC = 7; /** * Represents the CLOCK style. */ public static final int CLOCK = 8; /** * Represents the CLOCK_VIBRANT style. */ public static final int CLOCK_VIBRANT = 9; /** * Returns the string representation of the given style. * * @param style The style value. * @return The string representation of the style. * @throws IllegalArgumentException if the style value is invalid. */ @NonNull public static String toString(@Nullable @Type Integer style) { // Throw an exception if style is null if (style == null) { throw new IllegalArgumentException("Invalid style value: null"); } return switch (style) { case SPRITZ -> "SPRITZ"; case TONAL_SPOT -> "TONAL_SPOT"; case VIBRANT -> "VIBRANT"; case EXPRESSIVE -> "EXPRESSIVE"; case RAINBOW -> "RAINBOW"; case FRUIT_SALAD -> "FRUIT_SALAD"; case CONTENT -> "CONTENT"; case MONOCHROMATIC -> "MONOCHROMATIC"; case CLOCK -> "CLOCK"; case CLOCK_VIBRANT -> "CLOCK_VIBRANT"; default -> throw new IllegalArgumentException("Invalid style value: " + style); }; } /** * Returns the style value corresponding to the given style name. * * @param styleName The name of the style. * @return The style value. * @throws IllegalArgumentException if the style name is invalid. */ public static @Type int valueOf(@Nullable @NonNull String styleName) { if (styleName == null) { throw new IllegalArgumentException("Invalid style value: null"); } return switch (styleName) { case "SPRITZ" -> SPRITZ; case "TONAL_SPOT" -> TONAL_SPOT; case "VIBRANT" -> VIBRANT; case "EXPRESSIVE" -> EXPRESSIVE; case "RAINBOW" -> RAINBOW; case "FRUIT_SALAD" -> FRUIT_SALAD; case "CONTENT" -> CONTENT; case "MONOCHROMATIC" -> MONOCHROMATIC; case "CLOCK" -> CLOCK; case "CLOCK_VIBRANT" -> CLOCK_VIBRANT; default -> throw new IllegalArgumentException("Invalid style name: " + styleName); }; } /** * Returns the name of the given style. This method is equivalent to {@link #toString(int)}. * * @param style The style value. * @return The name of the style. */ @NonNull public static String name(@Type int style) { return toString(style); } /** * Returns an array containing all the style values. * * @return An array of all style values. */ public static int[] values() { return new int[]{ SPRITZ, TONAL_SPOT, VIBRANT, Loading @@ -26,4 +177,7 @@ public enum Style { MONOCHROMATIC, CLOCK, CLOCK_VIBRANT }; } } No newline at end of file monet/tests/com/android/systemui/monet/ColorSchemeTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -101,7 +101,7 @@ class ColorSchemeTest { theme.setAttribute("color", sourceColorHex) themes.appendChild(theme) for (styleValue in Style.entries) { for (styleValue in Style.values()) { if ( styleValue == Style.CLOCK || styleValue == Style.CLOCK_VIBRANT || Loading @@ -110,7 +110,7 @@ class ColorSchemeTest { continue } val style = document.createElement(styleValue.name.lowercase()) val style = document.createElement(Style.name(styleValue).lowercase()) val colorScheme = ColorScheme(sourceColor.toInt(), false, styleValue) style.appendChild( Loading Loading
monet/src/com/android/systemui/monet/ColorScheme.java +19 −15 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.monet; import android.annotation.ColorInt; import android.app.WallpaperColors; import android.graphics.Color; Loading Loading @@ -52,7 +53,8 @@ public class ColorScheme { @ColorInt private final int mSeed; private final boolean mIsDark; private final Style mStyle; @Style.Type private final int mStyle; private final DynamicScheme mMaterialScheme; private final TonalPalette mAccent1; private final TonalPalette mAccent2; Loading @@ -63,7 +65,8 @@ public class ColorScheme { private final Hct mProposedSeedHct; public ColorScheme(@ColorInt int seed, boolean isDark, Style style, double contrastLevel) { public ColorScheme(@ColorInt int seed, boolean isDark, @Style.Type int style, double contrastLevel) { this.mSeed = seed; this.mIsDark = isDark; this.mStyle = style; Loading @@ -78,17 +81,17 @@ public class ColorScheme { : seed)); mMaterialScheme = switch (style) { case SPRITZ -> new SchemeNeutral(seedHct, isDark, contrastLevel); case TONAL_SPOT -> new SchemeTonalSpot(seedHct, isDark, contrastLevel); case VIBRANT -> new SchemeVibrant(seedHct, isDark, contrastLevel); case EXPRESSIVE -> new SchemeExpressive(seedHct, isDark, contrastLevel); case RAINBOW -> new SchemeRainbow(seedHct, isDark, contrastLevel); case FRUIT_SALAD -> new SchemeFruitSalad(seedHct, isDark, contrastLevel); case CONTENT -> new SchemeContent(seedHct, isDark, contrastLevel); case MONOCHROMATIC -> new SchemeMonochrome(seedHct, isDark, contrastLevel); case Style.SPRITZ -> new SchemeNeutral(seedHct, isDark, contrastLevel); case Style.TONAL_SPOT -> new SchemeTonalSpot(seedHct, isDark, contrastLevel); case Style.VIBRANT -> new SchemeVibrant(seedHct, isDark, contrastLevel); case Style.EXPRESSIVE -> new SchemeExpressive(seedHct, isDark, contrastLevel); case Style.RAINBOW -> new SchemeRainbow(seedHct, isDark, contrastLevel); case Style.FRUIT_SALAD -> new SchemeFruitSalad(seedHct, isDark, contrastLevel); case Style.CONTENT -> new SchemeContent(seedHct, isDark, contrastLevel); case Style.MONOCHROMATIC -> new SchemeMonochrome(seedHct, isDark, contrastLevel); // SystemUI Schemes case CLOCK -> new SchemeClock(seedHct, isDark, contrastLevel); case CLOCK_VIBRANT -> new SchemeClockVibrant(seedHct, isDark, contrastLevel); case Style.CLOCK -> new SchemeClock(seedHct, isDark, contrastLevel); case Style.CLOCK_VIBRANT -> new SchemeClockVibrant(seedHct, isDark, contrastLevel); default -> throw new IllegalArgumentException("Unknown style: " + style); }; Loading @@ -104,11 +107,11 @@ public class ColorScheme { this(seed, darkTheme, Style.TONAL_SPOT); } public ColorScheme(@ColorInt int seed, boolean darkTheme, Style style) { public ColorScheme(@ColorInt int seed, boolean darkTheme, @Style.Type int style) { this(seed, darkTheme, style, 0.0); } public ColorScheme(WallpaperColors wallpaperColors, boolean darkTheme, Style style) { public ColorScheme(WallpaperColors wallpaperColors, boolean darkTheme, @Style.Type int style) { this(getSeedColor(wallpaperColors, style != Style.CONTENT), darkTheme, style); } Loading Loading @@ -136,7 +139,8 @@ public class ColorScheme { return mSeed; } public Style getStyle() { @Style.Type public int getStyle() { return mStyle; } Loading
monet/src/com/android/systemui/monet/Style.java +166 −12 Original line number Diff line number Diff line Loading @@ -15,7 +15,158 @@ */ package com.android.systemui.monet; public enum Style { import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * A class defining the different styles available for theming. * This class replaces the previous enum implementation for improved performance and compatibility. */ public final class Style { private Style() { } /** * @hide */ @IntDef({ SPRITZ, TONAL_SPOT, VIBRANT, EXPRESSIVE, RAINBOW, FRUIT_SALAD, CONTENT, MONOCHROMATIC, CLOCK, CLOCK_VIBRANT }) @Retention(RetentionPolicy.SOURCE) public @interface Type { } /** * Represents the SPRITZ style. */ public static final int SPRITZ = 0; /** * Represents the TONAL_SPOT style. */ public static final int TONAL_SPOT = 1; /** * Represents the VIBRANT style. */ public static final int VIBRANT = 2; /** * Represents the EXPRESSIVE style. */ public static final int EXPRESSIVE = 3; /** * Represents the RAINBOW style. */ public static final int RAINBOW = 4; /** * Represents the FRUIT_SALAD style. */ public static final int FRUIT_SALAD = 5; /** * Represents the CONTENT style. */ public static final int CONTENT = 6; /** * Represents the MONOCHROMATIC style. */ public static final int MONOCHROMATIC = 7; /** * Represents the CLOCK style. */ public static final int CLOCK = 8; /** * Represents the CLOCK_VIBRANT style. */ public static final int CLOCK_VIBRANT = 9; /** * Returns the string representation of the given style. * * @param style The style value. * @return The string representation of the style. * @throws IllegalArgumentException if the style value is invalid. */ @NonNull public static String toString(@Nullable @Type Integer style) { // Throw an exception if style is null if (style == null) { throw new IllegalArgumentException("Invalid style value: null"); } return switch (style) { case SPRITZ -> "SPRITZ"; case TONAL_SPOT -> "TONAL_SPOT"; case VIBRANT -> "VIBRANT"; case EXPRESSIVE -> "EXPRESSIVE"; case RAINBOW -> "RAINBOW"; case FRUIT_SALAD -> "FRUIT_SALAD"; case CONTENT -> "CONTENT"; case MONOCHROMATIC -> "MONOCHROMATIC"; case CLOCK -> "CLOCK"; case CLOCK_VIBRANT -> "CLOCK_VIBRANT"; default -> throw new IllegalArgumentException("Invalid style value: " + style); }; } /** * Returns the style value corresponding to the given style name. * * @param styleName The name of the style. * @return The style value. * @throws IllegalArgumentException if the style name is invalid. */ public static @Type int valueOf(@Nullable @NonNull String styleName) { if (styleName == null) { throw new IllegalArgumentException("Invalid style value: null"); } return switch (styleName) { case "SPRITZ" -> SPRITZ; case "TONAL_SPOT" -> TONAL_SPOT; case "VIBRANT" -> VIBRANT; case "EXPRESSIVE" -> EXPRESSIVE; case "RAINBOW" -> RAINBOW; case "FRUIT_SALAD" -> FRUIT_SALAD; case "CONTENT" -> CONTENT; case "MONOCHROMATIC" -> MONOCHROMATIC; case "CLOCK" -> CLOCK; case "CLOCK_VIBRANT" -> CLOCK_VIBRANT; default -> throw new IllegalArgumentException("Invalid style name: " + styleName); }; } /** * Returns the name of the given style. This method is equivalent to {@link #toString(int)}. * * @param style The style value. * @return The name of the style. */ @NonNull public static String name(@Type int style) { return toString(style); } /** * Returns an array containing all the style values. * * @return An array of all style values. */ public static int[] values() { return new int[]{ SPRITZ, TONAL_SPOT, VIBRANT, Loading @@ -26,4 +177,7 @@ public enum Style { MONOCHROMATIC, CLOCK, CLOCK_VIBRANT }; } } No newline at end of file
monet/tests/com/android/systemui/monet/ColorSchemeTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -101,7 +101,7 @@ class ColorSchemeTest { theme.setAttribute("color", sourceColorHex) themes.appendChild(theme) for (styleValue in Style.entries) { for (styleValue in Style.values()) { if ( styleValue == Style.CLOCK || styleValue == Style.CLOCK_VIBRANT || Loading @@ -110,7 +110,7 @@ class ColorSchemeTest { continue } val style = document.createElement(styleValue.name.lowercase()) val style = document.createElement(Style.name(styleValue).lowercase()) val colorScheme = ColorScheme(sourceColor.toInt(), false, styleValue) style.appendChild( Loading