Extract a condition from a method
Change-Id: I6b0262fe7cb3f7a31cc19d724c301467be932640
This commit is contained in:
parent
36c1b37914
commit
151d5cb532
1 changed files with 4 additions and 11 deletions
|
@ -454,8 +454,8 @@ public class Suggest implements Dictionary.WordCallback {
|
||||||
autoCorrectionAvailable &= !wordComposer.isMostlyCaps();
|
autoCorrectionAvailable &= !wordComposer.isMostlyCaps();
|
||||||
builder.setTypedWordValid(!allowsToBeAutoCorrected).setHasMinimalSuggestion(
|
builder.setTypedWordValid(!allowsToBeAutoCorrected).setHasMinimalSuggestion(
|
||||||
autoCorrectionAvailable);
|
autoCorrectionAvailable);
|
||||||
if (Suggest.shouldBlockAutoCorrectionBySafetyNet(builder, mAutoCorrectionThreshold,
|
if (allowsToBeAutoCorrected && builder.size() > 1 && mAutoCorrectionThreshold > 0
|
||||||
!allowsToBeAutoCorrected)) {
|
&& Suggest.shouldBlockAutoCorrectionBySafetyNet(builder)) {
|
||||||
builder.setShouldBlockAutoCorrectionBySafetyNet();
|
builder.setShouldBlockAutoCorrectionBySafetyNet();
|
||||||
}
|
}
|
||||||
return builder;
|
return builder;
|
||||||
|
@ -609,18 +609,11 @@ public class Suggest implements Dictionary.WordCallback {
|
||||||
// TODO: Resolve the inconsistencies between the native auto correction algorithms and
|
// TODO: Resolve the inconsistencies between the native auto correction algorithms and
|
||||||
// this safety net
|
// this safety net
|
||||||
public static boolean shouldBlockAutoCorrectionBySafetyNet(
|
public static boolean shouldBlockAutoCorrectionBySafetyNet(
|
||||||
final SuggestedWords.Builder suggestedWordsBuilder,
|
final SuggestedWords.Builder suggestedWordsBuilder) {
|
||||||
final double autoCorrectionThreshold, final boolean isTypedWordValid) {
|
|
||||||
// Safety net for auto correction.
|
// Safety net for auto correction.
|
||||||
// Actually if we hit this safety net, it's actually a bug.
|
// Actually if we hit this safety net, it's a bug.
|
||||||
if (suggestedWordsBuilder.size() <= 1 || isTypedWordValid) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// If user selected aggressive auto correction mode, there is no need to use the safety
|
// If user selected aggressive auto correction mode, there is no need to use the safety
|
||||||
// net.
|
// net.
|
||||||
if (0 == autoCorrectionThreshold) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final CharSequence typedWord = suggestedWordsBuilder.getWord(0);
|
final CharSequence typedWord = suggestedWordsBuilder.getWord(0);
|
||||||
// If the length of typed word is less than MINIMUM_SAFETY_NET_CHAR_LENGTH,
|
// If the length of typed word is less than MINIMUM_SAFETY_NET_CHAR_LENGTH,
|
||||||
// we should not use net because relatively edit distance can be big.
|
// we should not use net because relatively edit distance can be big.
|
||||||
|
|
Loading…
Reference in a new issue