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

Commit 387b97fa authored by Maryam Dehaini's avatar Maryam Dehaini
Browse files

Allow long clicks on maximize icon using switch access

The current implementation only allows listeners from a touchscreen
source. When a user uses switch access to long click, the onLongClick
listener is called, but the onTouch listener never is. This change
ignores onLongClick calls that have gone through onTouch first but
allows long clicks that are recieved directly from an onLongClick call.

Bug: 391652399
Test: open and close maximize menu using both switch access and
touchscreen
Flag: com.android.window.flags.enable_desktop_windowing_mode

Change-Id: Ie7d703a53aab8fa097b4850ca7d35129f1f58f77
parent 5a836187
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -911,7 +911,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
        private boolean mIsCustomHeaderGesture;
        private boolean mIsResizeGesture;
        private boolean mIsDragging;
        private boolean mTouchscreenInUse;
        private boolean mLongClickDisabled;
        private int mDragPointerId = -1;
        private MotionEvent mMotionEvent;

@@ -997,10 +997,12 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
            mMotionEvent = e;
            final int id = v.getId();
            final DesktopModeWindowDecoration decoration = mWindowDecorByTaskId.get(mTaskId);
            if ((e.getSource() & SOURCE_TOUCHSCREEN) == SOURCE_TOUCHSCREEN) {
                mTouchscreenInUse = e.getActionMasked() != ACTION_UP
            final boolean touchscreenSource =
                    (e.getSource() & SOURCE_TOUCHSCREEN) == SOURCE_TOUCHSCREEN;
            // Disable long click during events from a non-touchscreen source
            mLongClickDisabled = !touchscreenSource && e.getActionMasked() != ACTION_UP
                    && e.getActionMasked() != ACTION_CANCEL;
            }

            if (id != R.id.caption_handle && id != R.id.desktop_mode_caption
                    && id != R.id.open_menu_button && id != R.id.close_window
                    && id != R.id.maximize_window && id != R.id.minimize_window) {
@@ -1070,7 +1072,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
        @Override
        public boolean onLongClick(View v) {
            final int id = v.getId();
            if (id == R.id.maximize_window && mTouchscreenInUse) {
            if (id == R.id.maximize_window && !mLongClickDisabled) {
                final DesktopModeWindowDecoration decoration = mWindowDecorByTaskId.get(mTaskId);
                moveTaskToFront(decoration.mTaskInfo);
                if (decoration.isMaximizeMenuActive()) {