diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 78 |
1 files changed, 15 insertions, 63 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 882895f25..36e97af11 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; @@ -174,7 +173,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; @@ -235,14 +233,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); @@ -257,13 +254,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; @@ -308,16 +298,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), @@ -476,7 +456,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(); @@ -485,7 +464,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; @@ -764,8 +742,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()); @@ -854,7 +830,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 @@ -892,29 +867,18 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar if (((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(); + updateSuggestions(); final InputConnection ic = getCurrentInputConnection(); if (ic != null) { ic.finishComposingText(); } mVoiceProxy.setVoiceInputHighlighted(false); - } else if (!mHasUncommittedTypedChars && TextEntryState.isAcceptedDefault()) { + } else if (!mHasUncommittedTypedChars) { TextEntryState.reset(); + updateSuggestions(); } mJustAddedMagicSpace = false; // The user moved the cursor. mJustReplacedDoubleSpace = false; @@ -925,11 +889,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) { @@ -947,7 +906,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar */ @Override public void onExtractedTextClicked() { - if (mRecorrection.isRecorrectionEnabled() && isSuggestionsRequested()) return; + if (isSuggestionsRequested()) return; super.onExtractedTextClicked(); } @@ -963,7 +922,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); } @@ -979,7 +938,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar mOptionsDialog = null; } mVoiceProxy.hideVoiceWindow(mConfigurationChanging); - mRecorrection.clearWordsInHistory(); super.hideWindow(); } @@ -1335,7 +1293,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); @@ -1451,17 +1408,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(); } @@ -1527,7 +1479,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 @@ -1573,7 +1524,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar if (Keyboard.CODE_SPACE == primaryCode) { if (!isCursorTouchingWord()) { mHandler.cancelUpdateSuggestions(); - mHandler.cancelUpdateOldSuggestions(); mHandler.postUpdateBigramPredictions(); } } else { @@ -1660,6 +1610,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar return; } + mHandler.cancelUpdateSuggestions(); + mHandler.cancelUpdateBigramPredictions(); + if (!mHasUncommittedTypedChars) { setPunctuationSuggestions(); return; @@ -1892,7 +1845,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar ic.commitText(bestWord, 1); } } - mRecorrection.saveRecorrectionSuggestion(mWordComposer, bestWord); mHasUncommittedTypedChars = false; mCommittedLength = bestWord.length(); } |