Merge "Fix bug where folder with 1 icon can exist" into 24D1-dev

This commit is contained in:
Federico Baron
2024-03-15 21:42:24 +00:00
committed by Android (Google) Code Review
2 changed files with 18 additions and 0 deletions
@@ -1039,6 +1039,9 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
public void onDropCompleted(final View target, final DragObject d,
final boolean success) {
if (success) {
if (getItemCount() <= 1) {
mDeleteFolderOnDropCompleted = true;
}
if (mDeleteFolderOnDropCompleted && !mItemAddedBackToSelfViaIcon && target != this) {
replaceFolderWithFinalItem();
}
@@ -96,6 +96,21 @@ public class TaplDragTest extends AbstractLauncherUiTest {
MAPS_APP_NAME);
}
/**
* Adds two icons to the Workspace and combines them into a folder, then makes sure we are able
* to remove an icon from the folder and that the folder ceases to exist since it only has one
* icon left.
*/
@Test
public void testDragOutOfFolder() {
final HomeAppIcon playStoreIcon = createShortcutIfNotExist(STORE_APP_NAME, 0, 1);
final HomeAppIcon photosIcon = createShortcutInCenterIfNotExist(PHOTOS_APP_NAME);
FolderIcon folderIcon = photosIcon.dragToIcon(playStoreIcon);
Folder folder = folderIcon.open();
folder.getAppIcon(STORE_APP_NAME).internalDragToWorkspace(false, false);
assertNotNull(mLauncher.getWorkspace().tryGetWorkspaceAppIcon(STORE_APP_NAME));
assertNotNull(mLauncher.getWorkspace().tryGetWorkspaceAppIcon(PHOTOS_APP_NAME));
}
/** Drags a shortcut from a long press menu into the workspace.
* 1. Open all apps and wait for load complete.