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

Commit b8d1e352 authored by Hyunyoung Song's avatar Hyunyoung Song Committed by Android (Google) Code Review
Browse files

Merge "Fix folder UI open regression when tapping edit text / Fix NPE Bug:...

Merge "Fix folder UI open regression when tapping edit text / Fix NPE Bug: 149835166 Bug: 149839789" into ub-launcher3-master
parents 2d0f79b7 356a9f05
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -326,7 +326,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
                            (FolderNameInfo[]) mInfo.suggestedFolderNames.getParcelableArrayExtra(
                                    FolderInfo.EXTRA_FOLDER_SUGGESTIONS);
                    if (nameInfos != null) {
                        showLabelSuggestion(nameInfos);
                        showLabelSuggestion(nameInfos, false);
                    }
                }
            }
@@ -468,7 +468,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
                    nameInfos);
            if (isEmpty(mFolderName.getText().toString())
                    && !mInfo.hasOption(FLAG_MANUAL_FOLDER_NAME)) {
                showLabelSuggestion(nameInfos);
                showLabelSuggestion(nameInfos, true);
            }
        }
    }
@@ -477,7 +477,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
     * Show suggested folder title in FolderEditText if the first suggestion is non-empty, push
     * InputMethodManager suggestions.
     */
    private void showLabelSuggestion(FolderNameInfo[] nameInfos) {
    private void showLabelSuggestion(FolderNameInfo[] nameInfos, boolean animate) {
        if (nameInfos == null) {
            return;
        }
@@ -493,9 +493,10 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
            if (!isEmpty(firstLabel)) {
                mFolderName.setHint("");
                mFolderName.setText(firstLabel);
                mInfo.title = firstLabel;
            }
            if (animate) {
                animateOpen(mInfo.contents, 0, true);
            }
            mFolderName.showKeyboard();
            mFolderName.displayCompletions(
                    asList(nameInfos).subList(1, nameInfos.length).stream()
@@ -1651,6 +1652,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
                        .getParcelableArrayExtra(FolderInfo.EXTRA_FOLDER_SUGGESTIONS))
                .map(folderNameInfoArray ->
                        stream(folderNameInfoArray)
                                .filter(Objects::nonNull)
                                .map(FolderNameInfo::getLabel)
                                .map(CharSequence::toString)
                                .toArray(String[]::new));
+14 −0
Original line number Diff line number Diff line
@@ -70,11 +70,25 @@ public class FolderNameProvider implements ResourceBasedOverride {
        return fnp;
    }

    public static FolderNameProvider newInstance(Context context, List<AppInfo> appInfos,
            IntSparseArrayMap<FolderInfo> folderInfos) {
        FolderNameProvider fnp = Overrides.getObject(FolderNameProvider.class,
                context.getApplicationContext(), R.string.folder_name_provider_class);
        fnp.load(appInfos, folderInfos);

        return fnp;
    }

    private void load(Context context) {
        LauncherAppState.getInstance(context).getModel().enqueueModelUpdateTask(
                new FolderNameWorker());
    }

    private void load(List<AppInfo> appInfos, IntSparseArrayMap<FolderInfo> folderInfos) {
        mAppInfos = appInfos;
        mFolderInfos = folderInfos;
    }

    /**
     * Generate and rank the suggested Folder names.
     */
+2 −1
Original line number Diff line number Diff line
@@ -901,7 +901,8 @@ public class LoaderTask implements Runnable {
    }

    private void loadFolderNames() {
        FolderNameProvider provider = FolderNameProvider.newInstance(mApp.getContext());
        FolderNameProvider provider = FolderNameProvider.newInstance(mApp.getContext(),
                mBgAllAppsList.data, mBgDataModel.folders);

        synchronized (mBgDataModel) {
            for (int i = 0; i < mBgDataModel.folders.size(); i++) {