Fix incorrect offset in drag feedback, and other minor stuff.
- moved some dimens to -xlarge
- enlarge AllApps so that it's not clipped
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 2a8c573..2488e6e 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -764,7 +764,9 @@
final int countX = mCountX;
final int countY = mCountY;
- pointToCellRounded(originX, originY, result);
+ // originX and originY give the top left of the cell, but pointToCellRounded
+ // compares center-to-center, so pass in the middle coordinates
+ 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;
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 818cedd..2bb1b7f 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -1369,8 +1369,8 @@
public void onDragOver(DragSource source, int x, int y, int xOffset, int yOffset,
DragView dragView, Object dragInfo) {
- ItemInfo item = (ItemInfo)dragInfo;
- CellLayout currentLayout = getCurrentDropLayout();
+ final ItemInfo item = (ItemInfo)dragInfo;
+ final CellLayout currentLayout = getCurrentDropLayout();
if (dragInfo instanceof LauncherAppWidgetInfo) {
LauncherAppWidgetInfo widgetInfo = (LauncherAppWidgetInfo)dragInfo;
@@ -1393,6 +1393,17 @@
int originX = x - xOffset;
int originY = y - yOffset;
+ // If not dragging from the Workspace, the size of dragView might not match the cell size
+ if (!source.equals(this)) {
+ // Break the drag view up into evenly sized chunks based on its spans
+ int chunkWidth = dragView.getWidth() / item.spanX;
+ int chunkHeight = dragView.getHeight() / item.spanY;
+
+ // Adjust the origin for a cell centered at the top left chunk
+ originX += (chunkWidth - currentLayout.getCellWidth()) / 2;
+ originY += (chunkHeight - currentLayout.getCellHeight()) / 2;
+ }
+
final View child = (mDragInfo == null) ? null : mDragInfo.cell;
currentLayout.visualizeDropLocation(child, originX, originY, item.spanX, item.spanY);
}