Merge "Forward fix/revert of clock detached state on keyguard visibility" into sc-dev am: f369b89e37 am: 55f1855434

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14669018

Change-Id: Id4a0f0603cde19c17e0d4baba385645fefc36f2b
This commit is contained in:
Beverly Tai
2021-05-24 12:31:06 +00:00
committed by Automerger Merge Worker

View File

@@ -54,8 +54,8 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie
private boolean mIsDozing; private boolean mIsDozing;
private boolean mIsCharging; private boolean mIsCharging;
private float mDozeAmount; private float mDozeAmount;
boolean mKeyguardShowing;
private Locale mLocale; private Locale mLocale;
private boolean mAttached; // if keyguard isn't showing, mAttached = false
private final NumberFormat mBurmeseNf = NumberFormat.getInstance(Locale.forLanguageTag("my")); private final NumberFormat mBurmeseNf = NumberFormat.getInstance(Locale.forLanguageTag("my"));
private final String mBurmeseNumerals; private final String mBurmeseNumerals;
@@ -85,11 +85,15 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie
R.dimen.keyguard_clock_line_spacing_scale); R.dimen.keyguard_clock_line_spacing_scale);
} }
private void reset() {
mView.animateDoze(mIsDozing, false);
}
private final BatteryController.BatteryStateChangeCallback mBatteryCallback = private final BatteryController.BatteryStateChangeCallback mBatteryCallback =
new BatteryController.BatteryStateChangeCallback() { new BatteryController.BatteryStateChangeCallback() {
@Override @Override
public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) { public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) {
if (!mIsCharging && charging) { if (mKeyguardShowing && !mIsCharging && charging) {
mView.animateCharge(mIsDozing); mView.animateCharge(mIsDozing);
} }
mIsCharging = charging; mIsCharging = charging;
@@ -103,21 +107,6 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie
} }
}; };
private final KeyguardUpdateMonitorCallback mKeyguardPersistentCallback =
new KeyguardUpdateMonitorCallback() {
@Override
public void onKeyguardVisibilityChanged(boolean showing) {
// call attached/detached methods on visibility changes. benefits include:
// - no animations when keyguard/clock view aren't visible
// - resets state when keyguard is visible again (ie: font weight)
if (showing) {
onViewAttached();
} else {
onViewDetached();
}
}
};
private final KeyguardUpdateMonitorCallback mKeyguardUpdateMonitorCallback = private final KeyguardUpdateMonitorCallback mKeyguardUpdateMonitorCallback =
new KeyguardUpdateMonitorCallback() { new KeyguardUpdateMonitorCallback() {
@Override @Override
@@ -128,44 +117,41 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie
mView.animateDisappear(); mView.animateDisappear();
} }
} }
@Override
public void onKeyguardVisibilityChanged(boolean showing) {
mKeyguardShowing = showing;
if (!mKeyguardShowing) {
// reset state (ie: after animateDisappear)
reset();
}
}
}; };
@Override @Override
protected void onViewAttached() { protected void onViewAttached() {
if (mAttached) {
return;
}
mAttached = true;
updateLocale(); updateLocale();
mBroadcastDispatcher.registerReceiver(mLocaleBroadcastReceiver, mBroadcastDispatcher.registerReceiver(mLocaleBroadcastReceiver,
new IntentFilter(Intent.ACTION_LOCALE_CHANGED)); new IntentFilter(Intent.ACTION_LOCALE_CHANGED));
mStatusBarStateController.addCallback(mStatusBarStateListener); mStatusBarStateController.addCallback(mStatusBarStateListener);
mIsDozing = mStatusBarStateController.isDozing(); mIsDozing = mStatusBarStateController.isDozing();
mDozeAmount = mStatusBarStateController.getDozeAmount(); mDozeAmount = mStatusBarStateController.getDozeAmount();
mBatteryController.addCallback(mBatteryCallback); mBatteryController.addCallback(mBatteryCallback);
mKeyguardUpdateMonitor.registerCallback(mKeyguardUpdateMonitorCallback); mKeyguardUpdateMonitor.registerCallback(mKeyguardUpdateMonitorCallback);
mKeyguardShowing = true;
mKeyguardUpdateMonitor.removeCallback(mKeyguardPersistentCallback);
mKeyguardUpdateMonitor.registerCallback(mKeyguardPersistentCallback);
refreshTime(); refreshTime();
initColors(); initColors();
mView.animateDoze(mIsDozing, false);
} }
@Override @Override
protected void onViewDetached() { protected void onViewDetached() {
if (!mAttached) {
return;
}
mAttached = false;
mBroadcastDispatcher.unregisterReceiver(mLocaleBroadcastReceiver); mBroadcastDispatcher.unregisterReceiver(mLocaleBroadcastReceiver);
mStatusBarStateController.removeCallback(mStatusBarStateListener); mStatusBarStateController.removeCallback(mStatusBarStateListener);
mKeyguardUpdateMonitor.removeCallback(mKeyguardUpdateMonitorCallback); mKeyguardUpdateMonitor.removeCallback(mKeyguardUpdateMonitorCallback);
mBatteryController.removeCallback(mBatteryCallback); mBatteryController.removeCallback(mBatteryCallback);
if (!mView.isAttachedToWindow()) {
mKeyguardUpdateMonitor.removeCallback(mKeyguardPersistentCallback);
}
} }
/** Animate the clock appearance */ /** Animate the clock appearance */