Remove code related to AutoText

Bug: 5245751

Change-Id: Ic02f951e8e1dbde9d8964d2c16e4928fb374ca41
main
satok 2011-10-03 14:28:40 +09:00
parent 0aa9595773
commit 904baab25a
6 changed files with 20 additions and 72 deletions

View File

@ -57,7 +57,7 @@ public class RecorrectionSuggestionEntries {
private static SuggestedWords.Builder getTypedSuggestions(
Suggest suggest, KeyboardSwitcher keyboardSwitcher, WordComposer word) {
return suggest.getSuggestedWordBuilder(keyboardSwitcher.getKeyboardView(), word, null,
return suggest.getSuggestedWordBuilder(word, null,
keyboardSwitcher.getLatinKeyboard().getProximityInfo());
}
}

View File

@ -50,7 +50,7 @@ public class AutoCorrection {
public void updateAutoCorrectionStatus(Map<String, Dictionary> dictionaries,
WordComposer wordComposer, ArrayList<CharSequence> suggestions, int[] sortedScores,
CharSequence typedWord, double autoCorrectionThreshold, int correctionMode,
CharSequence quickFixedWord, CharSequence whitelistedWord) {
CharSequence whitelistedWord) {
if (hasAutoCorrectionForWhitelistedWord(whitelistedWord)) {
mHasAutoCorrection = true;
mAutoCorrectionWord = whitelistedWord;
@ -58,9 +58,6 @@ public class AutoCorrection {
dictionaries, wordComposer, suggestions, typedWord, correctionMode)) {
mHasAutoCorrection = true;
mAutoCorrectionWord = typedWord;
} else if (hasAutoCorrectionForQuickFix(quickFixedWord)) {
mHasAutoCorrection = true;
mAutoCorrectionWord = quickFixedWord;
} else if (hasAutoCorrectionForBinaryDictionary(wordComposer, suggestions, correctionMode,
sortedScores, typedWord, autoCorrectionThreshold)) {
mHasAutoCorrection = true;
@ -109,10 +106,6 @@ public class AutoCorrection {
|| correctionMode == Suggest.CORRECTION_FULL_BIGRAM);
}
private static boolean hasAutoCorrectionForQuickFix(CharSequence quickFixedWord) {
return quickFixedWord != null;
}
private boolean hasAutoCorrectionForBinaryDictionary(WordComposer wordComposer,
ArrayList<CharSequence> suggestions, int correctionMode, int[] sortedScores,
CharSequence typedWord, double autoCorrectionThreshold) {

View File

@ -550,7 +550,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 +733,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
loadSettings();
updateCorrectionMode();
updateAutoTextEnabled();
updateSuggestionVisibility(mPrefs, mResources);
if (mSuggest != null && mSettingsValues.mAutoCorrectEnabled) {
@ -1673,8 +1671,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();
@ -1907,9 +1904,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 +2210,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,

View File

@ -17,10 +17,8 @@
package com.android.inputmethod.latin;
import android.content.Context;
import android.text.AutoText;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import com.android.inputmethod.keyboard.ProximityInfo;
@ -97,8 +95,6 @@ public class Suggest implements Dictionary.WordCallback {
private static final int PREF_MAX_BIGRAMS = 60;
private boolean mQuickFixesEnabled;
private double mAutoCorrectionThreshold;
private int[] mScores = new int[mPrefMaxSuggestions];
private int[] mBigramScores = new int[PREF_MAX_BIGRAMS];
@ -160,6 +156,7 @@ public class Suggest implements Dictionary.WordCallback {
final Locale locale) {
mMainDict = null;
new Thread("InitializeBinaryDictionary") {
@Override
public void run() {
final Dictionary newMainDict = DictionaryFactory.createDictionaryFromManager(
context, locale, dictionaryResId);
@ -170,11 +167,6 @@ public class Suggest implements Dictionary.WordCallback {
}.start();
}
public void setQuickFixesEnabled(boolean enabled) {
mQuickFixesEnabled = enabled;
}
public int getCorrectionMode() {
return mCorrectionMode;
}
@ -256,14 +248,13 @@ public class Suggest implements Dictionary.WordCallback {
/**
* Returns a object which represents suggested words that match the list of character codes
* passed in. This object contents will be overwritten the next time this function is called.
* @param view a view for retrieving the context for AutoText
* @param wordComposer contains what is currently being typed
* @param prevWordForBigram previous word (used only for bigram)
* @return suggested words object.
*/
public SuggestedWords getSuggestions(final View view, final WordComposer wordComposer,
public SuggestedWords getSuggestions(final WordComposer wordComposer,
final CharSequence prevWordForBigram, final ProximityInfo proximityInfo) {
return getSuggestedWordBuilder(view, wordComposer, prevWordForBigram,
return getSuggestedWordBuilder(wordComposer, prevWordForBigram,
proximityInfo).build();
}
@ -295,7 +286,7 @@ public class Suggest implements Dictionary.WordCallback {
}
// TODO: cleanup dictionaries looking up and suggestions building with SuggestedWords.Builder
public SuggestedWords.Builder getSuggestedWordBuilder(final View view,
public SuggestedWords.Builder getSuggestedWordBuilder(
final WordComposer wordComposer, CharSequence prevWordForBigram,
final ProximityInfo proximityInfo) {
LatinImeLogger.onStartSuggestion(prevWordForBigram);
@ -336,6 +327,7 @@ public class Suggest implements Dictionary.WordCallback {
}
} else {
// Word entered: return only bigrams that match the first char of the typed word
@SuppressWarnings("null")
final char currentChar = typedWord.charAt(0);
// TODO: Must pay attention to locale when changing case.
final char currentCharUpper = Character.toUpperCase(currentChar);
@ -363,34 +355,14 @@ public class Suggest implements Dictionary.WordCallback {
dictionary.getWords(wordComposer, this, proximityInfo);
}
}
CharSequence autoText = null;
final String typedWordString = typedWord == null ? null : typedWord.toString();
if (typedWord != null) {
// Apply quick fix only for the typed word.
if (mQuickFixesEnabled) {
final String lowerCaseTypedWord = typedWordString.toLowerCase();
// Is there an AutoText (also known as Quick Fixes) correction?
// Capitalize as needed
autoText = capitalizeWord(mIsAllUpperCase, mIsFirstCharCapitalized, AutoText.get(
lowerCaseTypedWord, 0, lowerCaseTypedWord.length(), view));
if (DBG) {
if (autoText != null) {
Log.d(TAG, "Auto corrected by AUTOTEXT: " + typedWord + " -> " + autoText);
}
}
}
}
CharSequence whitelistedWord = capitalizeWord(mIsAllUpperCase, mIsFirstCharCapitalized,
mWhiteListDictionary.getWhiteListedWord(typedWordString));
mAutoCorrection.updateAutoCorrectionStatus(mUnigramDictionaries, wordComposer,
mSuggestions, mScores, typedWord, mAutoCorrectionThreshold, mCorrectionMode,
autoText, whitelistedWord);
if (autoText != null) {
mSuggestions.add(0, autoText);
}
whitelistedWord);
if (whitelistedWord != null) {
mSuggestions.add(0, whitelistedWord);

View File

@ -49,7 +49,6 @@ public class SuggestHelper {
}
private void init() {
mSuggest.setQuickFixesEnabled(false);
mSuggest.setCorrectionMode(Suggest.CORRECTION_FULL);
mKeyDetector.setKeyboard(mKeyboard, 0, 0);
mKeyDetector.setProximityCorrectionEnabled(true);
@ -94,13 +93,13 @@ public class SuggestHelper {
// TODO: This may be slow, but is OK for test so far.
public SuggestedWords getSuggestions(CharSequence typed) {
return mSuggest.getSuggestions(null, createWordComposer(typed), null,
return mSuggest.getSuggestions(createWordComposer(typed), null,
mKeyboard.getProximityInfo());
}
public CharSequence getFirstSuggestion(CharSequence typed) {
WordComposer word = createWordComposer(typed);
SuggestedWords suggestions = mSuggest.getSuggestions(null, word, null,
SuggestedWords suggestions = mSuggest.getSuggestions(word, null,
mKeyboard.getProximityInfo());
// Note that suggestions.getWord(0) is the word user typed.
return suggestions.size() > 1 ? suggestions.getWord(1) : null;
@ -108,7 +107,7 @@ public class SuggestHelper {
public CharSequence getAutoCorrection(CharSequence typed) {
WordComposer word = createWordComposer(typed);
SuggestedWords suggestions = mSuggest.getSuggestions(null, word, null,
SuggestedWords suggestions = mSuggest.getSuggestions(word, null,
mKeyboard.getProximityInfo());
// Note that suggestions.getWord(0) is the word user typed.
return (suggestions.size() > 1 && mSuggest.hasAutoCorrection())
@ -117,7 +116,7 @@ public class SuggestHelper {
public int getSuggestIndex(CharSequence typed, CharSequence expected) {
WordComposer word = createWordComposer(typed);
SuggestedWords suggestions = mSuggest.getSuggestions(null, word, null,
SuggestedWords suggestions = mSuggest.getSuggestions(word, null,
mKeyboard.getProximityInfo());
// Note that suggestions.getWord(0) is the word user typed.
for (int i = 1; i < suggestions.size(); i++) {
@ -130,14 +129,14 @@ public class SuggestHelper {
private void getBigramSuggestions(CharSequence previous, CharSequence typed) {
if (!TextUtils.isEmpty(previous) && (typed.length() > 1)) {
WordComposer firstChar = createWordComposer(Character.toString(typed.charAt(0)));
mSuggest.getSuggestions(null, firstChar, previous, mKeyboard.getProximityInfo());
mSuggest.getSuggestions(firstChar, previous, mKeyboard.getProximityInfo());
}
}
public CharSequence getBigramFirstSuggestion(CharSequence previous, CharSequence typed) {
WordComposer word = createWordComposer(typed);
getBigramSuggestions(previous, typed);
SuggestedWords suggestions = mSuggest.getSuggestions(null, word, previous,
SuggestedWords suggestions = mSuggest.getSuggestions(word, previous,
mKeyboard.getProximityInfo());
return suggestions.size() > 1 ? suggestions.getWord(1) : null;
}
@ -145,7 +144,7 @@ public class SuggestHelper {
public CharSequence getBigramAutoCorrection(CharSequence previous, CharSequence typed) {
WordComposer word = createWordComposer(typed);
getBigramSuggestions(previous, typed);
SuggestedWords suggestions = mSuggest.getSuggestions(null, word, previous,
SuggestedWords suggestions = mSuggest.getSuggestions(word, previous,
mKeyboard.getProximityInfo());
return (suggestions.size() > 1 && mSuggest.hasAutoCorrection())
? suggestions.getWord(1) : null;
@ -155,7 +154,7 @@ public class SuggestHelper {
CharSequence expected) {
WordComposer word = createWordComposer(typed);
getBigramSuggestions(previous, typed);
SuggestedWords suggestions = mSuggest.getSuggestions(null, word, previous,
SuggestedWords suggestions = mSuggest.getSuggestions(word, previous,
mKeyboard.getProximityInfo());
for (int i = 1; i < suggestions.size(); i++) {
if (TextUtils.equals(suggestions.getWord(i), expected))

View File

@ -58,7 +58,7 @@ public class UserBigramSuggestHelper extends SuggestHelper {
flushUserBigrams();
if (!TextUtils.isEmpty(previous) && !TextUtils.isEmpty(Character.toString(typed))) {
WordComposer firstChar = createWordComposer(Character.toString(typed));
mSuggest.getSuggestions(null, firstChar, previous, mKeyboard.getProximityInfo());
mSuggest.getSuggestions(firstChar, previous, mKeyboard.getProximityInfo());
boolean reloading = mUserBigram.reloadDictionaryIfRequired();
if (reloading) mUserBigram.waitForDictionaryLoading();
mUserBigram.getBigrams(firstChar, previous, mSuggest);