Don't open the Folder and IME when Folder is created.

Bug: 153751859
Change-Id: I8169d0890a43b614b293ca29f504e19c532b90ee
(cherry picked from commit 09066ffeb2262646f9cf6ff6aace97c264019419)
diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java
index b9b33fe..4fe1d1a 100644
--- a/src/com/android/launcher3/folder/Folder.java
+++ b/src/com/android/launcher3/folder/Folder.java
@@ -331,7 +331,7 @@
                         .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 @@
         });
     }
 
-    /**
-     * 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 @@
                     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 680c3ba..e29971e 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 @@
         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) {