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

Commit 99c37a68 authored by Grace's avatar Grace
Browse files

Fix latency issue

This change addresses the issue of the clock not updating colors until
the next animation. Now, an animation is triggered directly after
changing colors.

Bug: 202758428
Test: N/A
Change-Id: I37a27e27ce1c6b6d8eacbbad9182295619718c2e
parent 0201aca5
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -84,6 +84,9 @@ class DefaultClock(
        resources.getFloat(R.dimen.keyguard_clock_line_spacing_scale_burmese)
    private val defaultLineSpacing = resources.getFloat(R.dimen.keyguard_clock_line_spacing_scale)

    private var smallRegionDarkness = RegionDarkness.DEFAULT
    private var largeRegionDarkness = RegionDarkness.DEFAULT

    private fun updateClockColor(clock: AnimatableClockView, isRegionDark: RegionDarkness) {
        val color = if (isRegionDark.isDark) {
            resources.getColor(android.R.color.system_accent2_100)
@@ -91,6 +94,7 @@ class DefaultClock(
            resources.getColor(android.R.color.system_accent1_600)
        }
        clock.setColors(DOZE_COLOR, color)
        clock.animateAppearOnLockscreen()
    }

    override val events = object : ClockEvents {
@@ -119,9 +123,15 @@ class DefaultClock(
                smallClockIsDark: RegionDarkness,
                largeClockIsDark: RegionDarkness
        ) {
            if (smallRegionDarkness != smallClockIsDark) {
                smallRegionDarkness = smallClockIsDark
                updateClockColor(smallClock, smallClockIsDark)
            }
            if (largeRegionDarkness != largeClockIsDark) {
                largeRegionDarkness = largeClockIsDark
                updateClockColor(largeClock, largeClockIsDark)
            }
        }

        override fun onLocaleChanged(locale: Locale) {
            val nf = NumberFormat.getInstance(locale)
+0 −4
Original line number Diff line number Diff line
@@ -48,10 +48,6 @@ class RegionSamplingInstance(
        }
    }

    fun createRegionSamplingInstance(): Pair<RegionDarkness, Rect> {
        return Pair(isDark, samplingBounds)
    }

    fun currentClockDarkness(): RegionDarkness {
        return isDark
    }
+3 −0
Original line number Diff line number Diff line
@@ -80,6 +80,9 @@ class ClockEventController @Inject constructor(
    }

    fun updateRegionSamplers(currentClock: Clock?) {
        smallRegionSamplingInstance.stopRegionSampler()
        largeRegionSamplingInstance.stopRegionSampler()

        smallRegionSamplingInstance = RegionSamplingInstance(
                currentClock?.smallClock,
                mainExecutor,