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/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 9cc370f..3f60d50 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -677,6 +677,20 @@
return true;
}
+ public View getChildAt(int x, int y) {
+ final int count = getChildCount();
+ for (int i = 0; i < count; i++) {
+ View child = getChildAt(i);
+ LayoutParams lp = (LayoutParams) child.getLayoutParams();
+
+ if ((lp.cellX <= x) && (x < lp.cellX + lp.cellHSpan) &&
+ (lp.cellY <= y) && (y < lp.cellY + lp.cellHSpan)) {
+ return child;
+ }
+ }
+ return null;
+ }
+
/**
* Estimate where the top left cell of the dragged item will land if it is dropped.
*
@@ -690,7 +704,7 @@
final int countX = getCountX();
final int countY = getCountY();
- pointToCellRounded(originX, originY, result);
+ pointToCellRounded(originX + (mCellWidth / 2), originY + (mCellHeight / 2), result);
// If the item isn't fully on this screen, snap to the edges
int rightOverhang = result[0] + spanX - countX;