Show split options when overview actions hidden for grid

* We hide split option in task menu for focused task
if the user hasn't scrolled at all in overview
* We show option when user has scrolled because then
the split option from overview actions will be hidden
* Mostly uses the same logic as
RecentsView#updateActionsViewFocusedScroll()

Bug: 201380373
Test: Manual
Change-Id: Ia8769a67cfbb2e4414cd4d8e816e62245fc4bd2c
diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java
index 37a1674..308bca6 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java
@@ -179,7 +179,7 @@
                         mAllowGoingDown = i == mRecentsView.getCurrentPage()
                                 && SysUINavigationMode.getMode(mActivity).hasGestures
                                 && (!mRecentsView.showAsGrid() || mTaskBeingDragged.isFocusedTask())
-                                && mRecentsView.isTaskSnapped(i);
+                                && mRecentsView.isTaskInExpectedScrollPosition(i);
 
                         directionsToDetectScroll = mAllowGoingDown ? DIRECTION_BOTH : upDirection;
                         break;
diff --git a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
index 9ac00e8..c45159e 100644
--- a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
+++ b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
@@ -111,19 +111,30 @@
     }
 
 
+    /**
+     * Does NOT add split options in the following scenarios:
+     * * The taskView to add split options is already showing split screen tasks
+     * * There aren't at least 2 tasks in overview to show split options for
+     * * The taskView to show split options for is the focused task AND we haven't started
+     *   scrolling in overview (if we haven't scrolled, there's a split overview action so
+     *   we don't need this menu option)
+     */
     private static void addSplitOptions(List<SystemShortcut> outShortcuts,
             BaseDraggingActivity activity, TaskView taskView, DeviceProfile deviceProfile) {
+        RecentsView recentsView = taskView.getRecentsView();
+        PagedOrientationHandler orientationHandler = recentsView.getPagedOrientationHandler();
         int[] taskViewTaskIds = taskView.getTaskIds();
         boolean taskViewHasMultipleTasks = taskViewTaskIds[0] != -1 &&
                 taskViewTaskIds[1] != -1;
-        boolean notEnoughTasksToSplit = taskView.getRecentsView().getTaskViewCount() < 2;
+        boolean notEnoughTasksToSplit = recentsView.getTaskViewCount() < 2;
+        boolean isFocusedTask = deviceProfile.overviewShowAsGrid && taskView.isFocusedTask();
+        boolean isTaskInExpectedScrollPosition =
+                recentsView.isTaskInExpectedScrollPosition(recentsView.indexOfChild(taskView));
         if (taskViewHasMultipleTasks || notEnoughTasksToSplit ||
-                (deviceProfile.overviewShowAsGrid && taskView.isFocusedTask())) {
+                (isFocusedTask && isTaskInExpectedScrollPosition)) {
             return;
         }
 
-        PagedOrientationHandler orientationHandler =
-                taskView.getRecentsView().getPagedOrientationHandler();
         List<SplitPositionOption> positions =
                 orientationHandler.getSplitPositionOptions(deviceProfile);
         for (SplitPositionOption option : positions) {
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index e1a3895..c0e7fc2 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -1055,11 +1055,11 @@
     }
 
     /**
-     * Returns true if the task is snapped.
+     * Returns true if the task is in expected scroll position.
      *
      * @param taskIndex the index of the task
      */
-    public boolean isTaskSnapped(int taskIndex) {
+    public boolean isTaskInExpectedScrollPosition(int taskIndex) {
         return getScrollForPage(taskIndex) == getPagedOrientationHandler().getPrimaryScroll(this);
     }
 
@@ -1726,8 +1726,7 @@
         if (showAsGrid()) {
             TaskView focusedTaskView = getFocusedTaskView();
             hiddenFocusedScroll = focusedTaskView == null
-                    || getScrollForPage(indexOfChild(focusedTaskView))
-                    != mOrientationHandler.getPrimaryScroll(this);
+                    || !isTaskInExpectedScrollPosition(indexOfChild(focusedTaskView));
         } else {
             hiddenFocusedScroll = false;
         }