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
This commit is contained in:
Patrick Dubroy committed 2010-07-13 17:54:03 -07:00
1 parent 6569f2c80e
commit 440c360bc3
7 files changed
+107 -3

No files matched your search

+35 -1
View File
@@ -1219,11 +1219,45 @@ public class Workspace extends ViewGroup implements DropTarget, DragSource, Drag
clearVacantCache();
}
public DropTarget getDropTargetDelegate(DragSource source, int x, int y, int xOffset, int yOffset,
DragView dragView, Object dragInfo) {
// We may need to delegate the drag to a child view. If a 1x1 item
// would land in a cell occupied by a DragTarget (e.g. a Folder),
// then drag events should be handled by that child.
ItemInfo item = (ItemInfo)dragInfo;
CellLayout currentLayout = getCurrentDropLayout();
int dragPointX, dragPointY;
if (item.spanX == 1 && item.spanY == 1) {
// For a 1x1, calculate the drop cell exactly as in onDragOver
dragPointX = x - xOffset;
dragPointY = y - yOffset;
} else {
// Otherwise, use the exact drag coordinates
dragPointX = x;
dragPointY = y;
}
// If we are dragging over a cell that contains a DropTarget that will
// accept the drop, delegate to that DropTarget.
final int[] cellXY = mTempCell;
currentLayout.estimateDropCell(dragPointX, dragPointY, item.spanX, item.spanY, cellXY);
View child = currentLayout.getChildAt(cellXY[0], cellXY[1]);
if (child instanceof DropTarget) {
DropTarget target = (DropTarget)child;
if (target.acceptDrop(source, x, y, xOffset, yOffset, dragView, dragInfo)) {
return target;
}
}
return null;
}
public void onDragOver(DragSource source, int x, int y, int xOffset, int yOffset,
DragView dragView, Object dragInfo) {
ItemInfo item = (ItemInfo)dragInfo;
CellLayout currentLayout = getCurrentDropLayout();
if (dragInfo instanceof LauncherAppWidgetInfo) {