aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/LatinIME.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java133
1 files changed, 37 insertions, 96 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index dfb4d0622..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;
@@ -119,6 +118,12 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
public static final String SUBTYPE_EXTRA_VALUE_ASCII_CAPABLE = "AsciiCapable";
/**
+ * The subtype extra value used to indicate that the subtype keyboard layout supports touch
+ * position correction.
+ */
+ public static final String SUBTYPE_EXTRA_VALUE_SUPPORT_TOUCH_POSITION_CORRECTION =
+ "SupportTouchPositionCorrection";
+ /**
* The subtype extra value used to indicate that the subtype keyboard layout should be loaded
* from the specified locale.
*/
@@ -168,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;
@@ -229,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);
@@ -251,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;
@@ -302,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),
@@ -470,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();
@@ -479,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;
@@ -550,7 +534,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
if (mSettingsValues.mAutoCorrectEnabled) {
mSuggest.setAutoCorrectionThreshold(mSettingsValues.mAutoCorrectionThreshold);
}
- updateAutoTextEnabled();
mUserDictionary = new UserDictionary(this, localeStr);
mSuggest.setUserDictionary(mUserDictionary);
@@ -734,7 +717,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
loadSettings();
updateCorrectionMode();
- updateAutoTextEnabled();
updateSuggestionVisibility(mPrefs, mResources);
if (mSuggest != null && mSettingsValues.mAutoCorrectEnabled) {
@@ -760,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());
@@ -850,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
@@ -884,35 +863,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;
}
@@ -922,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) {
@@ -944,7 +906,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
*/
@Override
public void onExtractedTextClicked() {
- if (mRecorrection.isRecorrectionEnabled() && isSuggestionsRequested()) return;
+ if (isSuggestionsRequested()) return;
super.onExtractedTextClicked();
}
@@ -960,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);
}
@@ -976,7 +938,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mOptionsDialog = null;
}
mVoiceProxy.hideVoiceWindow(mConfigurationChanging);
- mRecorrection.clearWordsInHistory();
super.hideWindow();
}
@@ -1332,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);
@@ -1448,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();
}
@@ -1524,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
@@ -1570,7 +1524,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
if (Keyboard.CODE_SPACE == primaryCode) {
if (!isCursorTouchingWord()) {
mHandler.cancelUpdateSuggestions();
- mHandler.cancelUpdateOldSuggestions();
mHandler.postUpdateBigramPredictions();
}
} else {
@@ -1657,6 +1610,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
return;
}
+ mHandler.cancelUpdateSuggestions();
+ mHandler.cancelUpdateBigramPredictions();
+
if (!mHasUncommittedTypedChars) {
setPunctuationSuggestions();
return;
@@ -1673,8 +1629,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
}
// getSuggestedWordBuilder handles gracefully a null value of prevWord
final SuggestedWords.Builder builder = mSuggest.getSuggestedWordBuilder(
- mKeyboardSwitcher.getKeyboardView(), wordComposer, prevWord,
- mKeyboardSwitcher.getLatinKeyboard().getProximityInfo());
+ wordComposer, prevWord, mKeyboardSwitcher.getLatinKeyboard().getProximityInfo());
boolean autoCorrectionAvailable = !mInputTypeNoAutoCorrect && mSuggest.hasAutoCorrection();
final CharSequence typedWord = wordComposer.getTypedWord();
@@ -1890,7 +1845,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
ic.commitText(bestWord, 1);
}
}
- mRecorrection.saveRecorrectionSuggestion(mWordComposer, bestWord);
mHasUncommittedTypedChars = false;
mCommittedLength = bestWord.length();
}
@@ -1907,9 +1861,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
final CharSequence prevWord = EditingUtils.getThisWord(getCurrentInputConnection(),
mSettingsValues.mWordSeparators);
- SuggestedWords.Builder builder = mSuggest.getSuggestedWordBuilder(
- mKeyboardSwitcher.getKeyboardView(), sEmptyWordComposer, prevWord,
- mKeyboardSwitcher.getLatinKeyboard().getProximityInfo());
+ SuggestedWords.Builder builder = mSuggest.getSuggestedWordBuilder(sEmptyWordComposer,
+ prevWord, mKeyboardSwitcher.getLatinKeyboard().getProximityInfo());
if (builder.size() > 0) {
// Explicitly supply an empty typed word (the no-second-arg version of
@@ -2214,18 +2167,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
}
}
- private void updateAutoTextEnabled() {
- if (mSuggest == null) return;
- // We want to use autotext if the settings are asking for auto corrections, and if
- // the input language is the same as the system language (because autotext will only
- // work in the system language so if we are entering text in a different language we
- // do not want it on).
- // We used to look at the "quick fixes" option instead of mAutoCorrectEnabled, but
- // this option was redundant and confusing and therefore removed.
- mSuggest.setQuickFixesEnabled(mSettingsValues.mAutoCorrectEnabled
- && SubtypeSwitcher.getInstance().isSystemLanguageSameAsInputLanguage());
- }
-
private void updateSuggestionVisibility(final SharedPreferences prefs, final Resources res) {
final String suggestionVisiblityStr = prefs.getString(
Settings.PREF_SHOW_SUGGESTIONS_SETTING,