Merge "Fix clock font weight animation to always match the latest doze state." into sc-dev

This commit is contained in:
Shan Huang
2021-06-30 01:58:04 +00:00
committed by Android (Google) Code Review
2 changed files with 10 additions and 4 deletions

View File

@@ -94,7 +94,9 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie
@Override @Override
public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) { public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) {
if (mKeyguardShowing && !mIsCharging && charging) { if (mKeyguardShowing && !mIsCharging && charging) {
mView.animateCharge(mIsDozing); mView.animateCharge(() -> {
return mStatusBarStateController.isDozing();
});
} }
mIsCharging = charging; mIsCharging = charging;
} }

View File

@@ -196,20 +196,20 @@ public class AnimatableClockView extends TextView {
null /* onAnimationEnd */); null /* onAnimationEnd */);
} }
void animateCharge(boolean isDozing) { void animateCharge(DozeStateGetter dozeStateGetter) {
if (mTextAnimator == null || mTextAnimator.isRunning()) { if (mTextAnimator == null || mTextAnimator.isRunning()) {
// Skip charge animation if dozing animation is already playing. // Skip charge animation if dozing animation is already playing.
return; return;
} }
Runnable startAnimPhase2 = () -> setTextStyle( Runnable startAnimPhase2 = () -> setTextStyle(
isDozing ? mDozingWeight : mLockScreenWeight/* weight */, dozeStateGetter.isDozing() ? mDozingWeight : mLockScreenWeight/* weight */,
-1, -1,
null, null,
true /* animate */, true /* animate */,
CHARGE_ANIM_DURATION_PHASE_1, CHARGE_ANIM_DURATION_PHASE_1,
0 /* delay */, 0 /* delay */,
null /* onAnimationEnd */); null /* onAnimationEnd */);
setTextStyle(isDozing ? mLockScreenWeight : mDozingWeight/* weight */, setTextStyle(dozeStateGetter.isDozing() ? mLockScreenWeight : mDozingWeight/* weight */,
-1, -1,
null, null,
true /* animate */, true /* animate */,
@@ -279,4 +279,8 @@ public class AnimatableClockView extends TextView {
context.getResources().getConfiguration().locale); context.getResources().getConfiguration().locale);
return dtpg.getBestPattern(skeleton); return dtpg.getBestPattern(skeleton);
} }
interface DozeStateGetter {
boolean isDozing();
}
} }