From 9f7e4342447c5de75ba1e483aab851788cf2c4a3 Mon Sep 17 00:00:00 2001 From: Andy Wickham Date: Sat, 4 Apr 2020 00:25:49 +0000 Subject: [PATCH] Fixes issue where back tutorial animation didn't always appear. Specifically, when switching from right to left edge, the animation disappeared. This change forces the animation to restart whenever you switch to another tutorial. Bug: 148542211 Change-Id: Ie74c636a4afd1018c7c8e6998a1e7a176bf8099e (cherry picked from commit e725b6fe56f4b4acb53188803564adea76757bfe) --- .../BackGestureTutorialEngagedController.java | 2 +- .../BackGestureTutorialHandAnimation.java | 27 +++++-------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialEngagedController.java b/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialEngagedController.java index c9ee1e2006..297c287615 100644 --- a/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialEngagedController.java +++ b/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialEngagedController.java @@ -35,7 +35,7 @@ final class BackGestureTutorialEngagedController extends BackGestureTutorialCont @Override void transitToController() { super.transitToController(); - mHandCoachingAnimation.maybeStartLoopedAnimation(mTutorialTypeInfo.get().getTutorialType()); + mHandCoachingAnimation.startLoopedAnimation(mTutorialTypeInfo.get().getTutorialType()); } @Override diff --git a/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialHandAnimation.java b/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialHandAnimation.java index d03811de55..d7c10b0b9c 100644 --- a/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialHandAnimation.java +++ b/quickstep/src/com/android/quickstep/interaction/BackGestureTutorialHandAnimation.java @@ -38,8 +38,6 @@ final class BackGestureTutorialHandAnimation { private final ImageView mHandCoachingView; private final AnimatedVectorDrawable mGestureAnimation; - private boolean mIsAnimationPlayed = false; - BackGestureTutorialHandAnimation(Context context, View rootView) { mHandCoachingView = rootView.findViewById( R.id.back_gesture_tutorial_fragment_hand_coaching); @@ -47,20 +45,15 @@ final class BackGestureTutorialHandAnimation { R.drawable.back_gesture); } - boolean isRunning() { - return mGestureAnimation.isRunning(); - } - /** - * Starts animation if the playground is launched for the first time. + * [Re]starts animation for the given tutorial. */ - void maybeStartLoopedAnimation(TutorialType tutorialType) { - if (isRunning() || mIsAnimationPlayed) { - return; + void startLoopedAnimation(TutorialType tutorialType) { + if (mGestureAnimation.isRunning()) { + stop(); } - mIsAnimationPlayed = true; - clearAnimationCallbacks(); + mGestureAnimation.clearAnimationCallbacks(); mGestureAnimation.registerAnimationCallback( new Animatable2.AnimationCallback() { @Override @@ -78,17 +71,11 @@ final class BackGestureTutorialHandAnimation { float rotationY = tutorialType == TutorialType.LEFT_EDGE_BACK_NAVIGATION ? 180f : 0f; mHandCoachingView.setRotationY(rotationY); mHandCoachingView.setImageDrawable(mGestureAnimation); - mHandCoachingView.postDelayed(() -> mGestureAnimation.start(), - ANIMATION_START_DELAY.toMillis()); - } - - private void clearAnimationCallbacks() { - mGestureAnimation.clearAnimationCallbacks(); + mHandCoachingView.postDelayed(mGestureAnimation::start, ANIMATION_START_DELAY.toMillis()); } void stop() { - mIsAnimationPlayed = false; - clearAnimationCallbacks(); + mGestureAnimation.clearAnimationCallbacks(); mGestureAnimation.stop(); } }