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

Commit f89aff3e authored by Catherine Liang's avatar Catherine Liang Committed by Android (Google) Code Review
Browse files

Merge "Update preset color option icon mapping" into main

parents 8550be07 bc1070b4
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)
                        }