Move some auto-correction logic to where it belongs
Change-Id: I897c5ec3a630a4a6bfc593906df4d3fc7b244482main
parent
022ef7d13b
commit
ed9986824e
|
@ -1830,19 +1830,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
// length == 1).
|
||||
if (builder.size() > 1 || typedWord.length() == 1 || !builder.allowsToBeAutoCorrected()
|
||||
|| mSuggestionsView.isShowingAddToDictionaryHint()) {
|
||||
boolean autoCorrectionAvailable = builder.hasAutoCorrection();
|
||||
if (mCorrectionMode == Suggest.CORRECTION_FULL
|
||||
|| mCorrectionMode == Suggest.CORRECTION_FULL_BIGRAM) {
|
||||
autoCorrectionAvailable |= !builder.allowsToBeAutoCorrected();
|
||||
}
|
||||
// Don't auto-correct words with multiple capital letter
|
||||
autoCorrectionAvailable &= !mWordComposer.isMostlyCaps();
|
||||
builder.setTypedWordValid(!builder.allowsToBeAutoCorrected()).setHasMinimalSuggestion(
|
||||
autoCorrectionAvailable);
|
||||
if (Suggest.shouldBlockAutoCorrectionBySafetyNet(builder, mSuggest,
|
||||
mSettingsValues.mAutoCorrectionThreshold)) {
|
||||
builder.setShouldBlockAutoCorrectionBySafetyNet();
|
||||
}
|
||||
showSuggestions(builder.build(), typedWord);
|
||||
} else {
|
||||
SuggestedWords previousSuggestions = mSuggestionsView.getSuggestions();
|
||||
|
|
|
@ -411,6 +411,7 @@ public class Suggest implements Dictionary.WordCallback {
|
|||
mSuggestions.add(0, typedWord);
|
||||
StringUtils.removeDupes(mSuggestions);
|
||||
|
||||
final SuggestedWords.Builder builder;
|
||||
if (DBG) {
|
||||
final CharSequence autoCorrectionSuggestion = mSuggestions.get(0);
|
||||
final int autoCorrectionSuggestionScore = mScores[0];
|
||||
|
@ -435,13 +436,28 @@ public class Suggest implements Dictionary.WordCallback {
|
|||
for (int i = mScores.length; i < mSuggestions.size(); ++i) {
|
||||
scoreInfoList.add(new SuggestedWords.SuggestedWordInfo("--", false));
|
||||
}
|
||||
return new SuggestedWords.Builder().addWords(mSuggestions, scoreInfoList)
|
||||
builder = new SuggestedWords.Builder().addWords(mSuggestions, scoreInfoList)
|
||||
.setAllowsToBeAutoCorrected(allowsToBeAutoCorrected)
|
||||
.setHasAutoCorrection(hasAutoCorrection);
|
||||
} else {
|
||||
builder = new SuggestedWords.Builder().addWords(mSuggestions, null)
|
||||
.setAllowsToBeAutoCorrected(allowsToBeAutoCorrected)
|
||||
.setHasAutoCorrection(hasAutoCorrection);
|
||||
}
|
||||
return new SuggestedWords.Builder().addWords(mSuggestions, null)
|
||||
.setAllowsToBeAutoCorrected(allowsToBeAutoCorrected)
|
||||
.setHasAutoCorrection(hasAutoCorrection);
|
||||
|
||||
boolean autoCorrectionAvailable = hasAutoCorrection;
|
||||
if (correctionMode == Suggest.CORRECTION_FULL
|
||||
|| correctionMode == Suggest.CORRECTION_FULL_BIGRAM) {
|
||||
autoCorrectionAvailable |= !allowsToBeAutoCorrected;
|
||||
}
|
||||
// Don't auto-correct words with multiple capital letter
|
||||
autoCorrectionAvailable &= !wordComposer.isMostlyCaps();
|
||||
builder.setTypedWordValid(!allowsToBeAutoCorrected).setHasMinimalSuggestion(
|
||||
autoCorrectionAvailable);
|
||||
if (Suggest.shouldBlockAutoCorrectionBySafetyNet(builder, this, mAutoCorrectionThreshold)) {
|
||||
builder.setShouldBlockAutoCorrectionBySafetyNet();
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue