Do not listen to clock change if should hide clock

No need to listen to changes of clocks if clock is not shown in the
preview

Test: manually tested that there is no weird flash of smart space
Test: from clock updates when shouldHideClock
Bug: 282080440
Change-Id: I1508bb798b3984ac01d5c6b95cba58d2f4663fab
This commit is contained in:
George Lin
2023-05-11 01:18:38 +00:00
parent 66ca362533
commit e1e7338bf5

View File

@@ -122,7 +122,9 @@ constructor(
setUpUdfps(rootView)
setUpClock(rootView)
if (!shouldHideClock) {
setUpClock(rootView)
}
rootView.measure(
View.MeasureSpec.makeMeasureSpec(
@@ -352,28 +354,23 @@ constructor(
clockController.clock = clock
colorOverride?.let { clock.events.onSeedColorChanged(it) }
if (!shouldHideClock) {
clock.largeClock.events.onTargetRegionChanged(
KeyguardClockSwitch.getLargeClockRegion(parentView)
)
clockView?.let { parentView.removeView(it) }
clockView =
clock.largeClock.view.apply {
if (shouldHighlightSelectedAffordance) {
alpha = DIM_ALPHA
}
parentView.addView(this)
visibility = View.VISIBLE
clock.largeClock.events.onTargetRegionChanged(
KeyguardClockSwitch.getLargeClockRegion(parentView)
)
clockView?.let { parentView.removeView(it) }
clockView =
clock.largeClock.view.apply {
if (shouldHighlightSelectedAffordance) {
alpha = DIM_ALPHA
}
} else {
clockView?.visibility = View.GONE
}
parentView.addView(this)
visibility = View.VISIBLE
}
// Hide smart space if the clock has weather display; otherwise show it
val hasCustomWeatherDataDisplay =
clock.largeClock.config.hasCustomWeatherDataDisplay == true
hideSmartspace(hasCustomWeatherDataDisplay)
hideSmartspace(clock.largeClock.config.hasCustomWeatherDataDisplay)
}
companion object {