Export some more logic out of Latin IME
Change-Id: Ib264533a05e9e09347bf254789e6ab5beec92400
This commit is contained in:
parent
df9fce5df1
commit
67af2a2415
3 changed files with 18 additions and 11 deletions
|
@ -1831,7 +1831,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
// length == 1).
|
// length == 1).
|
||||||
if (builder.size() > 1 || typedWord.length() == 1 || !builder.allowsToBeAutoCorrected()
|
if (builder.size() > 1 || typedWord.length() == 1 || !builder.allowsToBeAutoCorrected()
|
||||||
|| mSuggestionsView.isShowingAddToDictionaryHint()) {
|
|| mSuggestionsView.isShowingAddToDictionaryHint()) {
|
||||||
boolean autoCorrectionAvailable = mSuggest.hasAutoCorrection();
|
boolean autoCorrectionAvailable = builder.hasAutoCorrection();
|
||||||
if (mCorrectionMode == Suggest.CORRECTION_FULL
|
if (mCorrectionMode == Suggest.CORRECTION_FULL
|
||||||
|| mCorrectionMode == Suggest.CORRECTION_FULL_BIGRAM) {
|
|| mCorrectionMode == Suggest.CORRECTION_FULL_BIGRAM) {
|
||||||
autoCorrectionAvailable |= !builder.allowsToBeAutoCorrected();
|
autoCorrectionAvailable |= !builder.allowsToBeAutoCorrected();
|
||||||
|
|
|
@ -83,8 +83,6 @@ public class Suggest implements Dictionary.WordCallback {
|
||||||
|
|
||||||
private static final boolean DBG = LatinImeLogger.sDBG;
|
private static final boolean DBG = LatinImeLogger.sDBG;
|
||||||
|
|
||||||
private boolean mHasAutoCorrection;
|
|
||||||
|
|
||||||
private Dictionary mMainDict;
|
private Dictionary mMainDict;
|
||||||
private ContactsDictionary mContactsDict;
|
private ContactsDictionary mContactsDict;
|
||||||
private WhitelistDictionary mWhiteListDictionary;
|
private WhitelistDictionary mWhiteListDictionary;
|
||||||
|
@ -351,15 +349,16 @@ public class Suggest implements Dictionary.WordCallback {
|
||||||
CharSequence whitelistedWord = capitalizeWord(mIsAllUpperCase, mIsFirstCharCapitalized,
|
CharSequence whitelistedWord = capitalizeWord(mIsAllUpperCase, mIsFirstCharCapitalized,
|
||||||
mWhiteListDictionary.getWhitelistedWord(consideredWordString));
|
mWhiteListDictionary.getWhitelistedWord(consideredWordString));
|
||||||
|
|
||||||
|
final boolean hasAutoCorrection;
|
||||||
if (CORRECTION_FULL == correctionMode
|
if (CORRECTION_FULL == correctionMode
|
||||||
|| CORRECTION_FULL_BIGRAM == correctionMode) {
|
|| CORRECTION_FULL_BIGRAM == correctionMode) {
|
||||||
final CharSequence autoCorrection =
|
final CharSequence autoCorrection =
|
||||||
AutoCorrection.computeAutoCorrectionWord(mUnigramDictionaries, wordComposer,
|
AutoCorrection.computeAutoCorrectionWord(mUnigramDictionaries, wordComposer,
|
||||||
mSuggestions, mScores, consideredWord, mAutoCorrectionThreshold,
|
mSuggestions, mScores, consideredWord, mAutoCorrectionThreshold,
|
||||||
whitelistedWord);
|
whitelistedWord);
|
||||||
mHasAutoCorrection = (null != autoCorrection);
|
hasAutoCorrection = (null != autoCorrection);
|
||||||
} else {
|
} else {
|
||||||
mHasAutoCorrection = false;
|
hasAutoCorrection = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (whitelistedWord != null) {
|
if (whitelistedWord != null) {
|
||||||
|
@ -402,14 +401,12 @@ public class Suggest implements Dictionary.WordCallback {
|
||||||
scoreInfoList.add(new SuggestedWords.SuggestedWordInfo("--", false));
|
scoreInfoList.add(new SuggestedWords.SuggestedWordInfo("--", false));
|
||||||
}
|
}
|
||||||
return new SuggestedWords.Builder().addWords(mSuggestions, scoreInfoList)
|
return new SuggestedWords.Builder().addWords(mSuggestions, scoreInfoList)
|
||||||
.setAllowsToBeAutoCorrected(allowsToBeAutoCorrected);
|
.setAllowsToBeAutoCorrected(allowsToBeAutoCorrected)
|
||||||
|
.setHasAutoCorrection(hasAutoCorrection);
|
||||||
}
|
}
|
||||||
return new SuggestedWords.Builder().addWords(mSuggestions, null)
|
return new SuggestedWords.Builder().addWords(mSuggestions, null)
|
||||||
.setAllowsToBeAutoCorrected(allowsToBeAutoCorrected);
|
.setAllowsToBeAutoCorrected(allowsToBeAutoCorrected)
|
||||||
}
|
.setHasAutoCorrection(hasAutoCorrection);
|
||||||
|
|
||||||
public boolean hasAutoCorrection() {
|
|
||||||
return mHasAutoCorrection;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -91,6 +91,7 @@ public class SuggestedWords {
|
||||||
private boolean mIsPunctuationSuggestions;
|
private boolean mIsPunctuationSuggestions;
|
||||||
private boolean mShouldBlockAutoCorrectionBySafetyNet;
|
private boolean mShouldBlockAutoCorrectionBySafetyNet;
|
||||||
private boolean mAllowsToBeAutoCorrected;
|
private boolean mAllowsToBeAutoCorrected;
|
||||||
|
private boolean mHasAutoCorrection;
|
||||||
private List<SuggestedWordInfo> mSuggestedWordInfoList =
|
private List<SuggestedWordInfo> mSuggestedWordInfoList =
|
||||||
new ArrayList<SuggestedWordInfo>();
|
new ArrayList<SuggestedWordInfo>();
|
||||||
|
|
||||||
|
@ -165,6 +166,11 @@ public class SuggestedWords {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder setHasAutoCorrection(final boolean hasAutoCorrection) {
|
||||||
|
mHasAutoCorrection = hasAutoCorrection;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
// Should get rid of the first one (what the user typed previously) from suggestions
|
// Should get rid of the first one (what the user typed previously) from suggestions
|
||||||
// and replace it with what the user currently typed.
|
// and replace it with what the user currently typed.
|
||||||
public Builder addTypedWordAndPreviousSuggestions(CharSequence typedWord,
|
public Builder addTypedWordAndPreviousSuggestions(CharSequence typedWord,
|
||||||
|
@ -210,6 +216,10 @@ public class SuggestedWords {
|
||||||
return mAllowsToBeAutoCorrected;
|
return mAllowsToBeAutoCorrected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasAutoCorrection() {
|
||||||
|
return mHasAutoCorrection;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
// Pretty-print method to help debug
|
// Pretty-print method to help debug
|
||||||
|
|
Loading…
Reference in a new issue