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

Commit bc1070b4 authored by Catherine Liang's avatar Catherine Liang
Browse files

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
parent 9bbcfb3e
Loading
Loading
Loading
Loading
+25 −10
Original line number Diff line number Diff line
@@ -306,24 +306,36 @@ class ColorProvider(private val context: Context, stubPackageName: String) :
        )
    }

    /**
     * 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 getDarkPresetColorPreview(colorScheme: ColorScheme): IntArray {
        val colors =
            when (colorScheme.style) {
                Style.FRUIT_SALAD -> intArrayOf(colorScheme.accent3.s100, colorScheme.accent1.s200)
                else -> intArrayOf(colorScheme.accent1.s200, colorScheme.accent1.s200)
            }
        return intArrayOf(colors[0], colors[1], colors[0], colors[1])
    }

    /**
     * Returns the 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 getFixedPresetColorPreview(colorScheme: ColorScheme, seed: Int): 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(seed, seed)
            }
        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 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 @@ class ColorProvider(private val context: Context, stubPackageName: String) :
                        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 @@ class ColorProvider(private val context: Context, stubPackageName: String) :
                    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)
                        }