Fixing flashing icon on delete, and offset of delete animation.

Change-Id: I993f2d8e54cc7052e16f318a09ada80e9b766147
diff --git a/src/com/android/launcher2/ButtonDropTarget.java b/src/com/android/launcher2/ButtonDropTarget.java
index 4ff7c96..dc34d88 100644
--- a/src/com/android/launcher2/ButtonDropTarget.java
+++ b/src/com/android/launcher2/ButtonDropTarget.java
@@ -19,6 +19,7 @@
 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 @@
     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 void onDragEnter(DragObject d) {
-        d.dragView.setPaint(mHoverPaint);
+        d.dragView.setColor(mHoverColor);
     }
 
     public void onDragOver(DragObject d) {
@@ -79,7 +80,7 @@
     }
 
     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 @@
         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;