Merge "Adaptive keyboard width/position parser"
diff --git a/java/src/com/android/inputmethod/compat/InputTypeCompatUtils.java b/java/src/com/android/inputmethod/compat/InputTypeCompatUtils.java
index 6684f6a..6c2f0f7 100644
--- a/java/src/com/android/inputmethod/compat/InputTypeCompatUtils.java
+++ b/java/src/com/android/inputmethod/compat/InputTypeCompatUtils.java
@@ -60,6 +60,11 @@
                         : 0;
     }
 
+    private static boolean isWebEditTextInputType(int inputType) {
+        return inputType == (InputType.TYPE_CLASS_TEXT
+                | InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT);
+    }
+
     private static boolean isWebPasswordInputType(int inputType) {
         return WEB_TEXT_PASSWORD_INPUT_TYPE != 0
                 && inputType == WEB_TEXT_PASSWORD_INPUT_TYPE;
@@ -92,8 +97,7 @@
     public static boolean isWebInputType(int inputType) {
         final int maskedInputType =
                 inputType & (InputType.TYPE_MASK_CLASS | InputType.TYPE_MASK_VARIATION);
-        return maskedInputType == InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT
-                || isWebPasswordInputType(maskedInputType)
+        return isWebEditTextInputType(maskedInputType) || isWebPasswordInputType(maskedInputType)
                 || isWebEmailAddressInputType(maskedInputType);
     }
 
diff --git a/java/src/com/android/inputmethod/deprecated/recorrection/Recorrection.java b/java/src/com/android/inputmethod/deprecated/recorrection/Recorrection.java
index 7f88066..d40728d 100644
--- a/java/src/com/android/inputmethod/deprecated/recorrection/Recorrection.java
+++ b/java/src/com/android/inputmethod/deprecated/recorrection/Recorrection.java
@@ -218,10 +218,10 @@
         mService.showSuggestions(builder.build(), entries.getOriginalWord());
     }
 
-    public void setRecorrectionSuggestions(VoiceProxy voiceProxy, CandidateView candidateView,
-            Suggest suggest, KeyboardSwitcher keyboardSwitcher, WordComposer word,
-            boolean hasUncommittedTypedChars, int lastSelectionStart, int lastSelectionEnd,
-            String wordSeparators) {
+    public void fetchAndDisplayRecorrectionSuggestions(VoiceProxy voiceProxy,
+            CandidateView candidateView, Suggest suggest, KeyboardSwitcher keyboardSwitcher,
+            WordComposer word, boolean hasUncommittedTypedChars, int lastSelectionStart,
+            int lastSelectionEnd, String wordSeparators) {
         if (!InputConnectionCompatUtils.RECORRECTION_SUPPORTED) return;
         if (SuggestionSpanUtils.SUGGESTION_SPAN_IS_SUPPORTED || !mRecorrectionEnabled) return;
         voiceProxy.setShowingVoiceSuggestions(false);
@@ -249,7 +249,7 @@
                 ic.endBatchEdit();
             } else {
                 abortRecorrection(true);
-                mService.setPunctuationSuggestions();  // Show the punctuation suggestions list
+                mService.updateBigramPredictions();
             }
         } else {
             abortRecorrection(true);
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 195c929..2512118 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -39,8 +39,8 @@
 import java.util.Locale;
 
 public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceChangeListener {
-    private static final String TAG = "KeyboardSwitcher";
-    private static final boolean DEBUG_CACHE = false;
+    private static final String TAG = KeyboardSwitcher.class.getSimpleName();
+    private static final boolean DEBUG_CACHE = LatinImeLogger.sDBG;
     public static final boolean DEBUG_STATE = false;
 
     private static String sConfigDefaultKeyboardThemeId;
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index d10ff11..a4a04ff 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -222,9 +222,9 @@
                 updateSuggestions();
                 break;
             case MSG_UPDATE_OLD_SUGGESTIONS:
-                mRecorrection.setRecorrectionSuggestions(mVoiceProxy, mCandidateView, mSuggest,
-                        mKeyboardSwitcher, mWord, mHasUncommittedTypedChars, mLastSelectionStart,
-                        mLastSelectionEnd, mSettingsValues.mWordSeparators);
+                mRecorrection.fetchAndDisplayRecorrectionSuggestions(mVoiceProxy, mCandidateView,
+                        mSuggest, mKeyboardSwitcher, mWord, mHasUncommittedTypedChars,
+                        mLastSelectionStart, mLastSelectionEnd, mSettingsValues.mWordSeparators);
                 break;
             case MSG_UPDATE_SHIFT_STATE:
                 switcher.updateShiftState();
@@ -1623,8 +1623,10 @@
         if (!showingAddToDictionaryHint) {
             // If we're not showing the "Touch again to save", then show corrections again.
             // In case the cursor position doesn't change, make sure we show the suggestions again.
-            clearSuggestions();
-            mHandler.postUpdateOldSuggestions();
+            updateBigramPredictions();
+            // Updating the predictions right away may be slow and feel unresponsive on slower
+            // terminals. On the other hand if we just postUpdateBigramPredictions() it will
+            // take a noticeable delay to update them which may feel uneasy.
         }
         if (showingAddToDictionaryHint) {
             mCandidateView.showAddToDictionaryHint(suggestion);
@@ -1655,7 +1657,7 @@
     }
 
     private static final WordComposer sEmptyWordComposer = new WordComposer();
-    private void updateBigramPredictions() {
+    public void updateBigramPredictions() {
         if (mSuggest == null || !isSuggestionsRequested())
             return;