Loading src/com/android/customization/model/color/ColorCustomizationManager.java +2 −1 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ 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 @@ -164,7 +165,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(colorOption.getStyle().toString())); String.valueOf(Style.toString(colorOption.getStyle()))); // OVERLAY_COLOR_BOTH is only for wallpaper color case, not preset. if (!COLOR_SOURCE_PRESET.equals(colorOption.getSource())) { Loading src/com/android/customization/model/color/ColorOption.java +9 −6 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; Loading @@ -56,13 +57,14 @@ public abstract class ColorOption implements CustomizationOption<ColorOption> { protected final Map<String, String> mPackagesByCategory; private final String mTitle; private final boolean mIsDefault; private final Style mStyle; @Style.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 style, int index) { int seedColor, @Style.Type Integer style, int index) { mTitle = title; mIsDefault = isDefault; mSeedColor = seedColor; Loading @@ -82,9 +84,9 @@ public abstract class ColorOption implements CustomizationOption<ColorOption> { String currentStyle = colorManager.getCurrentStyle(); if (TextUtils.isEmpty(currentStyle)) { currentStyle = Style.TONAL_SPOT.toString(); currentStyle = Style.toString(Style.TONAL_SPOT); } boolean isCurrentStyle = TextUtils.equals(getStyle().toString(), currentStyle); boolean isCurrentStyle = TextUtils.equals(Style.toString(getStyle()), currentStyle); if (mIsDefault) { String serializedOverlays = colorManager.getStoredOverlays(); Loading Loading @@ -116,7 +118,7 @@ public abstract class ColorOption implements CustomizationOption<ColorOption> { if (other == null) { return false; } if (mStyle != other.getStyle()) { if (!Objects.equals(mStyle, other.getStyle())) { return false; } String thisSerializedPackages = getSerializedPackages(); Loading Loading @@ -225,7 +227,8 @@ public abstract class ColorOption implements CustomizationOption<ColorOption> { /** * @return the style of this color option */ public Style getStyle() { @Style.Type public Integer getStyle() { return mStyle; } Loading src/com/android/customization/model/color/ColorOptionImpl.kt +3 −3 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ class ColorOptionImpl( isDefault: Boolean, private val source: String?, seedColor: Int, style: Style, @Style.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().hashCode() override fun getStyleForLogging(): Int = Style.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 var style = Style.TONAL_SPOT @Style.Type var style = Style.TONAL_SPOT var index = 0 var packages: MutableMap<String, String?> = HashMap() var type = ColorType.WALLPAPER_COLOR Loading src/com/android/customization/model/color/ColorProvider.kt +3 −1 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ 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 private var styleList = if (themeStyleEnabled) arrayOf(Style.TONAL_SPOT, Style.SPRITZ, Style.VIBRANT, Style.EXPRESSIVE) Loading Loading @@ -338,6 +339,7 @@ class ColorProvider(private val context: Context, stubPackageName: String) : } catch (e: Resources.NotFoundException) { null } @Style.Type val style = try { if (styleName != null) Style.valueOf(styleName) else Style.TONAL_SPOT Loading Loading @@ -374,7 +376,7 @@ class ColorProvider(private val context: Context, stubPackageName: String) : private fun buildPreset( bundleName: String, index: Int, style: Style? = null, @Style.Type style: Int? = null, type: ColorType = ColorType.PRESET_COLOR, ): ColorOptionImpl { val builder = ColorOptionImpl.Builder() Loading src/com/android/customization/model/color/ThemedWallpaperColorResources.kt +3 −6 Original line number Diff line number Diff line Loading @@ -38,11 +38,7 @@ class ThemedWallpaperColorResources( override suspend fun apply(context: Context, callback: () -> Unit) { withContext(Dispatchers.IO) { val wallpaperColorScheme = ColorScheme( wallpaperColors, false, fetchThemeStyleFromSetting(), ) ColorScheme(wallpaperColors, false, fetchThemeStyleFromSetting()) with<ColorScheme, Unit>(wallpaperColorScheme) { addOverlayColor(neutral1, R.color.system_neutral1_10) addOverlayColor(neutral2, R.color.system_neutral2_10) Loading @@ -55,7 +51,8 @@ class ThemedWallpaperColorResources( } } private suspend fun fetchThemeStyleFromSetting(): Style { @Style.Type private suspend fun fetchThemeStyleFromSetting(): Int { val overlayPackageJson = secureSettingsRepository.getString(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES) return if (!overlayPackageJson.isNullOrEmpty()) { Loading Loading
src/com/android/customization/model/color/ColorCustomizationManager.java +2 −1 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ 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 @@ -164,7 +165,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(colorOption.getStyle().toString())); String.valueOf(Style.toString(colorOption.getStyle()))); // OVERLAY_COLOR_BOTH is only for wallpaper color case, not preset. if (!COLOR_SOURCE_PRESET.equals(colorOption.getSource())) { Loading
src/com/android/customization/model/color/ColorOption.java +9 −6 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; Loading @@ -56,13 +57,14 @@ public abstract class ColorOption implements CustomizationOption<ColorOption> { protected final Map<String, String> mPackagesByCategory; private final String mTitle; private final boolean mIsDefault; private final Style mStyle; @Style.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 style, int index) { int seedColor, @Style.Type Integer style, int index) { mTitle = title; mIsDefault = isDefault; mSeedColor = seedColor; Loading @@ -82,9 +84,9 @@ public abstract class ColorOption implements CustomizationOption<ColorOption> { String currentStyle = colorManager.getCurrentStyle(); if (TextUtils.isEmpty(currentStyle)) { currentStyle = Style.TONAL_SPOT.toString(); currentStyle = Style.toString(Style.TONAL_SPOT); } boolean isCurrentStyle = TextUtils.equals(getStyle().toString(), currentStyle); boolean isCurrentStyle = TextUtils.equals(Style.toString(getStyle()), currentStyle); if (mIsDefault) { String serializedOverlays = colorManager.getStoredOverlays(); Loading Loading @@ -116,7 +118,7 @@ public abstract class ColorOption implements CustomizationOption<ColorOption> { if (other == null) { return false; } if (mStyle != other.getStyle()) { if (!Objects.equals(mStyle, other.getStyle())) { return false; } String thisSerializedPackages = getSerializedPackages(); Loading Loading @@ -225,7 +227,8 @@ public abstract class ColorOption implements CustomizationOption<ColorOption> { /** * @return the style of this color option */ public Style getStyle() { @Style.Type public Integer getStyle() { return mStyle; } Loading
src/com/android/customization/model/color/ColorOptionImpl.kt +3 −3 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ class ColorOptionImpl( isDefault: Boolean, private val source: String?, seedColor: Int, style: Style, @Style.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().hashCode() override fun getStyleForLogging(): Int = Style.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 var style = Style.TONAL_SPOT @Style.Type var style = Style.TONAL_SPOT var index = 0 var packages: MutableMap<String, String?> = HashMap() var type = ColorType.WALLPAPER_COLOR Loading
src/com/android/customization/model/color/ColorProvider.kt +3 −1 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ 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 private var styleList = if (themeStyleEnabled) arrayOf(Style.TONAL_SPOT, Style.SPRITZ, Style.VIBRANT, Style.EXPRESSIVE) Loading Loading @@ -338,6 +339,7 @@ class ColorProvider(private val context: Context, stubPackageName: String) : } catch (e: Resources.NotFoundException) { null } @Style.Type val style = try { if (styleName != null) Style.valueOf(styleName) else Style.TONAL_SPOT Loading Loading @@ -374,7 +376,7 @@ class ColorProvider(private val context: Context, stubPackageName: String) : private fun buildPreset( bundleName: String, index: Int, style: Style? = null, @Style.Type style: Int? = null, type: ColorType = ColorType.PRESET_COLOR, ): ColorOptionImpl { val builder = ColorOptionImpl.Builder() Loading
src/com/android/customization/model/color/ThemedWallpaperColorResources.kt +3 −6 Original line number Diff line number Diff line Loading @@ -38,11 +38,7 @@ class ThemedWallpaperColorResources( override suspend fun apply(context: Context, callback: () -> Unit) { withContext(Dispatchers.IO) { val wallpaperColorScheme = ColorScheme( wallpaperColors, false, fetchThemeStyleFromSetting(), ) ColorScheme(wallpaperColors, false, fetchThemeStyleFromSetting()) with<ColorScheme, Unit>(wallpaperColorScheme) { addOverlayColor(neutral1, R.color.system_neutral1_10) addOverlayColor(neutral2, R.color.system_neutral2_10) Loading @@ -55,7 +51,8 @@ class ThemedWallpaperColorResources( } } private suspend fun fetchThemeStyleFromSetting(): Style { @Style.Type private suspend fun fetchThemeStyleFromSetting(): Int { val overlayPackageJson = secureSettingsRepository.getString(Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES) return if (!overlayPackageJson.isNullOrEmpty()) { Loading