Removing support for long swipe to all-apps

Change-Id: I29e6b2d283126e584de6e49b6f658c153d582d6b
diff --git a/go/quickstep/src/com/android/quickstep/LauncherActivityControllerHelper.java b/go/quickstep/src/com/android/quickstep/LauncherActivityControllerHelper.java
index ac559ba..8f31e9f 100644
--- a/go/quickstep/src/com/android/quickstep/LauncherActivityControllerHelper.java
+++ b/go/quickstep/src/com/android/quickstep/LauncherActivityControllerHelper.java
@@ -44,18 +44,6 @@
 public final class LauncherActivityControllerHelper implements ActivityControlHelper<Launcher>{
 
     @Override
-    public LayoutListener createLayoutListener(Launcher activity) {
-        // Go does not have draggable task snapshots.
-        return null;
-    }
-
-
-    @Override
-    public void executeOnWindowAvailable(Launcher activity, Runnable action) {
-        // Go does not support live tiles.
-    }
-
-    @Override
     public void onTransitionCancelled(Launcher activity, boolean activityVisible) {
         LauncherState startState = activity.getStateManager().getRestState();
         activity.getStateManager().goToState(startState, activityVisible);
@@ -148,23 +136,11 @@
     }
 
     @Override
-    public boolean supportsLongSwipe(Launcher activity) {
-        // Go does not support long swipe from the app.
-        return false;
-    }
-
-    @Override
     public AlphaProperty getAlphaProperty(Launcher activity) {
         return activity.getDragLayer().getAlphaProperty(DragLayer.ALPHA_INDEX_SWIPE_UP);
     }
 
     @Override
-    public LongSwipeHelper getLongSwipeController(Launcher activity, int runningTaskId) {
-        // Go does not support long swipe from the app.
-        return null;
-    }
-
-    @Override
     public int getContainerType() {
         final Launcher launcher = getVisibleLauncher();
         return launcher != null ? launcher.getStateManager().getState().containerType
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
index 94237f0..ffd3b4b 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
@@ -36,7 +36,6 @@
 import android.graphics.Region;
 import android.view.MotionEvent;
 import android.view.View;
-import android.view.ViewOverlay;
 import android.view.animation.Interpolator;
 
 import com.android.launcher3.DeviceProfile;
@@ -44,8 +43,6 @@
 import com.android.launcher3.LauncherAppState;
 import com.android.launcher3.LauncherInitListener;
 import com.android.launcher3.LauncherState;
-import com.android.launcher3.R;
-import com.android.launcher3.TestProtocol;
 import com.android.launcher3.allapps.DiscoveryBounce;
 import com.android.launcher3.anim.AnimatorPlaybackController;
 import com.android.launcher3.anim.SpringObjectAnimator;
@@ -376,19 +373,6 @@
     }
 
     @Override
-    public boolean supportsLongSwipe(Launcher activity) {
-        return !activity.getDeviceProfile().isVerticalBarLayout();
-    }
-
-    @Override
-    public LongSwipeHelper getLongSwipeController(Launcher activity, int runningTaskId) {
-        if (activity.getDeviceProfile().isVerticalBarLayout()) {
-            return null;
-        }
-        return new LongSwipeHelper(activity, runningTaskId);
-    }
-
-    @Override
     public AlphaProperty getAlphaProperty(Launcher activity) {
         return activity.getDragLayer().getAlphaProperty(DragLayer.ALPHA_INDEX_SWIPE_UP);
     }
diff --git a/quickstep/src/com/android/quickstep/ActivityControlHelper.java b/quickstep/src/com/android/quickstep/ActivityControlHelper.java
index 4c2c279..eccef04 100644
--- a/quickstep/src/com/android/quickstep/ActivityControlHelper.java
+++ b/quickstep/src/com/android/quickstep/ActivityControlHelper.java
@@ -85,16 +85,9 @@
         return true;
     }
 
-    boolean supportsLongSwipe(T activity);
-
     AlphaProperty getAlphaProperty(T activity);
 
     /**
-     * Must return a non-null controller is supportsLongSwipe was true.
-     */
-    LongSwipeHelper getLongSwipeController(T activity, int runningTaskId);
-
-    /**
      * Used for containerType in {@link com.android.launcher3.logging.UserEventDispatcher}
      */
     int getContainerType();
diff --git a/quickstep/src/com/android/quickstep/FallbackActivityControllerHelper.java b/quickstep/src/com/android/quickstep/FallbackActivityControllerHelper.java
index 719795b..a84d230 100644
--- a/quickstep/src/com/android/quickstep/FallbackActivityControllerHelper.java
+++ b/quickstep/src/com/android/quickstep/FallbackActivityControllerHelper.java
@@ -186,16 +186,6 @@
     }
 
     @Override
-    public boolean supportsLongSwipe(RecentsActivity activity) {
-        return false;
-    }
-
-    @Override
-    public LongSwipeHelper getLongSwipeController(RecentsActivity activity, int runningTaskId) {
-        return null;
-    }
-
-    @Override
     public AlphaProperty getAlphaProperty(RecentsActivity activity) {
         return activity.getDragLayer().getAlphaProperty(0);
     }
diff --git a/quickstep/src/com/android/quickstep/LongSwipeHelper.java b/quickstep/src/com/android/quickstep/LongSwipeHelper.java
deleted file mode 100644
index ef56cb0..0000000
--- a/quickstep/src/com/android/quickstep/LongSwipeHelper.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.quickstep;
-
-import static com.android.launcher3.LauncherAnimUtils.MIN_PROGRESS_TO_ALL_APPS;
-import static com.android.launcher3.LauncherState.ALL_APPS;
-import static com.android.launcher3.LauncherState.OVERVIEW;
-import static com.android.launcher3.anim.Interpolators.DEACCEL;
-import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
-import static com.android.launcher3.config.FeatureFlags.QUICKSTEP_SPRINGS;
-import static com.android.quickstep.WindowTransformSwipeHandler.MAX_SWIPE_DURATION;
-import static com.android.quickstep.WindowTransformSwipeHandler.MIN_OVERSHOOT_DURATION;
-
-import android.animation.ValueAnimator;
-import android.view.animation.Interpolator;
-
-import com.android.launcher3.Launcher;
-import com.android.launcher3.LauncherStateManager;
-import com.android.launcher3.R;
-import com.android.launcher3.Utilities;
-import com.android.launcher3.allapps.AllAppsTransitionController;
-import com.android.launcher3.allapps.DiscoveryBounce;
-import com.android.launcher3.anim.AnimatorPlaybackController;
-import com.android.launcher3.anim.AnimatorSetBuilder;
-import com.android.launcher3.anim.Interpolators;
-import com.android.launcher3.anim.Interpolators.OvershootParams;
-import com.android.launcher3.uioverrides.PortraitStatesTouchController;
-import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
-import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
-import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
-import com.android.launcher3.util.FlingBlockCheck;
-import com.android.quickstep.views.RecentsView;
-
-/**
- * Utility class to handle long swipe from an app.
- * This assumes the presence of Launcher activity as long swipe is not supported on the
- * fallback activity.
- */
-public class LongSwipeHelper {
-
-    private static final float SWIPE_DURATION_MULTIPLIER =
-            Math.min(1 / MIN_PROGRESS_TO_ALL_APPS, 1 / (1 - MIN_PROGRESS_TO_ALL_APPS));
-
-    private final Launcher mLauncher;
-    private final int mRunningTaskId;
-
-    private float mMaxSwipeDistance = 1;
-    private AnimatorPlaybackController mAnimator;
-    private FlingBlockCheck mFlingBlockCheck = new FlingBlockCheck();
-
-    LongSwipeHelper(Launcher launcher, int runningTaskId) {
-        mLauncher = launcher;
-        mRunningTaskId = runningTaskId;
-        init();
-    }
-
-    private void init() {
-        mFlingBlockCheck.blockFling();
-
-        // Init animations
-        AllAppsTransitionController controller = mLauncher.getAllAppsController();
-        // TODO: Scale it down so that we can reach all-apps in screen space
-        mMaxSwipeDistance = Math.max(1, controller.getProgress() * controller.getShiftRange());
-
-        AnimatorSetBuilder builder = PortraitStatesTouchController.getOverviewToAllAppsAnimation();
-        mAnimator = mLauncher.getStateManager().createAnimationToNewWorkspace(ALL_APPS, builder,
-                Math.round(2 * mMaxSwipeDistance), null, LauncherStateManager.ANIM_ALL);
-        mAnimator.dispatchOnStart();
-    }
-
-    public void onMove(float displacement) {
-        mAnimator.setPlayFraction(displacement / mMaxSwipeDistance);
-        mFlingBlockCheck.onEvent();
-    }
-
-    public void destroy() {
-        // TODO: We can probably also show the task view
-
-        mLauncher.getStateManager().goToState(OVERVIEW, false);
-    }
-
-    public void end(float velocity, boolean isFling, Runnable callback) {
-        float velocityPxPerMs = velocity / 1000;
-        long duration = MAX_SWIPE_DURATION;
-        Interpolator interpolator = DEACCEL;
-
-        final float currentFraction = mAnimator.getProgressFraction();
-        final boolean toAllApps;
-        float endProgress;
-
-        boolean blockedFling = isFling && mFlingBlockCheck.isBlocked();
-        if (blockedFling) {
-            isFling = false;
-        }
-
-        if (!isFling) {
-            toAllApps = currentFraction > MIN_PROGRESS_TO_ALL_APPS;
-            endProgress = toAllApps ? 1 : 0;
-
-            long expectedDuration = Math.abs(Math.round((endProgress - currentFraction)
-                    * MAX_SWIPE_DURATION * SWIPE_DURATION_MULTIPLIER));
-            duration = Math.min(MAX_SWIPE_DURATION, expectedDuration);
-
-            if (blockedFling && !toAllApps && !QUICKSTEP_SPRINGS.get()) {
-                Interpolators.OvershootParams overshoot = new OvershootParams(currentFraction,
-                        currentFraction, endProgress, velocityPxPerMs, (int) mMaxSwipeDistance);
-                duration = (overshoot.duration + duration);
-                duration = Utilities.boundToRange(duration, MIN_OVERSHOOT_DURATION,
-                        MAX_SWIPE_DURATION);
-                interpolator = overshoot.interpolator;
-                endProgress = overshoot.end;
-            }
-        } else {
-            toAllApps = velocity < 0;
-            endProgress = toAllApps ? 1 : 0;
-
-            float minFlingVelocity = mLauncher.getResources()
-                    .getDimension(R.dimen.quickstep_fling_min_velocity);
-            if (Math.abs(velocity) > minFlingVelocity && mMaxSwipeDistance > 0) {
-                float distanceToTravel = (endProgress - currentFraction) * mMaxSwipeDistance;
-
-                // we want the page's snap velocity to approximately match the velocity at
-                // which the user flings, so we scale the duration by a value near to the
-                // derivative of the scroll interpolator at zero, ie. 2.
-                long baseDuration = Math.round(Math.abs(distanceToTravel / velocityPxPerMs));
-                duration = Math.min(MAX_SWIPE_DURATION, 2 * baseDuration);
-            }
-        }
-
-        final boolean finalIsFling = isFling;
-        mAnimator.setEndAction(() -> onSwipeAnimationComplete(toAllApps, finalIsFling, callback));
-
-        ValueAnimator animator = mAnimator.getAnimationPlayer();
-        animator.setDuration(duration).setInterpolator(interpolator);
-        animator.setFloatValues(currentFraction, endProgress);
-
-        if (QUICKSTEP_SPRINGS.get()) {
-            mAnimator.dispatchOnStartWithVelocity(endProgress, velocityPxPerMs);
-        }
-        animator.start();
-    }
-
-    private void onSwipeAnimationComplete(boolean toAllApps, boolean isFling, Runnable callback) {
-        RecentsView rv = mLauncher.getOverviewPanel();
-        if (!toAllApps) {
-            rv.setIgnoreResetTask(mRunningTaskId);
-        }
-
-        mLauncher.getStateManager().goToState(toAllApps ? ALL_APPS : OVERVIEW, false);
-        if (!toAllApps) {
-            DiscoveryBounce.showForOverviewIfNeeded(mLauncher);
-            rv.animateUpRunningTaskIconScale();
-            rv.setSwipeDownShouldLaunchApp(true);
-        }
-
-        mLauncher.getUserEventDispatcher().logStateChangeAction(
-                isFling ? Touch.FLING : Touch.SWIPE, Direction.UP,
-                ContainerType.NAVBAR, ContainerType.APP,
-                toAllApps ? ContainerType.ALLAPPS : ContainerType.TASKSWITCHER,
-                0);
-
-        callback.run();
-
-        if (ENABLE_QUICKSTEP_LIVE_TILE.get() && toAllApps) {
-            rv.finishRecentsAnimation(true, null);
-        }
-    }
-}
diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
index f3f5daf..67dcc78 100644
--- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
+++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
@@ -75,7 +75,6 @@
 import com.android.launcher3.anim.AnimationSuccessListener;
 import com.android.launcher3.anim.AnimatorPlaybackController;
 import com.android.launcher3.anim.Interpolators;
-import com.android.launcher3.config.FeatureFlags;
 import com.android.launcher3.logging.UserEventDispatcher;
 import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
 import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
@@ -169,21 +168,10 @@
     private static final int STATE_ASSIST_DATA_RECEIVED =
             getFlagForIndex(18, "STATE_ASSIST_DATA_RECEIVED");
 
-    private static final int STATE_LONG_SWIPE_ACTIVE =
-            getFlagForIndex(19, "LONG_SWIPE_ACTIVE");
-
     private static final int LAUNCHER_UI_STATES =
             STATE_LAUNCHER_PRESENT | STATE_LAUNCHER_DRAWN | STATE_ACTIVITY_MULTIPLIER_COMPLETE
             | STATE_LAUNCHER_STARTED;
 
-    private static final int LONG_SWIPE_ENTER_STATE =
-            STATE_ACTIVITY_MULTIPLIER_COMPLETE | STATE_LAUNCHER_STARTED
-                    | STATE_APP_CONTROLLER_RECEIVED;
-
-    private static final int LONG_SWIPE_START_STATE =
-            STATE_ACTIVITY_MULTIPLIER_COMPLETE | STATE_LAUNCHER_STARTED
-                    | STATE_APP_CONTROLLER_RECEIVED | STATE_SCREENSHOT_CAPTURED;
-
     // For debugging, keep in sync with above states
 
     enum GestureEndTarget {
@@ -273,10 +261,6 @@
     private final long mTouchTimeMs;
     private long mLauncherFrameDrawnTime;
 
-    private boolean mLongSwipeMode = false;
-    private float mLongSwipeDisplacement = 0;
-    private LongSwipeHelper mLongSwipeController;
-
     private Bundle mAssistData;
 
     WindowTransformSwipeHandler(RunningTaskInfo runningTaskInfo, Context context,
@@ -363,10 +347,6 @@
                 | STATE_SCALED_CONTROLLER_LAST_TASK,
                 this::notifyTransitionCancelled);
 
-        mStateCallback.addCallback(LONG_SWIPE_ENTER_STATE, this::checkLongSwipeCanEnter);
-        mStateCallback.addCallback(LONG_SWIPE_START_STATE, this::checkLongSwipeCanStart);
-        mStateCallback.addChangeHandler(STATE_LONG_SWIPE_ACTIVE, this::onLongSwipeActiveChanged);
-
         if (!ENABLE_QUICKSTEP_LIVE_TILE.get()) {
             mStateCallback.addChangeHandler(STATE_APP_CONTROLLER_RECEIVED | STATE_LAUNCHER_PRESENT
                             | STATE_SCREENSHOT_VIEW_SHOWN | STATE_CAPTURE_SCREENSHOT,
@@ -433,7 +413,7 @@
         mRecentsView.setEnableFreeScroll(false);
 
         mRecentsView.setOnScrollChangeListener((v, scrollX, scrollY, oldScrollX, oldScrollY) -> {
-            if (!mLongSwipeMode && mGestureEndTarget != HOME) {
+            if (mGestureEndTarget != HOME) {
                 updateFinalShift();
             }
         });
@@ -572,16 +552,7 @@
         displacement = -displacement;
         if (displacement > mTransitionDragLength && mTransitionDragLength > 0) {
             mCurrentShift.updateValue(1);
-
-            if (!mLongSwipeMode && !FeatureFlags.SWIPE_HOME.get()) {
-                setStateOnUiThread(STATE_LONG_SWIPE_ACTIVE);
-            }
-            mLongSwipeDisplacement = displacement - mTransitionDragLength;
-            onLongSwipeDisplacementUpdated();
         } else {
-            if (mLongSwipeMode) {
-                mStateCallback.clearState(STATE_LONG_SWIPE_ACTIVE);
-            }
             float translation = Math.max(displacement, 0);
             float shift = mTransitionDragLength == 0 ? 0 : translation / mTransitionDragLength;
             mCurrentShift.updateValue(shift);
@@ -769,12 +740,7 @@
         setStateOnUiThread(STATE_GESTURE_COMPLETED);
 
         mLogAction = isFling ? Touch.FLING : Touch.SWIPE;
-
-        if (mLongSwipeMode) {
-            onLongSwipeGestureFinish(endVelocity, isFling, velocityX);
-        } else {
-            handleNormalGestureEnd(endVelocity, isFling, velocityX);
-        }
+        handleNormalGestureEnd(endVelocity, isFling, velocityX);
     }
 
     @UiThread
@@ -1136,14 +1102,6 @@
         mActivity.clearForceInvisibleFlag(INVISIBLE_BY_STATE_HANDLER);
     }
 
-    public void layoutListenerClosed() {
-        mRecentsView.setRunningTaskHidden(false);
-        if (mWasLauncherAlreadyVisible && mLauncherTransitionController != null) {
-            mLauncherTransitionController.setPlayFraction(1);
-        }
-        mRecentsView.setEnableDrawingLiveTile(true);
-    }
-
     private void switchToScreenshot() {
         if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
             setStateOnUiThread(STATE_SCREENSHOT_CAPTURED);
@@ -1233,84 +1191,6 @@
         mGestureEndCallback = gestureEndCallback;
     }
 
-    // Handling long swipe
-    private void onLongSwipeActiveChanged(boolean isActive) {
-        mLongSwipeMode = isActive;
-
-        if (mLongSwipeMode) {
-            checkLongSwipeCanEnter();
-            checkLongSwipeCanStart();
-        } else {
-            mStateCallback.clearState(STATE_SCREENSHOT_VIEW_SHOWN);
-
-            if (mLongSwipeController != null) {
-                mLongSwipeController.destroy();
-                setTargetAlphaProvider((t, a1) -> a1);
-
-                // Rebuild animations
-                buildAnimationController();
-            }
-        }
-        mLiveTileOverlay.setDrawEnabled(!mLongSwipeMode);
-        if (mRecentsView != null) {
-            mRecentsView.setRunningTaskHidden(!isActive);
-            mRecentsView.setEnableDrawingLiveTile(isActive);
-        }
-    }
-
-    private void onLongSwipeDisplacementUpdated() {
-        if (!mLongSwipeMode || mLongSwipeController == null) {
-            return;
-        }
-
-        mLongSwipeController.onMove(mLongSwipeDisplacement);
-    }
-
-    private void checkLongSwipeCanEnter() {
-        if (!mLongSwipeMode || !mStateCallback.hasStates(LONG_SWIPE_ENTER_STATE)
-                || !mActivityControlHelper.supportsLongSwipe(mActivity)) {
-            return;
-        }
-
-        // We are entering long swipe mode, make sure the screen shot is captured.
-        mStateCallback.setState(STATE_CAPTURE_SCREENSHOT | STATE_SCREENSHOT_VIEW_SHOWN);
-
-    }
-
-    private void checkLongSwipeCanStart() {
-        if (!mLongSwipeMode || !mStateCallback.hasStates(LONG_SWIPE_START_STATE)
-                || !mActivityControlHelper.supportsLongSwipe(mActivity)) {
-            return;
-        }
-
-        RemoteAnimationTargetSet targetSet = mRecentsAnimationWrapper.targetSet;
-        if (targetSet == null) {
-            // This can happen when cancelAnimation comes on the background thread, while we are
-            // processing the long swipe on the UI thread.
-            return;
-        }
-
-        mLongSwipeController = mActivityControlHelper.getLongSwipeController(
-                mActivity, mRunningTaskId);
-        onLongSwipeDisplacementUpdated();
-        if (!ENABLE_QUICKSTEP_LIVE_TILE.get()) {
-            setTargetAlphaProvider(WindowTransformSwipeHandler::getHiddenTargetAlpha);
-        }
-    }
-
-    private void onLongSwipeGestureFinish(float velocity, boolean isFling, float velocityX) {
-        if (!mLongSwipeMode || mLongSwipeController == null) {
-            mLongSwipeMode = false;
-            handleNormalGestureEnd(velocity, isFling, velocityX);
-            return;
-        }
-        mLongSwipeMode = false;
-        finishCurrentTransitionToRecents();
-        mLongSwipeController.end(velocity, isFling,
-                () -> setStateOnUiThread(STATE_HANDLER_INVALIDATED));
-
-    }
-
     private void setTargetAlphaProvider(
             BiFunction<RemoteAnimationTargetCompat, Float, Float> provider) {
         mClipAnimationHelper.setTaskAlphaCallback(provider);