Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 95ee3582 authored by Vinit Nayak's avatar Vinit Nayak
Browse files

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
parent fd326d1a
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -179,7 +179,7 @@ public abstract class TaskViewTouchController<T extends BaseDraggingActivity>
                        mAllowGoingDown = i == mRecentsView.getCurrentPage()
                        mAllowGoingDown = i == mRecentsView.getCurrentPage()
                                && SysUINavigationMode.getMode(mActivity).hasGestures
                                && SysUINavigationMode.getMode(mActivity).hasGestures
                                && (!mRecentsView.showAsGrid() || mTaskBeingDragged.isFocusedTask())
                                && (!mRecentsView.showAsGrid() || mTaskBeingDragged.isFocusedTask())
                                && mRecentsView.isTaskSnapped(i);
                                && mRecentsView.isTaskInExpectedScrollPosition(i);


                        directionsToDetectScroll = mAllowGoingDown ? DIRECTION_BOTH : upDirection;
                        directionsToDetectScroll = mAllowGoingDown ? DIRECTION_BOTH : upDirection;
                        break;
                        break;
+15 −4
Original line number Original line Diff line number Diff line
@@ -111,19 +111,30 @@ public class TaskOverlayFactory implements ResourceBasedOverride {
    }
    }




    /**
     * 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,
    private static void addSplitOptions(List<SystemShortcut> outShortcuts,
            BaseDraggingActivity activity, TaskView taskView, DeviceProfile deviceProfile) {
            BaseDraggingActivity activity, TaskView taskView, DeviceProfile deviceProfile) {
        RecentsView recentsView = taskView.getRecentsView();
        PagedOrientationHandler orientationHandler = recentsView.getPagedOrientationHandler();
        int[] taskViewTaskIds = taskView.getTaskIds();
        int[] taskViewTaskIds = taskView.getTaskIds();
        boolean taskViewHasMultipleTasks = taskViewTaskIds[0] != -1 &&
        boolean taskViewHasMultipleTasks = taskViewTaskIds[0] != -1 &&
                taskViewTaskIds[1] != -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 ||
        if (taskViewHasMultipleTasks || notEnoughTasksToSplit ||
                (deviceProfile.overviewShowAsGrid && taskView.isFocusedTask())) {
                (isFocusedTask && isTaskInExpectedScrollPosition)) {
            return;
            return;
        }
        }


        PagedOrientationHandler orientationHandler =
                taskView.getRecentsView().getPagedOrientationHandler();
        List<SplitPositionOption> positions =
        List<SplitPositionOption> positions =
                orientationHandler.getSplitPositionOptions(deviceProfile);
                orientationHandler.getSplitPositionOptions(deviceProfile);
        for (SplitPositionOption option : positions) {
        for (SplitPositionOption option : positions) {
+3 −4
Original line number Original line Diff line number Diff line
@@ -1055,11 +1055,11 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
    }
    }


    /**
    /**
     * Returns true if the task is snapped.
     * Returns true if the task is in expected scroll position.
     *
     *
     * @param taskIndex the index of the task
     * @param taskIndex the index of the task
     */
     */
    public boolean isTaskSnapped(int taskIndex) {
    public boolean isTaskInExpectedScrollPosition(int taskIndex) {
        return getScrollForPage(taskIndex) == getPagedOrientationHandler().getPrimaryScroll(this);
        return getScrollForPage(taskIndex) == getPagedOrientationHandler().getPrimaryScroll(this);
    }
    }


@@ -1726,8 +1726,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
        if (showAsGrid()) {
        if (showAsGrid()) {
            TaskView focusedTaskView = getFocusedTaskView();
            TaskView focusedTaskView = getFocusedTaskView();
            hiddenFocusedScroll = focusedTaskView == null
            hiddenFocusedScroll = focusedTaskView == null
                    || getScrollForPage(indexOfChild(focusedTaskView))
                    || !isTaskInExpectedScrollPosition(indexOfChild(focusedTaskView));
                    != mOrientationHandler.getPrimaryScroll(this);
        } else {
        } else {
            hiddenFocusedScroll = false;
            hiddenFocusedScroll = false;
        }
        }