summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/Workspace.java
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2011-07-20 12:06:04 -0700
committerAdam Cohen <adamcohen@google.com>2011-07-20 15:46:22 -0700
commit00618753e9f0ad941c13efb0b6804e4a06ecb076 (patch)
treee0fde5a3bf20d6fdd3a0c49800c10cc72b8c8c69 /src/com/android/launcher2/Workspace.java
parent3d503fbd9468fb2b9fa645f4f7b91e11229edbfa (diff)
downloadandroid_packages_apps_Trebuchet-00618753e9f0ad941c13efb0b6804e4a06ecb076.tar.gz
android_packages_apps_Trebuchet-00618753e9f0ad941c13efb0b6804e4a06ecb076.tar.bz2
android_packages_apps_Trebuchet-00618753e9f0ad941c13efb0b6804e4a06ecb076.zip
Fixing issue 4083181, making springloaded dragging accurate
Change-Id: Iaa69903220b2fe62e3b3009989094487e3125843
Diffstat (limited to 'src/com/android/launcher2/Workspace.java')
-rw-r--r--src/com/android/launcher2/Workspace.java22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index ed4ae20f8..d40d77fdf 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -2611,7 +2611,7 @@ public class Workspace extends SmoothPagedView
*
*/
private CellLayout findMatchingPageForDragOver(
- DragView dragView, int originX, int originY, int offsetX, int offsetY, boolean exact) {
+ DragView dragView, float originX, float originY, boolean exact) {
// We loop through all the screens (ie CellLayouts) and see which ones overlap
// with the item being dragged and then choose the one that's closest to the touch point
final int screenCount = getChildCount();
@@ -2621,10 +2621,7 @@ public class Workspace extends SmoothPagedView
for (int i = 0; i < screenCount; i++) {
CellLayout cl = (CellLayout) getChildAt(i);
- final float[] touchXy = mTempTouchCoordinates;
- touchXy[0] = originX + offsetX;
- touchXy[1] = originY + offsetY;
-
+ final float[] touchXy = {originX, originY};
// Transform the touch coordinates to the CellLayout's local coordinates
// If the touch point is within the bounds of the cell layout, we can return immediately
cl.getMatrix().invert(mTempInverseMatrix);
@@ -2635,15 +2632,15 @@ public class Workspace extends SmoothPagedView
return cl;
}
- if (!exact && overlaps(cl, dragView, originX, originY, mTempInverseMatrix)) {
+ if (!exact && overlaps(cl, dragView, (int) originX, (int) originY, mTempInverseMatrix)) {
// Get the center of the cell layout in screen coordinates
final float[] cellLayoutCenter = mTempCellLayoutCenterCoordinates;
cellLayoutCenter[0] = cl.getWidth()/2;
cellLayoutCenter[1] = cl.getHeight()/2;
mapPointFromChildToSelf(cl, cellLayoutCenter);
- touchXy[0] = originX + offsetX;
- touchXy[1] = originY + offsetY;
+ touchXy[0] = originX;
+ touchXy[1] = originY;
// Calculate the distance between the center of the CellLayout
// and the touch point
@@ -2701,11 +2698,15 @@ public class Workspace extends SmoothPagedView
// Ensure that we have proper spans for the item that we are dropping
if (item.spanX < 0 || item.spanY < 0) throw new RuntimeException("Improper spans found");
+ mDragViewVisualCenter = getDragViewVisualCenter(d.x, d.y, d.xOffset, d.yOffset,
+ d.dragView, mDragViewVisualCenter);
+
// Identify whether we have dragged over a side page
if (isSmall()) {
int left = d.x - d.xOffset;
int top = d.y - d.yOffset;
- layout = findMatchingPageForDragOver(d.dragView, left, top, d.xOffset, d.yOffset, true);
+ layout = findMatchingPageForDragOver(d.dragView, mDragViewVisualCenter[0],
+ mDragViewVisualCenter[1], true);
if (layout != mDragTargetLayout) {
// Cancel all intermediate folder states
cleanupFolderCreation(d);
@@ -2754,9 +2755,6 @@ public class Workspace extends SmoothPagedView
if (mDragTargetLayout != null) {
final View child = (mDragInfo == null) ? null : mDragInfo.cell;
- mDragViewVisualCenter = getDragViewVisualCenter(d.x, d.y, d.xOffset, d.yOffset,
- d.dragView, mDragViewVisualCenter);
-
// We want the point to be mapped to the dragTarget.
if (mLauncher.isHotseatLayout(mDragTargetLayout)) {
mapPointFromSelfToSibling(mLauncher.getHotseat(), mDragViewVisualCenter);