diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java index b9b33fe14a..4fe1d1a3bd 100644 --- a/src/com/android/launcher3/folder/Folder.java +++ b/src/com/android/launcher3/folder/Folder.java @@ -331,7 +331,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo .map(info -> info.suggestedFolderNames) .map(folderNames -> (FolderNameInfo[]) folderNames .getParcelableArrayExtra(FolderInfo.EXTRA_FOLDER_SUGGESTIONS)) - .ifPresent(nameInfos -> showLabelSuggestion(nameInfos, false)); + .ifPresent(nameInfos -> showLabelSuggestions(nameInfos)); } mFolderName.setHint(""); mIsEditingName = true; @@ -457,24 +457,12 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo }); } - /** - * Show suggested folder title in FolderEditText, push InputMethodManager suggestions and save - * the suggestedFolderNames. - */ - public void showSuggestedTitle(FolderNameInfo[] nameInfos) { - if (FeatureFlags.FOLDER_NAME_SUGGEST.get()) { - if (isEmpty(mFolderName.getText().toString()) - && !mInfo.hasOption(FLAG_MANUAL_FOLDER_NAME)) { - showLabelSuggestion(nameInfos, true); - } - } - } /** * Show suggested folder title in FolderEditText if the first suggestion is non-empty, push - * InputMethodManager suggestions. + * rest of the suggestions to InputMethodManager. */ - private void showLabelSuggestion(FolderNameInfo[] nameInfos, boolean animate) { + private void showLabelSuggestions(FolderNameInfo[] nameInfos) { if (nameInfos == null) { return; } @@ -494,9 +482,6 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo mFolderName.setText(firstLabel); } } - if (animate) { - animateOpen(mInfo.contents, 0, true); - } mFolderName.showKeyboard(); mFolderName.displayCompletions( asList(nameInfos).subList(0, nameInfos.length).stream() diff --git a/src/com/android/launcher3/folder/FolderIcon.java b/src/com/android/launcher3/folder/FolderIcon.java index 680c3ba542..e29971eb2b 100644 --- a/src/com/android/launcher3/folder/FolderIcon.java +++ b/src/com/android/launcher3/folder/FolderIcon.java @@ -16,6 +16,8 @@ package com.android.launcher3.folder; +import static android.text.TextUtils.isEmpty; + import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.MAX_NUM_ITEMS_IN_PREVIEW; import static com.android.launcher3.folder.PreviewItemManager.INITIAL_ITEM_ANIMATION_DURATION; @@ -418,11 +420,33 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel postDelayed(() -> { mPreviewItemManager.hidePreviewItem(finalIndex, false); mFolder.showItem(item); + setLabelSuggestion(nameInfos); invalidate(); - mFolder.showSuggestedTitle(nameInfos); }, DROP_IN_ANIMATION_DURATION); } + /** + * Set the suggested folder name. + */ + public void setLabelSuggestion(FolderNameInfo[] nameInfos) { + if (!FeatureFlags.FOLDER_NAME_SUGGEST.get()) { + return; + } + if (!isEmpty(mFolderName.getText().toString()) + || mInfo.hasOption(FolderInfo.FLAG_MANUAL_FOLDER_NAME)) { + return; + } + if (nameInfos == null || nameInfos[0] == null || isEmpty(nameInfos[0].getLabel())) { + return; + } + mInfo.title = nameInfos[0].getLabel(); + onTitleChanged(mInfo.title); + mFolder.mFolderName.setText(mInfo.title); + mFolder.mLauncher.getModelWriter().updateItemInDatabase(mInfo); + // TODO: Add logging while folder creation. + } + + public void onDrop(DragObject d, boolean itemReturnedOnFailedDrop) { WorkspaceItemInfo item; if (d.dragInfo instanceof AppInfo) {