Track overview animation as atomic animation.

This fixed the bug where user can't double swipe up to All Apps. This is
needed before All Apps spring can be enabled, because the spring makes it
easier to get into this state.

To repo bug:
1. Hold shelf up so that overview starts to peek
2. Release
3. Before overview peek animation finishes, swipe up again to go to All Apps.

Bug: 79878197
Change-Id: I8c87b742d7da31d23be4decb72b45e9f21788af9
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/FlingAndHoldTouchController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/FlingAndHoldTouchController.java
index ff1b5f6..b80830a 100644
--- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/FlingAndHoldTouchController.java
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/FlingAndHoldTouchController.java
@@ -43,6 +43,7 @@
 import com.android.launcher3.Launcher;
 import com.android.launcher3.LauncherAppTransitionManagerImpl;
 import com.android.launcher3.LauncherState;
+import com.android.launcher3.anim.AnimationSuccessListener;
 import com.android.launcher3.anim.AnimatorSetBuilder;
 import com.android.launcher3.anim.Interpolators;
 import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
@@ -87,6 +88,10 @@
         if (handlingOverviewAnim()) {
             mMotionPauseDetector.setOnMotionPauseListener(this::onMotionPauseChanged);
         }
+
+        if (mAtomicAnim != null) {
+            mAtomicAnim.cancel();
+        }
     }
 
     protected void onMotionPauseChanged(boolean isPaused) {
@@ -193,13 +198,27 @@
 
         Animator overviewAnim = mLauncher.getAppTransitionManager().createStateElementAnimation(
                 INDEX_PAUSE_TO_OVERVIEW_ANIM);
-        overviewAnim.addListener(new AnimatorListenerAdapter() {
+        mAtomicAnim = new AnimatorSet();
+        mAtomicAnim.addListener(new AnimationSuccessListener() {
             @Override
-            public void onAnimationEnd(Animator animation) {
+            public void onAnimationSuccess(Animator animator) {
                 onSwipeInteractionCompleted(OVERVIEW, Touch.SWIPE);
             }
+
+            @Override
+            public void onAnimationEnd(Animator animation) {
+                super.onAnimationEnd(animation);
+                if (mCancelled) {
+                    mPeekAnim = mLauncher.getStateManager().createAtomicAnimation(mFromState,
+                            mToState, new AnimatorSetBuilder(), ATOMIC_OVERVIEW_PEEK_COMPONENT,
+                            PEEK_OUT_ANIM_DURATION);
+                    mPeekAnim.start();
+                }
+                mAtomicAnim = null;
+            }
         });
-        overviewAnim.start();
+        mAtomicAnim.play(overviewAnim);
+        mAtomicAnim.start();
     }
 
     @Override