aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2010-02-18 11:09:43 -0800
committerAmith Yamasani <yamasani@google.com>2010-02-18 11:09:43 -0800
commitfac5dcb5fee7c6416af4796f90a8272b7712890e (patch)
tree562753ea15464074e0afc457e680fd92e6de714a
parentdb84e0318cbbfa364abb364d961cb5e0d6015012 (diff)
downloadlatinime-fac5dcb5fee7c6416af4796f90a8272b7712890e.tar.gz
latinime-fac5dcb5fee7c6416af4796f90a8272b7712890e.tar.xz
latinime-fac5dcb5fee7c6416af4796f90a8272b7712890e.zip
Don't apply autotext to the wrong input language.
Since autotext is tied to the display language, if the input lang is different from the display lang, don't apply autotext. Bug: 2417495
-rw-r--r--src/com/android/inputmethod/latin/LatinIME.java2
-rwxr-xr-xsrc/com/android/inputmethod/latin/Suggest.java50
2 files changed, 31 insertions, 21 deletions
diff --git a/src/com/android/inputmethod/latin/LatinIME.java b/src/com/android/inputmethod/latin/LatinIME.java
index 6257f2d45..2af59d651 100644
--- a/src/com/android/inputmethod/latin/LatinIME.java
+++ b/src/com/android/inputmethod/latin/LatinIME.java
@@ -318,12 +318,14 @@ public class LatinIME extends InputMethodService
Resources orig = getResources();
Configuration conf = orig.getConfiguration();
Locale saveLocale = conf.locale;
+ boolean different = !conf.locale.getCountry().equalsIgnoreCase(locale.substring(0, 2));
conf.locale = new Locale(locale);
orig.updateConfiguration(conf, orig.getDisplayMetrics());
if (mSuggest != null) {
mSuggest.close();
}
mSuggest = new Suggest(this, R.raw.main);
+ mSuggest.setAutoTextEnabled(!different);
if (mUserDictionary != null) mUserDictionary.close();
mUserDictionary = new UserDictionary(this);
if (mContactsDictionary == null) {
diff --git a/src/com/android/inputmethod/latin/Suggest.java b/src/com/android/inputmethod/latin/Suggest.java
index 5833c02a5..e806dc59b 100755
--- a/src/com/android/inputmethod/latin/Suggest.java
+++ b/src/com/android/inputmethod/latin/Suggest.java
@@ -51,6 +51,8 @@ public class Suggest implements Dictionary.WordCallback {
private int mPrefMaxSuggestions = 12;
+ private boolean mAutoTextEnabled;
+
private int[] mPriorities = new int[mPrefMaxSuggestions];
// Handle predictive correction for only the first 1280 characters for performance reasons
// If we support scripts that need latin characters beyond that, we should probably use some
@@ -76,6 +78,10 @@ public class Suggest implements Dictionary.WordCallback {
}
}
+ public void setAutoTextEnabled(boolean enabled) {
+ mAutoTextEnabled = enabled;
+ }
+
public int getCorrectionMode() {
return mCorrectionMode;
}
@@ -207,29 +213,31 @@ public class Suggest implements Dictionary.WordCallback {
mHaveCorrection = false;
}
}
-
- int i = 0;
- int max = 6;
- // Don't autotext the suggestions from the dictionaries
- if (mCorrectionMode == CORRECTION_BASIC) max = 1;
- while (i < mSuggestions.size() && i < max) {
- String suggestedWord = mSuggestions.get(i).toString().toLowerCase();
- CharSequence autoText =
- AutoText.get(suggestedWord, 0, suggestedWord.length(), view);
- // Is there an AutoText correction?
- boolean canAdd = autoText != null;
- // Is that correction already the current prediction (or original word)?
- canAdd &= !TextUtils.equals(autoText, mSuggestions.get(i));
- // Is that correction already the next predicted word?
- if (canAdd && i + 1 < mSuggestions.size() && mCorrectionMode != CORRECTION_BASIC) {
- canAdd &= !TextUtils.equals(autoText, mSuggestions.get(i + 1));
- }
- if (canAdd) {
- mHaveCorrection = true;
- mSuggestions.add(i + 1, autoText);
+
+ if (mAutoTextEnabled) {
+ int i = 0;
+ int max = 6;
+ // Don't autotext the suggestions from the dictionaries
+ if (mCorrectionMode == CORRECTION_BASIC) max = 1;
+ while (i < mSuggestions.size() && i < max) {
+ String suggestedWord = mSuggestions.get(i).toString().toLowerCase();
+ CharSequence autoText =
+ AutoText.get(suggestedWord, 0, suggestedWord.length(), view);
+ // Is there an AutoText correction?
+ boolean canAdd = autoText != null;
+ // Is that correction already the current prediction (or original word)?
+ canAdd &= !TextUtils.equals(autoText, mSuggestions.get(i));
+ // Is that correction already the next predicted word?
+ if (canAdd && i + 1 < mSuggestions.size() && mCorrectionMode != CORRECTION_BASIC) {
+ canAdd &= !TextUtils.equals(autoText, mSuggestions.get(i + 1));
+ }
+ if (canAdd) {
+ mHaveCorrection = true;
+ mSuggestions.add(i + 1, autoText);
+ i++;
+ }
i++;
}
- i++;
}
removeDupes();