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

Commit 9f153823 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Make ACTION_CANCEL cancel drag-to-desktop" into main

parents a3fa000a 88149130
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -2036,6 +2036,18 @@ class DesktopTasksController(
            ?.onTaskbarCornerRoundingUpdate(doesAnyTaskRequireTaskbarRounding(taskInfo.displayId))
    }

    /**
     * Cancel the drag-to-desktop transition.
     *
     * @param taskInfo the task being dragged.
     */
    fun onDragPositioningCancelThroughStatusBar(
        taskInfo: RunningTaskInfo,
    ) {
        interactionJankMonitor.cancel(CUJ_DESKTOP_MODE_ENTER_APP_HANDLE_DRAG_HOLD)
        cancelDragToDesktop(taskInfo)
    }

    /**
     * Perform checks required when drag ends under status bar area.
     *
+34 −29
Original line number Diff line number Diff line
@@ -1277,6 +1277,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
                }
                break;
            }
            case MotionEvent.ACTION_CANCEL:
            case MotionEvent.ACTION_UP: {
                if (mTransitionDragActive) {
                    final DesktopModeVisualIndicator.DragStartState dragStartState =
@@ -1291,32 +1292,11 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
                        // Though this isn't a hover event, we need to update handle's hover state
                        // as it likely will change.
                        relevantDecor.updateHoverAndPressStatus(ev);
                        DesktopModeVisualIndicator.IndicatorType resultType =
                                mDesktopTasksController.onDragPositioningEndThroughStatusBar(
                                        new PointF(ev.getRawX(), ev.getRawY()),
                                        relevantDecor.mTaskInfo,
                                        relevantDecor.mTaskSurface);
                        // If we are entering split select, handle will no longer be visible and
                        // should not be receiving any input.
                        if (resultType == TO_SPLIT_LEFT_INDICATOR
                                || resultType == TO_SPLIT_RIGHT_INDICATOR) {
                            relevantDecor.disposeStatusBarInputLayer();
                            // We should also dispose the other split task's input layer if
                            // applicable.
                            final int splitPosition = mSplitScreenController
                                    .getSplitPosition(relevantDecor.mTaskInfo.taskId);
                            if (splitPosition != SPLIT_POSITION_UNDEFINED) {
                                final int oppositePosition =
                                        splitPosition == SPLIT_POSITION_TOP_OR_LEFT
                                                ? SPLIT_POSITION_BOTTOM_OR_RIGHT
                                                : SPLIT_POSITION_TOP_OR_LEFT;
                                final RunningTaskInfo oppositeTaskInfo =
                                        mSplitScreenController.getTaskInfo(oppositePosition);
                                if (oppositeTaskInfo != null) {
                                    mWindowDecorByTaskId.get(oppositeTaskInfo.taskId)
                                            .disposeStatusBarInputLayer();
                                }
                            }
                        if (ev.getActionMasked() == ACTION_CANCEL) {
                            mDesktopTasksController.onDragPositioningCancelThroughStatusBar(
                                    relevantDecor.mTaskInfo);
                        } else {
                            endDragToDesktop(ev, relevantDecor);
                        }
                        mMoveToDesktopAnimator = null;
                        return;
@@ -1365,10 +1345,35 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
                }
                break;
            }
        }
    }

            case MotionEvent.ACTION_CANCEL: {
                mTransitionDragActive = false;
                mMoveToDesktopAnimator = null;
    private void endDragToDesktop(MotionEvent ev, DesktopModeWindowDecoration relevantDecor) {
        DesktopModeVisualIndicator.IndicatorType resultType =
                mDesktopTasksController.onDragPositioningEndThroughStatusBar(
                        new PointF(ev.getRawX(), ev.getRawY()),
                        relevantDecor.mTaskInfo,
                        relevantDecor.mTaskSurface);
        // If we are entering split select, handle will no longer be visible and
        // should not be receiving any input.
        if (resultType == TO_SPLIT_LEFT_INDICATOR
                || resultType == TO_SPLIT_RIGHT_INDICATOR) {
            relevantDecor.disposeStatusBarInputLayer();
            // We should also dispose the other split task's input layer if
            // applicable.
            final int splitPosition = mSplitScreenController
                    .getSplitPosition(relevantDecor.mTaskInfo.taskId);
            if (splitPosition != SPLIT_POSITION_UNDEFINED) {
                final int oppositePosition =
                        splitPosition == SPLIT_POSITION_TOP_OR_LEFT
                                ? SPLIT_POSITION_BOTTOM_OR_RIGHT
                                : SPLIT_POSITION_TOP_OR_LEFT;
                final RunningTaskInfo oppositeTaskInfo =
                        mSplitScreenController.getTaskInfo(oppositePosition);
                if (oppositeTaskInfo != null) {
                    mWindowDecorByTaskId.get(oppositeTaskInfo.taskId)
                            .disposeStatusBarInputLayer();
                }
            }
        }
    }