Enabling accessibility dragging with the framework drag driver.
We don't want to start a framework DND (with drop shadow etc.) in the accessibility mode.
Besides, framework DND fails to start and immediately cancels the DND operation
if it's started in the accessibility mode. Presumably, this happens because
the finger doesn't press the screen when this happens.
The right solution is not to instantiate a drag driver at all when an accessible
DND starts, which is what this CL does.
Bug: 22028725
Change-Id: Ic743ba3f8de037c15d4e70e3b7687cdd3518b2a3
diff --git a/src/com/android/launcher3/DragController.java b/src/com/android/launcher3/DragController.java
index 1373bf2..ea41f3f 100644
--- a/src/com/android/launcher3/DragController.java
+++ b/src/com/android/launcher3/DragController.java
@@ -76,10 +76,11 @@
/**
* Drag driver for the current drag/drop operation, or null if there is no active DND operation.
+ * It's null during accessible drag operations.
*/
private DragDriver mDragDriver = null;
- /** Whether or not this is an accessible drag operation */
+ /** Whether or not an accessible drag operation is in progress. */
private boolean mIsAccessibleDrag;
/** X coordinate of the down event. */
@@ -255,7 +256,9 @@
final DragView dragView = mDragObject.dragView = new DragView(mLauncher, b, registrationX,
registrationY, 0, 0, b.getWidth(), b.getHeight(), initialDragViewScale);
- mDragDriver = DragDriver.create(this, dragInfo, dragView);
+ if (!accessible) {
+ mDragDriver = DragDriver.create(this, dragInfo, dragView);
+ }
if (dragOffset != null) {
dragView.setDragVisualizeOffset(new Point(dragOffset));
@@ -323,14 +326,14 @@
}
public boolean isDragging() {
- return mDragDriver != null;
+ return mDragDriver != null || mIsAccessibleDrag;
}
/**
* Stop dragging without dropping.
*/
public void cancelDrag() {
- if (mDragDriver != null) {
+ if (isDragging()) {
if (mLastDropTarget != null) {
mLastDropTarget.onDragExit(mDragObject);
}
@@ -365,7 +368,7 @@
}
private void endDrag() {
- if (mDragDriver != null) {
+ if (isDragging()) {
mDragDriver = null;
mIsAccessibleDrag = false;
clearScrollRunnable();
@@ -525,7 +528,7 @@
* Call this from a drag view.
*/
public void onDragViewAnimationEnd() {
- if (mDragDriver != null ) {
+ if (mDragDriver != null) {
mDragDriver.onDragViewAnimationEnd();
}
}
@@ -842,10 +845,6 @@
mScrollView = v;
}
- DragView getDragView() {
- return mDragObject.dragView;
- }
-
private class ScrollRunnable implements Runnable {
private int mDirection;