Merge "Fix content description for the grid option (2/2)" into main
diff --git a/src/com/android/customization/model/color/ColorProvider.kt b/src/com/android/customization/model/color/ColorProvider.kt
index 74da5c2..ef5e3d6 100644
--- a/src/com/android/customization/model/color/ColorProvider.kt
+++ b/src/com/android/customization/model/color/ColorProvider.kt
@@ -120,15 +120,15 @@
loaderJob?.join()
if (presetColorBundles == null || reload) {
try {
- loaderJob = launch { loadPreset() }
+ loaderJob = launch { loadPreset(isNewPickerUi) }
} catch (e: Throwable) {
colorsAvailable = false
callback?.onError(e)
return@launch
}
- callback?.onOptionsLoaded(buildFinalList())
+ callback?.onOptionsLoaded(buildFinalList(isNewPickerUi))
} else {
- callback?.onOptionsLoaded(buildFinalList())
+ callback?.onOptionsLoaded(buildFinalList(isNewPickerUi))
}
}
}
@@ -236,8 +236,8 @@
}
/**
- * Returns the light theme version of the Revamped UI preview of a ColorScheme based on this
- * order: top left, top right, bottom left, bottom right
+ * Returns the light theme preview of a dynamic ColorScheme based on this order: top left, top
+ * right, bottom left, bottom right
*
* This color mapping corresponds to GM3 colors: Primary (light), Primary (light), Secondary
* LStar 85, and Tertiary LStar 70
@@ -253,8 +253,8 @@
}
/**
- * Returns the dark theme version of the Revamped UI preview of a ColorScheme based on this
- * order: top left, top right, bottom left, bottom right
+ * Returns the dark theme preview of a dynamic ColorScheme based on this order: top left, top
+ * right, bottom left, bottom right
*
* This color mapping corresponds to GM3 colors: Primary (dark), Primary (dark), Secondary LStar
* 35, and Tertiary LStar 70
@@ -270,8 +270,8 @@
}
/**
- * Returns the light theme version of the Revamped UI preview of a ColorScheme based on this
- * order: top left, top right, bottom left, bottom right
+ * Returns the light theme preview of a monochrome ColorScheme based on this order: top left,
+ * top right, bottom left, bottom right
*
* This color mapping corresponds to GM3 colors: Primary LStar 0, Primary LStar 0, Secondary
* LStar 85, and Tertiary LStar 70
@@ -287,8 +287,8 @@
}
/**
- * Returns the dark theme version of the Revamped UI preview of a ColorScheme based on this
- * order: top left, top right, bottom left, bottom right
+ * Returns the dark theme preview of a monochrome ColorScheme based on this order: top left, top
+ * right, bottom left, bottom right
*
* This color mapping corresponds to GM3 colors: Primary LStar 99, Primary LStar 99, Secondary
* LStar 35, and Tertiary LStar 70
@@ -304,13 +304,13 @@
}
/**
- * Returns the Revamped UI preview of a preset ColorScheme based on this order: top left, top
- * right, bottom left, bottom right
+ * Returns the preview of a preset ColorScheme based on this order: top left, top right, bottom
+ * left, bottom right
*/
- private fun getPresetColorPreview(colorScheme: ColorScheme, seed: Int): IntArray {
+ private fun getFixedPresetColorPreview(colorScheme: ColorScheme): IntArray {
val colors =
when (colorScheme.style) {
- Style.FRUIT_SALAD -> intArrayOf(seed, colorScheme.accent1.s200)
+ Style.FRUIT_SALAD -> intArrayOf(colorScheme.accent3.s100, colorScheme.accent1.s200)
Style.TONAL_SPOT -> intArrayOf(colorScheme.accentColor, colorScheme.accentColor)
Style.RAINBOW -> intArrayOf(colorScheme.accent1.s200, colorScheme.accent1.s200)
else -> intArrayOf(colorScheme.accent1.s100, colorScheme.accent1.s100)
@@ -318,7 +318,30 @@
return intArrayOf(colors[0], colors[1], colors[0], colors[1])
}
- private suspend fun loadPreset() =
+ /**
+ * Returns the light theme contrast-adjusted preview of a preset ColorScheme, specifically for
+ * Revamped UI, based on this order: top left, top right, bottom left, bottom right
+ */
+ private fun getLightPresetColorPreview(colorScheme: ColorScheme): IntArray {
+ val colors =
+ when (colorScheme.style) {
+ Style.FRUIT_SALAD ->
+ intArrayOf(
+ colorScheme.accent3.getAtTone(450f),
+ colorScheme.accent1.getAtTone(550f),
+ )
+ Style.TONAL_SPOT -> intArrayOf(colorScheme.accentColor, colorScheme.accentColor)
+ Style.RAINBOW ->
+ intArrayOf(
+ colorScheme.accent1.getAtTone(450f),
+ colorScheme.accent1.getAtTone(450f),
+ )
+ else -> intArrayOf(colorScheme.accent1.s100, colorScheme.accent1.s100)
+ }
+ return intArrayOf(colors[0], colors[1], colors[0], colors[1])
+ }
+
+ private suspend fun loadPreset(isNewPickerUi: Boolean) =
withContext(Dispatchers.IO) {
val bundles: MutableList<ColorOption> = ArrayList()
@@ -358,9 +381,23 @@
hasMonochrome = true
monochromeBundleName = bundleName
}
- bundles.add(buildPreset(bundleName, index, style))
+ bundles.add(
+ buildPreset(
+ bundleName = bundleName,
+ index = index,
+ style = style,
+ isNewPickerUi = isNewPickerUi,
+ )
+ )
} else {
- bundles.add(buildPreset(bundleName, index, null))
+ bundles.add(
+ buildPreset(
+ bundleName = bundleName,
+ index = index,
+ style = null,
+ isNewPickerUi = isNewPickerUi,
+ )
+ )
}
index++
@@ -378,6 +415,7 @@
index: Int,
@Style.Type style: Int? = null,
type: ColorType = ColorType.PRESET_COLOR,
+ isNewPickerUi: Boolean,
): ColorOptionImpl {
val builder = ColorOptionImpl.Builder()
builder.title = getItemStringFromStub(COLOR_BUNDLE_NAME_PREFIX, bundleName)
@@ -406,8 +444,13 @@
lightColors = getLightMonochromePreview(lightColorScheme)
}
else -> {
- darkColors = getPresetColorPreview(darkColorScheme, colorFromStub)
- lightColors = getPresetColorPreview(lightColorScheme, colorFromStub)
+ darkColors = getFixedPresetColorPreview(darkColorScheme)
+ lightColors =
+ if (isNewPickerUi) {
+ getFixedPresetColorPreview(lightColorScheme)
+ } else {
+ getLightPresetColorPreview(lightColorScheme)
+ }
}
}
}
@@ -416,7 +459,7 @@
return builder.build()
}
- private fun buildFinalList(): List<ColorOption> {
+ private fun buildFinalList(isNewPickerUi: Boolean): 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
@@ -426,7 +469,13 @@
if (wallpaperColors.isNotEmpty()) {
wallpaperColors.add(
1,
- buildPreset(it, -1, Style.MONOCHROMATIC, ColorType.WALLPAPER_COLOR),
+ buildPreset(
+ bundleName = it,
+ index = -1,
+ style = Style.MONOCHROMATIC,
+ type = ColorType.WALLPAPER_COLOR,
+ isNewPickerUi = isNewPickerUi,
+ ),
)
}
}
diff --git a/src/com/android/customization/module/ThemePickerInjector.kt b/src/com/android/customization/module/ThemePickerInjector.kt
index b577e43..df68c32 100644
--- a/src/com/android/customization/module/ThemePickerInjector.kt
+++ b/src/com/android/customization/module/ThemePickerInjector.kt
@@ -70,6 +70,7 @@
import com.android.wallpaper.module.PartnerProvider
import com.android.wallpaper.module.WallpaperPicker2Injector
import com.android.wallpaper.module.WallpaperPreferences
+import com.android.wallpaper.module.WallpaperRefresher
import com.android.wallpaper.module.logging.UserEventLogger
import com.android.wallpaper.network.Requester
import com.android.wallpaper.picker.CustomizationPickerActivity
@@ -120,6 +121,7 @@
wallpaperColorsRepository: Lazy<WallpaperColorsRepository>,
defaultWallpaperCategoryWrapper: Lazy<WallpaperCategoryWrapper>,
packageNotifier: Lazy<PackageStatusNotifier>,
+ wallpaperRefresher: Lazy<WallpaperRefresher>,
) :
WallpaperPicker2Injector(
mainScope,
@@ -135,6 +137,7 @@
wallpaperColorsRepository,
defaultWallpaperCategoryWrapper,
packageNotifier,
+ wallpaperRefresher,
),
CustomizationInjector {
private var customizationSections: CustomizationSections? = null