summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/ButtonDropTarget.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher2/ButtonDropTarget.java')
-rw-r--r--src/com/android/launcher2/ButtonDropTarget.java27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/com/android/launcher2/ButtonDropTarget.java b/src/com/android/launcher2/ButtonDropTarget.java
index 4ff7c9669..dc34d8828 100644
--- a/src/com/android/launcher2/ButtonDropTarget.java
+++ b/src/com/android/launcher2/ButtonDropTarget.java
@@ -19,6 +19,7 @@ package com.android.launcher2;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Paint;
+import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.TextView;
@@ -41,7 +42,7 @@ public class ButtonDropTarget extends TextView implements DropTarget, DragContro
protected boolean mActive;
/** The paint applied to the drag view on hover */
- protected final Paint mHoverPaint = new Paint();
+ protected int mHoverColor = 0;
public ButtonDropTarget(Context context, AttributeSet attrs) {
this(context, attrs, 0);
@@ -71,7 +72,7 @@ public class ButtonDropTarget extends TextView implements DropTarget, DragContro
}
public void onDragEnter(DragObject d) {
- d.dragView.setPaint(mHoverPaint);
+ d.dragView.setColor(mHoverColor);
}
public void onDragOver(DragObject d) {
@@ -79,7 +80,7 @@ public class ButtonDropTarget extends TextView implements DropTarget, DragContro
}
public void onDragExit(DragObject d) {
- d.dragView.setPaint(null);
+ d.dragView.setColor(0);
}
public void onDragStart(DragSource source, Object info, int dragAction) {
@@ -100,6 +101,26 @@ public class ButtonDropTarget extends TextView implements DropTarget, DragContro
outRect.bottom += mBottomDragPadding;
}
+ Rect getIconRect(int itemWidth, int itemHeight, int drawableWidth, int drawableHeight) {
+ DragLayer dragLayer = mLauncher.getDragLayer();
+
+ // Find the rect to animate to (the view is center aligned)
+ Rect to = new Rect();
+ dragLayer.getViewRectRelativeToSelf(this, to);
+ int width = drawableWidth;
+ int height = drawableHeight;
+ int left = to.left + getPaddingLeft();
+ int top = to.top + (getMeasuredHeight() - height) / 2;
+ to.set(left, top, left + width, top + height);
+
+ // Center the destination rect about the trash icon
+ int xOffset = (int) -(itemWidth - width) / 2;
+ int yOffset = (int) -(itemHeight - height) / 2;
+ to.offset(xOffset, yOffset);
+
+ return to;
+ }
+
@Override
public DropTarget getDropTargetDelegate(DragObject d) {
return null;