summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/DropTarget.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/DropTarget.java')
-rw-r--r--src/com/android/launcher3/DropTarget.java65
1 files changed, 27 insertions, 38 deletions
diff --git a/src/com/android/launcher3/DropTarget.java b/src/com/android/launcher3/DropTarget.java
index 64f0ac867..c8fac5466 100644
--- a/src/com/android/launcher3/DropTarget.java
+++ b/src/com/android/launcher3/DropTarget.java
@@ -16,10 +16,8 @@
package com.android.launcher3;
-import android.content.Context;
import android.graphics.PointF;
import android.graphics.Rect;
-import android.util.Log;
/**
* Interface defining an object that can receive a drag.
@@ -29,7 +27,7 @@ public interface DropTarget {
public static final String TAG = "DropTarget";
- class DragObject {
+ public static class DragObject {
public int x = -1;
public int y = -1;
@@ -54,6 +52,9 @@ public interface DropTarget {
/** Where the drag originated */
public DragSource dragSource = null;
+ /** The object is part of an accessible drag operation */
+ public boolean accessibleDrag;
+
/** Post drag animation runnable */
public Runnable postAnimationRunnable = null;
@@ -65,42 +66,28 @@ public interface DropTarget {
public DragObject() {
}
- }
-
- public static class DragEnforcer implements DragController.DragListener {
- int dragParity = 0;
-
- public DragEnforcer(Context context) {
- Launcher launcher = (Launcher) context;
- launcher.getDragController().addDragListener(this);
- }
- void onDragEnter() {
- dragParity++;
- if (dragParity != 1) {
- Log.e(TAG, "onDragEnter: Drag contract violated: " + dragParity);
- }
- }
+ /**
+ * This is used to compute the visual center of the dragView. This point is then
+ * used to visualize drop locations and determine where to drop an item. The idea is that
+ * the visual center represents the user's interpretation of where the item is, and hence
+ * is the appropriate point to use when determining drop location.
+ */
+ public final float[] getVisualCenter(float[] recycle) {
+ final float res[] = (recycle == null) ? new float[2] : recycle;
- void onDragExit() {
- dragParity--;
- if (dragParity != 0) {
- Log.e(TAG, "onDragExit: Drag contract violated: " + dragParity);
- }
- }
+ // These represent the visual top and left of drag view if a dragRect was provided.
+ // If a dragRect was not provided, then they correspond to the actual view left and
+ // top, as the dragRect is in that case taken to be the entire dragView.
+ // R.dimen.dragViewOffsetY.
+ int left = x - xOffset;
+ int top = y - yOffset;
- @Override
- public void onDragStart(DragSource source, Object info, int dragAction) {
- if (dragParity != 0) {
- Log.e(TAG, "onDragEnter: Drag contract violated: " + dragParity);
- }
- }
+ // In order to find the visual center, we shift by half the dragRect
+ res[0] = left + dragView.getDragRegion().width() / 2;
+ res[1] = top + dragView.getDragRegion().height() / 2;
- @Override
- public void onDragEnd() {
- if (dragParity != 0) {
- Log.e(TAG, "onDragExit: Drag contract violated: " + dragParity);
- }
+ return res;
}
}
@@ -113,7 +100,7 @@ public interface DropTarget {
/**
* Handle an object being dropped on the DropTarget
- *
+ *
* @param source DragSource where the drag started
* @param x X coordinate of the drop location
* @param y Y coordinate of the drop location
@@ -138,12 +125,12 @@ public interface DropTarget {
* of onDrop(). (This is only called on objects that are set as the DragController's
* fling-to-delete target.
*/
- void onFlingToDelete(DragObject dragObject, int x, int y, PointF vec);
+ void onFlingToDelete(DragObject dragObject, PointF vec);
/**
* Check if a drop action can occur at, or near, the requested location.
* This will be called just before onDrop.
- *
+ *
* @param source DragSource where the drag started
* @param x X coordinate of the drop location
* @param y Y coordinate of the drop location
@@ -157,6 +144,8 @@ public interface DropTarget {
*/
boolean acceptDrop(DragObject dragObject);
+ void prepareAccessibilityDrop();
+
// These methods are implemented in Views
void getHitRectRelativeToDragLayer(Rect outRect);
void getLocationInDragLayer(int[] loc);