am 0675d374: am 86f77114: Merge "Don\'t auto-correct to non-whitelist shortcuts"

* commit '0675d37487f8f2ec92b0984b3ff28a5cd1d7a07e':
  Don't auto-correct to non-whitelist shortcuts
main
Jean Chalard 2013-10-09 20:59:45 -07:00 committed by Android Git Automerger
commit ea3a2f28ab
2 changed files with 5 additions and 3 deletions

View File

@ -286,14 +286,16 @@ public final class Suggest {
// the word *would* have been auto-corrected. // the word *would* have been auto-corrected.
if (!isCorrectionEnabled || !allowsToBeAutoCorrected || !wordComposer.isComposingWord() if (!isCorrectionEnabled || !allowsToBeAutoCorrected || !wordComposer.isComposingWord()
|| suggestionsSet.isEmpty() || wordComposer.hasDigits() || suggestionsSet.isEmpty() || wordComposer.hasDigits()
|| wordComposer.isMostlyCaps() || wordComposer.isResumed() || wordComposer.isMostlyCaps() || wordComposer.isResumed() || !hasMainDictionary()
|| !hasMainDictionary()) { || SuggestedWordInfo.KIND_SHORTCUT == suggestionsSet.first().mKind) {
// If we don't have a main dictionary, we never want to auto-correct. The reason for // If we don't have a main dictionary, we never want to auto-correct. The reason for
// this is, the user may have a contact whose name happens to match a valid word in // this is, the user may have a contact whose name happens to match a valid word in
// their language, and it will unexpectedly auto-correct. For example, if the user // their language, and it will unexpectedly auto-correct. For example, if the user
// types in English with no dictionary and has a "Will" in their contact list, "will" // types in English with no dictionary and has a "Will" in their contact list, "will"
// would always auto-correct to "Will" which is unwanted. Hence, no main dict => no // would always auto-correct to "Will" which is unwanted. Hence, no main dict => no
// auto-correct. // auto-correct.
// Also, shortcuts should never auto-correct unless they are whitelist entries.
// TODO: we may want to have shortcut-only entries auto-correct in the future.
hasAutoCorrection = false; hasAutoCorrection = false;
} else { } else {
hasAutoCorrection = AutoCorrectionUtils.suggestionExceedsAutoCorrectionThreshold( hasAutoCorrection = AutoCorrectionUtils.suggestionExceedsAutoCorrectionThreshold(

View File

@ -44,7 +44,7 @@ class ShortcutUtils {
shortcutScore = finalScore; shortcutScore = finalScore;
// Protection against int underflow // Protection against int underflow
shortcutScore = max(S_INT_MIN + 1, shortcutScore) - 1; shortcutScore = max(S_INT_MIN + 1, shortcutScore) - 1;
kind = Dictionary::KIND_CORRECTION; kind = Dictionary::KIND_SHORTCUT;
} }
outputTypes[outputWordIndex] = kind; outputTypes[outputWordIndex] = kind;
frequencies[outputWordIndex] = shortcutScore; frequencies[outputWordIndex] = shortcutScore;