summaryrefslogtreecommitdiff
path: root/src/com/android/launcher3/dragndrop/DragController.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/dragndrop/DragController.java')
-rw-r--r--src/com/android/launcher3/dragndrop/DragController.java24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java
index 5731db4cbb..fdb27998de 100644
--- a/src/com/android/launcher3/dragndrop/DragController.java
+++ b/src/com/android/launcher3/dragndrop/DragController.java
@@ -22,6 +22,7 @@ import android.content.ComponentName;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
+import android.util.Log;
import android.view.DragEvent;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -34,6 +35,7 @@ import com.android.launcher3.DropTarget;
import com.android.launcher3.logging.InstanceId;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
+import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.TouchController;
import com.android.launcher3.views.ActivityContext;
@@ -74,7 +76,7 @@ public abstract class DragController<T extends ActivityContext>
/** Coordinate for last touch event **/
protected final Point mLastTouch = new Point();
- private final Point mTmpPoint = new Point();
+ protected final Point mTmpPoint = new Point();
protected DropTarget.DragObject mDragObject;
@@ -146,6 +148,9 @@ public abstract class DragController<T extends ActivityContext>
float initialDragViewScale,
float dragViewScaleOnDrop,
DragOptions options) {
+ if (TestProtocol.sDebugTracing) {
+ Log.d(TestProtocol.NO_DROP_TARGET, "4");
+ }
return startDrag(drawable, /* view= */ null, originalView, dragLayerX, dragLayerY,
source, dragInfo, dragOffset, dragRegion, initialDragViewScale, dragViewScaleOnDrop,
options);
@@ -203,6 +208,9 @@ public abstract class DragController<T extends ActivityContext>
DragOptions options);
protected void callOnDragStart() {
+ if (TestProtocol.sDebugTracing) {
+ Log.d(TestProtocol.NO_DROP_TARGET, "6");
+ }
if (mOptions.preDragCondition != null) {
mOptions.preDragCondition.onPreDragEnd(mDragObject, true /* dragStarted*/);
}
@@ -317,7 +325,7 @@ public abstract class DragController<T extends ActivityContext>
mDragObject.dragView.animateTo(mMotionDown.x, mMotionDown.y, onCompleteRunnable, duration);
}
- private void callOnDragEnd() {
+ protected void callOnDragEnd() {
if (mIsInPreDrag && mOptions.preDragCondition != null) {
mOptions.preDragCondition.onPreDragEnd(mDragObject, false /* dragStarted*/);
}
@@ -343,7 +351,7 @@ public abstract class DragController<T extends ActivityContext>
/**
* Clamps the position to the drag layer bounds.
*/
- private Point getClampedDragLayerPos(float x, float y) {
+ protected Point getClampedDragLayerPos(float x, float y) {
mActivity.getDragLayer().getLocalVisibleRect(mRectTemp);
mTmpPoint.x = (int) Math.max(mRectTemp.left, Math.min(x, mRectTemp.right - 1));
mTmpPoint.y = (int) Math.max(mRectTemp.top, Math.min(y, mRectTemp.bottom - 1));
@@ -390,7 +398,7 @@ public abstract class DragController<T extends ActivityContext>
return false;
}
- Point dragLayerPos = getClampedDragLayerPos(ev.getX(), ev.getY());
+ Point dragLayerPos = getClampedDragLayerPos(getX(ev), getY(ev));
mLastTouch.set(dragLayerPos.x, dragLayerPos.y);
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
// Remember location of down touch
@@ -403,6 +411,14 @@ public abstract class DragController<T extends ActivityContext>
return mDragDriver != null && mDragDriver.onInterceptTouchEvent(ev);
}
+ protected float getX(MotionEvent ev) {
+ return ev.getX();
+ }
+
+ protected float getY(MotionEvent ev) {
+ return ev.getY();
+ }
+
/**
* Call this from a drag source view.
*/