From 23c2a024fc78f66c0e1d301b5638a11ecfcae0d6 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Fri, 4 Jan 2019 14:30:26 -0800 Subject: [PATCH] Fix bug in getVisualCenter where we do not offset by the dragRegion. This bug made it hard to create folders in landscape mode because since the visual center was off, placing the drag view directly in the center of the cell caused the underlying item to move since the distance calculation placed the drag view outside of the folder creation range. Bug: 111939693 Change-Id: Id0bccb87a87ff1be188def61e697319381f725e1 --- src/com/android/launcher3/DropTarget.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/com/android/launcher3/DropTarget.java b/src/com/android/launcher3/DropTarget.java index 4d30479204..763432df8f 100644 --- a/src/com/android/launcher3/DropTarget.java +++ b/src/com/android/launcher3/DropTarget.java @@ -78,17 +78,17 @@ public interface DropTarget { */ public final float[] getVisualCenter(float[] recycle) { final float res[] = (recycle == null) ? new float[2] : recycle; + Rect dragRegion = dragView.getDragRegion(); // These represent the visual top and left of drag view if a dragRect was provided. // If a dragRect was not provided, then they correspond to the actual view left and // top, as the dragRect is in that case taken to be the entire dragView. - // R.dimen.dragViewOffsetY. - int left = x - xOffset; - int top = y - yOffset; + int left = x - xOffset - dragRegion.left; + int top = y - yOffset - dragRegion.top; // In order to find the visual center, we shift by half the dragRect - res[0] = left + dragView.getDragRegion().width() / 2; - res[1] = top + dragView.getDragRegion().height() / 2; + res[0] = left + dragRegion.width() / 2; + res[1] = top + dragRegion.height() / 2; return res; }