Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 09066ffe authored by jayaprakashs's avatar jayaprakashs
Browse files

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

Bug: 153751859
Change-Id: I8169d0890a43b614b293ca29f504e19c532b90ee
parent 5d35b865
Loading
Loading
Loading
Loading
+3 −18
Original line number Original line Diff line number Diff line
@@ -329,7 +329,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
                        .map(info -> info.suggestedFolderNames)
                        .map(info -> info.suggestedFolderNames)
                        .map(folderNames -> (FolderNameInfo[]) folderNames
                        .map(folderNames -> (FolderNameInfo[]) folderNames
                                .getParcelableArrayExtra(FolderInfo.EXTRA_FOLDER_SUGGESTIONS))
                                .getParcelableArrayExtra(FolderInfo.EXTRA_FOLDER_SUGGESTIONS))
                        .ifPresent(nameInfos -> showLabelSuggestion(nameInfos, false));
                        .ifPresent(nameInfos -> showLabelSuggestions(nameInfos));
            }
            }
            mFolderName.setHint("");
            mFolderName.setHint("");
            mIsEditingName = true;
            mIsEditingName = true;
@@ -455,24 +455,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
     * 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) {
        if (nameInfos == null) {
            return;
            return;
        }
        }
@@ -492,9 +480,6 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
                    mFolderName.setText(firstLabel);
                    mFolderName.setText(firstLabel);
                }
                }
            }
            }
            if (animate) {
                animateOpen(mInfo.contents, 0, true);
            }
            mFolderName.showKeyboard();
            mFolderName.showKeyboard();
            mFolderName.displayCompletions(
            mFolderName.displayCompletions(
                    asList(nameInfos).subList(0, nameInfos.length).stream()
                    asList(nameInfos).subList(0, nameInfos.length).stream()
+25 −1
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


package com.android.launcher3.folder;
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.ClippedFolderIconLayoutRule.MAX_NUM_ITEMS_IN_PREVIEW;
import static com.android.launcher3.folder.PreviewItemManager.INITIAL_ITEM_ANIMATION_DURATION;
import static com.android.launcher3.folder.PreviewItemManager.INITIAL_ITEM_ANIMATION_DURATION;


@@ -418,11 +420,33 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel
        postDelayed(() -> {
        postDelayed(() -> {
            mPreviewItemManager.hidePreviewItem(finalIndex, false);
            mPreviewItemManager.hidePreviewItem(finalIndex, false);
            mFolder.showItem(item);
            mFolder.showItem(item);
            setLabelSuggestion(nameInfos);
            invalidate();
            invalidate();
            mFolder.showSuggestedTitle(nameInfos);
        }, DROP_IN_ANIMATION_DURATION);
        }, 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) {
    public void onDrop(DragObject d, boolean itemReturnedOnFailedDrop) {
        WorkspaceItemInfo item;
        WorkspaceItemInfo item;
        if (d.dragInfo instanceof AppInfo) {
        if (d.dragInfo instanceof AppInfo) {