Loading packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockController.kt +6 −3 Original line number Original line Diff line number Diff line Loading @@ -25,8 +25,10 @@ import android.widget.FrameLayout import androidx.annotation.VisibleForTesting import androidx.annotation.VisibleForTesting import com.android.systemui.customization.R import com.android.systemui.customization.R import com.android.systemui.plugins.ClockAnimations import com.android.systemui.plugins.ClockAnimations import com.android.systemui.plugins.ClockConfig import com.android.systemui.plugins.ClockController import com.android.systemui.plugins.ClockController import com.android.systemui.plugins.ClockEvents import com.android.systemui.plugins.ClockEvents import com.android.systemui.plugins.ClockFaceConfig import com.android.systemui.plugins.ClockFaceController import com.android.systemui.plugins.ClockFaceController import com.android.systemui.plugins.ClockFaceEvents import com.android.systemui.plugins.ClockFaceEvents import com.android.systemui.plugins.ClockSettings import com.android.systemui.plugins.ClockSettings Loading Loading @@ -63,6 +65,8 @@ class DefaultClockController( override lateinit var animations: DefaultClockAnimations override lateinit var animations: DefaultClockAnimations private set private set override val config = ClockConfig(hasCustomPositionUpdatedAnimation = true) init { init { val parent = FrameLayout(ctx) val parent = FrameLayout(ctx) smallClock = smallClock = Loading Loading @@ -103,6 +107,8 @@ class DefaultClockController( private var isRegionDark = false private var isRegionDark = false protected var targetRegion: Rect? = null protected var targetRegion: Rect? = null override val config = ClockFaceConfig() override var logBuffer: LogBuffer? override var logBuffer: LogBuffer? get() = view.logBuffer get() = view.logBuffer set(value) { set(value) { Loading Loading @@ -254,9 +260,6 @@ class DefaultClockController( override fun onPositionUpdated(fromRect: Rect, toRect: Rect, fraction: Float) { override fun onPositionUpdated(fromRect: Rect, toRect: Rect, fraction: Float) { largeClock.moveForSplitShade(fromRect, toRect, fraction) largeClock.moveForSplitShade(fromRect, toRect, fraction) } } override val hasCustomPositionUpdatedAnimation: Boolean get() = true } } class AnimationState( class AnimationState( Loading packages/SystemUI/plugin/src/com/android/systemui/plugins/ClockProviderPlugin.kt +28 −19 Original line number Original line Diff line number Diff line Loading @@ -63,6 +63,9 @@ interface ClockController { /** A large version of the clock, appropriate when a bigger viewport is available */ /** A large version of the clock, appropriate when a bigger viewport is available */ val largeClock: ClockFaceController val largeClock: ClockFaceController /** Determines the way the hosting app should behave when rendering either clock face */ val config: ClockConfig /** Events that clocks may need to respond to */ /** Events that clocks may need to respond to */ val events: ClockEvents val events: ClockEvents Loading Loading @@ -91,6 +94,9 @@ interface ClockFaceController { /** View that renders the clock face */ /** View that renders the clock face */ val view: View val view: View /** Determines the way the hosting app should behave when rendering this clock face */ val config: ClockFaceConfig /** Events specific to this clock face */ /** Events specific to this clock face */ val events: ClockFaceEvents val events: ClockFaceEvents Loading @@ -109,9 +115,6 @@ interface ClockEvents { /** Call whenever the locale changes */ /** Call whenever the locale changes */ fun onLocaleChanged(locale: Locale) {} fun onLocaleChanged(locale: Locale) {} val isReactiveToTone get() = true /** Call whenever the color palette should update */ /** Call whenever the color palette should update */ fun onColorPaletteChanged(resources: Resources) {} fun onColorPaletteChanged(resources: Resources) {} Loading Loading @@ -144,14 +147,6 @@ interface ClockAnimations { * 0.0 -> clock is scaled down in the shade; previewRatio is previewSize / screenSize * 0.0 -> clock is scaled down in the shade; previewRatio is previewSize / screenSize */ */ fun onPickerCarouselSwiping(swipingFraction: Float, previewRatio: Float) {} fun onPickerCarouselSwiping(swipingFraction: Float, previewRatio: Float) {} /** * Whether this clock has a custom position update animation. If true, the keyguard will call * `onPositionUpdated` to notify the clock of a position update animation. If false, a default * animation will be used (e.g. a simple translation). */ val hasCustomPositionUpdatedAnimation get() = false } } /** Events that have specific data about the related face */ /** Events that have specific data about the related face */ Loading @@ -159,14 +154,6 @@ interface ClockFaceEvents { /** Call every time tick */ /** Call every time tick */ fun onTimeTick() {} fun onTimeTick() {} /** Expected interval between calls to onTimeTick. Can always reduce to PER_MINUTE in AOD. */ val tickRate: ClockTickRate get() = ClockTickRate.PER_MINUTE /** Call to check whether the clock consumes weather data */ val hasCustomWeatherDataDisplay: Boolean get() = false /** /** * Region Darkness specific to the clock face. * Region Darkness specific to the clock face. * - isRegionDark = dark theme -> clock should be light * - isRegionDark = dark theme -> clock should be light Loading Loading @@ -203,6 +190,28 @@ data class ClockMetadata( val name: String, val name: String, ) ) /** Render configuration for the full clock. Modifies the way systemUI behaves with this clock. */ data class ClockConfig( /** * Whether this clock has a custom position update animation. If true, the keyguard will call * `onPositionUpdated` to notify the clock of a position update animation. If false, a default * animation will be used (e.g. a simple translation). */ val hasCustomPositionUpdatedAnimation: Boolean = false, /** True if the clock will react to tone changes in the seed color. */ val isReactiveToTone: Boolean = true, ) /** Render configuration options for a clock face. Modifies the way SystemUI behaves. */ data class ClockFaceConfig( /** Expected interval between calls to onTimeTick. Can always reduce to PER_MINUTE in AOD. */ val tickRate: ClockTickRate = ClockTickRate.PER_MINUTE, /** Call to check whether the clock consumes weather data */ val hasCustomWeatherDataDisplay: Boolean = false, ) /** Structure for keeping clock-specific settings */ /** Structure for keeping clock-specific settings */ @Keep @Keep data class ClockSettings( data class ClockSettings( Loading packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +6 −4 Original line number Original line Diff line number Diff line Loading @@ -46,10 +46,10 @@ import com.android.systemui.log.dagger.KeyguardSmallClockLog import com.android.systemui.plugins.ClockController import com.android.systemui.plugins.ClockController import com.android.systemui.plugins.ClockFaceController import com.android.systemui.plugins.ClockFaceController import com.android.systemui.plugins.ClockTickRate import com.android.systemui.plugins.ClockTickRate import com.android.systemui.plugins.WeatherData import com.android.systemui.plugins.log.LogBuffer import com.android.systemui.plugins.log.LogBuffer import com.android.systemui.plugins.log.LogLevel.DEBUG import com.android.systemui.plugins.log.LogLevel.DEBUG import com.android.systemui.shared.regionsampling.RegionSampler import com.android.systemui.shared.regionsampling.RegionSampler import com.android.systemui.plugins.WeatherData import com.android.systemui.statusbar.policy.BatteryController import com.android.systemui.statusbar.policy.BatteryController import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback import com.android.systemui.statusbar.policy.ConfigurationController import com.android.systemui.statusbar.policy.ConfigurationController Loading Loading @@ -144,8 +144,10 @@ constructor( val currentViewRect = Rect(left, top, right, bottom) val currentViewRect = Rect(left, top, right, bottom) val oldViewRect = Rect(oldLeft, oldTop, oldRight, oldBottom) val oldViewRect = Rect(oldLeft, oldTop, oldRight, oldBottom) if (currentViewRect.width() != oldViewRect.width() || if ( currentViewRect.height() != oldViewRect.height()) { currentViewRect.width() != oldViewRect.width() || currentViewRect.height() != oldViewRect.height() ) { updateRegionSampler(view) updateRegionSampler(view) } } } } Loading Loading @@ -425,7 +427,7 @@ constructor( } } isRunning = true isRunning = true when (clockFace.events.tickRate) { when (clockFace.config.tickRate) { ClockTickRate.PER_MINUTE -> { ClockTickRate.PER_MINUTE -> { /* Handled by KeyguardClockSwitchController */ /* Handled by KeyguardClockSwitchController */ } } Loading packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +2 −10 Original line number Original line Diff line number Diff line Loading @@ -40,7 +40,6 @@ import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dump.DumpManager; import com.android.systemui.dump.DumpManager; import com.android.systemui.keyguard.KeyguardUnlockAnimationController; import com.android.systemui.keyguard.KeyguardUnlockAnimationController; import com.android.systemui.log.dagger.KeyguardClockLog; import com.android.systemui.log.dagger.KeyguardClockLog; import com.android.systemui.plugins.ClockAnimations; import com.android.systemui.plugins.ClockController; import com.android.systemui.plugins.ClockController; import com.android.systemui.plugins.log.LogBuffer; import com.android.systemui.plugins.log.LogBuffer; import com.android.systemui.plugins.log.LogLevel; import com.android.systemui.plugins.log.LogLevel; Loading Loading @@ -469,7 +468,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS } } @Nullable @Nullable private ClockController getClock() { public ClockController getClock() { return mClockEventController.getClock(); return mClockEventController.getClock(); } } Loading Loading @@ -535,13 +534,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS } } return ((mCurrentClockSize == LARGE) ? clock.getLargeClock() : clock.getSmallClock()) return ((mCurrentClockSize == LARGE) ? clock.getLargeClock() : clock.getSmallClock()) .getEvents().getHasCustomWeatherDataDisplay(); .getConfig().getHasCustomWeatherDataDisplay(); } /** Gets the animations for the current clock. */ @Nullable public ClockAnimations getClockAnimations() { ClockController clock = getClock(); return clock == null ? null : clock.getAnimations(); } } } } packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java +6 −4 Original line number Original line Diff line number Diff line Loading @@ -16,12 +16,13 @@ package com.android.keyguard; package com.android.keyguard; import android.annotation.Nullable; import android.graphics.Rect; import android.graphics.Rect; import android.util.Slog; import android.util.Slog; import com.android.keyguard.KeyguardClockSwitch.ClockSize; import com.android.keyguard.KeyguardClockSwitch.ClockSize; import com.android.keyguard.logging.KeyguardLogger; import com.android.keyguard.logging.KeyguardLogger; import com.android.systemui.plugins.ClockAnimations; import com.android.systemui.plugins.ClockController; import com.android.systemui.statusbar.notification.AnimatableProperty; import com.android.systemui.statusbar.notification.AnimatableProperty; import com.android.systemui.statusbar.notification.PropertyAnimator; import com.android.systemui.statusbar.notification.PropertyAnimator; import com.android.systemui.statusbar.notification.stack.AnimationProperties; import com.android.systemui.statusbar.notification.stack.AnimationProperties; Loading Loading @@ -241,8 +242,9 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV } } } } /** Gets the animations for the current clock. */ /** Gets the current clock controller. */ public ClockAnimations getClockAnimations() { @Nullable return mKeyguardClockSwitchController.getClockAnimations(); public ClockController getClockController() { return mKeyguardClockSwitchController.getClock(); } } } } Loading
packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockController.kt +6 −3 Original line number Original line Diff line number Diff line Loading @@ -25,8 +25,10 @@ import android.widget.FrameLayout import androidx.annotation.VisibleForTesting import androidx.annotation.VisibleForTesting import com.android.systemui.customization.R import com.android.systemui.customization.R import com.android.systemui.plugins.ClockAnimations import com.android.systemui.plugins.ClockAnimations import com.android.systemui.plugins.ClockConfig import com.android.systemui.plugins.ClockController import com.android.systemui.plugins.ClockController import com.android.systemui.plugins.ClockEvents import com.android.systemui.plugins.ClockEvents import com.android.systemui.plugins.ClockFaceConfig import com.android.systemui.plugins.ClockFaceController import com.android.systemui.plugins.ClockFaceController import com.android.systemui.plugins.ClockFaceEvents import com.android.systemui.plugins.ClockFaceEvents import com.android.systemui.plugins.ClockSettings import com.android.systemui.plugins.ClockSettings Loading Loading @@ -63,6 +65,8 @@ class DefaultClockController( override lateinit var animations: DefaultClockAnimations override lateinit var animations: DefaultClockAnimations private set private set override val config = ClockConfig(hasCustomPositionUpdatedAnimation = true) init { init { val parent = FrameLayout(ctx) val parent = FrameLayout(ctx) smallClock = smallClock = Loading Loading @@ -103,6 +107,8 @@ class DefaultClockController( private var isRegionDark = false private var isRegionDark = false protected var targetRegion: Rect? = null protected var targetRegion: Rect? = null override val config = ClockFaceConfig() override var logBuffer: LogBuffer? override var logBuffer: LogBuffer? get() = view.logBuffer get() = view.logBuffer set(value) { set(value) { Loading Loading @@ -254,9 +260,6 @@ class DefaultClockController( override fun onPositionUpdated(fromRect: Rect, toRect: Rect, fraction: Float) { override fun onPositionUpdated(fromRect: Rect, toRect: Rect, fraction: Float) { largeClock.moveForSplitShade(fromRect, toRect, fraction) largeClock.moveForSplitShade(fromRect, toRect, fraction) } } override val hasCustomPositionUpdatedAnimation: Boolean get() = true } } class AnimationState( class AnimationState( Loading
packages/SystemUI/plugin/src/com/android/systemui/plugins/ClockProviderPlugin.kt +28 −19 Original line number Original line Diff line number Diff line Loading @@ -63,6 +63,9 @@ interface ClockController { /** A large version of the clock, appropriate when a bigger viewport is available */ /** A large version of the clock, appropriate when a bigger viewport is available */ val largeClock: ClockFaceController val largeClock: ClockFaceController /** Determines the way the hosting app should behave when rendering either clock face */ val config: ClockConfig /** Events that clocks may need to respond to */ /** Events that clocks may need to respond to */ val events: ClockEvents val events: ClockEvents Loading Loading @@ -91,6 +94,9 @@ interface ClockFaceController { /** View that renders the clock face */ /** View that renders the clock face */ val view: View val view: View /** Determines the way the hosting app should behave when rendering this clock face */ val config: ClockFaceConfig /** Events specific to this clock face */ /** Events specific to this clock face */ val events: ClockFaceEvents val events: ClockFaceEvents Loading @@ -109,9 +115,6 @@ interface ClockEvents { /** Call whenever the locale changes */ /** Call whenever the locale changes */ fun onLocaleChanged(locale: Locale) {} fun onLocaleChanged(locale: Locale) {} val isReactiveToTone get() = true /** Call whenever the color palette should update */ /** Call whenever the color palette should update */ fun onColorPaletteChanged(resources: Resources) {} fun onColorPaletteChanged(resources: Resources) {} Loading Loading @@ -144,14 +147,6 @@ interface ClockAnimations { * 0.0 -> clock is scaled down in the shade; previewRatio is previewSize / screenSize * 0.0 -> clock is scaled down in the shade; previewRatio is previewSize / screenSize */ */ fun onPickerCarouselSwiping(swipingFraction: Float, previewRatio: Float) {} fun onPickerCarouselSwiping(swipingFraction: Float, previewRatio: Float) {} /** * Whether this clock has a custom position update animation. If true, the keyguard will call * `onPositionUpdated` to notify the clock of a position update animation. If false, a default * animation will be used (e.g. a simple translation). */ val hasCustomPositionUpdatedAnimation get() = false } } /** Events that have specific data about the related face */ /** Events that have specific data about the related face */ Loading @@ -159,14 +154,6 @@ interface ClockFaceEvents { /** Call every time tick */ /** Call every time tick */ fun onTimeTick() {} fun onTimeTick() {} /** Expected interval between calls to onTimeTick. Can always reduce to PER_MINUTE in AOD. */ val tickRate: ClockTickRate get() = ClockTickRate.PER_MINUTE /** Call to check whether the clock consumes weather data */ val hasCustomWeatherDataDisplay: Boolean get() = false /** /** * Region Darkness specific to the clock face. * Region Darkness specific to the clock face. * - isRegionDark = dark theme -> clock should be light * - isRegionDark = dark theme -> clock should be light Loading Loading @@ -203,6 +190,28 @@ data class ClockMetadata( val name: String, val name: String, ) ) /** Render configuration for the full clock. Modifies the way systemUI behaves with this clock. */ data class ClockConfig( /** * Whether this clock has a custom position update animation. If true, the keyguard will call * `onPositionUpdated` to notify the clock of a position update animation. If false, a default * animation will be used (e.g. a simple translation). */ val hasCustomPositionUpdatedAnimation: Boolean = false, /** True if the clock will react to tone changes in the seed color. */ val isReactiveToTone: Boolean = true, ) /** Render configuration options for a clock face. Modifies the way SystemUI behaves. */ data class ClockFaceConfig( /** Expected interval between calls to onTimeTick. Can always reduce to PER_MINUTE in AOD. */ val tickRate: ClockTickRate = ClockTickRate.PER_MINUTE, /** Call to check whether the clock consumes weather data */ val hasCustomWeatherDataDisplay: Boolean = false, ) /** Structure for keeping clock-specific settings */ /** Structure for keeping clock-specific settings */ @Keep @Keep data class ClockSettings( data class ClockSettings( Loading
packages/SystemUI/src/com/android/keyguard/ClockEventController.kt +6 −4 Original line number Original line Diff line number Diff line Loading @@ -46,10 +46,10 @@ import com.android.systemui.log.dagger.KeyguardSmallClockLog import com.android.systemui.plugins.ClockController import com.android.systemui.plugins.ClockController import com.android.systemui.plugins.ClockFaceController import com.android.systemui.plugins.ClockFaceController import com.android.systemui.plugins.ClockTickRate import com.android.systemui.plugins.ClockTickRate import com.android.systemui.plugins.WeatherData import com.android.systemui.plugins.log.LogBuffer import com.android.systemui.plugins.log.LogBuffer import com.android.systemui.plugins.log.LogLevel.DEBUG import com.android.systemui.plugins.log.LogLevel.DEBUG import com.android.systemui.shared.regionsampling.RegionSampler import com.android.systemui.shared.regionsampling.RegionSampler import com.android.systemui.plugins.WeatherData import com.android.systemui.statusbar.policy.BatteryController import com.android.systemui.statusbar.policy.BatteryController import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback import com.android.systemui.statusbar.policy.ConfigurationController import com.android.systemui.statusbar.policy.ConfigurationController Loading Loading @@ -144,8 +144,10 @@ constructor( val currentViewRect = Rect(left, top, right, bottom) val currentViewRect = Rect(left, top, right, bottom) val oldViewRect = Rect(oldLeft, oldTop, oldRight, oldBottom) val oldViewRect = Rect(oldLeft, oldTop, oldRight, oldBottom) if (currentViewRect.width() != oldViewRect.width() || if ( currentViewRect.height() != oldViewRect.height()) { currentViewRect.width() != oldViewRect.width() || currentViewRect.height() != oldViewRect.height() ) { updateRegionSampler(view) updateRegionSampler(view) } } } } Loading Loading @@ -425,7 +427,7 @@ constructor( } } isRunning = true isRunning = true when (clockFace.events.tickRate) { when (clockFace.config.tickRate) { ClockTickRate.PER_MINUTE -> { ClockTickRate.PER_MINUTE -> { /* Handled by KeyguardClockSwitchController */ /* Handled by KeyguardClockSwitchController */ } } Loading
packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +2 −10 Original line number Original line Diff line number Diff line Loading @@ -40,7 +40,6 @@ import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dump.DumpManager; import com.android.systemui.dump.DumpManager; import com.android.systemui.keyguard.KeyguardUnlockAnimationController; import com.android.systemui.keyguard.KeyguardUnlockAnimationController; import com.android.systemui.log.dagger.KeyguardClockLog; import com.android.systemui.log.dagger.KeyguardClockLog; import com.android.systemui.plugins.ClockAnimations; import com.android.systemui.plugins.ClockController; import com.android.systemui.plugins.ClockController; import com.android.systemui.plugins.log.LogBuffer; import com.android.systemui.plugins.log.LogBuffer; import com.android.systemui.plugins.log.LogLevel; import com.android.systemui.plugins.log.LogLevel; Loading Loading @@ -469,7 +468,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS } } @Nullable @Nullable private ClockController getClock() { public ClockController getClock() { return mClockEventController.getClock(); return mClockEventController.getClock(); } } Loading Loading @@ -535,13 +534,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS } } return ((mCurrentClockSize == LARGE) ? clock.getLargeClock() : clock.getSmallClock()) return ((mCurrentClockSize == LARGE) ? clock.getLargeClock() : clock.getSmallClock()) .getEvents().getHasCustomWeatherDataDisplay(); .getConfig().getHasCustomWeatherDataDisplay(); } /** Gets the animations for the current clock. */ @Nullable public ClockAnimations getClockAnimations() { ClockController clock = getClock(); return clock == null ? null : clock.getAnimations(); } } } }
packages/SystemUI/src/com/android/keyguard/KeyguardStatusViewController.java +6 −4 Original line number Original line Diff line number Diff line Loading @@ -16,12 +16,13 @@ package com.android.keyguard; package com.android.keyguard; import android.annotation.Nullable; import android.graphics.Rect; import android.graphics.Rect; import android.util.Slog; import android.util.Slog; import com.android.keyguard.KeyguardClockSwitch.ClockSize; import com.android.keyguard.KeyguardClockSwitch.ClockSize; import com.android.keyguard.logging.KeyguardLogger; import com.android.keyguard.logging.KeyguardLogger; import com.android.systemui.plugins.ClockAnimations; import com.android.systemui.plugins.ClockController; import com.android.systemui.statusbar.notification.AnimatableProperty; import com.android.systemui.statusbar.notification.AnimatableProperty; import com.android.systemui.statusbar.notification.PropertyAnimator; import com.android.systemui.statusbar.notification.PropertyAnimator; import com.android.systemui.statusbar.notification.stack.AnimationProperties; import com.android.systemui.statusbar.notification.stack.AnimationProperties; Loading Loading @@ -241,8 +242,9 @@ public class KeyguardStatusViewController extends ViewController<KeyguardStatusV } } } } /** Gets the animations for the current clock. */ /** Gets the current clock controller. */ public ClockAnimations getClockAnimations() { @Nullable return mKeyguardClockSwitchController.getClockAnimations(); public ClockController getClockController() { return mKeyguardClockSwitchController.getClock(); } } } }