Introduce folder name type (auto vs manual).

Bug: 147769158

- Use both InputConnectionWrapper and TextWatcher to detect
manual input
- Also fix a bug in FolderNameProvider

Change-Id: I7bc0f380c6641481d934a53e9feb77caa19c674a
This commit is contained in:
Hyunyoung Song committed 2020-01-26 22:34:31 -08:00
1 parent 01f0964129
commit 48e6489871
6 files changed
+151 -30

No files matched your search

+18 -6
View File
@@ -96,7 +96,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
View.OnLongClickListener, DropTarget, FolderListener, TextView.OnEditorActionListener,
View.OnFocusChangeListener, DragListener, ExtendedEditText.OnBackKeyListener {
private static final String TAG = "Launcher.Folder";
private static final boolean DEBUG = false;
/**
* We avoid measuring {@link #mContent} with a 0 width or height, as this
* results in CellLayout being measured as UNSPECIFIED, which it does not support.
@@ -146,7 +146,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
@Thunk FolderIcon mFolderIcon;
@Thunk FolderPagedView mContent;
public ExtendedEditText mFolderName;
public FolderNameEditText mFolderName;
private PageIndicatorDots mPageIndicator;
protected View mFooter;
@@ -306,6 +306,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
mFolderName.setText(suggestedNames[0]);
mFolderName.displayCompletions(Arrays.asList(suggestedNames).subList(1,
suggestedNames.length));
mFolderName.setEnteredCompose(false);
}
}
mFolderName.setHint("");
@@ -318,7 +319,13 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
// Convert to a string here to ensure that no other state associated with the text field
// gets saved.
String newTitle = mFolderName.getText().toString();
if (DEBUG) {
Log.d(TAG, "onBackKey newTitle=" + newTitle);
}
mInfo.title = newTitle;
mInfo.setOption(FolderInfo.FLAG_MANUAL_FOLDER_NAME, mFolderName.isEnteredCompose(),
mLauncher.getModelWriter());
mFolderIcon.onTitleChanged(newTitle);
mLauncher.getModelWriter().updateItemInDatabase(mInfo);
@@ -350,6 +357,10 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
}
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (DEBUG) {
Log.d(TAG, "onEditorAction actionId=" + actionId + " key="
+ (event != null ? event.getKeyCode() : "null event"));
}
if (actionId == EditorInfo.IME_ACTION_DONE) {
mFolderName.dispatchBackKey();
return true;
@@ -436,7 +447,8 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
*/
public void showSuggestedTitle(String[] suggestName) {
if (FeatureFlags.FOLDER_NAME_SUGGEST.get()
&& TextUtils.isEmpty(mFolderName.getText().toString())) {
&& TextUtils.isEmpty(mFolderName.getText().toString())
&& !mInfo.hasOption(FolderInfo.FLAG_MANUAL_FOLDER_NAME)) {
if (suggestName.length > 0 && !TextUtils.isEmpty(suggestName[0])) {
mFolderName.setHint("");
mFolderName.setText(suggestName[0]);
@@ -552,9 +564,6 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
openFolder.close(true);
}
if (FeatureFlags.FOLDER_NAME_SUGGEST.get()) {
mLauncher.getFolderNameProvider().load(getContext());
}
mContent.bindItems(items);
centerAboutIcon();
mItemsInvalidated = true;
@@ -1495,6 +1504,9 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
return ContainerType.FOLDER;
}
/**
* Navigation bar back key or hardware input back key has been issued.
*/
@Override
public boolean onBackPressed() {
if (isEditingName()) {