Animate icons back to where they were picked up.

We do this for pre-dragged icons instead of calling onDrop().
- Removes need for special logic in onDrop() to check if mIsInPreDrag
- Dropping from pre-drag in all apps also animates instead of jumping

We also do this when dropping an icon while still transitioning
to spring-loaded mode, to avoid having a janky jump at the end
- Bug: 27135377

Change-Id: I4548c3e2fef3423d1ba36057fb53807b1b4ad0fc
This commit is contained in:
Tony Wickham committed 2016-11-02 15:07:57 -07:00
1 parent df3bc52ca9
commit ea62fe0be1
4 files changed
+53 -26

No files matched your search

+17 -1
View File
@@ -2528,6 +2528,7 @@ public class Workspace extends PagedView
onDropExternal(touchXY, d.dragInfo, dropTargetLayout, false, d);
} else if (mDragInfo != null) {
final View cell = mDragInfo.cell;
boolean droppedOnOriginalCellDuringTransition = false;
if (dropTargetLayout != null && !d.cancelled) {
// Move internally
@@ -2570,6 +2571,10 @@ public class Workspace extends PagedView
minSpanY = item.minSpanY;
}
droppedOnOriginalCellDuringTransition = mIsSwitchingState
&& item.screenId == screenId && item.container == container
&& item.cellX == mTargetCell[0] && item.cellY == mTargetCell[1];
int[] resultSpan = new int[2];
mTargetCell = dropTargetLayout.performReorder((int) mDragViewVisualCenter[0],
(int) mDragViewVisualCenter[1], minSpanX, minSpanY, spanX, spanY, cell,
@@ -2627,7 +2632,7 @@ public class Workspace extends PagedView
&& !d.accessibleDrag) {
mDelayedResizeRunnable = new Runnable() {
public void run() {
if (!isPageInTransition() && !mIsSwitchingState) {
if (!isPageInTransition()) {
DragLayer dragLayer = mLauncher.getDragLayer();
dragLayer.addResizeFrame(hostView, cellLayout);
}
@@ -2662,6 +2667,17 @@ public class Workspace extends PagedView
};
mAnimatingViewIntoPlace = true;
if (d.dragView.hasDrawn()) {
if (droppedOnOriginalCellDuringTransition) {
// Animate the item to its original position, while simultaneously exiting
// spring-loaded mode so the page meets the icon where it was picked up.
mLauncher.getDragController().animateDragViewToOriginalPosition(
mDelayedResizeRunnable, cell,
mStateTransitionAnimation.mSpringLoadedTransitionTime);
mLauncher.exitSpringLoadedDragMode();
mLauncher.getDropTargetBar().onDragEnd();
parent.onDropChild(cell);
return;
}
final ItemInfo info = (ItemInfo) cell.getTag();
boolean isWidget = info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET
|| info.itemType == LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET;