aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/Utils.java
diff options
context:
space:
mode:
authorsatok <satok@google.com>2011-01-27 01:43:06 +0900
committersatok <satok@google.com>2011-01-27 13:09:27 +0900
commit14e427d5bb13d59d23fb317ef90a6c44ae279425 (patch)
tree0e8bc17431ebf20537899e4a413e5289c3e79276 /java/src/com/android/inputmethod/latin/Utils.java
parent5c35e4109fc5a035605605b62bf5e5a5888b0f6b (diff)
downloadlatinime-14e427d5bb13d59d23fb317ef90a6c44ae279425.tar.gz
latinime-14e427d5bb13d59d23fb317ef90a6c44ae279425.tar.xz
latinime-14e427d5bb13d59d23fb317ef90a6c44ae279425.zip
Fix safety net not to be enabled at aggressive autocompletion mode
Bug: 3374359 Change-Id: I7b1dbeb64a87dda05397c236bb58da292f819471
Diffstat (limited to 'java/src/com/android/inputmethod/latin/Utils.java')
-rw-r--r--java/src/com/android/inputmethod/latin/Utils.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java
index 5059860d7..bb7239daf 100644
--- a/java/src/com/android/inputmethod/latin/Utils.java
+++ b/java/src/com/android/inputmethod/latin/Utils.java
@@ -38,6 +38,7 @@ import java.util.Date;
public class Utils {
private static final String TAG = Utils.class.getSimpleName();
+ private static final int MINIMUM_SAFETY_NET_CHAR_LENGTH = 4;
private static boolean DBG = LatinImeLogger.sDBG;
/**
@@ -106,11 +107,18 @@ public class Utils {
throw new RuntimeException("Can not find input method id for " + packageName);
}
- public static boolean shouldBlockedBySafetyNetForAutoCorrection(SuggestedWords suggestions) {
+ public static boolean shouldBlockedBySafetyNetForAutoCorrection(SuggestedWords suggestions,
+ Suggest suggest) {
// Safety net for auto correction.
// Actually if we hit this safety net, it's actually a bug.
if (suggestions.size() <= 1 || suggestions.mTypedWordValid) return false;
+ // If user selected aggressive auto correction mode, there is no need to use the safety
+ // net.
+ if (suggest.isAggressiveAutoCorrectionMode()) return false;
CharSequence typedWord = suggestions.getWord(0);
+ // 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.
+ if (typedWord.length() < MINIMUM_SAFETY_NET_CHAR_LENGTH) return false;
CharSequence candidateWord = suggestions.getWord(1);
final int typedWordLength = typedWord.length();
final int maxEditDistanceOfNativeDictionary = typedWordLength < 5 ? 2 : typedWordLength / 2;