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

Commit ac730808 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update aod colors to ensure contrast" into main

parents f63abe5a 2d59f696
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -164,7 +164,10 @@ class ComposedDigitalLayerController(private val clockCtx: ClockContext) :
            }

            override fun onThemeChanged(theme: ThemeConfig) {
                view.updateColor(theme.getDefaultColor(clockCtx.context))
                view.updateColor(
                    lockscreenColor = theme.getDefaultColor(clockCtx.context),
                    aodColor = clockCtx.resources.getColor(android.R.color.system_accent1_100),
                )
            }

            override fun onFontSettingChanged(fontSizePx: Float) {
+12 −2
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ 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 java.io.PrintWriter
import java.util.Locale
import java.util.TimeZone
@@ -138,7 +139,7 @@ class DefaultClockController(

        init {
            view.id = ClockViewIds.LOCKSCREEN_CLOCK_VIEW_SMALL
            view.setColors(DOZE_COLOR, currentColor)
            view.setColors(getAodColor(), currentColor)
            messageBuffer?.let { view.messageBuffer = it }
        }

@@ -155,7 +156,8 @@ class DefaultClockController(
                    }

                    currentColor = color
                    view.setColors(DOZE_COLOR, color)

                    view.setColors(getAodColor(), color)
                    if (!animations.dozeState.isActive) {
                        view.animateColorChange()
                    }
@@ -175,6 +177,14 @@ class DefaultClockController(
            }

        open fun recomputePadding(targetRegion: Rect?) {}

        private fun getAodColor(): Int {
            return if (ambientAod()) {
                ctx.resources.getColor(android.R.color.system_accent1_100)
            } else {
                DOZE_COLOR
            }
        }
    }

    inner class LargeClockFaceController(
+19 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ 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
@@ -33,6 +34,7 @@ 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
@@ -224,7 +226,23 @@ open class SimpleDigitalHandLayerController(
            }

            override fun onThemeChanged(theme: ThemeConfig) {
                view.updateColor(theme.getDefaultColor(clockCtx.context))
                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,
                    )
                } else {
                    view.updateColor(lockscreenColor = theme.getDefaultColor(clockCtx.context))
                }
                refreshTime()
            }

+2 −2
Original line number Diff line number Diff line
@@ -267,8 +267,8 @@ class FlexClockView(clockCtx: ClockContext) : ViewGroup(clockCtx.context) {
        requestLayout()
    }

    fun updateColor(color: Int) {
        childViews.forEach { view -> view.updateColor(color) }
    fun updateColor(lockscreenColor: Int, aodColor: Int) {
        childViews.forEach { view -> view.updateColor(lockscreenColor, aodColor) }
        invalidate()
    }

+8 −4
Original line number Diff line number Diff line
@@ -197,10 +197,15 @@ open class SimpleDigitalClockTextView(
    var textBorderWidth = 0f
    var measuredBaseline = 0
    var lockscreenColor = Color.WHITE
    var aodColor = Color.WHITE

    fun updateColor(color: Int) {
        lockscreenColor = color
    fun updateColor(lockscreenColor: Int, aodColor: Int = Color.WHITE) {
        this.lockscreenColor = lockscreenColor
        if (ambientAod()) {
            this.aodColor = aodColor
        }
        lockScreenPaint.color = lockscreenColor

        if (dozeFraction < 1f) {
            textAnimator.setTextStyle(TextAnimator.Style(color = lockscreenColor))
        }
@@ -355,7 +360,7 @@ open class SimpleDigitalClockTextView(
        textAnimator.setTextStyle(
            TextAnimator.Style(
                fVar = if (isDozing) aodFontVariation else lsFontVariation,
                color = if (isDozing && !ambientAod()) AOD_COLOR else lockscreenColor,
                color = if (isDozing) aodColor else lockscreenColor,
                textSize = if (isDozing) aodFontSizePx else lockScreenPaint.textSize,
            ),
            TextAnimator.Animation(
@@ -706,7 +711,6 @@ open class SimpleDigitalClockTextView(
                AxisAnimation(GSFAxes.SLANT, 0f),
            )

        val AOD_COLOR = Color.WHITE
        private val LS_WEIGHT_AXIS = GSFAxes.WEIGHT to 400f
        private val AOD_WEIGHT_AXIS = GSFAxes.WEIGHT to 200f
        private val WIDTH_AXIS = GSFAxes.WIDTH to 85f
Loading