aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/SuggestedWords.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-08-26 18:54:08 +0900
committerJean Chalard <jchalard@google.com>2014-08-26 20:35:59 +0900
commit8380f921f7edaeea2033a1e967a14941400fe246 (patch)
treedb2e7cd9758440158a6e4096be43161ca2481c5b /java/src/com/android/inputmethod/latin/SuggestedWords.java
parentfdfe73ff1f4b8c9d7d8728baa322d70c3a74df99 (diff)
downloadlatinime-8380f921f7edaeea2033a1e967a14941400fe246.tar.gz
latinime-8380f921f7edaeea2033a1e967a14941400fe246.tar.xz
latinime-8380f921f7edaeea2033a1e967a14941400fe246.zip
Fix a bug where the top prediction would disappear.
This is because prediction can't be easily distinguished in style. This fixes the bug by simulating the right members, but some refactoring should be done to remove useless booleans. Bug: 17271923 Change-Id: Ib88f3fb95678021624e59535492926dd315d26fb
Diffstat (limited to 'java/src/com/android/inputmethod/latin/SuggestedWords.java')
-rw-r--r--java/src/com/android/inputmethod/latin/SuggestedWords.java28
1 files changed, 14 insertions, 14 deletions
diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java
index 38fcb683d..1eebabece 100644
--- a/java/src/com/android/inputmethod/latin/SuggestedWords.java
+++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java
@@ -38,14 +38,15 @@ public class SuggestedWords {
public static final int INPUT_STYLE_TAIL_BATCH = 3;
public static final int INPUT_STYLE_APPLICATION_SPECIFIED = 4;
public static final int INPUT_STYLE_RECORRECTION = 5;
+ public static final int INPUT_STYLE_PREDICTION = 6;
// The maximum number of suggestions available.
public static final int MAX_SUGGESTIONS = 18;
private static final ArrayList<SuggestedWordInfo> EMPTY_WORD_INFO_LIST = new ArrayList<>(0);
public static final SuggestedWords EMPTY = new SuggestedWords(
- EMPTY_WORD_INFO_LIST, null /* rawSuggestions */, false, false, false, false,
- INPUT_STYLE_NONE);
+ EMPTY_WORD_INFO_LIST, null /* rawSuggestions */, false /* typedWordValid */,
+ false /* willAutoCorrect */, false /* isObsoleteSuggestions */, INPUT_STYLE_NONE);
public final String mTypedWord;
public final boolean mTypedWordValid;
@@ -54,7 +55,6 @@ public class SuggestedWords {
// whether this exactly matches the user entry or not.
public final boolean mWillAutoCorrect;
public final boolean mIsObsoleteSuggestions;
- public final boolean mIsPrediction;
// How the input for these suggested words was done by the user. Must be one of the
// INPUT_STYLE_* constants above.
public final int mInputStyle;
@@ -67,10 +67,9 @@ public class SuggestedWords {
final boolean typedWordValid,
final boolean willAutoCorrect,
final boolean isObsoleteSuggestions,
- final boolean isPrediction,
final int inputStyle) {
this(suggestedWordInfoList, rawSuggestions, typedWordValid, willAutoCorrect,
- isObsoleteSuggestions, isPrediction, inputStyle, NOT_A_SEQUENCE_NUMBER);
+ isObsoleteSuggestions, inputStyle, NOT_A_SEQUENCE_NUMBER);
}
public SuggestedWords(final ArrayList<SuggestedWordInfo> suggestedWordInfoList,
@@ -78,13 +77,12 @@ public class SuggestedWords {
final boolean typedWordValid,
final boolean willAutoCorrect,
final boolean isObsoleteSuggestions,
- final boolean isPrediction,
final int inputStyle,
final int sequenceNumber) {
this(suggestedWordInfoList, rawSuggestions,
- (suggestedWordInfoList.isEmpty() || isPrediction) ? null
+ (suggestedWordInfoList.isEmpty() || INPUT_STYLE_PREDICTION == inputStyle) ? null
: suggestedWordInfoList.get(INDEX_OF_TYPED_WORD).mWord,
- typedWordValid, willAutoCorrect, isObsoleteSuggestions, isPrediction, inputStyle,
+ typedWordValid, willAutoCorrect, isObsoleteSuggestions, inputStyle,
sequenceNumber);
}
@@ -94,7 +92,6 @@ public class SuggestedWords {
final boolean typedWordValid,
final boolean willAutoCorrect,
final boolean isObsoleteSuggestions,
- final boolean isPrediction,
final int inputStyle,
final int sequenceNumber) {
mSuggestedWordInfoList = suggestedWordInfoList;
@@ -102,7 +99,6 @@ public class SuggestedWords {
mTypedWordValid = typedWordValid;
mWillAutoCorrect = willAutoCorrect;
mIsObsoleteSuggestions = isObsoleteSuggestions;
- mIsPrediction = isPrediction;
mInputStyle = inputStyle;
mSequenceNumber = sequenceNumber;
mTypedWord = typedWord;
@@ -381,9 +377,14 @@ public class SuggestedWords {
}
}
+ public boolean isPrediction() {
+ return INPUT_STYLE_PREDICTION == mInputStyle;
+ }
+
// SuggestedWords is an immutable object, as much as possible. We must not just remove
// words from the member ArrayList as some other parties may expect the object to never change.
- public SuggestedWords getSuggestedWordsExcludingTypedWord(final int inputStyle) {
+ // This is only ever called by recorrection at the moment, hence the ForRecorrection moniker.
+ public SuggestedWords getSuggestedWordsExcludingTypedWordForRecorrection() {
final ArrayList<SuggestedWordInfo> newSuggestions = new ArrayList<>();
String typedWord = null;
for (int i = 0; i < mSuggestedWordInfoList.size(); ++i) {
@@ -399,7 +400,7 @@ public class SuggestedWords {
// no auto-correction should take place hence willAutoCorrect = false.
return new SuggestedWords(newSuggestions, null /* rawSuggestions */, typedWord,
true /* typedWordValid */, false /* willAutoCorrect */, mIsObsoleteSuggestions,
- mIsPrediction, inputStyle, NOT_A_SEQUENCE_NUMBER);
+ SuggestedWords.INPUT_STYLE_RECORRECTION, NOT_A_SEQUENCE_NUMBER);
}
// Creates a new SuggestedWordInfo from the currently suggested words that removes all but the
@@ -418,8 +419,7 @@ public class SuggestedWords {
SuggestedWordInfo.NOT_A_CONFIDENCE));
}
return new SuggestedWords(newSuggestions, null /* rawSuggestions */, mTypedWordValid,
- mWillAutoCorrect, mIsObsoleteSuggestions, mIsPrediction,
- INPUT_STYLE_TAIL_BATCH);
+ mWillAutoCorrect, mIsObsoleteSuggestions, INPUT_STYLE_TAIL_BATCH);
}
/**