Stop a flag from escaping.
The ultimate intent is to close it up in the settings, as it does not change while typing, only when the keyboard is open again. Change-Id: I12ff56e7482c1584877fe5531473bf03e95a60f6main
parent
a76c62e92d
commit
4606de117b
|
@ -1791,8 +1791,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
prevWord = EditingUtils.getPreviousWord(ic, mSettingsValues.mWordSeparators);
|
||||
}
|
||||
// getSuggestedWordBuilder handles gracefully a null value of prevWord
|
||||
final SuggestedWords.Builder builder = mSuggest.getSuggestedWordBuilder(
|
||||
wordComposer, prevWord, mKeyboardSwitcher.getLatinKeyboard().getProximityInfo());
|
||||
final SuggestedWords.Builder builder = mSuggest.getSuggestedWordBuilder(wordComposer,
|
||||
prevWord, mKeyboardSwitcher.getLatinKeyboard().getProximityInfo(), mCorrectionMode);
|
||||
|
||||
boolean autoCorrectionAvailable = !mInputTypeNoAutoCorrect && mSuggest.hasAutoCorrection();
|
||||
final CharSequence typedWord = wordComposer.getTypedWord();
|
||||
|
@ -2035,7 +2035,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
final CharSequence prevWord = EditingUtils.getThisWord(getCurrentInputConnection(),
|
||||
mSettingsValues.mWordSeparators);
|
||||
SuggestedWords.Builder builder = mSuggest.getSuggestedWordBuilder(sEmptyWordComposer,
|
||||
prevWord, mKeyboardSwitcher.getLatinKeyboard().getProximityInfo());
|
||||
prevWord, mKeyboardSwitcher.getLatinKeyboard().getProximityInfo(), mCorrectionMode);
|
||||
|
||||
if (builder.size() > 0) {
|
||||
// Explicitly supply an empty typed word (the no-second-arg version of
|
||||
|
@ -2399,9 +2399,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
mCorrectionMode = shouldAutoCorrect ? Suggest.CORRECTION_FULL : Suggest.CORRECTION_NONE;
|
||||
mCorrectionMode = (mSettingsValues.mBigramSuggestionEnabled && shouldAutoCorrect)
|
||||
? Suggest.CORRECTION_FULL_BIGRAM : mCorrectionMode;
|
||||
if (mSuggest != null) {
|
||||
mSuggest.setCorrectionMode(mCorrectionMode);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSuggestionVisibility(final SharedPreferences prefs, final Resources res) {
|
||||
|
|
|
@ -43,9 +43,8 @@ public class Suggest implements Dictionary.WordCallback {
|
|||
public static final int APPROX_MAX_WORD_LENGTH = 32;
|
||||
|
||||
public static final int CORRECTION_NONE = 0;
|
||||
public static final int CORRECTION_BASIC = 1;
|
||||
public static final int CORRECTION_FULL = 2;
|
||||
public static final int CORRECTION_FULL_BIGRAM = 3;
|
||||
public static final int CORRECTION_FULL = 1;
|
||||
public static final int CORRECTION_FULL_BIGRAM = 2;
|
||||
|
||||
/**
|
||||
* Words that appear in both bigram and unigram data gets multiplier ranging from
|
||||
|
@ -109,8 +108,6 @@ public class Suggest implements Dictionary.WordCallback {
|
|||
private boolean mIsAllUpperCase;
|
||||
private int mTrailingSingleQuotesCount;
|
||||
|
||||
private int mCorrectionMode = CORRECTION_BASIC;
|
||||
|
||||
public Suggest(final Context context, final int dictionaryResId, final Locale locale) {
|
||||
initAsynchronously(context, dictionaryResId, locale);
|
||||
}
|
||||
|
@ -171,10 +168,6 @@ public class Suggest implements Dictionary.WordCallback {
|
|||
}.start();
|
||||
}
|
||||
|
||||
public void setCorrectionMode(int mode) {
|
||||
mCorrectionMode = mode;
|
||||
}
|
||||
|
||||
// The main dictionary could have been loaded asynchronously. Don't cache the return value
|
||||
// of this method.
|
||||
public boolean hasMainDictionary() {
|
||||
|
@ -253,9 +246,10 @@ public class Suggest implements Dictionary.WordCallback {
|
|||
* @return suggested words object.
|
||||
*/
|
||||
public SuggestedWords getSuggestions(final WordComposer wordComposer,
|
||||
final CharSequence prevWordForBigram, final ProximityInfo proximityInfo) {
|
||||
final CharSequence prevWordForBigram, final ProximityInfo proximityInfo,
|
||||
final int correctionMode) {
|
||||
return getSuggestedWordBuilder(wordComposer, prevWordForBigram,
|
||||
proximityInfo).build();
|
||||
proximityInfo, correctionMode).build();
|
||||
}
|
||||
|
||||
private CharSequence capitalizeWord(boolean all, boolean first, CharSequence word) {
|
||||
|
@ -288,7 +282,7 @@ public class Suggest implements Dictionary.WordCallback {
|
|||
// TODO: cleanup dictionaries looking up and suggestions building with SuggestedWords.Builder
|
||||
public SuggestedWords.Builder getSuggestedWordBuilder(
|
||||
final WordComposer wordComposer, CharSequence prevWordForBigram,
|
||||
final ProximityInfo proximityInfo) {
|
||||
final ProximityInfo proximityInfo, final int correctionMode) {
|
||||
LatinImeLogger.onStartSuggestion(prevWordForBigram);
|
||||
mAutoCorrection.init();
|
||||
mIsFirstCharCapitalized = wordComposer.isFirstCharCapitalized();
|
||||
|
@ -308,8 +302,7 @@ public class Suggest implements Dictionary.WordCallback {
|
|||
}
|
||||
mConsideredWord = consideredWord;
|
||||
|
||||
if (wordComposer.size() <= 1 && (mCorrectionMode == CORRECTION_FULL_BIGRAM
|
||||
|| mCorrectionMode == CORRECTION_BASIC)) {
|
||||
if (wordComposer.size() <= 1 && (correctionMode == CORRECTION_FULL_BIGRAM)) {
|
||||
// At first character typed, search only the bigrams
|
||||
Arrays.fill(mBigramScores, 0);
|
||||
collectGarbage(mBigramSuggestions, PREF_MAX_BIGRAMS);
|
||||
|
@ -373,7 +366,7 @@ public class Suggest implements Dictionary.WordCallback {
|
|||
mWhiteListDictionary.getWhitelistedWord(consideredWordString));
|
||||
|
||||
mAutoCorrection.updateAutoCorrectionStatus(mUnigramDictionaries, wordComposer,
|
||||
mSuggestions, mScores, consideredWord, mAutoCorrectionThreshold, mCorrectionMode,
|
||||
mSuggestions, mScores, consideredWord, mAutoCorrectionThreshold, correctionMode,
|
||||
whitelistedWord);
|
||||
|
||||
if (whitelistedWord != null) {
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.util.Locale;
|
|||
|
||||
public class SuggestHelper {
|
||||
protected final Suggest mSuggest;
|
||||
protected int mCorrectionMode;
|
||||
protected final LatinKeyboard mKeyboard;
|
||||
private final KeyDetector mKeyDetector;
|
||||
|
||||
|
@ -50,14 +51,14 @@ public class SuggestHelper {
|
|||
}
|
||||
|
||||
private void init() {
|
||||
mSuggest.setCorrectionMode(Suggest.CORRECTION_FULL);
|
||||
setCorrectionMode(Suggest.CORRECTION_FULL);
|
||||
mKeyDetector.setKeyboard(mKeyboard, 0, 0);
|
||||
mKeyDetector.setProximityCorrectionEnabled(true);
|
||||
mKeyDetector.setProximityThreshold(mKeyboard.mMostCommonKeyWidth);
|
||||
}
|
||||
|
||||
public void setCorrectionMode(int correctionMode) {
|
||||
mSuggest.setCorrectionMode(correctionMode);
|
||||
mCorrectionMode = correctionMode;
|
||||
}
|
||||
|
||||
public boolean hasMainDictionary() {
|
||||
|
@ -78,13 +79,13 @@ public class SuggestHelper {
|
|||
// TODO: This may be slow, but is OK for test so far.
|
||||
public SuggestedWords getSuggestions(CharSequence typed) {
|
||||
return mSuggest.getSuggestions(createWordComposer(typed), null,
|
||||
mKeyboard.getProximityInfo());
|
||||
mKeyboard.getProximityInfo(), mCorrectionMode);
|
||||
}
|
||||
|
||||
public CharSequence getFirstSuggestion(CharSequence typed) {
|
||||
WordComposer word = createWordComposer(typed);
|
||||
SuggestedWords suggestions = mSuggest.getSuggestions(word, null,
|
||||
mKeyboard.getProximityInfo());
|
||||
mKeyboard.getProximityInfo(), mCorrectionMode);
|
||||
// Note that suggestions.getWord(0) is the word user typed.
|
||||
return suggestions.size() > 1 ? suggestions.getWord(1) : null;
|
||||
}
|
||||
|
@ -92,7 +93,7 @@ public class SuggestHelper {
|
|||
public CharSequence getAutoCorrection(CharSequence typed) {
|
||||
WordComposer word = createWordComposer(typed);
|
||||
SuggestedWords suggestions = mSuggest.getSuggestions(word, null,
|
||||
mKeyboard.getProximityInfo());
|
||||
mKeyboard.getProximityInfo(), mCorrectionMode);
|
||||
// Note that suggestions.getWord(0) is the word user typed.
|
||||
return (suggestions.size() > 1 && mSuggest.hasAutoCorrection())
|
||||
? suggestions.getWord(1) : null;
|
||||
|
@ -101,7 +102,7 @@ public class SuggestHelper {
|
|||
public int getSuggestIndex(CharSequence typed, CharSequence expected) {
|
||||
WordComposer word = createWordComposer(typed);
|
||||
SuggestedWords suggestions = mSuggest.getSuggestions(word, null,
|
||||
mKeyboard.getProximityInfo());
|
||||
mKeyboard.getProximityInfo(), mCorrectionMode);
|
||||
// Note that suggestions.getWord(0) is the word user typed.
|
||||
for (int i = 1; i < suggestions.size(); i++) {
|
||||
if (TextUtils.equals(suggestions.getWord(i), expected))
|
||||
|
@ -113,7 +114,8 @@ 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(firstChar, previous, mKeyboard.getProximityInfo());
|
||||
mSuggest.getSuggestions(firstChar, previous, mKeyboard.getProximityInfo(),
|
||||
mCorrectionMode);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,7 +123,7 @@ public class SuggestHelper {
|
|||
WordComposer word = createWordComposer(typed);
|
||||
getBigramSuggestions(previous, typed);
|
||||
SuggestedWords suggestions = mSuggest.getSuggestions(word, previous,
|
||||
mKeyboard.getProximityInfo());
|
||||
mKeyboard.getProximityInfo(), mCorrectionMode);
|
||||
return suggestions.size() > 1 ? suggestions.getWord(1) : null;
|
||||
}
|
||||
|
||||
|
@ -129,7 +131,7 @@ public class SuggestHelper {
|
|||
WordComposer word = createWordComposer(typed);
|
||||
getBigramSuggestions(previous, typed);
|
||||
SuggestedWords suggestions = mSuggest.getSuggestions(word, previous,
|
||||
mKeyboard.getProximityInfo());
|
||||
mKeyboard.getProximityInfo(), mCorrectionMode);
|
||||
return (suggestions.size() > 1 && mSuggest.hasAutoCorrection())
|
||||
? suggestions.getWord(1) : null;
|
||||
}
|
||||
|
@ -139,7 +141,7 @@ public class SuggestHelper {
|
|||
WordComposer word = createWordComposer(typed);
|
||||
getBigramSuggestions(previous, typed);
|
||||
SuggestedWords suggestions = mSuggest.getSuggestions(word, previous,
|
||||
mKeyboard.getProximityInfo());
|
||||
mKeyboard.getProximityInfo(), mCorrectionMode);
|
||||
for (int i = 1; i < suggestions.size(); i++) {
|
||||
if (TextUtils.equals(suggestions.getWord(i), expected))
|
||||
return i;
|
||||
|
|
|
@ -38,7 +38,7 @@ public class UserBigramSuggestHelper extends SuggestHelper {
|
|||
Suggest.DIC_USER);
|
||||
mUserBigram.setDatabaseMax(userBigramMax);
|
||||
mUserBigram.setDatabaseDelete(userBigramDelete);
|
||||
mSuggest.setCorrectionMode(Suggest.CORRECTION_FULL_BIGRAM);
|
||||
setCorrectionMode(Suggest.CORRECTION_FULL_BIGRAM);
|
||||
mSuggest.setUserBigramDictionary(mUserBigram);
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,8 @@ public class UserBigramSuggestHelper extends SuggestHelper {
|
|||
flushUserBigrams();
|
||||
if (!TextUtils.isEmpty(previous) && !TextUtils.isEmpty(Character.toString(typed))) {
|
||||
WordComposer firstChar = createWordComposer(Character.toString(typed));
|
||||
mSuggest.getSuggestions(firstChar, previous, mKeyboard.getProximityInfo());
|
||||
mSuggest.getSuggestions(firstChar, previous, mKeyboard.getProximityInfo(),
|
||||
mCorrectionMode);
|
||||
boolean reloading = mUserBigram.reloadDictionaryIfRequired();
|
||||
if (reloading) mUserBigram.waitForDictionaryLoading();
|
||||
mUserBigram.getBigrams(firstChar, previous, mSuggest);
|
||||
|
|
Loading…
Reference in New Issue