Loading packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockFaceController.kt +10 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ interface ClockFaceController { @get:SimpleProperty /** Current theme information the clock is using */ val theme: ThemeConfig var theme: ThemeConfig @get:SimpleProperty /** Events specific to this clock face */ Loading @@ -44,4 +44,13 @@ interface ClockFaceController { @get:SimpleProperty /** Triggers for various animations */ val animations: ClockAnimations companion object { fun ClockFaceController.updateTheme(mutateTheme: (ThemeConfig) -> ThemeConfig) { val theme = mutateTheme(this.theme) if (this.theme == theme) return events.onThemeChanged(theme) this.theme = theme } } } packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +5 −4 Original line number Diff line number Diff line Loading @@ -57,6 +57,7 @@ import com.android.systemui.plugins.clocks.AlarmData import com.android.systemui.plugins.clocks.ClockController import com.android.systemui.plugins.clocks.ClockEventListener import com.android.systemui.plugins.clocks.ClockFaceController import com.android.systemui.plugins.clocks.ClockFaceController.Companion.updateTheme import com.android.systemui.plugins.clocks.ClockMessageBuffers import com.android.systemui.plugins.clocks.ClockTickRate import com.android.systemui.plugins.clocks.VRectF Loading Loading @@ -264,19 +265,19 @@ constructor( if (regionSamplingEnabled) { clock?.smallClock?.run { val isDark = smallRegionSampler?.currentRegionDarkness()?.isDark ?: isDarkTheme events.onThemeChanged(theme.copy(isDarkTheme = isDark)) updateTheme { it.copy(isDarkTheme = isDark) } } clock?.largeClock?.run { val isDark = largeRegionSampler?.currentRegionDarkness()?.isDark ?: isDarkTheme events.onThemeChanged(theme.copy(isDarkTheme = isDark)) updateTheme { it.copy(isDarkTheme = isDark) } } return } clock?.run { Log.i(TAG, "isThemeDark: $isDarkTheme") smallClock.events.onThemeChanged(smallClock.theme.copy(isDarkTheme = isDarkTheme)) largeClock.events.onThemeChanged(largeClock.theme.copy(isDarkTheme = isDarkTheme)) smallClock.updateTheme { it.copy(isDarkTheme = isDarkTheme) } largeClock.updateTheme { it.copy(isDarkTheme = isDarkTheme) } } } Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinder.kt +21 −20 Original line number Diff line number Diff line Loading @@ -163,6 +163,7 @@ object KeyguardClockViewBinder { repeatOnLifecycle(Lifecycle.State.STARTED) { viewModel.currentClock.collect { currentClock -> currentClock?.apply { // Reapply existing theme smallClock.run { events.onThemeChanged(theme) } largeClock.run { events.onThemeChanged(theme) } } Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewClockViewBinder.kt +3 −10 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import com.android.systemui.keyguard.ui.view.layout.sections.setVisibility import com.android.systemui.keyguard.ui.viewmodel.KeyguardPreviewClockViewModel import com.android.systemui.lifecycle.repeatWhenAttached import com.android.systemui.plugins.clocks.ClockController import com.android.systemui.plugins.clocks.ClockFaceController.Companion.updateTheme import com.android.systemui.plugins.clocks.ClockPreviewConfig import com.android.systemui.shared.clocks.ClockRegistry import kotlinx.coroutines.flow.combine Loading Loading @@ -114,16 +115,8 @@ object KeyguardPreviewClockViewBinder { .invokeOnCompletion { // recover seed color especially for Transit clock lastClock?.apply { smallClock.run { events.onThemeChanged( theme.copy(seedColor = clockRegistry.seedColor) ) } largeClock.run { events.onThemeChanged( theme.copy(seedColor = clockRegistry.seedColor) ) } smallClock.updateTheme { it.copy(seedColor = clockRegistry.seedColor) } largeClock.updateTheme { it.copy(seedColor = clockRegistry.seedColor) } } lastClock = null } Loading packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -153,8 +153,8 @@ class ClockEventControllerTest : SysuiTestCase() { .thenReturn(ClockFaceConfig(tickRate = ClockTickRate.PER_MINUTE)) whenever(largeClockController.config) .thenReturn(ClockFaceConfig(tickRate = ClockTickRate.PER_MINUTE)) whenever(smallClockController.theme).thenReturn(ThemeConfig(true, null)) whenever(largeClockController.theme).thenReturn(ThemeConfig(true, null)) whenever(smallClockController.theme).thenReturn(ThemeConfig(false, null)) whenever(largeClockController.theme).thenReturn(ThemeConfig(false, null)) whenever(userTracker.userId).thenReturn(1) repository = kosmos.fakeKeyguardRepository Loading Loading
packages/SystemUI/plugin/src/com/android/systemui/plugins/clocks/ClockFaceController.kt +10 −1 Original line number Diff line number Diff line Loading @@ -35,7 +35,7 @@ interface ClockFaceController { @get:SimpleProperty /** Current theme information the clock is using */ val theme: ThemeConfig var theme: ThemeConfig @get:SimpleProperty /** Events specific to this clock face */ Loading @@ -44,4 +44,13 @@ interface ClockFaceController { @get:SimpleProperty /** Triggers for various animations */ val animations: ClockAnimations companion object { fun ClockFaceController.updateTheme(mutateTheme: (ThemeConfig) -> ThemeConfig) { val theme = mutateTheme(this.theme) if (this.theme == theme) return events.onThemeChanged(theme) this.theme = theme } } }
packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +5 −4 Original line number Diff line number Diff line Loading @@ -57,6 +57,7 @@ import com.android.systemui.plugins.clocks.AlarmData import com.android.systemui.plugins.clocks.ClockController import com.android.systemui.plugins.clocks.ClockEventListener import com.android.systemui.plugins.clocks.ClockFaceController import com.android.systemui.plugins.clocks.ClockFaceController.Companion.updateTheme import com.android.systemui.plugins.clocks.ClockMessageBuffers import com.android.systemui.plugins.clocks.ClockTickRate import com.android.systemui.plugins.clocks.VRectF Loading Loading @@ -264,19 +265,19 @@ constructor( if (regionSamplingEnabled) { clock?.smallClock?.run { val isDark = smallRegionSampler?.currentRegionDarkness()?.isDark ?: isDarkTheme events.onThemeChanged(theme.copy(isDarkTheme = isDark)) updateTheme { it.copy(isDarkTheme = isDark) } } clock?.largeClock?.run { val isDark = largeRegionSampler?.currentRegionDarkness()?.isDark ?: isDarkTheme events.onThemeChanged(theme.copy(isDarkTheme = isDark)) updateTheme { it.copy(isDarkTheme = isDark) } } return } clock?.run { Log.i(TAG, "isThemeDark: $isDarkTheme") smallClock.events.onThemeChanged(smallClock.theme.copy(isDarkTheme = isDarkTheme)) largeClock.events.onThemeChanged(largeClock.theme.copy(isDarkTheme = isDarkTheme)) smallClock.updateTheme { it.copy(isDarkTheme = isDarkTheme) } largeClock.updateTheme { it.copy(isDarkTheme = isDarkTheme) } } } Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinder.kt +21 −20 Original line number Diff line number Diff line Loading @@ -163,6 +163,7 @@ object KeyguardClockViewBinder { repeatOnLifecycle(Lifecycle.State.STARTED) { viewModel.currentClock.collect { currentClock -> currentClock?.apply { // Reapply existing theme smallClock.run { events.onThemeChanged(theme) } largeClock.run { events.onThemeChanged(theme) } } Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardPreviewClockViewBinder.kt +3 −10 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import com.android.systemui.keyguard.ui.view.layout.sections.setVisibility import com.android.systemui.keyguard.ui.viewmodel.KeyguardPreviewClockViewModel import com.android.systemui.lifecycle.repeatWhenAttached import com.android.systemui.plugins.clocks.ClockController import com.android.systemui.plugins.clocks.ClockFaceController.Companion.updateTheme import com.android.systemui.plugins.clocks.ClockPreviewConfig import com.android.systemui.shared.clocks.ClockRegistry import kotlinx.coroutines.flow.combine Loading Loading @@ -114,16 +115,8 @@ object KeyguardPreviewClockViewBinder { .invokeOnCompletion { // recover seed color especially for Transit clock lastClock?.apply { smallClock.run { events.onThemeChanged( theme.copy(seedColor = clockRegistry.seedColor) ) } largeClock.run { events.onThemeChanged( theme.copy(seedColor = clockRegistry.seedColor) ) } smallClock.updateTheme { it.copy(seedColor = clockRegistry.seedColor) } largeClock.updateTheme { it.copy(seedColor = clockRegistry.seedColor) } } lastClock = null } Loading
packages/SystemUI/tests/src/com/android/keyguard/ClockEventControllerTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -153,8 +153,8 @@ class ClockEventControllerTest : SysuiTestCase() { .thenReturn(ClockFaceConfig(tickRate = ClockTickRate.PER_MINUTE)) whenever(largeClockController.config) .thenReturn(ClockFaceConfig(tickRate = ClockTickRate.PER_MINUTE)) whenever(smallClockController.theme).thenReturn(ThemeConfig(true, null)) whenever(largeClockController.theme).thenReturn(ThemeConfig(true, null)) whenever(smallClockController.theme).thenReturn(ThemeConfig(false, null)) whenever(largeClockController.theme).thenReturn(ThemeConfig(false, null)) whenever(userTracker.userId).thenReturn(1) repository = kosmos.fakeKeyguardRepository Loading