Loading packages/SystemUI/customization/src/com/android/systemui/shared/clocks/AnimatableClockView.kt +11 −22 Original line number Original line Diff line number Diff line Loading @@ -97,6 +97,8 @@ class AnimatableClockView @JvmOverloads constructor( @VisibleForTesting var textAnimatorFactory: (Layout, () -> Unit) -> TextAnimator = @VisibleForTesting var textAnimatorFactory: (Layout, () -> Unit) -> TextAnimator = { layout, invalidateCb -> { layout, invalidateCb -> TextAnimator(layout, NUM_CLOCK_FONT_ANIMATION_STEPS, invalidateCb) } TextAnimator(layout, NUM_CLOCK_FONT_ANIMATION_STEPS, invalidateCb) } // Used by screenshot tests to provide stability @VisibleForTesting var isAnimationEnabled: Boolean = true @VisibleForTesting var isAnimationEnabled: Boolean = true @VisibleForTesting var timeOverrideInMillis: Long? = null @VisibleForTesting var timeOverrideInMillis: Long? = null Loading Loading @@ -242,15 +244,8 @@ class AnimatableClockView @JvmOverloads constructor( } } logger.d({ "onDraw($str1)"}) { str1 = text.toString() } logger.d({ "onDraw($str1)"}) { str1 = text.toString() } // Use textAnimator to render text if animation is enabled. // Otherwise default to using standard draw functions. if (isAnimationEnabled) { // intentionally doesn't call super.onDraw here or else the text will be rendered twice // intentionally doesn't call super.onDraw here or else the text will be rendered twice textAnimator?.draw(canvas) textAnimator?.draw(canvas) } else { super.onDraw(canvas) } canvas.restore() canvas.restore() } } Loading Loading @@ -318,7 +313,7 @@ class AnimatableClockView @JvmOverloads constructor( weight = lockScreenWeight, weight = lockScreenWeight, textSize = -1f, textSize = -1f, color = lockScreenColor, color = lockScreenColor, animate = isAnimationEnabled, animate = true, duration = APPEAR_ANIM_DURATION, duration = APPEAR_ANIM_DURATION, interpolator = Interpolators.EMPHASIZED_DECELERATE, interpolator = Interpolators.EMPHASIZED_DECELERATE, delay = 0, delay = 0, Loading @@ -327,7 +322,7 @@ class AnimatableClockView @JvmOverloads constructor( } } fun animateFoldAppear(animate: Boolean = true) { fun animateFoldAppear(animate: Boolean = true) { if (isAnimationEnabled && textAnimator == null) { if (textAnimator == null) { return return } } logger.d("animateFoldAppear") logger.d("animateFoldAppear") Loading @@ -344,7 +339,7 @@ class AnimatableClockView @JvmOverloads constructor( weight = dozingWeightInternal, weight = dozingWeightInternal, textSize = -1f, textSize = -1f, color = dozingColor, color = dozingColor, animate = animate && isAnimationEnabled, animate = animate, interpolator = Interpolators.EMPHASIZED_DECELERATE, interpolator = Interpolators.EMPHASIZED_DECELERATE, duration = ANIMATION_DURATION_FOLD_TO_AOD.toLong(), duration = ANIMATION_DURATION_FOLD_TO_AOD.toLong(), delay = 0, delay = 0, Loading @@ -363,7 +358,7 @@ class AnimatableClockView @JvmOverloads constructor( weight = if (isDozing()) dozingWeight else lockScreenWeight, weight = if (isDozing()) dozingWeight else lockScreenWeight, textSize = -1f, textSize = -1f, color = null, color = null, animate = isAnimationEnabled, animate = true, duration = CHARGE_ANIM_DURATION_PHASE_1, duration = CHARGE_ANIM_DURATION_PHASE_1, delay = 0, delay = 0, onAnimationEnd = null onAnimationEnd = null Loading @@ -373,7 +368,7 @@ class AnimatableClockView @JvmOverloads constructor( weight = if (isDozing()) lockScreenWeight else dozingWeight, weight = if (isDozing()) lockScreenWeight else dozingWeight, textSize = -1f, textSize = -1f, color = null, color = null, animate = isAnimationEnabled, animate = true, duration = CHARGE_ANIM_DURATION_PHASE_0, duration = CHARGE_ANIM_DURATION_PHASE_0, delay = chargeAnimationDelay.toLong(), delay = chargeAnimationDelay.toLong(), onAnimationEnd = startAnimPhase2 onAnimationEnd = startAnimPhase2 Loading @@ -386,7 +381,7 @@ class AnimatableClockView @JvmOverloads constructor( weight = if (isDozing) dozingWeight else lockScreenWeight, weight = if (isDozing) dozingWeight else lockScreenWeight, textSize = -1f, textSize = -1f, color = if (isDozing) dozingColor else lockScreenColor, color = if (isDozing) dozingColor else lockScreenColor, animate = animate && isAnimationEnabled, animate = animate, duration = DOZE_ANIM_DURATION, duration = DOZE_ANIM_DURATION, delay = 0, delay = 0, onAnimationEnd = null onAnimationEnd = null Loading Loading @@ -445,9 +440,6 @@ class AnimatableClockView @JvmOverloads constructor( onAnimationEnd = onAnimationEnd onAnimationEnd = onAnimationEnd ) ) textAnimator?.glyphFilter = glyphFilter textAnimator?.glyphFilter = glyphFilter if (color != null && !isAnimationEnabled) { setTextColor(color) } } else { } else { // when the text animator is set, update its start values // when the text animator is set, update its start values onTextAnimatorInitialized = Runnable { onTextAnimatorInitialized = Runnable { Loading @@ -462,9 +454,6 @@ class AnimatableClockView @JvmOverloads constructor( onAnimationEnd = onAnimationEnd onAnimationEnd = onAnimationEnd ) ) textAnimator?.glyphFilter = glyphFilter textAnimator?.glyphFilter = glyphFilter if (color != null && !isAnimationEnabled) { setTextColor(color) } } } } } } } Loading @@ -482,7 +471,7 @@ class AnimatableClockView @JvmOverloads constructor( weight = weight, weight = weight, textSize = textSize, textSize = textSize, color = color, color = color, animate = animate && isAnimationEnabled, animate = animate, interpolator = null, interpolator = null, duration = duration, duration = duration, delay = delay, delay = delay, Loading Loading
packages/SystemUI/customization/src/com/android/systemui/shared/clocks/AnimatableClockView.kt +11 −22 Original line number Original line Diff line number Diff line Loading @@ -97,6 +97,8 @@ class AnimatableClockView @JvmOverloads constructor( @VisibleForTesting var textAnimatorFactory: (Layout, () -> Unit) -> TextAnimator = @VisibleForTesting var textAnimatorFactory: (Layout, () -> Unit) -> TextAnimator = { layout, invalidateCb -> { layout, invalidateCb -> TextAnimator(layout, NUM_CLOCK_FONT_ANIMATION_STEPS, invalidateCb) } TextAnimator(layout, NUM_CLOCK_FONT_ANIMATION_STEPS, invalidateCb) } // Used by screenshot tests to provide stability @VisibleForTesting var isAnimationEnabled: Boolean = true @VisibleForTesting var isAnimationEnabled: Boolean = true @VisibleForTesting var timeOverrideInMillis: Long? = null @VisibleForTesting var timeOverrideInMillis: Long? = null Loading Loading @@ -242,15 +244,8 @@ class AnimatableClockView @JvmOverloads constructor( } } logger.d({ "onDraw($str1)"}) { str1 = text.toString() } logger.d({ "onDraw($str1)"}) { str1 = text.toString() } // Use textAnimator to render text if animation is enabled. // Otherwise default to using standard draw functions. if (isAnimationEnabled) { // intentionally doesn't call super.onDraw here or else the text will be rendered twice // intentionally doesn't call super.onDraw here or else the text will be rendered twice textAnimator?.draw(canvas) textAnimator?.draw(canvas) } else { super.onDraw(canvas) } canvas.restore() canvas.restore() } } Loading Loading @@ -318,7 +313,7 @@ class AnimatableClockView @JvmOverloads constructor( weight = lockScreenWeight, weight = lockScreenWeight, textSize = -1f, textSize = -1f, color = lockScreenColor, color = lockScreenColor, animate = isAnimationEnabled, animate = true, duration = APPEAR_ANIM_DURATION, duration = APPEAR_ANIM_DURATION, interpolator = Interpolators.EMPHASIZED_DECELERATE, interpolator = Interpolators.EMPHASIZED_DECELERATE, delay = 0, delay = 0, Loading @@ -327,7 +322,7 @@ class AnimatableClockView @JvmOverloads constructor( } } fun animateFoldAppear(animate: Boolean = true) { fun animateFoldAppear(animate: Boolean = true) { if (isAnimationEnabled && textAnimator == null) { if (textAnimator == null) { return return } } logger.d("animateFoldAppear") logger.d("animateFoldAppear") Loading @@ -344,7 +339,7 @@ class AnimatableClockView @JvmOverloads constructor( weight = dozingWeightInternal, weight = dozingWeightInternal, textSize = -1f, textSize = -1f, color = dozingColor, color = dozingColor, animate = animate && isAnimationEnabled, animate = animate, interpolator = Interpolators.EMPHASIZED_DECELERATE, interpolator = Interpolators.EMPHASIZED_DECELERATE, duration = ANIMATION_DURATION_FOLD_TO_AOD.toLong(), duration = ANIMATION_DURATION_FOLD_TO_AOD.toLong(), delay = 0, delay = 0, Loading @@ -363,7 +358,7 @@ class AnimatableClockView @JvmOverloads constructor( weight = if (isDozing()) dozingWeight else lockScreenWeight, weight = if (isDozing()) dozingWeight else lockScreenWeight, textSize = -1f, textSize = -1f, color = null, color = null, animate = isAnimationEnabled, animate = true, duration = CHARGE_ANIM_DURATION_PHASE_1, duration = CHARGE_ANIM_DURATION_PHASE_1, delay = 0, delay = 0, onAnimationEnd = null onAnimationEnd = null Loading @@ -373,7 +368,7 @@ class AnimatableClockView @JvmOverloads constructor( weight = if (isDozing()) lockScreenWeight else dozingWeight, weight = if (isDozing()) lockScreenWeight else dozingWeight, textSize = -1f, textSize = -1f, color = null, color = null, animate = isAnimationEnabled, animate = true, duration = CHARGE_ANIM_DURATION_PHASE_0, duration = CHARGE_ANIM_DURATION_PHASE_0, delay = chargeAnimationDelay.toLong(), delay = chargeAnimationDelay.toLong(), onAnimationEnd = startAnimPhase2 onAnimationEnd = startAnimPhase2 Loading @@ -386,7 +381,7 @@ class AnimatableClockView @JvmOverloads constructor( weight = if (isDozing) dozingWeight else lockScreenWeight, weight = if (isDozing) dozingWeight else lockScreenWeight, textSize = -1f, textSize = -1f, color = if (isDozing) dozingColor else lockScreenColor, color = if (isDozing) dozingColor else lockScreenColor, animate = animate && isAnimationEnabled, animate = animate, duration = DOZE_ANIM_DURATION, duration = DOZE_ANIM_DURATION, delay = 0, delay = 0, onAnimationEnd = null onAnimationEnd = null Loading Loading @@ -445,9 +440,6 @@ class AnimatableClockView @JvmOverloads constructor( onAnimationEnd = onAnimationEnd onAnimationEnd = onAnimationEnd ) ) textAnimator?.glyphFilter = glyphFilter textAnimator?.glyphFilter = glyphFilter if (color != null && !isAnimationEnabled) { setTextColor(color) } } else { } else { // when the text animator is set, update its start values // when the text animator is set, update its start values onTextAnimatorInitialized = Runnable { onTextAnimatorInitialized = Runnable { Loading @@ -462,9 +454,6 @@ class AnimatableClockView @JvmOverloads constructor( onAnimationEnd = onAnimationEnd onAnimationEnd = onAnimationEnd ) ) textAnimator?.glyphFilter = glyphFilter textAnimator?.glyphFilter = glyphFilter if (color != null && !isAnimationEnabled) { setTextColor(color) } } } } } } } Loading @@ -482,7 +471,7 @@ class AnimatableClockView @JvmOverloads constructor( weight = weight, weight = weight, textSize = textSize, textSize = textSize, color = color, color = color, animate = animate && isAnimationEnabled, animate = animate, interpolator = null, interpolator = null, duration = duration, duration = duration, delay = delay, delay = delay, Loading