From 3635082c958a75d66a4f5678227b995fdce031ea Mon Sep 17 00:00:00 2001 From: Florence Yang Date: Wed, 23 Nov 2022 00:43:47 +0000 Subject: [PATCH] Color Change Animation for AnimatableClockView Creating a simple color fade animation for when theme or region sampling changes the color of the clock. This replaces the use of animateAppearOnLockscreen() for those cases by creating a specific animation that only deals with color. Fixes: 259282866 Test: manual Change-Id: I279b5e01025a0f7bf5815599ea786a1ab68c06ef --- .../shared/clocks/AnimatableClockView.kt | 24 +++++++++++++++++++ .../shared/clocks/DefaultClockController.kt | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/AnimatableClockView.kt b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/AnimatableClockView.kt index 22944b8fba89b..462b90a10aee9 100644 --- a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/AnimatableClockView.kt +++ b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/AnimatableClockView.kt @@ -237,6 +237,28 @@ class AnimatableClockView @JvmOverloads constructor( this.lockScreenColor = lockScreenColor } + fun animateColorChange() { + logBuffer?.log(tag, DEBUG, "animateColorChange") + setTextStyle( + weight = lockScreenWeight, + textSize = -1f, + color = null, /* using current color */ + animate = false, + duration = 0, + delay = 0, + onAnimationEnd = null + ) + setTextStyle( + weight = lockScreenWeight, + textSize = -1f, + color = lockScreenColor, + animate = true, + duration = COLOR_ANIM_DURATION, + delay = 0, + onAnimationEnd = null + ) + } + fun animateAppearOnLockscreen() { logBuffer?.log(tag, DEBUG, "animateAppearOnLockscreen") setTextStyle( @@ -350,6 +372,7 @@ class AnimatableClockView @JvmOverloads constructor( * * By passing -1 to weight, the view preserves its current weight. * By passing -1 to textSize, the view preserves its current text size. + * By passing null to color, the view preserves its current color. * * @param weight text weight. * @param textSize font size. @@ -611,6 +634,7 @@ class AnimatableClockView @JvmOverloads constructor( private const val APPEAR_ANIM_DURATION: Long = 350 private const val CHARGE_ANIM_DURATION_PHASE_0: Long = 500 private const val CHARGE_ANIM_DURATION_PHASE_1: Long = 1000 + private const val COLOR_ANIM_DURATION: Long = 400 // Constants for the animation private val MOVE_INTERPOLATOR = Interpolators.EMPHASIZED diff --git a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockController.kt b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockController.kt index 869884474ffe3..e138ef8a1ea89 100644 --- a/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockController.kt +++ b/packages/SystemUI/customization/src/com/android/systemui/shared/clocks/DefaultClockController.kt @@ -143,7 +143,7 @@ class DefaultClockController( currentColor = color view.setColors(DOZE_COLOR, color) if (!animations.dozeState.isActive) { - view.animateAppearOnLockscreen() + view.animateColorChange() } } }