Merge "Move and rename computeProximityThreshold"
diff --git a/java/src/com/android/inputmethod/keyboard/KeyDetector.java b/java/src/com/android/inputmethod/keyboard/KeyDetector.java
index e7a9d85..3979fb5 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyDetector.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyDetector.java
@@ -17,6 +17,7 @@
 package com.android.inputmethod.keyboard;
 
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
 
 public abstract class KeyDetector {
@@ -108,4 +109,31 @@
      * @return The nearest key index
      */
     abstract public int getKeyIndexAndNearbyCodes(int x, int y, int[] allKeys);
+
+    /**
+     * Compute the most common key width in order to use it as proximity key detection threshold.
+     *
+     * @param keyboard The keyboard to compute the most common key width
+     * @return The most common key width in the keyboard
+     */
+    public static int getMostCommonKeyWidth(Keyboard keyboard) {
+        if (keyboard == null) return 0;
+        final List<Key> keys = keyboard.getKeys();
+        if (keys == null || keys.size() == 0) return 0;
+        final HashMap<Integer, Integer> histogram = new HashMap<Integer, Integer>();
+        int maxCount = 0;
+        int mostCommonWidth = 0;
+        for (Key key : keys) {
+            final Integer width = key.mWidth + key.mGap;
+            Integer count = histogram.get(width);
+            if (count == null)
+                count = 0;
+            histogram.put(width, ++count);
+            if (count > maxCount) {
+                maxCount = count;
+                mostCommonWidth = width;
+            }
+        }
+        return mostCommonWidth;
+    }
 }
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardView.java b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
index b490d3a..d4c5e57 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardView.java
@@ -508,7 +508,7 @@
         requestLayout();
         mKeyboardChanged = true;
         invalidateAllKeys();
-        computeProximityThreshold(keyboard, mKeys);
+        mKeyDetector.setProximityThreshold(KeyDetector.getMostCommonKeyWidth(keyboard));
         mMiniKeyboardCache.clear();
     }
 
@@ -600,30 +600,6 @@
         }
     }
 
-    /**
-     * Compute the most common key width and use it as proximity key detection threshold.
-     * @param keyboard
-     * @param keys
-     */
-    private void computeProximityThreshold(Keyboard keyboard, Key[] keys) {
-        if (keyboard == null || keys == null || keys.length == 0) return;
-        final HashMap<Integer, Integer> histogram = new HashMap<Integer, Integer>();
-        int maxCount = 0;
-        int mostCommonWidth = 0;
-        for (Key key : keys) {
-            final Integer width = key.mWidth + key.mGap;
-            Integer count = histogram.get(width);
-            if (count == null)
-                count = 0;
-            histogram.put(width, ++count);
-            if (count > maxCount) {
-                maxCount = count;
-                mostCommonWidth = width;
-            }
-        }
-        mKeyDetector.setProximityThreshold(mostCommonWidth);
-    }
-
     @Override
     public void onDraw(Canvas canvas) {
         super.onDraw(canvas);
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 181043d..67a9f32 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -2082,7 +2082,7 @@
 
     private void updateAutoTextEnabled() {
         if (mSuggest == null) return;
-        mSuggest.setAutoTextEnabled(mQuickFixes
+        mSuggest.setQuickFixesEnabled(mQuickFixes
                 && SubtypeSwitcher.getInstance().isSystemLanguageSameAsInputLanguage());
     }
 
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java
index 7bd6d91..85a4903 100644
--- a/java/src/com/android/inputmethod/latin/Suggest.java
+++ b/java/src/com/android/inputmethod/latin/Suggest.java
@@ -80,7 +80,7 @@
 
     private static final int PREF_MAX_BIGRAMS = 60;
 
-    private boolean mAutoTextEnabled;
+    private boolean mQuickFixesEnabled;
 
     private double mAutoCorrectionThreshold;
     private int[] mPriorities = new int[mPrefMaxSuggestions];
@@ -116,8 +116,8 @@
         }
     }
 
-    public void setAutoTextEnabled(boolean enabled) {
-        mAutoTextEnabled = enabled;
+    public void setQuickFixesEnabled(boolean enabled) {
+        mQuickFixesEnabled = enabled;
     }
 
     public int getCorrectionMode() {
@@ -309,7 +309,7 @@
         if (typedWord != null) {
             mSuggestions.add(0, typedWord.toString());
         }
-        if (mAutoTextEnabled) {
+        if (mQuickFixesEnabled) {
             int i = 0;
             int max = 6;
             // Don't autotext the suggestions from the dictionaries
@@ -416,12 +416,12 @@
         return mHasAutoCorrection;
     }
 
-    private boolean compareCaseInsensitive(final String mLowerOriginalWord,
+    private static boolean compareCaseInsensitive(final String lowerOriginalWord,
             final char[] word, final int offset, final int length) {
-        final int originalLength = mLowerOriginalWord.length();
+        final int originalLength = lowerOriginalWord.length();
         if (originalLength == length && Character.isUpperCase(word[offset])) {
             for (int i = 0; i < originalLength; i++) {
-                if (mLowerOriginalWord.charAt(i) != Character.toLowerCase(word[offset+i])) {
+                if (lowerOriginalWord.charAt(i) != Character.toLowerCase(word[offset+i])) {
                     return false;
                 }
             }
diff --git a/tests/src/com/android/inputmethod/latin/SuggestHelper.java b/tests/src/com/android/inputmethod/latin/SuggestHelper.java
index c734f07..bcc0d6c 100644
--- a/tests/src/com/android/inputmethod/latin/SuggestHelper.java
+++ b/tests/src/com/android/inputmethod/latin/SuggestHelper.java
@@ -41,7 +41,7 @@
     public SuggestHelper(String tag, Context context, int resId) {
         TAG = tag;
         mSuggest = new Suggest(context, resId);
-        mSuggest.setAutoTextEnabled(false);
+        mSuggest.setQuickFixesEnabled(false);
         mSuggest.setCorrectionMode(Suggest.CORRECTION_FULL_BIGRAM);
     }