Fix misaligned folder creation drag over target
Previously, the folder creation distance was based on the center of the cell, rather than the *visual* center, i.e. around the icon. Updated to use existing getWorkspaceVisualDragBounds() to handle this. Test: with DEBUG_VISUALIZE_OCCUPIED=true, ensure green circles are centered around the app icons; manually drag and drop to check the drawn regions are correct Bug: 204406063 Change-Id: I691a5cbbfc18c88436b88b7bda42f7920b9a5750
This commit is contained in:
1 parent
0ac045fe23
commit
3cfa5edc93
2 files changed
+31
-12
No files matched your search
@@ -1751,8 +1751,8 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
mTargetCell = findNearestArea((int) mDragViewVisualCenter[0],
|
||||
(int) mDragViewVisualCenter[1], minSpanX, minSpanY, dropTargetLayout,
|
||||
mTargetCell);
|
||||
float distance = dropTargetLayout.getDistanceFromCell(mDragViewVisualCenter[0],
|
||||
mDragViewVisualCenter[1], mTargetCell);
|
||||
float distance = dropTargetLayout.getDistanceFromWorkspaceCellVisualCenter(
|
||||
mDragViewVisualCenter[0], mDragViewVisualCenter[1], mTargetCell);
|
||||
if (mCreateUserFolderOnDrop && willCreateUserFolder(d.dragInfo,
|
||||
dropTargetLayout, mTargetCell, distance, true)) {
|
||||
return true;
|
||||
@@ -1966,8 +1966,8 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
|
||||
mTargetCell = findNearestArea((int) mDragViewVisualCenter[0], (int)
|
||||
mDragViewVisualCenter[1], spanX, spanY, dropTargetLayout, mTargetCell);
|
||||
float distance = dropTargetLayout.getDistanceFromCell(mDragViewVisualCenter[0],
|
||||
mDragViewVisualCenter[1], mTargetCell);
|
||||
float distance = dropTargetLayout.getDistanceFromWorkspaceCellVisualCenter(
|
||||
mDragViewVisualCenter[0], mDragViewVisualCenter[1], mTargetCell);
|
||||
|
||||
// If the item being dropped is a shortcut and the nearest drop
|
||||
// cell also contains a shortcut, then create a folder with the two shortcuts.
|
||||
@@ -2395,7 +2395,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
|
||||
setCurrentDropOverCell(mTargetCell[0], mTargetCell[1]);
|
||||
|
||||
float targetCellDistance = mDragTargetLayout.getDistanceFromCell(
|
||||
float targetCellDistance = mDragTargetLayout.getDistanceFromWorkspaceCellVisualCenter(
|
||||
mDragViewVisualCenter[0], mDragViewVisualCenter[1], mTargetCell);
|
||||
|
||||
manageFolderFeedback(targetCellDistance, d);
|
||||
@@ -2651,8 +2651,8 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
if (pendingInfo.itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT) {
|
||||
mTargetCell = findNearestArea(touchXY[0], touchXY[1], spanX, spanY,
|
||||
cellLayout, mTargetCell);
|
||||
float distance = cellLayout.getDistanceFromCell(mDragViewVisualCenter[0],
|
||||
mDragViewVisualCenter[1], mTargetCell);
|
||||
float distance = cellLayout.getDistanceFromWorkspaceCellVisualCenter(
|
||||
mDragViewVisualCenter[0], mDragViewVisualCenter[1], mTargetCell);
|
||||
if (willCreateUserFolder(d.dragInfo, cellLayout, mTargetCell, distance, true)
|
||||
|| willAddToExistingUserFolder(
|
||||
d.dragInfo, cellLayout, mTargetCell, distance)) {
|
||||
@@ -2751,8 +2751,8 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
|
||||
if (touchXY != null) {
|
||||
mTargetCell = findNearestArea(touchXY[0], touchXY[1], spanX, spanY,
|
||||
cellLayout, mTargetCell);
|
||||
float distance = cellLayout.getDistanceFromCell(mDragViewVisualCenter[0],
|
||||
mDragViewVisualCenter[1], mTargetCell);
|
||||
float distance = cellLayout.getDistanceFromWorkspaceCellVisualCenter(
|
||||
mDragViewVisualCenter[0], mDragViewVisualCenter[1], mTargetCell);
|
||||
if (createUserFolderIfNecessary(view, container, cellLayout, mTargetCell, distance,
|
||||
true, d)) {
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user