aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/WordComposer.java
diff options
context:
space:
mode:
authorKeisuke Kuroyanagi <ksk@google.com>2014-05-19 13:55:40 +0900
committerKeisuke Kuroyanagi <ksk@google.com>2014-05-19 13:55:40 +0900
commit83c40a2301a0b5a42a75eecada48e7887a7c940e (patch)
tree19a7a38c09f81891d786c0aa980ba1d98a42ec74 /java/src/com/android/inputmethod/latin/WordComposer.java
parent169c4d25201abd538cee7eb1b978f9ad0f895bf2 (diff)
downloadlatinime-83c40a2301a0b5a42a75eecada48e7887a7c940e.tar.gz
latinime-83c40a2301a0b5a42a75eecada48e7887a7c940e.tar.xz
latinime-83c40a2301a0b5a42a75eecada48e7887a7c940e.zip
Use PrevWordsInfo instead of String in Java side.
Bug: 14119293 Bug: 14425059 Change-Id: I3d5da84881a49a04550180dd9aac2c37da2ed762
Diffstat (limited to 'java/src/com/android/inputmethod/latin/WordComposer.java')
-rw-r--r--java/src/com/android/inputmethod/latin/WordComposer.java28
1 files changed, 13 insertions, 15 deletions
diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java
index 9cf71c7f4..227b42bde 100644
--- a/java/src/com/android/inputmethod/latin/WordComposer.java
+++ b/java/src/com/android/inputmethod/latin/WordComposer.java
@@ -46,11 +46,9 @@ public final class WordComposer {
// The list of events that served to compose this string.
private final ArrayList<Event> mEvents;
private final InputPointers mInputPointers = new InputPointers(MAX_WORD_LENGTH);
- // The previous word (before the composing word). Used as context for suggestions. May be null
- // after resetting and before starting a new composing word, or when there is no context like
- // at the start of text for example. It can also be set to null externally when the user
- // enters a separator that does not let bigrams across, like a period or a comma.
- private String mPreviousWordForSuggestion;
+ // The information of previous words (before the composing word). Must not be null. Used as
+ // context for suggestions.
+ private PrevWordsInfo mPrevWordsInfo;
private String mAutoCorrection;
private boolean mIsResumed;
private boolean mIsBatchMode;
@@ -87,7 +85,7 @@ public final class WordComposer {
mIsBatchMode = false;
mCursorPositionWithinWord = 0;
mRejectedBatchModeSuggestion = null;
- mPreviousWordForSuggestion = null;
+ mPrevWordsInfo = new PrevWordsInfo(null);
refreshTypedWordCache();
}
@@ -119,7 +117,7 @@ public final class WordComposer {
mIsBatchMode = false;
mCursorPositionWithinWord = 0;
mRejectedBatchModeSuggestion = null;
- mPreviousWordForSuggestion = null;
+ mPrevWordsInfo = new PrevWordsInfo(null);
refreshTypedWordCache();
}
@@ -309,7 +307,7 @@ public final class WordComposer {
CoordinateUtils.yFromArray(coordinates, i)));
}
mIsResumed = true;
- mPreviousWordForSuggestion = null == previousWord ? null : previousWord.toString();
+ mPrevWordsInfo = new PrevWordsInfo(null == previousWord ? null : previousWord.toString());
}
/**
@@ -320,8 +318,8 @@ public final class WordComposer {
return mTypedWordCache.toString();
}
- public String getPreviousWordForSuggestion() {
- return mPreviousWordForSuggestion;
+ public PrevWordsInfo getPrevWordsInfoForSuggestion() {
+ return mPrevWordsInfo;
}
/**
@@ -379,7 +377,7 @@ public final class WordComposer {
public void setCapitalizedModeAndPreviousWordAtStartComposingTime(final int mode,
final CharSequence previousWord) {
mCapitalizedMode = mode;
- mPreviousWordForSuggestion = null == previousWord ? null : previousWord.toString();
+ mPrevWordsInfo = new PrevWordsInfo(null == previousWord ? null : previousWord.toString());
}
/**
@@ -430,7 +428,7 @@ public final class WordComposer {
mCapsCount = 0;
mDigitsCount = 0;
mIsBatchMode = false;
- mPreviousWordForSuggestion = committedWord.toString();
+ mPrevWordsInfo = new PrevWordsInfo(committedWord.toString());
mCombinerChain.reset();
mEvents.clear();
mCodePointSize = 0;
@@ -448,11 +446,11 @@ public final class WordComposer {
// when the user inputs a separator that's not whitespace (including the case of the
// double-space-to-period feature).
public void discardPreviousWordForSuggestion() {
- mPreviousWordForSuggestion = null;
+ mPrevWordsInfo = new PrevWordsInfo(null);
}
public void resumeSuggestionOnLastComposedWord(final LastComposedWord lastComposedWord,
- final String previousWord) {
+ final PrevWordsInfo prevWordsInfo) {
mEvents.clear();
Collections.copy(mEvents, lastComposedWord.mEvents);
mInputPointers.set(lastComposedWord.mInputPointers);
@@ -463,7 +461,7 @@ public final class WordComposer {
mCursorPositionWithinWord = mCodePointSize;
mRejectedBatchModeSuggestion = null;
mIsResumed = true;
- mPreviousWordForSuggestion = previousWord;
+ mPrevWordsInfo = prevWordsInfo;
}
public boolean isBatchMode() {