Loading src/com/android/documentsui/Events.java +10 −0 Original line number Diff line number Diff line Loading @@ -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. Loading @@ -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(); Loading Loading @@ -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; Loading src/com/android/documentsui/dirlist/BandController.java +3 −0 Original line number Diff line number Diff line Loading @@ -182,6 +182,9 @@ public class BandController extends OnScrollListener { boolean onInterceptTouchEvent(InputEvent e) { if (shouldStart(e)) { if (!e.isCtrlKeyDown()) { mSelectionManager.clearSelection(); } startBandSelect(e.getOrigin()); } else if (shouldStop(e)) { endBandSelect(); Loading src/com/android/documentsui/dirlist/GestureSelector.java +0 −2 Original line number Diff line number Diff line Loading @@ -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; Loading src/com/android/documentsui/dirlist/UserInputHandler.java +10 −1 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading @@ -280,6 +284,7 @@ public final class UserInputHandler<T extends InputEvent> mHandledOnDown = true; return onRightClick(event); } return false; } Loading Loading @@ -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; Loading tests/src/com/android/documentsui/TestInputEvent.java +6 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 Loading
src/com/android/documentsui/Events.java +10 −0 Original line number Diff line number Diff line Loading @@ -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. Loading @@ -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(); Loading Loading @@ -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; Loading
src/com/android/documentsui/dirlist/BandController.java +3 −0 Original line number Diff line number Diff line Loading @@ -182,6 +182,9 @@ public class BandController extends OnScrollListener { boolean onInterceptTouchEvent(InputEvent e) { if (shouldStart(e)) { if (!e.isCtrlKeyDown()) { mSelectionManager.clearSelection(); } startBandSelect(e.getOrigin()); } else if (shouldStop(e)) { endBandSelect(); Loading
src/com/android/documentsui/dirlist/GestureSelector.java +0 −2 Original line number Diff line number Diff line Loading @@ -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; Loading
src/com/android/documentsui/dirlist/UserInputHandler.java +10 −1 Original line number Diff line number Diff line Loading @@ -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) { Loading Loading @@ -280,6 +284,7 @@ public final class UserInputHandler<T extends InputEvent> mHandledOnDown = true; return onRightClick(event); } return false; } Loading Loading @@ -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; Loading
tests/src/com/android/documentsui/TestInputEvent.java +6 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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