From e0362426ebc1d1e10d32616ed88e9227718a5ba8 Mon Sep 17 00:00:00 2001 From: Shan Huang Date: Thu, 8 Apr 2021 12:43:13 +0800 Subject: [PATCH] Animate LockScreen and AOD clock text for charging events Test: Manual Bug: 182719493 Change-Id: I57f7cd834a08d8846a35cdf731611fc7a239b85a --- .../layout/keyguard_clock_switch.xml | 2 + .../SystemUI/res-keyguard/values/attrs.xml | 1 + .../keyguard/AnimatableClockController.java | 15 +++++- .../android/keyguard/AnimatableClockView.java | 47 ++++++++++++++++--- .../KeyguardClockSwitchController.java | 12 +++-- .../src/com/android/keyguard/TextAnimator.kt | 25 +++++++++- .../KeyguardClockSwitchControllerTest.java | 6 ++- .../com/android/keyguard/TextAnimatorTest.kt | 33 +++++++++++++ 8 files changed, 128 insertions(+), 13 deletions(-) diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml b/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml index e025e2748fb26..00c27bf5f10d7 100644 --- a/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml +++ b/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml @@ -42,6 +42,7 @@ android:typeface="monospace" android:elegantTextHeight="false" android:singleLine="true" + chargeAnimationDelay="350" dozeWeight="200" lockScreenWeight="400" /> @@ -62,6 +63,7 @@ android:fontFamily="@font/clock" android:typeface="monospace" android:elegantTextHeight="false" + chargeAnimationDelay="200" dozeWeight="200" lockScreenWeight="400" /> diff --git a/packages/SystemUI/res-keyguard/values/attrs.xml b/packages/SystemUI/res-keyguard/values/attrs.xml index eb7a1f73fbc92..25be37adac5b7 100644 --- a/packages/SystemUI/res-keyguard/values/attrs.xml +++ b/packages/SystemUI/res-keyguard/values/attrs.xml @@ -45,5 +45,6 @@ + diff --git a/packages/SystemUI/src/com/android/keyguard/AnimatableClockController.java b/packages/SystemUI/src/com/android/keyguard/AnimatableClockController.java index ab219f36bab3a..60b677a4e5618 100644 --- a/packages/SystemUI/src/com/android/keyguard/AnimatableClockController.java +++ b/packages/SystemUI/src/com/android/keyguard/AnimatableClockController.java @@ -27,6 +27,7 @@ import com.android.settingslib.Utils; import com.android.systemui.R; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.plugins.statusbar.StatusBarStateController; +import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.util.ViewController; import java.util.Locale; @@ -45,6 +46,7 @@ public class AnimatableClockController extends ViewController setTextStyle( + isDozing ? mDozingWeight : mLockScreenWeight/* weight */, + -1, + null, + true /* animate */, + CHARGE_ANIM_DURATION_PHASE_1, + 0 /* delay */, + null /* onAnimationEnd */); + setTextStyle(isDozing ? mLockScreenWeight : mDozingWeight/* weight */, + -1, + null, + true /* animate */, + CHARGE_ANIM_DURATION_PHASE_0, + mChargeAnimationDelay, + startAnimPhase2); + } + void animateDoze(boolean isDozing, boolean animate) { setTextStyle(isDozing ? mDozingWeight : mLockScreenWeight /* weight */, -1, isDozing ? mDozingColor : mLockScreenColor, - animate); + animate, + DOZE_ANIM_DURATION, + 0 /* delay */, + null /* onAnimationEnd */); } /** @@ -170,15 +200,20 @@ public class AnimatableClockView extends TextView { private void setTextStyle( @IntRange(from = 0, to = 1000) int weight, @FloatRange(from = 0) float textSize, - int color, - boolean animate) { + Integer color, + boolean animate, + long duration, + long delay, + Runnable onAnimationEnd) { if (mTextAnimator != null) { - mTextAnimator.setTextStyle(weight, textSize, color, animate, ANIM_DURATION, null); + mTextAnimator.setTextStyle(weight, textSize, color, animate, duration, null, + delay, onAnimationEnd); } else { // when the text animator is set, update its start values mOnTextAnimatorInitialized = () -> mTextAnimator.setTextStyle( - weight, textSize, color, false, ANIM_DURATION, null); + weight, textSize, color, false, duration, null, + delay, onAnimationEnd); } } diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java index 874b4d9f95e90..032ed7da0a46b 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java @@ -49,6 +49,7 @@ import com.android.systemui.statusbar.notification.PropertyAnimator; import com.android.systemui.statusbar.notification.stack.AnimationProperties; import com.android.systemui.statusbar.phone.NotificationIconAreaController; import com.android.systemui.statusbar.phone.NotificationIconContainer; +import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.util.ViewController; import java.util.Locale; @@ -70,6 +71,7 @@ public class KeyguardClockSwitchController extends ViewController