Bug 859212 - Part 1: Move AwesomeBar's Swype logic to InputMethods. r=jchen
authorChris Peterson <cpeterson@mozilla.com>
Thu, 04 Apr 2013 23:05:48 -0700
changeset 128035 d678fbf4ca2e4ecbaae7cfed34401ba6b86718d6
parent 128034 fd139be90362fe3918a6c6ce7da330af0d82e08e
child 128036 0c4b651f1a448efede1659d81e3393fc6d278d50
push id26107
push usercpeterson@mozilla.com
push dateMon, 08 Apr 2013 20:22:12 +0000
treeherdermozilla-inbound@f971d287ba11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen
bugs859212
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 859212 - Part 1: Move AwesomeBar's Swype logic to InputMethods. r=jchen
mobile/android/base/AwesomeBar.java
mobile/android/base/InputMethods.java
--- a/mobile/android/base/AwesomeBar.java
+++ b/mobile/android/base/AwesomeBar.java
@@ -40,42 +40,35 @@ import android.view.inputmethod.InputMet
 import android.widget.Button;
 import android.widget.EditText;
 import android.widget.ImageButton;
 import android.widget.ListView;
 import android.widget.TabWidget;
 import android.widget.Toast;
 
 import java.net.URLEncoder;
-import java.util.Arrays;
-import java.util.Collection;
 
 public class AwesomeBar extends GeckoActivity {
     private static final String LOGTAG = "GeckoAwesomeBar";
 
-    private static final Collection<String> sSwypeInputMethods = Arrays.asList(new String[] {
-                                                                 InputMethods.METHOD_SWYPE,
-                                                                 InputMethods.METHOD_SWYPE_BETA,
-                                                                 });
-
     public static final String URL_KEY = "url";
     public static final String CURRENT_URL_KEY = "currenturl";
     public static final String TARGET_KEY = "target";
     public static final String SEARCH_KEY = "search";
     public static final String TITLE_KEY = "title";
     public static final String USER_ENTERED_KEY = "user_entered";
     public static final String READING_LIST_KEY = "reading_list";
     public static enum Target { NEW_TAB, CURRENT_TAB, PICK_SITE };
 
     private String mTarget;
     private AwesomeBarTabs mAwesomeTabs;
     private CustomEditText mText;
     private ImageButton mGoButton;
     private ContextMenuSubject mContextMenuSubject;
-    private boolean mIsUsingSwype;
+    private boolean mIsUsingGestureKeyboard;
     private boolean mDelayRestartInput;
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         Log.d(LOGTAG, "creating awesomebar");
 
@@ -292,27 +285,25 @@ public class AwesomeBar extends GeckoAct
         // closes the "Select Input Method" window. If the input method changes to or from Swype,
         // then toggle the URL mode flag. Swype's URL mode disables the automatic word spacing that
         // Swype users expect when entering search queries, but does not add any special VKB keys
         // like ".com" or "/" that would be useful for entering URLs.
 
         if (!hasFocus)
             return;
 
-        boolean wasUsingSwype = mIsUsingSwype;
-        mIsUsingSwype = sSwypeInputMethods.contains(InputMethods.getCurrentInputMethod(this));
-
-        if (mIsUsingSwype == wasUsingSwype)
+        boolean wasUsingGestureKeyboard = mIsUsingGestureKeyboard;
+        mIsUsingGestureKeyboard = InputMethods.isGestureKeyboard(this);
+        if (mIsUsingGestureKeyboard == wasUsingGestureKeyboard)
             return;
 
         int currentInputType = mText.getInputType();
-        int newInputType = mIsUsingSwype
-                           ? (currentInputType & ~InputType.TYPE_TEXT_VARIATION_URI)    // URL=OFF
-                           : (currentInputType | InputType.TYPE_TEXT_VARIATION_URI);    // URL=ON
-
+        int newInputType = mIsUsingGestureKeyboard
+                           ? (currentInputType & ~InputType.TYPE_TEXT_VARIATION_URI) // Text mode
+                           : (currentInputType | InputType.TYPE_TEXT_VARIATION_URI); // URL mode
         mText.setRawInputType(newInputType);
     }
 
     @Override
     public void onConfigurationChanged(Configuration newConfiguration) {
         super.onConfigurationChanged(newConfiguration);
     }
 
--- a/mobile/android/base/InputMethods.java
+++ b/mobile/android/base/InputMethods.java
@@ -94,9 +94,15 @@ final class InputMethods {
                METHOD_STOCK_LATINIME.equals(inputMethod);
     }
 
     public static boolean shouldDelayAwesomebarUpdate(Context context) {
         String inputMethod = getCurrentInputMethod(context);
         return METHOD_SAMSUNG.equals(inputMethod) ||
                METHOD_SWIFTKEY.equals(inputMethod);
     }
+
+    public static boolean isGestureKeyboard(Context context) {
+        String inputMethod = getCurrentInputMethod(context);
+        return METHOD_SWYPE.equals(inputMethod) ||
+               METHOD_SWYPE_BETA.equals(inputMethod);
+    }
 }