Update reorder and folder creation radii

- Before, dragging anywhere in the cell (including space between cells) would trigger a reorder. Now, we compute the radius to the closest cell edge
- For creating folders on icons, we split the difference between the reorder circle (above) and the icon size

Test: enable DEBUG_VISUALIZE_OCCUPIED and manually drag to ensure works as described above
Bug: 204406063
Change-Id: I368714634ed42a930fd16849f2bde1589df1aa63
This commit is contained in:
Tony Wickham
2021-11-03 14:02:10 -07:00
parent 3cfa5edc93
commit 1278490ac0
2 changed files with 53 additions and 14 deletions

View File

@@ -1786,7 +1786,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
boolean willCreateUserFolder(ItemInfo info, CellLayout target, int[] targetCell,
float distance, boolean considerTimeout) {
if (distance > target.getFolderCreationRadius()) return false;
if (distance > target.getFolderCreationRadius(targetCell)) return false;
View dropOverView = target.getChildAt(targetCell[0], targetCell[1]);
return willCreateUserFolder(info, dropOverView, considerTimeout);
}
@@ -1821,7 +1821,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
boolean willAddToExistingUserFolder(ItemInfo dragInfo, CellLayout target, int[] targetCell,
float distance) {
if (distance > target.getFolderCreationRadius()) return false;
if (distance > target.getFolderCreationRadius(targetCell)) return false;
View dropOverView = target.getChildAt(targetCell[0], targetCell[1]);
return willAddToExistingUserFolder(dragInfo, dropOverView);
@@ -1845,7 +1845,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
boolean createUserFolderIfNecessary(View newView, int container, CellLayout target,
int[] targetCell, float distance, boolean external, DragObject d) {
if (distance > target.getFolderCreationRadius()) return false;
if (distance > target.getFolderCreationRadius(targetCell)) return false;
View v = target.getChildAt(targetCell[0], targetCell[1]);
boolean hasntMoved = false;
@@ -1902,7 +1902,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
boolean addToExistingFolderIfNecessary(View newView, CellLayout target, int[] targetCell,
float distance, DragObject d, boolean external) {
if (distance > target.getFolderCreationRadius()) return false;
if (distance > target.getFolderCreationRadius(targetCell)) return false;
View dropOverView = target.getChildAt(targetCell[0], targetCell[1]);
if (!mAddToExistingFolderOnDrop) return false;
@@ -2408,8 +2408,9 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
mDragTargetLayout.visualizeDropLocation(mTargetCell[0], mTargetCell[1],
item.spanX, item.spanY, d);
} else if ((mDragMode == DRAG_MODE_NONE || mDragMode == DRAG_MODE_REORDER)
&& !mReorderAlarm.alarmPending() && (mLastReorderX != reorderX ||
mLastReorderY != reorderY)) {
&& !mReorderAlarm.alarmPending()
&& (mLastReorderX != reorderX || mLastReorderY != reorderY)
&& targetCellDistance < mDragTargetLayout.getReorderRadius(mTargetCell)) {
int[] resultSpan = new int[2];
mDragTargetLayout.performReorder((int) mDragViewVisualCenter[0],
@@ -2506,7 +2507,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
}
private void manageFolderFeedback(float distance, DragObject dragObject) {
if (distance > mDragTargetLayout.getFolderCreationRadius()) {
if (distance > mDragTargetLayout.getFolderCreationRadius(mTargetCell)) {
if ((mDragMode == DRAG_MODE_ADD_TO_FOLDER
|| mDragMode == DRAG_MODE_CREATE_FOLDER)) {
setDragMode(DRAG_MODE_NONE);