diff options
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 26 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/SettingsValues.java | 19 |
2 files changed, 15 insertions, 30 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 02b966625..8f1facd9d 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -452,7 +452,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen oldContactsDictionary = null; } mSuggest = new Suggest(this, subtypeLocale); - if (mCurrentSettings.isCorrectionOn()) { + if (mCurrentSettings.mCorrectionEnabled) { mSuggest.setAutoCorrectionThreshold(mCurrentSettings.mAutoCorrectionThreshold); } @@ -685,7 +685,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen loadSettings(); - if (mSuggest != null && mCurrentSettings.isCorrectionOn()) { + if (mSuggest != null && mCurrentSettings.mCorrectionEnabled) { mSuggest.setAutoCorrectionThreshold(mCurrentSettings.mAutoCorrectionThreshold); } @@ -1076,7 +1076,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } private boolean maybeDoubleSpace() { - if (mCurrentSettings.mCorrectionMode == Suggest.CORRECTION_NONE) return false; + if (!mCurrentSettings.mCorrectionEnabled) return false; if (!mHandler.isAcceptingDoubleSpaces()) return false; final CharSequence lastThree = mConnection.getTextBeforeCursor(3, 0); if (lastThree != null && lastThree.length() == 3 @@ -1557,8 +1557,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // not to auto correct, but accept the typed word. For instance, // in Italian dov' should not be expanded to dove' because the elision // requires the last vowel to be removed. - final boolean shouldAutoCorrect = mCurrentSettings.isCorrectionOn(); - if (shouldAutoCorrect && primaryCode != Keyboard.CODE_SINGLE_QUOTE) { + if (mCurrentSettings.mCorrectionEnabled && primaryCode != Keyboard.CODE_SINGLE_QUOTE) { commitCurrentAutoCorrection(primaryCode); didAutoCorrect = true; } else { @@ -1712,7 +1711,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // getSuggestedWords handles gracefully a null value of prevWord final SuggestedWords suggestedWords = mSuggest.getSuggestedWords(mWordComposer, prevWord, mKeyboardSwitcher.getKeyboard().getProximityInfo(), - mCurrentSettings.isCorrectionOn()); + mCurrentSettings.mCorrectionEnabled); // Basically, we update the suggestion strip only when suggestion count > 1. However, // there is an exception: We update the suggestion strip whenever typed word's length @@ -1864,8 +1863,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // - There is a dictionary and the word is not in it // Please note that if mSuggest is null, it means that everything is off: suggestion // and correction, so we shouldn't try to show the hint - // We used to look at mCorrectionMode here, but showing the hint should have nothing - // to do with the autocorrection setting. final boolean showingAddToDictionaryHint = index == 0 && mSuggest != null // If there is no dictionary the hint should be shown. && (!mSuggest.hasMainDictionary() @@ -1928,7 +1925,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } final SuggestedWords suggestedWords; - if (mCurrentSettings.isCorrectionOn()) { + if (mCurrentSettings.mCorrectionEnabled) { final CharSequence prevWord = mConnection.getThisWord(mCurrentSettings.mWordSeparators); if (!TextUtils.isEmpty(prevWord)) { suggestedWords = mSuggest.getBigramPredictions(prevWord); @@ -1961,10 +1958,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private CharSequence addToUserHistoryDictionary(final CharSequence suggestion) { if (TextUtils.isEmpty(suggestion)) return null; - // Only auto-add to dictionary if auto-correct is ON. Otherwise we'll be - // adding words in situations where the user or application really didn't - // want corrections enabled or learned. - if (!mCurrentSettings.isCorrectionOn()) return null; + // If correction is not enabled, we don't add words to the user history dictionary. + // That's to avoid unintended additions in some sensitive fields, or fields that + // expect to receive non-words. + if (!mCurrentSettings.mCorrectionEnabled) return null; if (mUserHistoryDictionary != null) { final CharSequence prevWord @@ -2220,9 +2217,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen p.println(" Keyboard mode = " + keyboardMode); p.println(" mIsSuggestionsSuggestionsRequested = " + mCurrentSettings.isSuggestionsRequested(mDisplayOrientation)); - p.println(" mCorrectionMode=" + mCurrentSettings.mCorrectionMode); + p.println(" mCorrectionEnabled=" + mCurrentSettings.mCorrectionEnabled); p.println(" isComposingWord=" + mWordComposer.isComposingWord()); - p.println(" isCorrectionOn=" + mCurrentSettings.isCorrectionOn()); p.println(" mSoundOn=" + mCurrentSettings.mSoundOn); p.println(" mVibrateOn=" + mCurrentSettings.mVibrateOn); p.println(" mKeyPreviewPopupOn=" + mCurrentSettings.mKeyPreviewPopupOn); diff --git a/java/src/com/android/inputmethod/latin/SettingsValues.java b/java/src/com/android/inputmethod/latin/SettingsValues.java index 53f2dfcdb..6b4b85ff6 100644 --- a/java/src/com/android/inputmethod/latin/SettingsValues.java +++ b/java/src/com/android/inputmethod/latin/SettingsValues.java @@ -94,7 +94,7 @@ public class SettingsValues { public final int mKeyPreviewPopupDismissDelay; private final boolean mAutoCorrectEnabled; public final float mAutoCorrectionThreshold; - public final int mCorrectionMode; + public final boolean mCorrectionEnabled; public final int mSuggestionVisibility; private final boolean mVoiceKeyEnabled; private final boolean mVoiceKeyOnMain; @@ -172,7 +172,7 @@ public class SettingsValues { mVoiceKeyOnMain = mVoiceMode != null && mVoiceMode.equals(voiceModeMain); mAdditionalSubtypes = AdditionalSubtype.createAdditionalSubtypesArray( getPrefAdditionalSubtypes(prefs, res)); - mCorrectionMode = createCorrectionMode(); + mCorrectionEnabled = mAutoCorrectEnabled && !mInputAttributes.mInputTypeNoAutoCorrect; mSuggestionVisibility = createSuggestionVisibility(res); } @@ -206,14 +206,6 @@ public class SettingsValues { return wordSeparators; } - private int createCorrectionMode() { - if (mAutoCorrectEnabled && !mInputAttributes.mInputTypeNoAutoCorrect) { - return Suggest.CORRECTION_FULL; - } else { - return Suggest.CORRECTION_NONE; - } - } - private int createSuggestionVisibility(final Resources res) { final String suggestionVisiblityStr = mShowSuggestionsSetting; for (int visibility : SUGGESTION_VISIBILITY_VALUE_ARRAY) { @@ -241,11 +233,8 @@ public class SettingsValues { public boolean isSuggestionsRequested(final int displayOrientation) { return mInputAttributes.mIsSettingsSuggestionStripOn - && (isCorrectionOn() || isSuggestionStripVisibleInOrientation(displayOrientation)); - } - - public boolean isCorrectionOn() { - return mCorrectionMode == Suggest.CORRECTION_FULL; + && (mCorrectionEnabled + || isSuggestionStripVisibleInOrientation(displayOrientation)); } public boolean isSuggestionStripVisibleInOrientation(final int orientation) { |