Loading src/com/android/customization/model/color/ColorCustomizationManager.java +3 −3 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import static com.android.customization.model.color.ColorOptionsProvider.OVERLAY import android.app.WallpaperColors; import android.content.ContentResolver; import android.content.Context; import android.content.theming.ThemeStyle; import android.database.ContentObserver; import android.graphics.Color; import android.net.Uri; Loading @@ -48,7 +49,6 @@ import com.android.customization.model.ResourceConstants; import com.android.customization.model.color.ColorOptionsProvider.ColorSource; import com.android.customization.model.theme.OverlayManagerCompat; import com.android.customization.module.logging.ThemesUserEventLogger; import com.android.systemui.monet.Style; import com.android.themepicker.R; import org.json.JSONArray; Loading Loading @@ -170,7 +170,7 @@ public class ColorCustomizationManager implements CustomizationManager<ColorOpti overlaysJson.put(OVERLAY_COLOR_SOURCE, colorOption.getSource()); overlaysJson.put(OVERLAY_COLOR_INDEX, String.valueOf(colorOption.getIndex())); overlaysJson.put(OVERLAY_THEME_STYLE, String.valueOf(Style.toString(colorOption.getStyle()))); String.valueOf(ThemeStyle.toString(colorOption.getStyle()))); // OVERLAY_COLOR_BOTH is only for wallpaper color case, not preset. if (!COLOR_SOURCE_PRESET.equals(colorOption.getSource())) { Loading Loading @@ -273,7 +273,7 @@ public class ColorCustomizationManager implements CustomizationManager<ColorOpti /** * @return The style of the currently applied color. One of enum values in * {@link com.android.systemui.monet.Style}. * {@link ThemeStyle}. */ public @Nullable String getCurrentStyle() { if (mCurrentStyle == null) { Loading src/com/android/customization/model/color/ColorOption.java +6 −6 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_SYSTEM_PALETTE; import android.content.Context; import android.content.theming.ThemeStyle; import android.text.TextUtils; import android.util.Log; Loading @@ -29,7 +30,6 @@ import com.android.customization.model.CustomizationManager; import com.android.customization.model.CustomizationOption; import com.android.customization.model.color.ColorOptionsProvider.ColorSource; import com.android.customization.module.logging.ThemesUserEventLogger; import com.android.systemui.monet.Style; import com.android.themepicker.R; import org.json.JSONException; Loading Loading @@ -57,14 +57,14 @@ public abstract class ColorOption implements CustomizationOption<ColorOption> { protected final Map<String, String> mPackagesByCategory; private final String mTitle; private final boolean mIsDefault; @Style.Type @ThemeStyle.Type private final Integer mStyle; private final int mIndex; private CharSequence mContentDescription; private final @ColorInt int mSeedColor; protected ColorOption(String title, Map<String, String> overlayPackages, boolean isDefault, int seedColor, @Style.Type Integer style, int index) { int seedColor, @ThemeStyle.Type Integer style, int index) { mTitle = title; mIsDefault = isDefault; mSeedColor = seedColor; Loading @@ -84,9 +84,9 @@ public abstract class ColorOption implements CustomizationOption<ColorOption> { String currentStyle = colorManager.getCurrentStyle(); if (TextUtils.isEmpty(currentStyle)) { currentStyle = Style.toString(Style.TONAL_SPOT); currentStyle = ThemeStyle.toString(ThemeStyle.TONAL_SPOT); } boolean isCurrentStyle = TextUtils.equals(Style.toString(getStyle()), currentStyle); boolean isCurrentStyle = TextUtils.equals(ThemeStyle.toString(getStyle()), currentStyle); if (mIsDefault) { String serializedOverlays = colorManager.getStoredOverlays(); Loading Loading @@ -227,7 +227,7 @@ public abstract class ColorOption implements CustomizationOption<ColorOption> { /** * @return the style of this color option */ @Style.Type @ThemeStyle.Type public Integer getStyle() { return mStyle; } Loading src/com/android/customization/model/color/ColorOptionImpl.kt +4 −4 Original line number Diff line number Diff line Loading @@ -17,12 +17,12 @@ package com.android.customization.model.color import android.content.Context import android.content.theming.ThemeStyle import android.stats.style.StyleEnums import android.view.View import androidx.annotation.ColorInt import com.android.customization.model.color.ColorOptionsProvider.ColorSource import com.android.customization.picker.color.shared.model.ColorType import com.android.systemui.monet.Style import com.android.themepicker.R /** Loading @@ -34,7 +34,7 @@ class ColorOptionImpl( isDefault: Boolean, private val source: String?, seedColor: Int, @Style.Type style: Int, @ThemeStyle.Type style: Int, index: Int, private val previewInfo: PreviewInfo, val type: ColorType, Loading Loading @@ -77,7 +77,7 @@ class ColorOptionImpl( } } override fun getStyleForLogging(): Int = Style.toString(style).hashCode() override fun getStyleForLogging(): Int = ThemeStyle.toString(style).hashCode() class Builder { var title: String? = null Loading @@ -89,7 +89,7 @@ class ColorOptionImpl( @ColorSource var source: String? = null var isDefault = false @ColorInt var seedColor = 0 @Style.Type var style = Style.TONAL_SPOT @ThemeStyle.Type var style = ThemeStyle.TONAL_SPOT var index = 0 var packages: MutableMap<String, String?> = HashMap() var type = ColorType.WALLPAPER_COLOR Loading src/com/android/customization/model/color/ColorOptionsProvider.java +2 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.customization.model.color; import android.app.WallpaperColors; import android.content.theming.ThemeStyle; import androidx.annotation.Nullable; import androidx.annotation.StringDef; Loading @@ -35,7 +36,7 @@ public interface ColorOptionsProvider { /** * Extra setting indicating the style of the color overlays (it can be one of * {@link com.android.systemui.monet.Style}). * {@link ThemeStyle}). */ String OVERLAY_THEME_STYLE = "android.theme.customization.theme_style"; Loading src/com/android/customization/model/color/ColorProvider.kt +25 −18 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.app.WallpaperManager import android.content.Context import android.content.res.ColorStateList import android.content.res.Resources import android.content.theming.ThemeStyle import androidx.annotation.ColorInt import androidx.core.graphics.ColorUtils.setAlphaComponent import androidx.lifecycle.LifecycleOwner Loading @@ -37,7 +38,6 @@ import com.android.customization.model.color.ColorOptionsProvider.COLOR_SOURCE_L import com.android.customization.model.color.ColorUtils.toColorString import com.android.customization.picker.color.shared.model.ColorType import com.android.systemui.monet.ColorScheme import com.android.systemui.monet.Style import com.android.themepicker.R import com.android.wallpaper.config.BaseFlags import com.android.wallpaper.module.InjectorProvider Loading @@ -57,7 +57,7 @@ class ColorProvider(private val context: Context, stubPackageName: String) : companion object { const val themeStyleEnabled = true val styleSize = if (themeStyleEnabled) Style.values().size else 1 val styleSize = if (themeStyleEnabled) ThemeStyle.values().size else 1 private const val TAG = "ColorProvider" private const val MAX_SEED_COLORS = 4 private const val MAX_PRESET_COLORS = 4 Loading @@ -67,11 +67,16 @@ class ColorProvider(private val context: Context, stubPackageName: String) : private var loaderJob: Job? = null private val monetEnabled = ColorUtils.isMonetEnabled(context) // TODO(b/202145216): Use style method to fetch the list of style. @Style.Type @ThemeStyle.Type private var styleList = if (themeStyleEnabled) arrayOf(Style.TONAL_SPOT, Style.SPRITZ, Style.VIBRANT, Style.EXPRESSIVE) else arrayOf(Style.TONAL_SPOT) arrayOf( ThemeStyle.TONAL_SPOT, ThemeStyle.SPRITZ, ThemeStyle.VIBRANT, ThemeStyle.EXPRESSIVE, ) else arrayOf(ThemeStyle.TONAL_SPOT) private var monochromeBundleName: String? = null Loading Loading @@ -218,13 +223,13 @@ class ColorProvider(private val context: Context, stubPackageName: String) : ) builder.title = when (style) { Style.TONAL_SPOT -> ThemeStyle.TONAL_SPOT -> context.getString(R.string.content_description_dynamic_color_option) Style.SPRITZ -> ThemeStyle.SPRITZ -> context.getString(R.string.content_description_neutral_color_option) Style.VIBRANT -> ThemeStyle.VIBRANT -> context.getString(R.string.content_description_vibrant_color_option) Style.EXPRESSIVE -> ThemeStyle.EXPRESSIVE -> context.getString(R.string.content_description_expressive_color_option) else -> context.getString(R.string.content_description_dynamic_color_option) } Loading Loading @@ -313,7 +318,8 @@ class ColorProvider(private val context: Context, stubPackageName: String) : private fun getDarkPresetColorPreview(colorScheme: ColorScheme): IntArray { val colors = when (colorScheme.style) { Style.FRUIT_SALAD -> intArrayOf(colorScheme.accent3.s100, colorScheme.accent1.s200) ThemeStyle.FRUIT_SALAD -> intArrayOf(colorScheme.accent3.s100, colorScheme.accent1.s200) else -> intArrayOf(colorScheme.accent1.s200, colorScheme.accent1.s200) } return intArrayOf(colors[0], colors[1], colors[0], colors[1]) Loading @@ -326,7 +332,7 @@ class ColorProvider(private val context: Context, stubPackageName: String) : private fun getLightPresetColorPreview(colorScheme: ColorScheme): IntArray { val colors = when (colorScheme.style) { Style.FRUIT_SALAD -> ThemeStyle.FRUIT_SALAD -> intArrayOf( colorScheme.accent3.getAtTone(450f), colorScheme.accent1.getAtTone(550f), Loading Loading @@ -361,15 +367,16 @@ class ColorProvider(private val context: Context, stubPackageName: String) : } catch (e: Resources.NotFoundException) { null } @Style.Type @ThemeStyle.Type val style = try { if (styleName != null) Style.valueOf(styleName) else Style.TONAL_SPOT if (styleName != null) ThemeStyle.valueOf(styleName) else ThemeStyle.TONAL_SPOT } catch (e: IllegalArgumentException) { Style.TONAL_SPOT ThemeStyle.TONAL_SPOT } if (style == Style.MONOCHROMATIC) { if (style == ThemeStyle.MONOCHROMATIC) { if ( !InjectorProvider.getInjector() .getFlags() Loading Loading @@ -412,7 +419,7 @@ class ColorProvider(private val context: Context, stubPackageName: String) : private fun buildPreset( bundleName: String, index: Int, @Style.Type style: Int? = null, @ThemeStyle.Type style: Int? = null, type: ColorType = ColorType.PRESET_COLOR, isNewPickerUi: Boolean, ): ColorOptionImpl { Loading @@ -438,7 +445,7 @@ class ColorProvider(private val context: Context, stubPackageName: String) : darkColorScheme = ColorScheme(colorFromStub, /* darkTheme= */ true, style) when (style) { Style.MONOCHROMATIC -> { ThemeStyle.MONOCHROMATIC -> { darkColors = getDarkMonochromePreview(darkColorScheme) lightColors = getLightMonochromePreview(lightColorScheme) } Loading Loading @@ -466,7 +473,7 @@ class ColorProvider(private val context: Context, stubPackageName: String) : buildPreset( bundleName = it, index = -1, style = Style.MONOCHROMATIC, style = ThemeStyle.MONOCHROMATIC, type = ColorType.WALLPAPER_COLOR, isNewPickerUi = isNewPickerUi, ), Loading Loading
src/com/android/customization/model/color/ColorCustomizationManager.java +3 −3 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import static com.android.customization.model.color.ColorOptionsProvider.OVERLAY import android.app.WallpaperColors; import android.content.ContentResolver; import android.content.Context; import android.content.theming.ThemeStyle; import android.database.ContentObserver; import android.graphics.Color; import android.net.Uri; Loading @@ -48,7 +49,6 @@ import com.android.customization.model.ResourceConstants; import com.android.customization.model.color.ColorOptionsProvider.ColorSource; import com.android.customization.model.theme.OverlayManagerCompat; import com.android.customization.module.logging.ThemesUserEventLogger; import com.android.systemui.monet.Style; import com.android.themepicker.R; import org.json.JSONArray; Loading Loading @@ -170,7 +170,7 @@ public class ColorCustomizationManager implements CustomizationManager<ColorOpti overlaysJson.put(OVERLAY_COLOR_SOURCE, colorOption.getSource()); overlaysJson.put(OVERLAY_COLOR_INDEX, String.valueOf(colorOption.getIndex())); overlaysJson.put(OVERLAY_THEME_STYLE, String.valueOf(Style.toString(colorOption.getStyle()))); String.valueOf(ThemeStyle.toString(colorOption.getStyle()))); // OVERLAY_COLOR_BOTH is only for wallpaper color case, not preset. if (!COLOR_SOURCE_PRESET.equals(colorOption.getSource())) { Loading Loading @@ -273,7 +273,7 @@ public class ColorCustomizationManager implements CustomizationManager<ColorOpti /** * @return The style of the currently applied color. One of enum values in * {@link com.android.systemui.monet.Style}. * {@link ThemeStyle}. */ public @Nullable String getCurrentStyle() { if (mCurrentStyle == null) { Loading
src/com/android/customization/model/color/ColorOption.java +6 −6 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_SYSTEM_PALETTE; import android.content.Context; import android.content.theming.ThemeStyle; import android.text.TextUtils; import android.util.Log; Loading @@ -29,7 +30,6 @@ import com.android.customization.model.CustomizationManager; import com.android.customization.model.CustomizationOption; import com.android.customization.model.color.ColorOptionsProvider.ColorSource; import com.android.customization.module.logging.ThemesUserEventLogger; import com.android.systemui.monet.Style; import com.android.themepicker.R; import org.json.JSONException; Loading Loading @@ -57,14 +57,14 @@ public abstract class ColorOption implements CustomizationOption<ColorOption> { protected final Map<String, String> mPackagesByCategory; private final String mTitle; private final boolean mIsDefault; @Style.Type @ThemeStyle.Type private final Integer mStyle; private final int mIndex; private CharSequence mContentDescription; private final @ColorInt int mSeedColor; protected ColorOption(String title, Map<String, String> overlayPackages, boolean isDefault, int seedColor, @Style.Type Integer style, int index) { int seedColor, @ThemeStyle.Type Integer style, int index) { mTitle = title; mIsDefault = isDefault; mSeedColor = seedColor; Loading @@ -84,9 +84,9 @@ public abstract class ColorOption implements CustomizationOption<ColorOption> { String currentStyle = colorManager.getCurrentStyle(); if (TextUtils.isEmpty(currentStyle)) { currentStyle = Style.toString(Style.TONAL_SPOT); currentStyle = ThemeStyle.toString(ThemeStyle.TONAL_SPOT); } boolean isCurrentStyle = TextUtils.equals(Style.toString(getStyle()), currentStyle); boolean isCurrentStyle = TextUtils.equals(ThemeStyle.toString(getStyle()), currentStyle); if (mIsDefault) { String serializedOverlays = colorManager.getStoredOverlays(); Loading Loading @@ -227,7 +227,7 @@ public abstract class ColorOption implements CustomizationOption<ColorOption> { /** * @return the style of this color option */ @Style.Type @ThemeStyle.Type public Integer getStyle() { return mStyle; } Loading
src/com/android/customization/model/color/ColorOptionImpl.kt +4 −4 Original line number Diff line number Diff line Loading @@ -17,12 +17,12 @@ package com.android.customization.model.color import android.content.Context import android.content.theming.ThemeStyle import android.stats.style.StyleEnums import android.view.View import androidx.annotation.ColorInt import com.android.customization.model.color.ColorOptionsProvider.ColorSource import com.android.customization.picker.color.shared.model.ColorType import com.android.systemui.monet.Style import com.android.themepicker.R /** Loading @@ -34,7 +34,7 @@ class ColorOptionImpl( isDefault: Boolean, private val source: String?, seedColor: Int, @Style.Type style: Int, @ThemeStyle.Type style: Int, index: Int, private val previewInfo: PreviewInfo, val type: ColorType, Loading Loading @@ -77,7 +77,7 @@ class ColorOptionImpl( } } override fun getStyleForLogging(): Int = Style.toString(style).hashCode() override fun getStyleForLogging(): Int = ThemeStyle.toString(style).hashCode() class Builder { var title: String? = null Loading @@ -89,7 +89,7 @@ class ColorOptionImpl( @ColorSource var source: String? = null var isDefault = false @ColorInt var seedColor = 0 @Style.Type var style = Style.TONAL_SPOT @ThemeStyle.Type var style = ThemeStyle.TONAL_SPOT var index = 0 var packages: MutableMap<String, String?> = HashMap() var type = ColorType.WALLPAPER_COLOR Loading
src/com/android/customization/model/color/ColorOptionsProvider.java +2 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.customization.model.color; import android.app.WallpaperColors; import android.content.theming.ThemeStyle; import androidx.annotation.Nullable; import androidx.annotation.StringDef; Loading @@ -35,7 +36,7 @@ public interface ColorOptionsProvider { /** * Extra setting indicating the style of the color overlays (it can be one of * {@link com.android.systemui.monet.Style}). * {@link ThemeStyle}). */ String OVERLAY_THEME_STYLE = "android.theme.customization.theme_style"; Loading
src/com/android/customization/model/color/ColorProvider.kt +25 −18 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.app.WallpaperManager import android.content.Context import android.content.res.ColorStateList import android.content.res.Resources import android.content.theming.ThemeStyle import androidx.annotation.ColorInt import androidx.core.graphics.ColorUtils.setAlphaComponent import androidx.lifecycle.LifecycleOwner Loading @@ -37,7 +38,6 @@ import com.android.customization.model.color.ColorOptionsProvider.COLOR_SOURCE_L import com.android.customization.model.color.ColorUtils.toColorString import com.android.customization.picker.color.shared.model.ColorType import com.android.systemui.monet.ColorScheme import com.android.systemui.monet.Style import com.android.themepicker.R import com.android.wallpaper.config.BaseFlags import com.android.wallpaper.module.InjectorProvider Loading @@ -57,7 +57,7 @@ class ColorProvider(private val context: Context, stubPackageName: String) : companion object { const val themeStyleEnabled = true val styleSize = if (themeStyleEnabled) Style.values().size else 1 val styleSize = if (themeStyleEnabled) ThemeStyle.values().size else 1 private const val TAG = "ColorProvider" private const val MAX_SEED_COLORS = 4 private const val MAX_PRESET_COLORS = 4 Loading @@ -67,11 +67,16 @@ class ColorProvider(private val context: Context, stubPackageName: String) : private var loaderJob: Job? = null private val monetEnabled = ColorUtils.isMonetEnabled(context) // TODO(b/202145216): Use style method to fetch the list of style. @Style.Type @ThemeStyle.Type private var styleList = if (themeStyleEnabled) arrayOf(Style.TONAL_SPOT, Style.SPRITZ, Style.VIBRANT, Style.EXPRESSIVE) else arrayOf(Style.TONAL_SPOT) arrayOf( ThemeStyle.TONAL_SPOT, ThemeStyle.SPRITZ, ThemeStyle.VIBRANT, ThemeStyle.EXPRESSIVE, ) else arrayOf(ThemeStyle.TONAL_SPOT) private var monochromeBundleName: String? = null Loading Loading @@ -218,13 +223,13 @@ class ColorProvider(private val context: Context, stubPackageName: String) : ) builder.title = when (style) { Style.TONAL_SPOT -> ThemeStyle.TONAL_SPOT -> context.getString(R.string.content_description_dynamic_color_option) Style.SPRITZ -> ThemeStyle.SPRITZ -> context.getString(R.string.content_description_neutral_color_option) Style.VIBRANT -> ThemeStyle.VIBRANT -> context.getString(R.string.content_description_vibrant_color_option) Style.EXPRESSIVE -> ThemeStyle.EXPRESSIVE -> context.getString(R.string.content_description_expressive_color_option) else -> context.getString(R.string.content_description_dynamic_color_option) } Loading Loading @@ -313,7 +318,8 @@ class ColorProvider(private val context: Context, stubPackageName: String) : private fun getDarkPresetColorPreview(colorScheme: ColorScheme): IntArray { val colors = when (colorScheme.style) { Style.FRUIT_SALAD -> intArrayOf(colorScheme.accent3.s100, colorScheme.accent1.s200) ThemeStyle.FRUIT_SALAD -> intArrayOf(colorScheme.accent3.s100, colorScheme.accent1.s200) else -> intArrayOf(colorScheme.accent1.s200, colorScheme.accent1.s200) } return intArrayOf(colors[0], colors[1], colors[0], colors[1]) Loading @@ -326,7 +332,7 @@ class ColorProvider(private val context: Context, stubPackageName: String) : private fun getLightPresetColorPreview(colorScheme: ColorScheme): IntArray { val colors = when (colorScheme.style) { Style.FRUIT_SALAD -> ThemeStyle.FRUIT_SALAD -> intArrayOf( colorScheme.accent3.getAtTone(450f), colorScheme.accent1.getAtTone(550f), Loading Loading @@ -361,15 +367,16 @@ class ColorProvider(private val context: Context, stubPackageName: String) : } catch (e: Resources.NotFoundException) { null } @Style.Type @ThemeStyle.Type val style = try { if (styleName != null) Style.valueOf(styleName) else Style.TONAL_SPOT if (styleName != null) ThemeStyle.valueOf(styleName) else ThemeStyle.TONAL_SPOT } catch (e: IllegalArgumentException) { Style.TONAL_SPOT ThemeStyle.TONAL_SPOT } if (style == Style.MONOCHROMATIC) { if (style == ThemeStyle.MONOCHROMATIC) { if ( !InjectorProvider.getInjector() .getFlags() Loading Loading @@ -412,7 +419,7 @@ class ColorProvider(private val context: Context, stubPackageName: String) : private fun buildPreset( bundleName: String, index: Int, @Style.Type style: Int? = null, @ThemeStyle.Type style: Int? = null, type: ColorType = ColorType.PRESET_COLOR, isNewPickerUi: Boolean, ): ColorOptionImpl { Loading @@ -438,7 +445,7 @@ class ColorProvider(private val context: Context, stubPackageName: String) : darkColorScheme = ColorScheme(colorFromStub, /* darkTheme= */ true, style) when (style) { Style.MONOCHROMATIC -> { ThemeStyle.MONOCHROMATIC -> { darkColors = getDarkMonochromePreview(darkColorScheme) lightColors = getLightMonochromePreview(lightColorScheme) } Loading Loading @@ -466,7 +473,7 @@ class ColorProvider(private val context: Context, stubPackageName: String) : buildPreset( bundleName = it, index = -1, style = Style.MONOCHROMATIC, style = ThemeStyle.MONOCHROMATIC, type = ColorType.WALLPAPER_COLOR, isNewPickerUi = isNewPickerUi, ), Loading