Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4e5754eb authored by Marcelo Arteiro's avatar Marcelo Arteiro
Browse files

Migrates Monet's Style Enum to @IntDef

This is part of the effort to move all Color System depenencies to
server. Enum are not allowerd there.

Bug: 335429258
Test: None
Flag: EXEMPT rearchitecture
Change-Id: I24f22e3057d81ba32c9e66997b15bbbd75025cc3
parent e0a4d1fb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ data class ClockDesign(
    val thumbnail: String? = null,
    val large: ClockFace? = null,
    val small: ClockFace? = null,
    val colorPalette: MonetStyle? = null,
    @MonetStyle.Type val colorPalette: Int? = null,
)

/** Describes a clock using layers */
+4 −4
Original line number Diff line number Diff line
@@ -434,13 +434,13 @@ public class ThemeOverlayControllerTest extends SysuiTestCase {
    @Test
    public void onSettingChanged_honorThemeStyle() {
        when(mDeviceProvisionedController.isUserSetup(anyInt())).thenReturn(true);
        List<Style> validStyles = Arrays.asList(Style.EXPRESSIVE, Style.SPRITZ, Style.TONAL_SPOT,
                Style.FRUIT_SALAD, Style.RAINBOW, Style.VIBRANT);
        for (Style style : validStyles) {
        @Style.Type List<Integer> validStyles = Arrays.asList(Style.EXPRESSIVE, Style.SPRITZ,
                Style.TONAL_SPOT, Style.FRUIT_SALAD, Style.RAINBOW, Style.VIBRANT);
        for (@Style.Type int style : validStyles) {
            reset(mSecureSettings);

            String jsonString = "{\"android.theme.customization.system_palette\":\"A16B00\","
                    + "\"android.theme.customization.theme_style\":\"" + style.name() + "\"}";
                    + "\"android.theme.customization.theme_style\":\"" + Style.name(style) + "\"}";

            when(mSecureSettings.getStringForUser(
                    eq(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES), anyInt()))
+5 −2
Original line number Diff line number Diff line
@@ -187,7 +187,8 @@ constructor(
    private val shortcutsBindings = mutableSetOf<KeyguardQuickAffordanceViewBinder.Binding>()

    private val coroutineScope: CoroutineScope
    private var themeStyle: Style? = null

    @Style.Type private var themeStyle: Int? = null

    init {
        coroutineScope =
@@ -655,6 +656,7 @@ constructor(
            // Seed color null means users do not override any color on the clock. The default
            // color will need to use wallpaper's extracted color and consider if the
            // wallpaper's color is dark or light.
            @Style.Type
            val style = themeStyle ?: fetchThemeStyleFromSetting().also { themeStyle = it }
            val wallpaperColorScheme = ColorScheme(colors, false, style)
            val lightClockColor = wallpaperColorScheme.accent1.s100
@@ -707,7 +709,8 @@ constructor(
        }
    }

    private suspend fun fetchThemeStyleFromSetting(): Style {
    @Style.Type
    private suspend fun fetchThemeStyleFromSetting(): Int {
        val overlayPackageJson =
            withContext(backgroundDispatcher) {
                secureSettings.getString(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES)
+5 −1
Original line number Diff line number Diff line
@@ -98,7 +98,11 @@ object MediaArtworkHelper {
    }

    /** Returns [ColorScheme] of media app given its [icon]. */
    fun getColorScheme(icon: Drawable, tag: String, style: Style = Style.TONAL_SPOT): ColorScheme? {
    fun getColorScheme(
        icon: Drawable,
        tag: String,
        @Style.Type style: Int = Style.TONAL_SPOT,
    ): ColorScheme? {
        return try {
            ColorScheme(WallpaperColors.fromDrawable(icon), true, style)
        } catch (e: PackageManager.NameNotFoundException) {
+7 −5
Original line number Diff line number Diff line
@@ -149,7 +149,8 @@ public class ThemeOverlayController implements CoreStartable, Dumpable {
    private double mContrast = 0.0;
    // Theme variant: Vibrant, Tonal, Expressive, etc
    @VisibleForTesting
    protected Style mThemeStyle = Style.TONAL_SPOT;
    @Style.Type
    protected int mThemeStyle = Style.TONAL_SPOT;
    // Accent colors overlay
    private FabricatedOverlay mSecondaryOverlay;
    // Neutral system colors overlay
@@ -826,15 +827,16 @@ public class ThemeOverlayController implements CoreStartable, Dumpable {

    }

    private Style fetchThemeStyleFromSetting() {
    @Style.Type
    private int fetchThemeStyleFromSetting() {
        // Allow-list of Style objects that can be created from a setting string, i.e. can be
        // used as a system-wide theme.
        // - Content intentionally excluded, intended for media player, not system-wide
        List<Style> validStyles = new ArrayList<>(Arrays.asList(Style.EXPRESSIVE, Style.SPRITZ,
                Style.TONAL_SPOT, Style.FRUIT_SALAD, Style.RAINBOW, Style.VIBRANT,
        @Style.Type List<Integer> validStyles = new ArrayList<>(Arrays.asList(Style.EXPRESSIVE,
                Style.SPRITZ, Style.TONAL_SPOT, Style.FRUIT_SALAD, Style.RAINBOW, Style.VIBRANT,
                Style.MONOCHROMATIC));

        Style style = mThemeStyle;
        @Style.Type int style = mThemeStyle;
        final String overlayPackageJson = mSecureSettings.getStringForUser(
                Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES,
                mUserTracker.getUserId());