OSDN Git Service

Enable suggestions for Folder names.
authorJon Miranda <jonmiranda@google.com>
Fri, 24 Feb 2017 18:00:14 +0000 (10:00 -0800)
committerJon Miranda <jonmiranda@google.com>
Fri, 24 Feb 2017 23:51:09 +0000 (15:51 -0800)
We turn on suggestions, turn off auto complete, and disable the
default behavior where red lines appear under typos.

Bug: 30055146
Change-Id: Ia151b7a4db1dfc6908504e6ea82a1f6989f05ca5

src/com/android/launcher3/ExtendedEditText.java
src/com/android/launcher3/folder/Folder.java

index d05673c..596aa8f 100644 (file)
@@ -29,6 +29,7 @@ import android.widget.EditText;
 public class ExtendedEditText extends EditText {
 
     private boolean mShowImeAfterFirstLayout;
+    private boolean mForceDisableSuggestions = false;
 
     /**
      * Implemented by listeners of the back key.
@@ -107,4 +108,17 @@ public class ExtendedEditText extends EditText {
             mBackKeyListener.onBackKey();
         }
     }
+
+    /**
+     * Set to true when you want isSuggestionsEnabled to return false.
+     * Use this to disable the red underlines that appear under typos when suggestions is enabled.
+     */
+    public void forceDisableSuggestions(boolean forceDisableSuggestions) {
+        mForceDisableSuggestions = forceDisableSuggestions;
+    }
+
+    @Override
+    public boolean isSuggestionsEnabled() {
+        return !mForceDisableSuggestions && super.isSuggestionsEnabled();
+    }
 }
index 2695594..67b8e6d 100644 (file)
@@ -56,7 +56,6 @@ import com.android.launcher3.FolderInfo.FolderListener;
 import com.android.launcher3.ItemInfo;
 import com.android.launcher3.Launcher;
 import com.android.launcher3.LauncherAnimUtils;
-import com.android.launcher3.LauncherModel;
 import com.android.launcher3.LauncherSettings;
 import com.android.launcher3.LogDecelerateInterpolator;
 import com.android.launcher3.OnAlarmListener;
@@ -74,7 +73,6 @@ import com.android.launcher3.dragndrop.DragController.DragListener;
 import com.android.launcher3.dragndrop.DragLayer;
 import com.android.launcher3.dragndrop.DragOptions;
 import com.android.launcher3.pageindicators.PageIndicatorDots;
-import com.android.launcher3.userevent.nano.LauncherLogProto;
 import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
 import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
 import com.android.launcher3.util.CircleRevealOutlineProvider;
@@ -249,8 +247,11 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC
         }
         mFolderName.setOnEditorActionListener(this);
         mFolderName.setSelectAllOnFocus(true);
-        mFolderName.setInputType(mFolderName.getInputType() |
-                InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
+        mFolderName.setInputType(mFolderName.getInputType()
+                & ~InputType.TYPE_TEXT_FLAG_AUTO_CORRECT
+                & ~InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
+                | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
+        mFolderName.forceDisableSuggestions(true);
 
         mFooter = findViewById(R.id.folder_footer);