diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 105 |
1 files changed, 28 insertions, 77 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 777881ca1..036873cd9 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -60,7 +60,6 @@ import com.android.inputmethod.compat.SuggestionSpanUtils; import com.android.inputmethod.compat.VibratorCompatWrapper; import com.android.inputmethod.deprecated.LanguageSwitcherProxy; import com.android.inputmethod.deprecated.VoiceProxy; -import com.android.inputmethod.deprecated.recorrection.Recorrection; import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.KeyboardActionListener; @@ -168,7 +167,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar private KeyboardSwitcher mKeyboardSwitcher; private SubtypeSwitcher mSubtypeSwitcher; private VoiceProxy mVoiceProxy; - private Recorrection mRecorrection; private UserDictionary mUserDictionary; private UserBigramDictionary mUserBigramDictionary; @@ -229,14 +227,13 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar public static class UIHandler extends StaticInnerHandlerWrapper<LatinIME> { private static final int MSG_UPDATE_SUGGESTIONS = 0; - private static final int MSG_UPDATE_OLD_SUGGESTIONS = 1; - private static final int MSG_UPDATE_SHIFT_STATE = 2; - private static final int MSG_VOICE_RESULTS = 3; - private static final int MSG_FADEOUT_LANGUAGE_ON_SPACEBAR = 4; - private static final int MSG_DISMISS_LANGUAGE_ON_SPACEBAR = 5; - private static final int MSG_SPACE_TYPED = 6; - private static final int MSG_SET_BIGRAM_PREDICTIONS = 7; - private static final int MSG_PENDING_IMS_CALLBACK = 8; + private static final int MSG_UPDATE_SHIFT_STATE = 1; + private static final int MSG_VOICE_RESULTS = 2; + private static final int MSG_FADEOUT_LANGUAGE_ON_SPACEBAR = 3; + private static final int MSG_DISMISS_LANGUAGE_ON_SPACEBAR = 4; + private static final int MSG_SPACE_TYPED = 5; + private static final int MSG_SET_BIGRAM_PREDICTIONS = 6; + private static final int MSG_PENDING_IMS_CALLBACK = 7; public UIHandler(LatinIME outerInstance) { super(outerInstance); @@ -251,13 +248,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar case MSG_UPDATE_SUGGESTIONS: latinIme.updateSuggestions(); break; - case MSG_UPDATE_OLD_SUGGESTIONS: - latinIme.mRecorrection.fetchAndDisplayRecorrectionSuggestions( - latinIme.mVoiceProxy, latinIme.mSuggestionsView, - latinIme.mSuggest, latinIme.mKeyboardSwitcher, latinIme.mWordComposer, - latinIme.mHasUncommittedTypedChars, latinIme.mLastSelectionStart, - latinIme.mLastSelectionEnd, latinIme.mSettingsValues.mWordSeparators); - break; case MSG_UPDATE_SHIFT_STATE: switcher.updateShiftState(); break; @@ -302,16 +292,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar return hasMessages(MSG_UPDATE_SUGGESTIONS); } - public void postUpdateOldSuggestions() { - removeMessages(MSG_UPDATE_OLD_SUGGESTIONS); - sendMessageDelayed(obtainMessage(MSG_UPDATE_OLD_SUGGESTIONS), - getOuterInstance().mSettingsValues.mDelayUpdateOldSuggestions); - } - - public void cancelUpdateOldSuggestions() { - removeMessages(MSG_UPDATE_OLD_SUGGESTIONS); - } - public void postUpdateShiftKeyState() { removeMessages(MSG_UPDATE_SHIFT_STATE); sendMessageDelayed(obtainMessage(MSG_UPDATE_SHIFT_STATE), @@ -470,7 +450,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar InputMethodManagerCompatWrapper.init(this); SubtypeSwitcher.init(this); KeyboardSwitcher.init(this, prefs); - Recorrection.init(this, prefs); AccessibilityUtils.init(this, prefs); super.onCreate(); @@ -479,7 +458,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar mInputMethodId = Utils.getInputMethodId(mImm, getPackageName()); mSubtypeSwitcher = SubtypeSwitcher.getInstance(); mKeyboardSwitcher = KeyboardSwitcher.getInstance(); - mRecorrection = Recorrection.getInstance(); mVibrator = VibratorCompatWrapper.getInstance(this); DEBUG = LatinImeLogger.sDBG; @@ -758,8 +736,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar inputView.setKeyPreviewPopupEnabled(mSettingsValues.mKeyPreviewPopupOn, mSettingsValues.mKeyPreviewPopupDismissDelay); inputView.setProximityCorrectionEnabled(true); - // If we just entered a text field, maybe it has some old text that requires correction - mRecorrection.checkRecorrectionOnStart(); voiceIme.onStartInputView(inputView.getWindowToken()); @@ -848,7 +824,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar if (inputView != null) inputView.cancelAllMessages(); // Remove pending messages related to update suggestions mHandler.cancelUpdateSuggestions(); - mHandler.cancelUpdateOldSuggestions(); } @Override @@ -882,35 +857,23 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar final boolean selectionChanged = (newSelStart != candidatesEnd || newSelEnd != candidatesEnd) && mLastSelectionStart != newSelStart; final boolean candidatesCleared = candidatesStart == -1 && candidatesEnd == -1; - if (!mExpectingUpdateSelection - && ((mComposingStringBuilder.length() > 0 && mHasUncommittedTypedChars) - || mVoiceProxy.isVoiceInputHighlighted()) - && (selectionChanged || candidatesCleared)) { - if (candidatesCleared) { - // If the composing span has been cleared, save the typed word in the history for - // recorrection before we reset the suggestions strip. Then, we'll be able to show - // suggestions for recorrection right away. - mRecorrection.saveRecorrectionSuggestion(mWordComposer, mComposingStringBuilder); - } - mComposingStringBuilder.setLength(0); - mHasUncommittedTypedChars = false; - if (isCursorTouchingWord()) { - mHandler.cancelUpdateBigramPredictions(); - mHandler.postUpdateSuggestions(); - } else { - setPunctuationSuggestions(); - } - TextEntryState.reset(); - final InputConnection ic = getCurrentInputConnection(); - if (ic != null) { - ic.finishComposingText(); - } - mVoiceProxy.setVoiceInputHighlighted(false); - } else if (!mHasUncommittedTypedChars && !mExpectingUpdateSelection - && TextEntryState.isAcceptedDefault()) { - TextEntryState.reset(); - } if (!mExpectingUpdateSelection) { + if (((mComposingStringBuilder.length() > 0 && mHasUncommittedTypedChars) + || mVoiceProxy.isVoiceInputHighlighted()) + && (selectionChanged || candidatesCleared)) { + mComposingStringBuilder.setLength(0); + mHasUncommittedTypedChars = false; + TextEntryState.reset(); + updateSuggestions(); + final InputConnection ic = getCurrentInputConnection(); + if (ic != null) { + ic.finishComposingText(); + } + mVoiceProxy.setVoiceInputHighlighted(false); + } else if (!mHasUncommittedTypedChars) { + TextEntryState.reset(); + updateSuggestions(); + } mJustAddedMagicSpace = false; // The user moved the cursor. mJustReplacedDoubleSpace = false; } @@ -920,11 +883,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar // Make a note of the cursor position mLastSelectionStart = newSelStart; mLastSelectionEnd = newSelEnd; - - mRecorrection.updateRecorrectionSelection(mKeyboardSwitcher, - mSuggestionsView, candidatesStart, candidatesEnd, newSelStart, - newSelEnd, oldSelStart, mLastSelectionStart, - mLastSelectionEnd, mHasUncommittedTypedChars); } public void setLastSelection(int start, int end) { @@ -942,7 +900,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar */ @Override public void onExtractedTextClicked() { - if (mRecorrection.isRecorrectionEnabled() && isSuggestionsRequested()) return; + if (isSuggestionsRequested()) return; super.onExtractedTextClicked(); } @@ -958,7 +916,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar */ @Override public void onExtractedCursorMovement(int dx, int dy) { - if (mRecorrection.isRecorrectionEnabled() && isSuggestionsRequested()) return; + if (isSuggestionsRequested()) return; super.onExtractedCursorMovement(dx, dy); } @@ -974,7 +932,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar mOptionsDialog = null; } mVoiceProxy.hideVoiceWindow(mConfigurationChanging); - mRecorrection.clearWordsInHistory(); super.hideWindow(); } @@ -1330,7 +1287,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar mVoiceProxy.commitVoiceInput(); final InputConnection ic = getCurrentInputConnection(); if (ic == null) return; - mRecorrection.abortRecorrection(false); ic.beginBatchEdit(); commitTyped(ic); maybeRemovePreviousPeriod(ic, text); @@ -1446,17 +1402,12 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar removeTrailingSpace(); } - if (mLastSelectionStart == mLastSelectionEnd) { - mRecorrection.abortRecorrection(false); - } - int code = primaryCode; if ((isAlphabet(code) || mSettingsValues.isSymbolExcludedFromWordSeparators(code)) && isSuggestionsRequested() && !isCursorTouchingWord()) { if (!mHasUncommittedTypedChars) { mHasUncommittedTypedChars = true; mComposingStringBuilder.setLength(0); - mRecorrection.saveRecorrectionSuggestion(mWordComposer, mBestWord); mWordComposer.reset(); clearSuggestions(); } @@ -1522,7 +1473,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar final InputConnection ic = getCurrentInputConnection(); if (ic != null) { ic.beginBatchEdit(); - mRecorrection.abortRecorrection(false); } if (mHasUncommittedTypedChars) { // In certain languages where single quote is a separator, it's better @@ -1568,7 +1518,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar if (Keyboard.CODE_SPACE == primaryCode) { if (!isCursorTouchingWord()) { mHandler.cancelUpdateSuggestions(); - mHandler.cancelUpdateOldSuggestions(); mHandler.postUpdateBigramPredictions(); } } else { @@ -1655,6 +1604,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar return; } + mHandler.cancelUpdateSuggestions(); + mHandler.cancelUpdateBigramPredictions(); + if (!mHasUncommittedTypedChars) { setPunctuationSuggestions(); return; @@ -1887,7 +1839,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar ic.commitText(bestWord, 1); } } - mRecorrection.saveRecorrectionSuggestion(mWordComposer, bestWord); mHasUncommittedTypedChars = false; mCommittedLength = bestWord.length(); } |