From 7e3d96c6209a3b57d999070d76cc7a8bb13b8882 Mon Sep 17 00:00:00 2001 From: Steven Ng Date: Wed, 26 May 2021 22:26:48 +0100 Subject: [PATCH] Show app widget resize frame after launcher state change When this bug occurs, the resize frame coordinate is incorrect because the launcher state animation has not finished when the drag view finishes animating back to its original position. Test: Quickly long press and release a widget from the home screen. Observe the resize frame is correctly shown around the widget. Bug: 186370472 Change-Id: I6bfba2e85e3354a215c26203dd22df13db3b8b83 --- src/com/android/launcher3/Workspace.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 98d80fedbc..b09ec0a1ba 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -103,6 +103,7 @@ import com.android.launcher3.util.IntSparseArrayMap; import com.android.launcher3.util.ItemInfoMatcher; import com.android.launcher3.util.OverlayEdgeEffect; import com.android.launcher3.util.PackageUserKey; +import com.android.launcher3.util.RunnableList; import com.android.launcher3.util.Thunk; import com.android.launcher3.util.WallpaperOffsetInterpolator; import com.android.launcher3.widget.LauncherAppWidgetHost; @@ -1921,10 +1922,16 @@ public class Workspace extends PagedView 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. + final RunnableList callbackList = new RunnableList(); + final Runnable onCompleteCallback = onCompleteRunnable; mLauncher.getDragController().animateDragViewToOriginalPosition( - onCompleteRunnable, cell, + /* onComplete= */ callbackList::executeAllAndDestroy, cell, SPRING_LOADED.getTransitionDuration(mLauncher)); - mLauncher.getStateManager().goToState(NORMAL); + mLauncher.getStateManager().goToState(NORMAL, /* delay= */ 0, + onCompleteCallback == null + ? null + : forSuccessCallback( + () -> callbackList.add(onCompleteCallback))); mLauncher.getDropTargetBar().onDragEnd(); parent.onDropChild(cell); return;