Merge "onFinished, update scrim based on lastState" into sc-dev

This commit is contained in:
Beverly Tai
2021-05-19 12:20:38 +00:00
committed by Android (Google) Code Review

View File

@@ -852,7 +852,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
setScrimAlpha(mScrimForBubble, mBubbleAlpha); setScrimAlpha(mScrimForBubble, mBubbleAlpha);
} }
// The animation could have all already finished, let's call onFinished just in case // The animation could have all already finished, let's call onFinished just in case
onFinished(); onFinished(mState);
dispatchScrimsVisible(); dispatchScrimsVisible();
} }
@@ -919,7 +919,6 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
Trace.traceCounter(Trace.TRACE_TAG_APP, getScrimName(scrimView) + "_tint", Trace.traceCounter(Trace.TRACE_TAG_APP, getScrimName(scrimView) + "_tint",
Color.alpha(tint)); Color.alpha(tint));
scrimView.setTint(tint); scrimView.setTint(tint);
scrimView.setViewAlpha(alpha); scrimView.setViewAlpha(alpha);
} else { } else {
@@ -950,12 +949,13 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
anim.setStartDelay(mAnimationDelay); anim.setStartDelay(mAnimationDelay);
anim.setDuration(mAnimationDuration); anim.setDuration(mAnimationDuration);
anim.addListener(new AnimatorListenerAdapter() { anim.addListener(new AnimatorListenerAdapter() {
private Callback lastCallback = mCallback; private final ScrimState mLastState = mState;
private final Callback mLastCallback = mCallback;
@Override @Override
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
scrim.setTag(TAG_KEY_ANIM, null); scrim.setTag(TAG_KEY_ANIM, null);
onFinished(lastCallback); onFinished(mLastCallback, mLastState);
dispatchScrimsVisible(); dispatchScrimsVisible();
} }
@@ -1009,11 +1009,14 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
return true; return true;
} }
private void onFinished() { /**
onFinished(mCallback); * @param state that finished
*/
private void onFinished(ScrimState state) {
onFinished(mCallback, state);
} }
private void onFinished(Callback callback) { private void onFinished(Callback callback, ScrimState state) {
if (mPendingFrameCallback != null) { if (mPendingFrameCallback != null) {
// No animations can finish while we're waiting on the blanking to finish // No animations can finish while we're waiting on the blanking to finish
return; return;
@@ -1045,7 +1048,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
// When unlocking with fingerprint, we'll fade the scrims from black to transparent. // When unlocking with fingerprint, we'll fade the scrims from black to transparent.
// At the end of the animation we need to remove the tint. // At the end of the animation we need to remove the tint.
if (mState == ScrimState.UNLOCKED) { if (state == ScrimState.UNLOCKED) {
mInFrontTint = Color.TRANSPARENT; mInFrontTint = Color.TRANSPARENT;
mBehindTint = mState.getBehindTint(); mBehindTint = mState.getBehindTint();
mNotificationsTint = mState.getNotifTint(); mNotificationsTint = mState.getNotifTint();