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

Commit 71b6215e authored by mattsziklay's avatar mattsziklay
Browse files

Perform double tap toggle on ACTION_UP.

Currently, the double tap event is processed on the initial ACTION_DOWN
of the second tap. This conflicts with potential drag reposition events
that may follow, causing the size change to be reverted when the drag
ends.

This CL has the double tap resize occur on ACTION_UP instead, and only
if there isn't a drag event being handled.

Bug: 301322788
Test: Manual
Change-Id: I78b446a17f74040a2c1f6a9ebb21f137163b40b7
parent 97d24320
Loading
Loading
Loading
Loading
+15 −5
Original line number Original line Diff line number Diff line
@@ -32,6 +32,7 @@ import static com.android.wm.shell.windowdecor.MoveToDesktopAnimator.DRAG_FREEFO
import android.animation.Animator;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator;
import android.annotation.NonNull;
import android.app.ActivityManager;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningTaskInfo;
import android.app.ActivityManager.RunningTaskInfo;
import android.app.ActivityTaskManager;
import android.app.ActivityTaskManager;
@@ -60,7 +61,6 @@ import android.view.ViewConfiguration;
import android.window.WindowContainerToken;
import android.window.WindowContainerToken;
import android.window.WindowContainerTransaction;
import android.window.WindowContainerTransaction;


import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.Nullable;


import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
@@ -544,12 +544,22 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
            return true;
            return true;
        }
        }


        /**
         * Perform a task size toggle on release of the double-tap, assuming no drag event
         * was handled during the double-tap.
         * @param e The motion event that occurred during the double-tap gesture.
         * @return true if the event should be consumed, false if not
         */
        @Override
        @Override
        public boolean onDoubleTap(@NonNull MotionEvent e) {
        public boolean onDoubleTapEvent(@NonNull MotionEvent e) {
            final int action = e.getActionMasked();
            if (mIsDragging || (action != MotionEvent.ACTION_UP
                    && action != MotionEvent.ACTION_CANCEL)) {
                return false;
            }
            final RunningTaskInfo taskInfo = mTaskOrganizer.getRunningTaskInfo(mTaskId);
            final RunningTaskInfo taskInfo = mTaskOrganizer.getRunningTaskInfo(mTaskId);
            mDesktopTasksController.ifPresent(c -> {
            mDesktopTasksController.ifPresent(c -> c.toggleDesktopTaskSize(taskInfo,
                c.toggleDesktopTaskSize(taskInfo, mWindowDecorByTaskId.get(taskInfo.taskId));
                    mWindowDecorByTaskId.get(taskInfo.taskId)));
            });
            return true;
            return true;
        }
        }
    }
    }