diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 51 |
1 files changed, 9 insertions, 42 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index da091dd05..4670bedb4 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -449,7 +449,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen oldContactsDictionary = null; } mSuggest = new Suggest(this, subtypeLocale); - if (mCurrentSettings.mAutoCorrectEnabled) { + if (mCurrentSettings.isCorrectionOn()) { mSuggest.setAutoCorrectionThreshold(mCurrentSettings.mAutoCorrectionThreshold); } @@ -680,7 +680,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen loadSettings(); - if (mSuggest != null && mCurrentSettings.mAutoCorrectEnabled) { + if (mSuggest != null && mCurrentSettings.isCorrectionOn()) { mSuggest.setAutoCorrectionThreshold(mCurrentSettings.mAutoCorrectionThreshold); } @@ -1401,7 +1401,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen return; } } else if (SPACE_STATE_SWAP_PUNCTUATION == spaceState) { - if (revertSwapPunctuation()) { + if (mConnection.revertSwapPunctuation()) { // Likewise return; } @@ -1553,8 +1553,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.mAutoCorrectEnabled - && !mInputAttributes.mInputTypeNoAutoCorrect; + final boolean shouldAutoCorrect = mCurrentSettings.isCorrectionOn(); if (shouldAutoCorrect && primaryCode != Keyboard.CODE_SINGLE_QUOTE) { commitCurrentAutoCorrection(primaryCode); didAutoCorrect = true; @@ -1914,14 +1913,11 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mConnection.commitText(SuggestionSpanUtils.getTextWithSuggestionSpan( this, chosenWord, suggestedWords, mIsMainDictionaryAvailable), 1); - if (ProductionFlag.IS_EXPERIMENTAL) { - ResearchLogger.latinIME_commitText(chosenWord); - } } else { mConnection.commitText(chosenWord, 1); - if (ProductionFlag.IS_EXPERIMENTAL) { - ResearchLogger.latinIME_commitText(chosenWord); - } + } + if (ProductionFlag.IS_EXPERIMENTAL) { + ResearchLogger.latinIME_commitText(chosenWord); } // Add the word to the user history dictionary final CharSequence prevWord = addToUserHistoryDictionary(chosenWord); @@ -1975,10 +1971,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // 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.mCorrectionMode == Suggest.CORRECTION_FULL - || mCurrentSettings.mCorrectionMode == Suggest.CORRECTION_FULL_BIGRAM)) { - return null; - } + if (!mCurrentSettings.isCorrectionOn()) return null; if (mUserHistoryDictionary != null) { final CharSequence prevWord @@ -2075,32 +2068,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mHandler.postUpdateSuggestions(); } - private boolean revertSwapPunctuation() { - // Here we test whether we indeed have a space and something else before us. This should not - // be needed, but it's there just in case something went wrong. - final CharSequence textBeforeCursor = mConnection.getTextBeforeCursor(2, 0); - // NOTE: This does not work with surrogate pairs. Hopefully when the keyboard is able to - // enter surrogate pairs this code will have been removed. - if (TextUtils.isEmpty(textBeforeCursor) - || (Keyboard.CODE_SPACE != textBeforeCursor.charAt(1))) { - // We may only come here if the application is changing the text while we are typing. - // This is quite a broken case, but not logically impossible, so we shouldn't crash, - // but some debugging log may be in order. - Log.d(TAG, "Tried to revert a swap of punctuation but we didn't " - + "find a space just before the cursor."); - return false; - } - mConnection.deleteSurroundingText(2, 0); - if (ProductionFlag.IS_EXPERIMENTAL) { - ResearchLogger.latinIME_deleteSurroundingText(2); - } - mConnection.commitText(" " + textBeforeCursor.subSequence(0, 1), 1); - if (ProductionFlag.IS_EXPERIMENTAL) { - ResearchLogger.latinIME_revertSwapPunctuation(); - } - return true; - } - public boolean isWordSeparator(int code) { return mCurrentSettings.isWordSeparator(code); } @@ -2260,7 +2227,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen p.println(" mIsSuggestionsRequested=" + mInputAttributes.mIsSettingsSuggestionStripOn); p.println(" mCorrectionMode=" + mCurrentSettings.mCorrectionMode); p.println(" isComposingWord=" + mWordComposer.isComposingWord()); - p.println(" mAutoCorrectEnabled=" + mCurrentSettings.mAutoCorrectEnabled); + p.println(" isCorrectionOn=" + mCurrentSettings.isCorrectionOn()); p.println(" mSoundOn=" + mCurrentSettings.mSoundOn); p.println(" mVibrateOn=" + mCurrentSettings.mVibrateOn); p.println(" mKeyPreviewPopupOn=" + mCurrentSettings.mKeyPreviewPopupOn); |