aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/SuggestedWords.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-11-17 18:26:15 +0900
committerJean Chalard <jchalard@google.com>2014-11-20 13:57:01 +0900
commita2cb2f36a6b51f73602bd7e917c418657da0c973 (patch)
treeb0a035c7d26a84e3ac29e0f315863aedf1e663be /java/src/com/android/inputmethod/latin/SuggestedWords.java
parent7cca01aa1d5aa1c8b8f10117fd2d83a49c82bea5 (diff)
downloadlatinime-a2cb2f36a6b51f73602bd7e917c418657da0c973.tar.gz
latinime-a2cb2f36a6b51f73602bd7e917c418657da0c973.tar.xz
latinime-a2cb2f36a6b51f73602bd7e917c418657da0c973.zip
Make the typed word a SuggestedWordInfo
That allows to carry the language information in an accurate manner. Bug: 18063142 Change-Id: I0bca8981372ae10648274095b18b26a3686b762b
Diffstat (limited to 'java/src/com/android/inputmethod/latin/SuggestedWords.java')
-rw-r--r--java/src/com/android/inputmethod/latin/SuggestedWords.java26
1 files changed, 14 insertions, 12 deletions
diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java
index 02b2d56e7..49153d261 100644
--- a/java/src/com/android/inputmethod/latin/SuggestedWords.java
+++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java
@@ -29,6 +29,7 @@ import java.util.Arrays;
import java.util.HashSet;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
public class SuggestedWords {
public static final int INDEX_OF_TYPED_WORD = 0;
@@ -54,7 +55,8 @@ public class SuggestedWords {
false /* typedWordValid */, false /* willAutoCorrect */,
false /* isObsoleteSuggestions */, INPUT_STYLE_NONE, NOT_A_SEQUENCE_NUMBER);
- public final String mTypedWord;
+ @Nullable
+ public final SuggestedWordInfo mTypedWordInfo;
public final boolean mTypedWordValid;
// Note: this INCLUDES cases where the word will auto-correct to itself. A good definition
// of what this flag means would be "the top suggestion is strong enough to auto-correct",
@@ -65,12 +67,14 @@ public class SuggestedWords {
// INPUT_STYLE_* constants above.
public final int mInputStyle;
public final int mSequenceNumber; // Sequence number for auto-commit.
+ @Nonnull
protected final ArrayList<SuggestedWordInfo> mSuggestedWordInfoList;
+ @Nullable
public final ArrayList<SuggestedWordInfo> mRawSuggestions;
- public SuggestedWords(final ArrayList<SuggestedWordInfo> suggestedWordInfoList,
- final ArrayList<SuggestedWordInfo> rawSuggestions,
- final String typedWord,
+ public SuggestedWords(@Nonnull final ArrayList<SuggestedWordInfo> suggestedWordInfoList,
+ @Nullable final ArrayList<SuggestedWordInfo> rawSuggestions,
+ @Nullable final SuggestedWordInfo typedWordInfo,
final boolean typedWordValid,
final boolean willAutoCorrect,
final boolean isObsoleteSuggestions,
@@ -83,7 +87,7 @@ public class SuggestedWords {
mIsObsoleteSuggestions = isObsoleteSuggestions;
mInputStyle = inputStyle;
mSequenceNumber = sequenceNumber;
- mTypedWord = typedWord;
+ mTypedWordInfo = typedWordInfo;
}
public boolean isEmpty() {
@@ -199,14 +203,12 @@ public class SuggestedWords {
// Should get rid of the first one (what the user typed previously) from suggestions
// and replace it with what the user currently typed.
public static ArrayList<SuggestedWordInfo> getTypedWordAndPreviousSuggestions(
- final String typedWord, final SuggestedWords previousSuggestions) {
+ @Nonnull final SuggestedWordInfo typedWordInfo,
+ @Nonnull final SuggestedWords previousSuggestions) {
final ArrayList<SuggestedWordInfo> suggestionsList = new ArrayList<>();
final HashSet<String> alreadySeen = new HashSet<>();
- suggestionsList.add(new SuggestedWordInfo(typedWord, SuggestedWordInfo.MAX_SCORE,
- SuggestedWordInfo.KIND_TYPED, Dictionary.DICTIONARY_USER_TYPED,
- SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */,
- SuggestedWordInfo.NOT_A_CONFIDENCE /* autoCommitFirstWordConfidence */));
- alreadySeen.add(typedWord.toString());
+ suggestionsList.add(typedWordInfo);
+ alreadySeen.add(typedWordInfo.mWord);
final int previousSize = previousSuggestions.size();
for (int index = 1; index < previousSize; index++) {
final SuggestedWordInfo prevWordInfo = previousSuggestions.getInfo(index);
@@ -412,7 +414,7 @@ public class SuggestedWords {
SuggestedWordInfo.NOT_A_CONFIDENCE));
}
return new SuggestedWords(newSuggestions, null /* rawSuggestions */,
- newSuggestions.isEmpty() ? null : newSuggestions.get(0).mWord /* typedWord */,
+ newSuggestions.isEmpty() ? null : newSuggestions.get(0) /* typedWordInfo */,
mTypedWordValid, mWillAutoCorrect, mIsObsoleteSuggestions, INPUT_STYLE_TAIL_BATCH,
NOT_A_SEQUENCE_NUMBER);
}