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

Commit 64ac117a authored by Ben Lin's avatar Ben Lin
Browse files

Add CTRL selection support.

Bug: 30230012
Change-Id: I13b65790058cad2dcd995f072477a64ceb31c63c
parent 45ce375a
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -90,6 +90,10 @@ public final class Events {
        return (metaState & KeyEvent.META_SHIFT_ON) != 0;
    }

    public static boolean hasCtrlBit(int metaState) {
        return (metaState & KeyEvent.META_CTRL_ON) != 0;
    }

    /**
     * A facade over MotionEvent primarily designed to permit for unit testing
     * of related code.
@@ -99,6 +103,7 @@ public final class Events {
        boolean isPrimaryButtonPressed();
        boolean isSecondaryButtonPressed();
        boolean isShiftKeyDown();
        boolean isCtrlKeyDown();

        /** Returns true if the action is the initial press of a mouse or touch. */
        boolean isActionDown();
@@ -213,6 +218,11 @@ public final class Events {
            return Events.hasShiftBit(mEvent.getMetaState());
        }

        @Override
        public boolean isCtrlKeyDown() {
            return Events.hasCtrlBit(mEvent.getMetaState());
        }

        @Override
        public boolean isActionDown() {
            return mEvent.getActionMasked() == MotionEvent.ACTION_DOWN;
+3 −0
Original line number Diff line number Diff line
@@ -185,6 +185,9 @@ public class BandController extends OnScrollListener {
        // events in onTouchEvent. Where it not for this issue, we'd
        // push start handling down into handleInputEvent.
        if (shouldStart(e)) {
            if (!e.isCtrlKeyDown()) {
                mSelectionManager.clearSelection();
            }
            startBandSelect(e.getOrigin());
        } else if (shouldStop(e)) {
            // Same issue here w b/23793622. The ACTION_UP event
+0 −2
Original line number Diff line number Diff line
@@ -19,11 +19,9 @@ package com.android.documentsui.dirlist;
import android.graphics.Point;
import android.support.annotation.VisibleForTesting;
import android.support.v7.widget.RecyclerView;
import android.view.MotionEvent;
import android.view.View;

import com.android.documentsui.Events.InputEvent;
import com.android.documentsui.Events.MotionInputEvent;
import com.android.documentsui.dirlist.ViewAutoScroller.ScrollActionDelegate;
import com.android.documentsui.dirlist.ViewAutoScroller.ScrollDistanceDelegate;

+10 −1
Original line number Diff line number Diff line
@@ -200,6 +200,10 @@ public final class UserInputHandler<T extends InputEvent>
        mSelectionMgr.snapRangeSelection(event.getItemPosition());
    }

    private boolean shouldClearSelection(T event, DocumentDetails doc) {
        return !event.isCtrlKeyDown() && !mSelectionMgr.getSelection().contains(doc.getModelId());
    }

    private final class TouchInputDelegate {

        boolean onDown(T event) {
@@ -280,6 +284,7 @@ public final class UserInputHandler<T extends InputEvent>
                mHandledOnDown = true;
                return onRightClick(event);
            }

            return false;
        }

@@ -307,7 +312,11 @@ public final class UserInputHandler<T extends InputEvent>
                if (isRangeExtension(event)) {
                    extendSelectionRange(event);
                } else {
                    selectDocument(mDocFinder.apply(event));
                    DocumentDetails doc = mDocFinder.apply(event);
                    if (shouldClearSelection(event, doc)) {
                        mSelectionMgr.clearSelection();
                    }
                    selectDocument(doc);
                }
                mHandledTapUp = true;
                return true;
+6 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ public class TestInputEvent implements Events.InputEvent {
    public boolean primaryButtonPressed;
    public boolean secondaryButtonPressed;
    public boolean shiftKeyDow;
    public boolean ctrlKeyDow;
    public boolean actionDown;
    public boolean actionUp;
    public boolean actionMove;
@@ -42,6 +43,11 @@ public class TestInputEvent implements Events.InputEvent {
        return shiftKeyDow;
    }

    @Override
    public boolean isCtrlKeyDown() {
        return ctrlKeyDow;
    }

    @Override
    public boolean isActionDown() {
        return actionDown;
Loading