Updating bounce animation to move hotseat instead of all-apps

Bug: 193827513
Test: Manual
Change-Id: I86c0e9cb56ab3c6e8e978f574e564fe1e1a41c43
diff --git a/src/com/android/launcher3/allapps/DiscoveryBounce.java b/src/com/android/launcher3/allapps/DiscoveryBounce.java
index d8ef18e..be261f7 100644
--- a/src/com/android/launcher3/allapps/DiscoveryBounce.java
+++ b/src/com/android/launcher3/allapps/DiscoveryBounce.java
@@ -20,16 +20,17 @@
 
 import android.animation.Animator;
 import android.animation.AnimatorInflater;
-import android.animation.AnimatorListenerAdapter;
 import android.os.Handler;
 import android.os.UserManager;
 import android.view.MotionEvent;
+import android.view.View;
 
 import com.android.launcher3.AbstractFloatingView;
 import com.android.launcher3.Launcher;
 import com.android.launcher3.LauncherState;
 import com.android.launcher3.R;
 import com.android.launcher3.Utilities;
+import com.android.launcher3.anim.AnimatorListeners;
 import com.android.launcher3.statemanager.StateManager.StateListener;
 import com.android.launcher3.util.OnboardingPrefs;
 
@@ -53,21 +54,15 @@
         public void onStateTransitionComplete(LauncherState finalState) {}
     };
 
-    public DiscoveryBounce(Launcher launcher, float delta) {
+    public DiscoveryBounce(Launcher launcher) {
         super(launcher, null);
         mLauncher = launcher;
-        AllAppsTransitionController controller = mLauncher.getAllAppsController();
 
         mDiscoBounceAnimation =
                 AnimatorInflater.loadAnimator(launcher, R.animator.discovery_bounce);
-        mDiscoBounceAnimation.setTarget(new VerticalProgressWrapper(controller, delta));
-        mDiscoBounceAnimation.addListener(new AnimatorListenerAdapter() {
-            @Override
-            public void onAnimationEnd(Animator animation) {
-                handleClose(false);
-            }
-        });
-        mDiscoBounceAnimation.addListener(controller.getProgressAnimatorListener());
+        mDiscoBounceAnimation.setTarget(new VerticalProgressWrapper(
+                launcher.getHotseat(), mLauncher.getDragLayer().getHeight()));
+        mDiscoBounceAnimation.addListener(AnimatorListeners.forEndCallback(this::handleClose));
         launcher.getStateManager().addStateListener(mStateListener);
     }
 
@@ -104,9 +99,9 @@
         if (mIsOpen) {
             mIsOpen = false;
             mLauncher.getDragLayer().removeView(this);
-            // Reset the all-apps progress to what ever it was previously.
-            mLauncher.getAllAppsController().setProgress(mLauncher.getStateManager()
-                    .getState().getVerticalProgress(mLauncher));
+            // Reset the translation to what ever it was previously.
+            mLauncher.getHotseat().setTranslationY(mLauncher.getStateManager().getState()
+                    .getHotseatScaleAndTranslation(mLauncher).translationY);
             mLauncher.getStateManager().removeStateListener(mStateListener);
         }
     }
@@ -141,29 +136,28 @@
             return;
         }
         onboardingPrefs.incrementEventCount(OnboardingPrefs.HOME_BOUNCE_COUNT);
-
-        new DiscoveryBounce(launcher, 0).show();
+        new DiscoveryBounce(launcher).show();
     }
 
     /**
-     * A wrapper around {@link AllAppsTransitionController} allowing a fixed shift in the value.
+     * A wrapper around hotseat animator allowing a fixed shift in the value.
      */
     public static class VerticalProgressWrapper {
 
-        private final float mDelta;
-        private final AllAppsTransitionController mController;
+        private final View mView;
+        private final float mLimit;
 
-        private VerticalProgressWrapper(AllAppsTransitionController controller, float delta) {
-            mController = controller;
-            mDelta = delta;
+        private VerticalProgressWrapper(View view, float limit) {
+            mView = view;
+            mLimit = limit;
         }
 
         public float getProgress() {
-            return mController.getProgress() + mDelta;
+            return 1 + mView.getTranslationY() / mLimit;
         }
 
         public void setProgress(float progress) {
-            mController.setProgress(progress - mDelta);
+            mView.setTranslationY(mLimit * (progress - 1));
         }
     }
 }