Fix bug with drag visualization and UserFolders.

When dragging an app shortcut, it was possible that we'd show a red rectangle
around a cell occupied by a UserFolder. This shouldn't be possible -- as soon
as that cell becomes the target drop cell, the folder should start handling
the drag and drop events.

Change-Id: I1b7a8b1aa9aeb7e2f1bd51ce8d947c06455e988f
diff --git a/src/com/android/launcher2/DragController.java b/src/com/android/launcher2/DragController.java
index b4f972b..f2fad9a 100644
--- a/src/com/android/launcher2/DragController.java
+++ b/src/com/android/launcher2/DragController.java
@@ -394,6 +394,12 @@
             // Drop on someone?
             final int[] coordinates = mCoordinatesTemp;
             DropTarget dropTarget = findDropTarget(screenX, screenY, coordinates);
+            DropTarget delegate = dropTarget.getDropTargetDelegate(
+                    mDragSource, coordinates[0], coordinates[1],
+                    (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo);
+            if (delegate != null) {
+                dropTarget = delegate;
+            }
             if (dropTarget != null) {
                 if (mLastDropTarget == dropTarget) {
                     dropTarget.onDragOver(mDragSource, coordinates[0], coordinates[1],
@@ -482,13 +488,25 @@
         final ArrayList<DropTarget> dropTargets = mDropTargets;
         final int count = dropTargets.size();
         for (int i=count-1; i>=0; i--) {
-            final DropTarget target = dropTargets.get(i);
+            DropTarget target = dropTargets.get(i);
             target.getHitRect(r);
+
+            // Convert the hit rect to screen coordinates
             target.getLocationOnScreen(dropCoordinates);
             r.offset(dropCoordinates[0] - target.getLeft(), dropCoordinates[1] - target.getTop());
+
             if (r.contains(x, y)) {
+                DropTarget delegate = target.getDropTargetDelegate(mDragSource,
+                        x, y, (int)mTouchOffsetX, (int)mTouchOffsetY, mDragView, mDragInfo);
+                if (delegate != null) {
+                    target = delegate;
+                    target.getLocationOnScreen(dropCoordinates);
+                }
+
+                // Make dropCoordinates relative to the DropTarget
                 dropCoordinates[0] = x - dropCoordinates[0];
                 dropCoordinates[1] = y - dropCoordinates[1];
+
                 return target;
             }
         }