diff options
author | 2019-05-16 11:14:43 -0400 | |
---|---|---|
committer | 2019-05-16 11:14:43 -0400 | |
commit | b66e982fa7b4f8ce1c47c414195d1bdd93c8bcb0 (patch) | |
tree | c16fd233f3eaf85ac61d1f3101428c153e1af474 | |
parent | 3bd719b534b023ff34d46e156df633f2a4de2acc (diff) |
End transitions before starting new transition.
This ensures that the new transition starts from a good state so that
start-end state are computed corretly. Otherwise, it is possible that
the new animation starts from a transient state that doesn't compute
correct start and end states.
Some other cleanup:
- TransitionListener that sets the regular digital clock to GONE is
added before starting the transition to eliminate a race condition.
- Setting the view to the beginning visibility is performed in
AnimatorListener#onAnimationStart.
Bug: 132629519
Test: manual - flick to advance tracks while listening to YT music. It
is necessary to flick during the transition from lock to AOD to
reproduce the issue.
Change-Id: Id9d9732028a1693389f65dbb2f5c38ea60433bc6
-rw-r--r-- | packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java index d0b2c58e8021..0bb9e744f2b6 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java @@ -3,6 +3,7 @@ package com.android.keyguard; import static com.android.systemui.util.InjectionInflationController.VIEW_CONTEXT; import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; import android.app.WallpaperManager; import android.content.Context; @@ -412,15 +413,10 @@ public class KeyguardClockSwitch extends RelativeLayout { mClockTransition.setScale(smallFontSize / bigFontSize); mBoldClockTransition.setScale(bigFontSize / smallFontSize); - TransitionManager.beginDelayedTransition((ViewGroup) mClockView.getParent(), mTransition); - mClockView.setVisibility(hasHeader ? View.INVISIBLE : View.VISIBLE); - mClockViewBold.setVisibility(hasHeader ? View.VISIBLE : View.INVISIBLE); - int paddingBottom = mContext.getResources().getDimensionPixelSize(hasHeader - ? R.dimen.widget_vertical_padding_clock : R.dimen.title_clock_padding); - mClockView.setPadding(mClockView.getPaddingLeft(), mClockView.getPaddingTop(), - mClockView.getPaddingRight(), paddingBottom); - mClockViewBold.setPadding(mClockViewBold.getPaddingLeft(), mClockViewBold.getPaddingTop(), - mClockViewBold.getPaddingRight(), paddingBottom); + // End any current transitions before starting a new transition so that the new transition + // starts from a good state instead of a potentially bad intermediate state arrived at + // during a transition animation. + TransitionManager.endTransitions((ViewGroup) mClockView.getParent()); if (hasHeader) { // After the transition, make the default clock GONE so that it doesn't make the @@ -439,6 +435,16 @@ public class KeyguardClockSwitch extends RelativeLayout { } }); } + + TransitionManager.beginDelayedTransition((ViewGroup) mClockView.getParent(), mTransition); + mClockView.setVisibility(hasHeader ? View.INVISIBLE : View.VISIBLE); + mClockViewBold.setVisibility(hasHeader ? View.VISIBLE : View.INVISIBLE); + int paddingBottom = mContext.getResources().getDimensionPixelSize(hasHeader + ? R.dimen.widget_vertical_padding_clock : R.dimen.title_clock_padding); + mClockView.setPadding(mClockView.getPaddingLeft(), mClockView.getPaddingTop(), + mClockView.getPaddingRight(), paddingBottom); + mClockViewBold.setPadding(mClockViewBold.getPaddingLeft(), mClockViewBold.getPaddingTop(), + mClockViewBold.getPaddingRight(), paddingBottom); } @VisibleForTesting(otherwise = VisibleForTesting.NONE) @@ -553,7 +559,6 @@ public class KeyguardClockSwitch extends RelativeLayout { private Animator createAnimator(View view, float cutoff, int startVisibility, int endVisibility, float startScale, float endScale) { view.setPivotY(view.getHeight() - view.getPaddingBottom()); - view.setVisibility(startVisibility); ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f); animator.addUpdateListener(animation -> { final float fraction = animation.getAnimatedFraction(); @@ -564,6 +569,14 @@ public class KeyguardClockSwitch extends RelativeLayout { view.setScaleX(scale); view.setScaleY(scale); }); + animator.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationStart(Animator animation) { + super.onAnimationStart(animation); + view.setVisibility(startVisibility); + animation.removeListener(this); + } + }); addListener(new TransitionListenerAdapter() { @Override public void onTransitionEnd(Transition transition) { |