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

Commit d39e507a authored by Matt Pietal's avatar Matt Pietal
Browse files

Ensure large clock uses the seed color on AOD

Prior, it was using the system theme color on AOD instead

Fixes: 413532266
Test: manual - override clock color, observe large clock
Flag: com.android.systemui.shared.ambient_aod
Change-Id: Ice931798ca03e3eb0201e297f8978f7549f8355a
parent 1f1914cd
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -166,7 +166,7 @@ class ComposedDigitalLayerController(private val clockCtx: ClockContext) :
            override fun onThemeChanged(theme: ThemeConfig) {
                view.updateColor(
                    lockscreenColor = theme.getDefaultColor(clockCtx.context),
                    aodColor = clockCtx.resources.getColor(android.R.color.system_accent1_100),
                    aodColor = theme.getAodColor(clockCtx.context),
                )
            }

+4 −19
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import android.widget.RelativeLayout
import androidx.annotation.VisibleForTesting
import com.android.systemui.animation.TextAnimator
import com.android.systemui.log.core.Logger
import com.android.systemui.monet.ColorScheme
import com.android.systemui.plugins.clocks.AlarmData
import com.android.systemui.plugins.clocks.ClockAnimations
import com.android.systemui.plugins.clocks.ClockAxisStyle
@@ -34,7 +33,6 @@ import com.android.systemui.plugins.clocks.ClockViewIds
import com.android.systemui.plugins.clocks.ThemeConfig
import com.android.systemui.plugins.clocks.WeatherData
import com.android.systemui.plugins.clocks.ZenData
import com.android.systemui.shared.Flags.ambientAod
import com.android.systemui.shared.clocks.view.HorizontalAlignment
import com.android.systemui.shared.clocks.view.SimpleDigitalClockTextView
import com.android.systemui.shared.clocks.view.VerticalAlignment
@@ -226,23 +224,10 @@ open class SimpleDigitalHandLayerController(
            }

            override fun onThemeChanged(theme: ThemeConfig) {
                if (ambientAod()) {
                    val aodColor =
                        theme.seedColor?.let {
                            val colorScheme =
                                ColorScheme(
                                    it,
                                    false, // darkTheme is not used for palette generation
                                )
                            colorScheme.accent1.s100
                        } ?: clockCtx.resources.getColor(android.R.color.system_accent1_100)
                view.updateColor(
                    lockscreenColor = theme.getDefaultColor(clockCtx.context),
                        aodColor = aodColor,
                    aodColor = theme.getAodColor(clockCtx.context),
                )
                } else {
                    view.updateColor(lockscreenColor = theme.getDefaultColor(clockCtx.context))
                }
                refreshTime()
            }

+2 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.shared.clocks.view

import android.graphics.Canvas
import android.graphics.Color
import android.icu.text.NumberFormat
import android.util.MathUtils.constrainedMap
import android.view.View
@@ -267,7 +268,7 @@ class FlexClockView(clockCtx: ClockContext) : ViewGroup(clockCtx.context) {
        requestLayout()
    }

    fun updateColor(lockscreenColor: Int, aodColor: Int) {
    fun updateColor(lockscreenColor: Int, aodColor: Int = Color.WHITE) {
        childViews.forEach { view -> view.updateColor(lockscreenColor, aodColor) }
        invalidate()
    }
+1 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ java_library {
        "androidx.annotation_annotation",
        "androidx.compose.ui_ui",
        "androidx.compose.runtime_runtime",
        "monet",
    ],
}

+18 −0
Original line number Diff line number Diff line
@@ -14,8 +14,11 @@
package com.android.systemui.plugins.clocks

import android.content.Context
import android.graphics.Color
import android.graphics.Rect
import com.android.systemui.monet.ColorScheme
import com.android.systemui.plugins.annotations.ProtectedInterface
import com.android.systemui.shared.Flags.ambientAod

/** Events that have specific data about the related face */
@ProtectedInterface
@@ -70,4 +73,19 @@ data class ThemeConfig(
            else -> context.resources.getColor(android.R.color.system_accent2_600)
        }
    }

    fun getAodColor(context: Context): Int {
        return if (!ambientAod()) {
            Color.WHITE
        } else {
            seedColor?.let {
                val colorScheme =
                    ColorScheme(
                        it,
                        false, // darkTheme is not used for palette generation
                    )
                colorScheme.accent1.s100
            } ?: context.resources.getColor(android.R.color.system_accent1_100)
        }
    }
}