aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/SuggestedWords.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-08-14 18:03:11 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-08-14 18:03:11 +0000
commite04c8b10d7876effbfdf2340a1fec6bf368c3409 (patch)
treea7e7002b213b07b5381e9cbd24bd99ee4113e010 /java/src/com/android/inputmethod/latin/SuggestedWords.java
parent1901c331283e2f60e6277a7773a103a447bd31ca (diff)
parentb8d764772b174cbd37354ffd0009bda56f223dc4 (diff)
downloadlatinime-e04c8b10d7876effbfdf2340a1fec6bf368c3409.tar.gz
latinime-e04c8b10d7876effbfdf2340a1fec6bf368c3409.tar.xz
latinime-e04c8b10d7876effbfdf2340a1fec6bf368c3409.zip
am b8d76477: Add the input style to SuggestedWords.
* commit 'b8d764772b174cbd37354ffd0009bda56f223dc4': Add the input style to SuggestedWords.
Diffstat (limited to 'java/src/com/android/inputmethod/latin/SuggestedWords.java')
-rw-r--r--java/src/com/android/inputmethod/latin/SuggestedWords.java30
1 files changed, 23 insertions, 7 deletions
diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java
index 5231cc893..d7693af41 100644
--- a/java/src/com/android/inputmethod/latin/SuggestedWords.java
+++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java
@@ -31,12 +31,20 @@ public class SuggestedWords {
public static final int INDEX_OF_AUTO_CORRECTION = 1;
public static final int NOT_A_SEQUENCE_NUMBER = -1;
+ public static final int INPUT_STYLE_NONE = 0;
+ public static final int INPUT_STYLE_TYPING = 1;
+ public static final int INPUT_STYLE_UPDATE_BATCH = 2;
+ 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;
+
// 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);
+ EMPTY_WORD_INFO_LIST, null /* rawSuggestions */, false, false, false, false,
+ INPUT_STYLE_NONE);
public final String mTypedWord;
public final boolean mTypedWordValid;
@@ -46,6 +54,9 @@ public class SuggestedWords {
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;
public final int mSequenceNumber; // Sequence number for auto-commit.
protected final ArrayList<SuggestedWordInfo> mSuggestedWordInfoList;
public final ArrayList<SuggestedWordInfo> mRawSuggestions;
@@ -55,9 +66,10 @@ public class SuggestedWords {
final boolean typedWordValid,
final boolean willAutoCorrect,
final boolean isObsoleteSuggestions,
- final boolean isPrediction) {
+ final boolean isPrediction,
+ final int inputStyle) {
this(suggestedWordInfoList, rawSuggestions, typedWordValid, willAutoCorrect,
- isObsoleteSuggestions, isPrediction, NOT_A_SEQUENCE_NUMBER);
+ isObsoleteSuggestions, isPrediction, inputStyle, NOT_A_SEQUENCE_NUMBER);
}
public SuggestedWords(final ArrayList<SuggestedWordInfo> suggestedWordInfoList,
@@ -66,11 +78,12 @@ public class SuggestedWords {
final boolean willAutoCorrect,
final boolean isObsoleteSuggestions,
final boolean isPrediction,
+ final int inputStyle,
final int sequenceNumber) {
this(suggestedWordInfoList, rawSuggestions,
(suggestedWordInfoList.isEmpty() || isPrediction) ? null
: suggestedWordInfoList.get(INDEX_OF_TYPED_WORD).mWord,
- typedWordValid, willAutoCorrect, isObsoleteSuggestions, isPrediction,
+ typedWordValid, willAutoCorrect, isObsoleteSuggestions, isPrediction, inputStyle,
sequenceNumber);
}
@@ -81,6 +94,7 @@ public class SuggestedWords {
final boolean willAutoCorrect,
final boolean isObsoleteSuggestions,
final boolean isPrediction,
+ final int inputStyle,
final int sequenceNumber) {
mSuggestedWordInfoList = suggestedWordInfoList;
mRawSuggestions = rawSuggestions;
@@ -88,6 +102,7 @@ public class SuggestedWords {
mWillAutoCorrect = willAutoCorrect;
mIsObsoleteSuggestions = isObsoleteSuggestions;
mIsPrediction = isPrediction;
+ mInputStyle = inputStyle;
mSequenceNumber = sequenceNumber;
mTypedWord = typedWord;
}
@@ -367,7 +382,7 @@ public class SuggestedWords {
// 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() {
+ public SuggestedWords getSuggestedWordsExcludingTypedWord(final int inputStyle) {
final ArrayList<SuggestedWordInfo> newSuggestions = new ArrayList<>();
String typedWord = null;
for (int i = 0; i < mSuggestedWordInfoList.size(); ++i) {
@@ -383,7 +398,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, NOT_A_SEQUENCE_NUMBER);
+ mIsPrediction, inputStyle, NOT_A_SEQUENCE_NUMBER);
}
// Creates a new SuggestedWordInfo from the currently suggested words that removes all but the
@@ -402,6 +417,7 @@ public class SuggestedWords {
SuggestedWordInfo.NOT_A_CONFIDENCE));
}
return new SuggestedWords(newSuggestions, null /* rawSuggestions */, mTypedWordValid,
- mWillAutoCorrect, mIsObsoleteSuggestions, mIsPrediction);
+ mWillAutoCorrect, mIsObsoleteSuggestions, mIsPrediction,
+ INPUT_STYLE_TAIL_BATCH);
}
}