diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2017-10-06 13:29:57 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2017-10-16 13:06:52 -0700 |
commit | 1797af41d162413dc98c33fab8ba19f96b63874b (patch) | |
tree | a9003b1952e98db0ec53dab673e00499e46bb6f7 /src/com/android/launcher3/folder | |
parent | cbdfc598fae13f5aa7f7263351872d160004fbe7 (diff) | |
download | android_packages_apps_Trebuchet-1797af41d162413dc98c33fab8ba19f96b63874b.tar.gz android_packages_apps_Trebuchet-1797af41d162413dc98c33fab8ba19f96b63874b.tar.bz2 android_packages_apps_Trebuchet-1797af41d162413dc98c33fab8ba19f96b63874b.zip |
Cleaning up drag state management.
When the drag is started, the UI automatically goes into spring loaded mode. On a successful
drop, it is the responsibility of the {@link DropTarget} to exit out of the spring loaded
mode. If the drop was cancelled for some reason, the UI will automatically exit out of this mode.
Bug: 34692289
Change-Id: Ic611739a43bb8d9279b587aaee3039326c143e8b
Diffstat (limited to 'src/com/android/launcher3/folder')
-rw-r--r-- | src/com/android/launcher3/folder/Folder.java | 29 | ||||
-rw-r--r-- | src/com/android/launcher3/folder/FolderIcon.java | 10 |
2 files changed, 9 insertions, 30 deletions
diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java index b930ad3ca..4a60d4c56 100644 --- a/src/com/android/launcher3/folder/Folder.java +++ b/src/com/android/launcher3/folder/Folder.java @@ -283,7 +283,6 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC } }); } - options.deferCompleteForUninstall = true; mLauncher.getWorkspace().beginDragShared(v, this, options); } @@ -850,7 +849,7 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC } public void onDropCompleted(final View target, final DragObject d, - final boolean isFlingToDelete, final boolean success) { + final boolean success) { if (success) { if (mDeleteFolderOnDropCompleted && !mItemAddedBackToSelfViaIcon && target != this) { @@ -898,12 +897,6 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC mInfo.setOption(FolderInfo.FLAG_MULTI_PAGE_ANIMATION, false, mLauncher.getModelWriter()); } - - if (!isFlingToDelete) { - // Fling to delete already exits spring loaded mode after the animation finishes. - mLauncher.exitSpringLoadedDragModeDelayed(success, - Launcher.EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT, null); - } } private void updateItemLocationsInDatabaseBatch() { @@ -1158,21 +1151,6 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC } public void onDrop(DragObject d, DragOptions options) { - Runnable cleanUpRunnable = null; - - // If we are coming from All Apps space, we defer removing the extra empty screen - // until the folder closes - if (d.dragSource != mLauncher.getWorkspace() && !(d.dragSource instanceof Folder)) { - cleanUpRunnable = new Runnable() { - @Override - public void run() { - mLauncher.exitSpringLoadedDragModeDelayed(true, - Launcher.EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT, - null); - } - }; - } - // If the icon was dropped while the page was being scrolled, we need to compute // the target location again such that the icon is placed of the final page. if (!mContent.rankOnCurrentPage(mEmptyCellRank)) { @@ -1238,8 +1216,7 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC float scaleY = getScaleY(); setScaleX(1.0f); setScaleY(1.0f); - mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, currentDragView, - cleanUpRunnable, null); + mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, currentDragView, null); setScaleX(scaleX); setScaleY(scaleY); } else { @@ -1264,6 +1241,8 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC mInfo.setOption(FolderInfo.FLAG_MULTI_PAGE_ANIMATION, true, mLauncher.getModelWriter()); } + mLauncher.exitSpringLoadedDragMode(true, + Launcher.EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT); if (d.stateAnnouncer != null) { d.stateAnnouncer.completeAction(R.string.item_moved); } diff --git a/src/com/android/launcher3/folder/FolderIcon.java b/src/com/android/launcher3/folder/FolderIcon.java index 399888899..d469eb254 100644 --- a/src/com/android/launcher3/folder/FolderIcon.java +++ b/src/com/android/launcher3/folder/FolderIcon.java @@ -254,7 +254,7 @@ public class FolderIcon extends FrameLayout implements FolderListener { public void performCreateAnimation(final ShortcutInfo destInfo, final View destView, final ShortcutInfo srcInfo, final DragView srcView, Rect dstRect, - float scaleRelativeToDragLayer, Runnable postAnimationRunnable) { + float scaleRelativeToDragLayer) { prepareCreateAnimation(destView); addItem(destInfo); // This will animate the first item from it's position as an icon into its @@ -263,7 +263,7 @@ public class FolderIcon extends FrameLayout implements FolderListener { .start(); // This will animate the dragView (srcView) into the new folder - onDrop(srcInfo, srcView, dstRect, scaleRelativeToDragLayer, 1, postAnimationRunnable, + onDrop(srcInfo, srcView, dstRect, scaleRelativeToDragLayer, 1, false /* itemReturnedOnFailedDrop */); } @@ -279,7 +279,7 @@ public class FolderIcon extends FrameLayout implements FolderListener { } private void onDrop(final ShortcutInfo item, DragView animateView, Rect finalRect, - float scaleRelativeToDragLayer, int index, Runnable postAnimationRunnable, + float scaleRelativeToDragLayer, int index, boolean itemReturnedOnFailedDrop) { item.cellX = -1; item.cellY = -1; @@ -351,7 +351,7 @@ public class FolderIcon extends FrameLayout implements FolderListener { dragLayer.animateView(animateView, from, to, finalAlpha, 1, 1, finalScale, finalScale, DROP_IN_ANIMATION_DURATION, new DecelerateInterpolator(2), new AccelerateInterpolator(2), - postAnimationRunnable, DragLayer.ANIMATION_END_DISAPPEAR, null); + null, DragLayer.ANIMATION_END_DISAPPEAR, null); mFolder.hideItem(item); @@ -381,7 +381,7 @@ public class FolderIcon extends FrameLayout implements FolderListener { item = (ShortcutInfo) d.dragInfo; } mFolder.notifyDrop(); - onDrop(item, d.dragView, null, 1.0f, mInfo.contents.size(), d.postAnimationRunnable, + onDrop(item, d.dragView, null, 1.0f, mInfo.contents.size(), itemReturnedOnFailedDrop); } |