Loading src/com/android/documentsui/base/Events.java +48 −1 Original line number Diff line number Diff line Loading @@ -134,6 +134,20 @@ public final class Events { /** Returns true if the action is the final release of a mouse or touch. */ boolean isActionUp(); /** * Returns true when the action is the initial press of a non-primary (ex. second finger) * pointer. * See {@link MotionEvent#ACTION_POINTER_DOWN}. */ boolean isMultiPointerActionDown(); /** * Returns true when the action is the final of a non-primary (ex. second finger) * pointer. * * See {@link MotionEvent#ACTION_POINTER_UP}. */ boolean isMultiPointerActionUp(); /** Returns true if the action is neither the initial nor the final release of a mouse * or touch. */ boolean isActionMove(); Loading @@ -150,6 +164,7 @@ public final class Events { float getY(); float getRawX(); float getRawY(); int getPointerCount(); /** Returns true if there is an item under the finger/cursor. */ boolean isOverItem(); Loading @@ -161,9 +176,17 @@ public final class Events { */ boolean isOverModelItem(); /** Returns true if the event is over an area that can be dragged via touch */ /** * Returns true if the event is over an area that can be dragged via touch. * List items have a white area that is not draggable. */ boolean isOverDragHotspot(); /** * Returns true if the event is a two/three-finger scroll on touchpad. */ boolean isTouchpadScroll(); /** Returns the adapter position of the item under the finger/cursor. */ int getItemPosition(); Loading Loading @@ -267,6 +290,17 @@ public final class Events { return mEvent.getActionMasked() == MotionEvent.ACTION_UP; } @Override public boolean isMultiPointerActionDown() { return mEvent.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN; } @Override public boolean isMultiPointerActionUp() { return mEvent.getActionMasked() == MotionEvent.ACTION_POINTER_UP; } @Override public boolean isActionMove() { return mEvent.getActionMasked() == MotionEvent.ACTION_MOVE; Loading Loading @@ -302,6 +336,18 @@ public final class Events { return mEvent.getRawY(); } @Override public int getPointerCount() { return mEvent.getPointerCount(); } @Override public boolean isTouchpadScroll() { // Touchpad inputs are treated as mouse inputs, and when scrolling, there are no buttons // returned. return isMouseEvent() && isActionMove() && mEvent.getButtonState() == 0; } @Override public boolean isOverDragHotspot() { return isOverItem() ? getDocumentDetails().isInDragHotspot(this) : false; Loading Loading @@ -357,6 +403,7 @@ public final class Events { .append(" isOverItem=").append(isOverItem()) .append(" getItemPosition=").append(getItemPosition()) .append(" getDocumentDetails=").append(getDocumentDetails()) .append(" getPointerCount=").append(getPointerCount()) .append("}") .toString(); } Loading src/com/android/documentsui/dirlist/UserInputHandler.java +2 −1 Original line number Diff line number Diff line Loading @@ -305,7 +305,8 @@ public final class UserInputHandler<T extends InputEvent> // Don't scroll content window in response to mouse drag boolean onScroll(T event) { if (VERBOSE) Log.v(MTAG, "Delegated onScroll event."); return true; // If it's two-finger trackpad scrolling, we want to scroll return !event.isTouchpadScroll(); } boolean onSingleTapUp(T event) { Loading src/com/android/documentsui/selection/BandController.java +7 −5 Original line number Diff line number Diff line Loading @@ -82,7 +82,8 @@ public class BandController extends OnScrollListener { this(new RuntimeSelectionEnvironment(view), adapter, selectionManager, lock, gridItemTester); } private BandController( @VisibleForTesting BandController( SelectionEnvironment env, DocumentsAdapter adapter, SelectionManager selectionManager, Loading Loading @@ -174,7 +175,8 @@ public class BandController extends OnScrollListener { }; } private boolean isActive() { @VisibleForTesting boolean isActive() { return mModel != null; } Loading Loading @@ -210,8 +212,8 @@ public class BandController extends OnScrollListener { } public boolean shouldStart(InputEvent e) { // Don't start, or extend bands on right click. if (e.isSecondaryButtonPressed()) { // Don't start, or extend bands on non-left clicks. if (!e.isPrimaryButtonPressed()) { return false; } Loading @@ -237,7 +239,7 @@ public class BandController extends OnScrollListener { public boolean shouldStop(InputEvent input) { return isActive() && input.isMouseEvent() && (input.isActionUp() || input.isActionCancel()); && (input.isActionUp() || input.isMultiPointerActionUp() || input.isActionCancel()); } /** Loading tests/common/com/android/documentsui/testing/TestEvent.java +35 −6 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ public class TestEvent implements InputEvent { private @Action int mAction; private @ToolType int mToolType; private int mPointerCount; private Set<Integer> mButtons; private Set<Integer> mKeys; private Point mLocation; Loading @@ -87,6 +88,7 @@ public class TestEvent implements InputEvent { mLocation = new Point(0, 0); mRawLocation = new Point(0, 0); mDetails = new Details(); mPointerCount = 0; } private TestEvent(TestEvent source) { Loading @@ -98,6 +100,7 @@ public class TestEvent implements InputEvent { mLocation = source.mLocation; mRawLocation = source.mRawLocation; mDetails = new Details(source.mDetails); mPointerCount = source.mPointerCount; } @Override Loading Loading @@ -125,6 +128,11 @@ public class TestEvent implements InputEvent { return mRawLocation.y; } @Override public int getPointerCount() { return mPointerCount; } @Override public boolean isMouseEvent() { return mToolType == MotionEvent.TOOL_TYPE_MOUSE; Loading Loading @@ -170,6 +178,16 @@ public class TestEvent implements InputEvent { return mAction == MotionEvent.ACTION_UP; } @Override public boolean isMultiPointerActionDown() { return mAction == MotionEvent.ACTION_POINTER_DOWN; } @Override public boolean isMultiPointerActionUp() { return mAction == MotionEvent.ACTION_POINTER_UP; } @Override public boolean isActionMove() { return mAction == MotionEvent.ACTION_MOVE; Loading @@ -187,7 +205,7 @@ public class TestEvent implements InputEvent { @Override public boolean isOverDragHotspot() { return mDetails.isOverInteractiveArea(); return isOverItem() && mDetails.isInDragHotspot(this); } @Override Loading @@ -199,6 +217,11 @@ public class TestEvent implements InputEvent { return false; } @Override public boolean isTouchpadScroll() { return isMouseEvent() && mButtons.isEmpty() && isActionMove(); } @Override public int getItemPosition() { return mDetails.mPosition; Loading Loading @@ -260,10 +283,6 @@ public class TestEvent implements InputEvent { return mPosition != Integer.MIN_VALUE && mPosition != RecyclerView.NO_POSITION; } private boolean isOverInteractiveArea() { return mPosition != Integer.MIN_VALUE && mPosition != RecyclerView.NO_POSITION; } @Override public boolean hasModelId() { return !TextUtils.isEmpty(mModelId); Loading Loading @@ -352,6 +371,11 @@ public class TestEvent implements InputEvent { return this; } public Builder pointerCount(int count) { mState.mPointerCount = count; return this; } /** * Adds one or more button press attributes. */ Loading Loading @@ -408,6 +432,11 @@ public class TestEvent implements InputEvent { return this; } public Builder notInDragHotspot() { mState.mDetails.mInDragHotspot = false; return this; } public Builder touch() { type(MotionEvent.TOOL_TYPE_FINGER); return this; Loading tests/unit/com/android/documentsui/dirlist/DragStartListenerTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,7 @@ public class DragStartListenerTest extends AndroidTestCase { .action(MotionEvent.ACTION_MOVE) .mouse() .at(1) .inDragHotspot() .primary(); } Loading Loading
src/com/android/documentsui/base/Events.java +48 −1 Original line number Diff line number Diff line Loading @@ -134,6 +134,20 @@ public final class Events { /** Returns true if the action is the final release of a mouse or touch. */ boolean isActionUp(); /** * Returns true when the action is the initial press of a non-primary (ex. second finger) * pointer. * See {@link MotionEvent#ACTION_POINTER_DOWN}. */ boolean isMultiPointerActionDown(); /** * Returns true when the action is the final of a non-primary (ex. second finger) * pointer. * * See {@link MotionEvent#ACTION_POINTER_UP}. */ boolean isMultiPointerActionUp(); /** Returns true if the action is neither the initial nor the final release of a mouse * or touch. */ boolean isActionMove(); Loading @@ -150,6 +164,7 @@ public final class Events { float getY(); float getRawX(); float getRawY(); int getPointerCount(); /** Returns true if there is an item under the finger/cursor. */ boolean isOverItem(); Loading @@ -161,9 +176,17 @@ public final class Events { */ boolean isOverModelItem(); /** Returns true if the event is over an area that can be dragged via touch */ /** * Returns true if the event is over an area that can be dragged via touch. * List items have a white area that is not draggable. */ boolean isOverDragHotspot(); /** * Returns true if the event is a two/three-finger scroll on touchpad. */ boolean isTouchpadScroll(); /** Returns the adapter position of the item under the finger/cursor. */ int getItemPosition(); Loading Loading @@ -267,6 +290,17 @@ public final class Events { return mEvent.getActionMasked() == MotionEvent.ACTION_UP; } @Override public boolean isMultiPointerActionDown() { return mEvent.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN; } @Override public boolean isMultiPointerActionUp() { return mEvent.getActionMasked() == MotionEvent.ACTION_POINTER_UP; } @Override public boolean isActionMove() { return mEvent.getActionMasked() == MotionEvent.ACTION_MOVE; Loading Loading @@ -302,6 +336,18 @@ public final class Events { return mEvent.getRawY(); } @Override public int getPointerCount() { return mEvent.getPointerCount(); } @Override public boolean isTouchpadScroll() { // Touchpad inputs are treated as mouse inputs, and when scrolling, there are no buttons // returned. return isMouseEvent() && isActionMove() && mEvent.getButtonState() == 0; } @Override public boolean isOverDragHotspot() { return isOverItem() ? getDocumentDetails().isInDragHotspot(this) : false; Loading Loading @@ -357,6 +403,7 @@ public final class Events { .append(" isOverItem=").append(isOverItem()) .append(" getItemPosition=").append(getItemPosition()) .append(" getDocumentDetails=").append(getDocumentDetails()) .append(" getPointerCount=").append(getPointerCount()) .append("}") .toString(); } Loading
src/com/android/documentsui/dirlist/UserInputHandler.java +2 −1 Original line number Diff line number Diff line Loading @@ -305,7 +305,8 @@ public final class UserInputHandler<T extends InputEvent> // Don't scroll content window in response to mouse drag boolean onScroll(T event) { if (VERBOSE) Log.v(MTAG, "Delegated onScroll event."); return true; // If it's two-finger trackpad scrolling, we want to scroll return !event.isTouchpadScroll(); } boolean onSingleTapUp(T event) { Loading
src/com/android/documentsui/selection/BandController.java +7 −5 Original line number Diff line number Diff line Loading @@ -82,7 +82,8 @@ public class BandController extends OnScrollListener { this(new RuntimeSelectionEnvironment(view), adapter, selectionManager, lock, gridItemTester); } private BandController( @VisibleForTesting BandController( SelectionEnvironment env, DocumentsAdapter adapter, SelectionManager selectionManager, Loading Loading @@ -174,7 +175,8 @@ public class BandController extends OnScrollListener { }; } private boolean isActive() { @VisibleForTesting boolean isActive() { return mModel != null; } Loading Loading @@ -210,8 +212,8 @@ public class BandController extends OnScrollListener { } public boolean shouldStart(InputEvent e) { // Don't start, or extend bands on right click. if (e.isSecondaryButtonPressed()) { // Don't start, or extend bands on non-left clicks. if (!e.isPrimaryButtonPressed()) { return false; } Loading @@ -237,7 +239,7 @@ public class BandController extends OnScrollListener { public boolean shouldStop(InputEvent input) { return isActive() && input.isMouseEvent() && (input.isActionUp() || input.isActionCancel()); && (input.isActionUp() || input.isMultiPointerActionUp() || input.isActionCancel()); } /** Loading
tests/common/com/android/documentsui/testing/TestEvent.java +35 −6 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ public class TestEvent implements InputEvent { private @Action int mAction; private @ToolType int mToolType; private int mPointerCount; private Set<Integer> mButtons; private Set<Integer> mKeys; private Point mLocation; Loading @@ -87,6 +88,7 @@ public class TestEvent implements InputEvent { mLocation = new Point(0, 0); mRawLocation = new Point(0, 0); mDetails = new Details(); mPointerCount = 0; } private TestEvent(TestEvent source) { Loading @@ -98,6 +100,7 @@ public class TestEvent implements InputEvent { mLocation = source.mLocation; mRawLocation = source.mRawLocation; mDetails = new Details(source.mDetails); mPointerCount = source.mPointerCount; } @Override Loading Loading @@ -125,6 +128,11 @@ public class TestEvent implements InputEvent { return mRawLocation.y; } @Override public int getPointerCount() { return mPointerCount; } @Override public boolean isMouseEvent() { return mToolType == MotionEvent.TOOL_TYPE_MOUSE; Loading Loading @@ -170,6 +178,16 @@ public class TestEvent implements InputEvent { return mAction == MotionEvent.ACTION_UP; } @Override public boolean isMultiPointerActionDown() { return mAction == MotionEvent.ACTION_POINTER_DOWN; } @Override public boolean isMultiPointerActionUp() { return mAction == MotionEvent.ACTION_POINTER_UP; } @Override public boolean isActionMove() { return mAction == MotionEvent.ACTION_MOVE; Loading @@ -187,7 +205,7 @@ public class TestEvent implements InputEvent { @Override public boolean isOverDragHotspot() { return mDetails.isOverInteractiveArea(); return isOverItem() && mDetails.isInDragHotspot(this); } @Override Loading @@ -199,6 +217,11 @@ public class TestEvent implements InputEvent { return false; } @Override public boolean isTouchpadScroll() { return isMouseEvent() && mButtons.isEmpty() && isActionMove(); } @Override public int getItemPosition() { return mDetails.mPosition; Loading Loading @@ -260,10 +283,6 @@ public class TestEvent implements InputEvent { return mPosition != Integer.MIN_VALUE && mPosition != RecyclerView.NO_POSITION; } private boolean isOverInteractiveArea() { return mPosition != Integer.MIN_VALUE && mPosition != RecyclerView.NO_POSITION; } @Override public boolean hasModelId() { return !TextUtils.isEmpty(mModelId); Loading Loading @@ -352,6 +371,11 @@ public class TestEvent implements InputEvent { return this; } public Builder pointerCount(int count) { mState.mPointerCount = count; return this; } /** * Adds one or more button press attributes. */ Loading Loading @@ -408,6 +432,11 @@ public class TestEvent implements InputEvent { return this; } public Builder notInDragHotspot() { mState.mDetails.mInDragHotspot = false; return this; } public Builder touch() { type(MotionEvent.TOOL_TYPE_FINGER); return this; Loading
tests/unit/com/android/documentsui/dirlist/DragStartListenerTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,7 @@ public class DragStartListenerTest extends AndroidTestCase { .action(MotionEvent.ACTION_MOVE) .mouse() .at(1) .inDragHotspot() .primary(); } Loading