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

Commit da245e71 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 12735943 from acb00e7a to 25Q1-release

Change-Id: Ie63a7fed05786f0d16af96846f13208e1fbf2990
parents 1a3869d2 acb00e7a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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;
@@ -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())) {
+9 −6
Original line number Diff line number Diff line
@@ -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;

@@ -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;
@@ -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();
@@ -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();
@@ -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;
    }

+3 −3
Original line number Diff line number Diff line
@@ -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,
@@ -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
@@ -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
+3 −1
Original line number Diff line number Diff line
@@ -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)
@@ -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
@@ -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()
+3 −6
Original line number Diff line number Diff line
@@ -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)
@@ -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