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
This commit is contained in:
Grace
2022-07-15 18:59:49 +00:00
parent 0201aca5b3
commit 99c37a68d9
3 changed files with 15 additions and 6 deletions

View File

@@ -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,8 +123,14 @@ class DefaultClock(
smallClockIsDark: RegionDarkness,
largeClockIsDark: RegionDarkness
) {
updateClockColor(smallClock, smallClockIsDark)
updateClockColor(largeClock, largeClockIsDark)
if (smallRegionDarkness != smallClockIsDark) {
smallRegionDarkness = smallClockIsDark
updateClockColor(smallClock, smallClockIsDark)
}
if (largeRegionDarkness != largeClockIsDark) {
largeRegionDarkness = largeClockIsDark
updateClockColor(largeClock, largeClockIsDark)
}
}
override fun onLocaleChanged(locale: Locale) {

View File

@@ -48,10 +48,6 @@ class RegionSamplingInstance(
}
}
fun createRegionSamplingInstance(): Pair<RegionDarkness, Rect> {
return Pair(isDark, samplingBounds)
}
fun currentClockDarkness(): RegionDarkness {
return isDark
}

View File

@@ -80,6 +80,9 @@ class ClockEventController @Inject constructor(
}
fun updateRegionSamplers(currentClock: Clock?) {
smallRegionSamplingInstance.stopRegionSampler()
largeRegionSamplingInstance.stopRegionSampler()
smallRegionSamplingInstance = RegionSamplingInstance(
currentClock?.smallClock,
mainExecutor,