Fix resize frame for widgets added with tap-to-add button

This change updates the tap-to-add code to wait for the animations
between each step (close widget sheet, snap to Workspace page)
to finish before continuing with the next step of the flow.

Bug: 331425905
Bug: 331699050
Test: manual
Flag: ACONFIG com.android.launcher3.enable_widget_tap_to_add TEAMFOOD
Change-Id: I774b86b429cd2e8a397e5605243056e6cea666b3
This commit is contained in:
Willie Koomson
2024-04-04 00:40:00 +00:00
parent e0330e17e3
commit 7d2d6ced25
2 changed files with 32 additions and 11 deletions
@@ -423,11 +423,16 @@ public class LauncherAccessibilityDelegate extends BaseAccessibilityDelegate<Lau
widgetInfo.bindOptions = widgetInfo.getDefaultSizeOptions(mContext);
}
Workspace<?> workspace = mContext.getWorkspace();
workspace.post(
() -> workspace.snapToPage(workspace.getPageIndexForScreenId(screenId))
);
mContext.addPendingItem(info, LauncherSettings.Favorites.CONTAINER_DESKTOP,
screenId, coordinates, info.spanX, info.spanY);
workspace.post(() -> {
workspace.snapToPage(workspace.getPageIndexForScreenId(screenId));
workspace.setOnPageTransitionEndCallback(() -> {
mContext.addPendingItem(info, LauncherSettings.Favorites.CONTAINER_DESKTOP,
screenId, coordinates, info.spanX, info.spanY);
if (finishCallback != null) {
finishCallback.accept(/* success= */ true);
}
});
});
} else if (item instanceof WorkspaceItemInfo) {
WorkspaceItemInfo info = ((WorkspaceItemInfo) item).clone();
mContext.getModelWriter().addItemToDatabase(info,