Merge "Adding an abort listener in app launches to clear state" into main
diff --git a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
index 23e922c..27224f2 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
@@ -17,6 +17,7 @@
 
 import static com.android.app.animation.Interpolators.LINEAR;
 import static com.android.launcher3.LauncherState.CLEAR_ALL_BUTTON;
+import static com.android.launcher3.LauncherState.OVERVIEW;
 import static com.android.launcher3.LauncherState.OVERVIEW_ACTIONS;
 import static com.android.launcher3.LauncherState.OVERVIEW_SPLIT_SELECT;
 import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_ACTIONS_FADE;
@@ -27,6 +28,7 @@
 import static com.android.quickstep.views.RecentsView.TASK_PRIMARY_SPLIT_TRANSLATION;
 import static com.android.quickstep.views.RecentsView.TASK_SECONDARY_SPLIT_TRANSLATION;
 import static com.android.quickstep.views.TaskView.FLAG_UPDATE_ALL;
+import static com.android.wm.shell.Flags.enableSplitContextual;
 
 import android.animation.AnimatorSet;
 import android.annotation.TargetApi;
@@ -120,7 +122,9 @@
      */
     private void handleSplitSelectionState(@NonNull LauncherState toState,
             @NonNull PendingAnimation builder, boolean animate) {
-        if (toState != OVERVIEW_SPLIT_SELECT) {
+        boolean goingToOverviewFromWorkspaceContextual = enableSplitContextual() &&
+                toState == OVERVIEW && mLauncher.isSplitSelectionActive();
+        if (toState != OVERVIEW_SPLIT_SELECT && !goingToOverviewFromWorkspaceContextual) {
             // Not going to split
             return;
         }
@@ -135,9 +139,11 @@
 
         SplitAnimationTimings timings =
                 AnimUtils.getDeviceOverviewToSplitTimings(mLauncher.getDeviceProfile().isTablet);
-
-        mRecentsView.createSplitSelectInitAnimation(builder,
-                toState.getTransitionDuration(mLauncher, true /* isToState */));
+        if (!goingToOverviewFromWorkspaceContextual) {
+            // This animation is already done for the contextual case, don't redo it
+            mRecentsView.createSplitSelectInitAnimation(builder,
+                    toState.getTransitionDuration(mLauncher, true /* isToState */));
+        }
         // Shift tasks vertically downward to get out of placeholder view
         builder.setFloat(mRecentsView, taskViewsFloat.first,
                 toState.getSplitSelectTranslation(mLauncher),
diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
index 396d0ab..7650235 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
@@ -17,6 +17,7 @@
 
 import static com.android.app.animation.Interpolators.DECELERATE_2;
 import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_OVERVIEW;
+import static com.android.wm.shell.Flags.enableSplitContextual;
 
 import android.content.Context;
 import android.graphics.Rect;
@@ -120,10 +121,22 @@
         if (showFloatingSearch) {
             elements |= FLOATING_SEARCH_BAR;
         }
+        if (enableSplitContextual() && launcher.isSplitSelectionActive()) {
+            elements &= ~CLEAR_ALL_BUTTON;
+        }
         return elements;
     }
 
     @Override
+    public float getSplitSelectTranslation(Launcher launcher) {
+        if (!enableSplitContextual() || !launcher.isSplitSelectionActive()) {
+            return 0f;
+        }
+        RecentsView recentsView = launcher.getOverviewPanel();
+        return recentsView.getSplitSelectTranslation();
+    }
+
+    @Override
     public int getFloatingSearchBarRestingMarginBottom(Launcher launcher) {
         return areElementsVisible(launcher, FLOATING_SEARCH_BAR) ? 0
                 : super.getFloatingSearchBarRestingMarginBottom(launcher);