Show IME suggestions while tapping on Folder EditText
Current behaviour doesn't show the suggestions in IME if the folder
name is non-empty (Shown only if the folder name is empty).
This change shows the IME suggestions always, but primary suggestions
are shown only if the folder name is empty (not overwritting the
current folder name with suggestion).
Bug: 151762006
Tested: on phone. (created a folder name, assigned custom name, added
the third app to Folder, tap on Folder EditText and it shows IME
suggestions)
Change-Id: Ic4d43660a371b8dd7d18acb42fe3dee06a730347
diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java
index 2be8ff4..5f496f4 100644
--- a/src/com/android/launcher3/folder/Folder.java
+++ b/src/com/android/launcher3/folder/Folder.java
@@ -324,13 +324,11 @@
public void startEditingFolderName() {
post(() -> {
if (FeatureFlags.FOLDER_NAME_SUGGEST.get()) {
- if (isEmpty(mFolderName.getText())) {
- ofNullable(mInfo)
- .map(info -> info.suggestedFolderNames)
- .map(folderNames -> (FolderNameInfo[]) folderNames
- .getParcelableArrayExtra(FolderInfo.EXTRA_FOLDER_SUGGESTIONS))
- .ifPresent(nameInfos -> showLabelSuggestion(nameInfos, false));
- }
+ ofNullable(mInfo)
+ .map(info -> info.suggestedFolderNames)
+ .map(folderNames -> (FolderNameInfo[]) folderNames
+ .getParcelableArrayExtra(FolderInfo.EXTRA_FOLDER_SUGGESTIONS))
+ .ifPresent(nameInfos -> showLabelSuggestion(nameInfos, false));
}
mFolderName.setHint("");
mIsEditingName = true;
@@ -485,19 +483,24 @@
nameInfos[1].getLabel());
if (shouldOpen) {
- CharSequence firstLabel = nameInfos[0] == null ? "" : nameInfos[0].getLabel();
- if (!isEmpty(firstLabel)) {
- mFolderName.setHint("");
- mFolderName.setText(firstLabel);
+ // update the primary suggestion if the folder name is empty.
+ if (isEmpty(mFolderName.getText())) {
+ CharSequence firstLabel = nameInfos[0] == null ? "" : nameInfos[0].getLabel();
+ if (!isEmpty(firstLabel)) {
+ mFolderName.setHint("");
+ mFolderName.setText(firstLabel);
+ }
}
if (animate) {
animateOpen(mInfo.contents, 0, true);
}
mFolderName.showKeyboard();
mFolderName.displayCompletions(
- asList(nameInfos).subList(1, nameInfos.length).stream()
+ asList(nameInfos).subList(0, nameInfos.length).stream()
.filter(Objects::nonNull)
.map(s -> s.getLabel().toString())
+ .filter(s -> !s.isEmpty())
+ .filter(s -> !s.equalsIgnoreCase(mFolderName.getText().toString()))
.collect(Collectors.toList()));
}
}