Update preset color option icon mapping
Update how color option icons appear to make sure there is adequate
contrast and to match the spec.
Flag: com.android.systemui.shared.new_customization_picker_ui
Test: build & install different themes stub packages
Test: manually verified color options with flag on and off
Bug: 399098020
Change-Id: I7bb48635a5a6ad715707fc22de1c2e8117b0f728
diff --git a/src/com/android/customization/model/color/ColorProvider.kt b/src/com/android/customization/model/color/ColorProvider.kt
index 5c2b891..173a7d1 100644
--- a/src/com/android/customization/model/color/ColorProvider.kt
+++ b/src/com/android/customization/model/color/ColorProvider.kt
@@ -307,23 +307,35 @@
}
/**
- * Returns the preview of a preset ColorScheme based on this order: top left, top right, bottom
- * left, bottom right
+ * Returns the light theme contrast-adjusted preview of a preset ColorScheme, based on this
+ * order: top left, top right, bottom left, bottom right
*/
- private fun getFixedPresetColorPreview(colorScheme: ColorScheme): IntArray {
+ private fun getDarkPresetColorPreview(colorScheme: ColorScheme): IntArray {
val colors =
when (colorScheme.style) {
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)
+ else -> intArrayOf(colorScheme.accent1.s200, colorScheme.accent1.s200)
}
return intArrayOf(colors[0], colors[1], colors[0], colors[1])
}
/**
- * 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
+ * Returns the preview of a preset ColorScheme based on this order: top left, top right, bottom
+ * left, bottom right
+ */
+ private fun getFixedPresetColorPreview(colorScheme: ColorScheme, seed: Int): IntArray {
+ val colors =
+ when (colorScheme.style) {
+ Style.FRUIT_SALAD -> intArrayOf(colorScheme.accent3.s100, colorScheme.accent1.s200)
+ Style.RAINBOW -> intArrayOf(colorScheme.accent1.s200, colorScheme.accent1.s200)
+ else -> intArrayOf(seed, seed)
+ }
+ return intArrayOf(colors[0], colors[1], colors[0], colors[1])
+ }
+
+ /**
+ * Returns the light theme contrast-adjusted preview of a preset ColorScheme, based on this
+ * order: top left, top right, bottom left, bottom right
*/
private fun getLightPresetColorPreview(colorScheme: ColorScheme): IntArray {
val colors =
@@ -333,13 +345,11 @@
colorScheme.accent3.getAtTone(450f),
colorScheme.accent1.getAtTone(550f),
)
- Style.TONAL_SPOT -> intArrayOf(colorScheme.accentColor, colorScheme.accentColor)
- Style.RAINBOW ->
+ else ->
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])
}
@@ -447,10 +457,15 @@
lightColors = getLightMonochromePreview(lightColorScheme)
}
else -> {
- darkColors = getFixedPresetColorPreview(darkColorScheme)
+ darkColors =
+ if (isNewPickerUi) {
+ getFixedPresetColorPreview(darkColorScheme, colorFromStub)
+ } else {
+ getDarkPresetColorPreview(darkColorScheme)
+ }
lightColors =
if (isNewPickerUi) {
- getFixedPresetColorPreview(lightColorScheme)
+ getFixedPresetColorPreview(lightColorScheme, colorFromStub)
} else {
getLightPresetColorPreview(lightColorScheme)
}