Snap for 11520864 from a7b94a6349a3d094c741646a7924e4398ccaaf60 to 24Q2-release
Change-Id: I9ac78da9756a7705ea3cd7ea72176d6be88af803
diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml
index 4319b93..4392fb8 100644
--- a/res/values-da/strings.xml
+++ b/res/values-da/strings.xml
@@ -64,7 +64,7 @@
<string name="preview_name_shape" msgid="5676971146080968721">"Form"</string>
<string name="preview_name_wallpaper" msgid="1738652462949531828">"Baggrund"</string>
<string name="font_card_title" msgid="2343292653502548685">"ABC • abc • 123"</string>
- <string name="font_card_body" msgid="6790525594503904468">"Føj dine foretrukne skrifttyper til alle skærmbilleder"</string>
+ <string name="font_card_body" msgid="6790525594503904468">"Føj dine foretrukne skrifttyper til alle skærme"</string>
<string name="grid_options_title" msgid="7071930966989877023">"Vælg gitterstørrelse"</string>
<string name="grid_title_pattern" msgid="9188866567612607806">"<xliff:g id="ID_1">%1$d</xliff:g>x<xliff:g id="ID_2">%2$d</xliff:g>"</string>
<string name="apply_grid_btn_note" msgid="2966021967355139181">"Når du ændrer gitterstørrelsen genindlæses arbejdsområdet, hvilket kan tage et par sekunder."</string>
diff --git a/src/com/android/customization/model/color/ColorProvider.kt b/src/com/android/customization/model/color/ColorProvider.kt
index 79925d8..eb8d8df 100644
--- a/src/com/android/customization/model/color/ColorProvider.kt
+++ b/src/com/android/customization/model/color/ColorProvider.kt
@@ -79,7 +79,8 @@
}
private var colorsAvailable = true
- private var colorBundles: List<ColorOption>? = null
+ private var presetColorBundles: List<ColorOption>? = null
+ private var wallpaperColorBundles: List<ColorOption>? = null
private var homeWallpaperColors: WallpaperColors? = null
private var lockWallpaperColors: WallpaperColors? = null
@@ -96,31 +97,27 @@
val wallpaperColorsChanged =
this.homeWallpaperColors != homeWallpaperColors ||
this.lockWallpaperColors != lockWallpaperColors
- if (wallpaperColorsChanged) {
+ if (wallpaperColorsChanged || reload) {
+ loadSeedColors(
+ homeWallpaperColors,
+ lockWallpaperColors,
+ )
this.homeWallpaperColors = homeWallpaperColors
this.lockWallpaperColors = lockWallpaperColors
}
- if (colorBundles == null || reload || wallpaperColorsChanged) {
+ if (presetColorBundles == null || reload) {
scope.launch {
try {
- if (colorBundles == null || reload) {
- loadPreset()
- }
- if (wallpaperColorsChanged || reload) {
- loadSeedColors(
- homeWallpaperColors,
- lockWallpaperColors,
- )
- }
+ loadPreset()
} catch (e: Throwable) {
colorsAvailable = false
callback?.onError(e)
return@launch
}
- callback?.onOptionsLoaded(colorBundles)
+ callback?.onOptionsLoaded(buildFinalList())
}
} else {
- callback?.onOptionsLoaded(colorBundles)
+ callback?.onOptionsLoaded(buildFinalList())
}
}
@@ -173,19 +170,7 @@
bundles,
)
}
-
- // Insert monochrome in the second position if it is enabled and included in preset
- // colors
- if (InjectorProvider.getInjector().getFlags().isMonochromaticThemeEnabled(mContext)) {
- monochromeBundleName?.let {
- bundles.add(1, buildPreset(it, -1, Style.MONOCHROMATIC, ColorType.WALLPAPER_COLOR))
- }
- }
- bundles.addAll(
- colorBundles?.filterNot { (it as ColorOptionImpl).type == ColorType.WALLPAPER_COLOR }
- ?: emptyList()
- )
- colorBundles = bundles
+ wallpaperColorBundles = bundles
}
private fun buildColorSeeds(
@@ -381,7 +366,7 @@
monochromeBundleName = null
}
- colorBundles = bundles
+ presetColorBundles = bundles
}
private fun buildPreset(
@@ -425,4 +410,22 @@
builder.darkColors = darkColors
return builder.build()
}
+
+ private fun buildFinalList(): List<ColorOption> {
+ val presetColors = presetColorBundles ?: emptyList()
+ val wallpaperColors = wallpaperColorBundles?.toMutableList() ?: mutableListOf()
+ // Insert monochrome in the second position if it is enabled and included in preset
+ // colors
+ if (InjectorProvider.getInjector().getFlags().isMonochromaticThemeEnabled(mContext)) {
+ monochromeBundleName?.let {
+ if (wallpaperColors.isNotEmpty()) {
+ wallpaperColors.add(
+ 1,
+ buildPreset(it, -1, Style.MONOCHROMATIC, ColorType.WALLPAPER_COLOR)
+ )
+ }
+ }
+ }
+ return wallpaperColors + presetColors
+ }
}