aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-01-26 02:15:38 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-01-26 02:15:38 -0800
commitdd5e1d157b6bd8d7642dfd1dd855c97adc9f4b67 (patch)
treef3eddf70b9659c4a2aca9a1a10c5e74562c96491 /java/src
parent3c09bb18d93800be14466f90502c344dcfafa738 (diff)
parent2712f23acbb197af3b125da4cc47108e71b7446d (diff)
downloadlatinime-dd5e1d157b6bd8d7642dfd1dd855c97adc9f4b67.tar.gz
latinime-dd5e1d157b6bd8d7642dfd1dd855c97adc9f4b67.tar.xz
latinime-dd5e1d157b6bd8d7642dfd1dd855c97adc9f4b67.zip
Merge "Remove mCommittedWordSavedForSuggestionResuming (A4)"
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java4
-rw-r--r--java/src/com/android/inputmethod/latin/WordComposer.java36
2 files changed, 15 insertions, 25 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 5ef35dab5..62b287e3c 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -2165,7 +2165,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
// "ic" must not be null
private void cancelAutoCorrect(final InputConnection ic) {
- mWordComposer.resumeSuggestionOnKeptWord();
+ mWordComposer.resumeSuggestionOnLastComposedWord(mLastComposedWord);
final String originallyTypedWord = mWordComposer.getTypedWord();
final CharSequence autoCorrectedTo = mWordComposer.getAutoCorrectionOrNull();
final int cancelLength = autoCorrectedTo.length();
@@ -2205,7 +2205,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
// Note: in the interest of code simplicity, we may want to just call
// restartSuggestionsOnWordBeforeCursorIfAtEndOfWord instead, but retrieving
// the old WordComposer allows to reuse the actual typed coordinates.
- mWordComposer.resumeSuggestionOnKeptWord();
+ mWordComposer.resumeSuggestionOnLastComposedWord(mLastComposedWord);
// We resume suggestion, and then we want to set the composing text to the content
// of the word composer again. But since we just manually picked a word, there is
// no composing text at the moment, so we have to delete the word before we set a
diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java
index f97eb52f6..f994d68e3 100644
--- a/java/src/com/android/inputmethod/latin/WordComposer.java
+++ b/java/src/com/android/inputmethod/latin/WordComposer.java
@@ -67,8 +67,6 @@ public class WordComposer {
// The currently typing word. May not be null.
private CharacterStore mCurrentWord;
- // The information being kept for resuming suggestion. May be null if wiped.
- private CharacterStore mCommittedWordSavedForSuggestionResuming;
private int mCapsCount;
@@ -83,7 +81,6 @@ public class WordComposer {
public WordComposer() {
mCurrentWord = new CharacterStore();
- mCommittedWordSavedForSuggestionResuming = null;
mTrailingSingleQuotesCount = 0;
}
@@ -93,7 +90,6 @@ public class WordComposer {
public void init(WordComposer source) {
mCurrentWord = new CharacterStore(source.mCurrentWord);
- mCommittedWordSavedForSuggestionResuming = source.mCommittedWordSavedForSuggestionResuming;
mCapsCount = source.mCapsCount;
mIsFirstCharCapitalized = source.mIsFirstCharCapitalized;
mAutoCapitalized = source.mAutoCapitalized;
@@ -105,7 +101,6 @@ public class WordComposer {
*/
public void reset() {
mCurrentWord.reset();
- mCommittedWordSavedForSuggestionResuming = null;
mCapsCount = 0;
mIsFirstCharCapitalized = false;
mTrailingSingleQuotesCount = 0;
@@ -201,7 +196,6 @@ public class WordComposer {
int codePoint = word.charAt(i);
addKeyInfo(codePoint, keyboard, keyDetector);
}
- mCommittedWordSavedForSuggestionResuming = null;
}
/**
@@ -331,7 +325,6 @@ public class WordComposer {
// `type' should be one of the LastComposedWord.COMMIT_TYPE_* constants above.
public LastComposedWord commitWord(final int type) {
- mCommittedWordSavedForSuggestionResuming = mCurrentWord;
// Note: currently, we come here whenever we commit a word. If it's any *other* kind than
// DECIDED_WORD, we should reset mAutoCorrection so that we don't attempt to cancel later.
// If it's a DECIDED_WORD, it may be an actual auto-correction by the IME, or what the user
@@ -339,29 +332,26 @@ public class WordComposer {
// Ideally we would also null it when it was a DECIDED_WORD that was not an auto-correct.
// As it happens these two cases should behave differently, because the former can be
// canceled while the latter can't. Currently, we figure this out in
- // #didAutoCorrectToAnotherWord with #equals(). It would be marginally cleaner to do it
- // here, but it would be slower (since we would #equals() for each commit, instead of
- // only on cancel), and ultimately we want to figure it out even earlier anyway.
- if (type != LastComposedWord.COMMIT_TYPE_DECIDED_WORD) {
- // Only ever revert an auto-correct.
- mCommittedWordSavedForSuggestionResuming.mAutoCorrection = null;
- }
+ // LastComposedWord#didAutoCorrectToAnotherWord with #equals(). It would be marginally
+ // cleaner to do it here, but it would be slower (since we would #equals() for each commit,
+ // instead of only on cancel), and ultimately we want to figure it out even earlier anyway.
final LastComposedWord lastComposedWord = new LastComposedWord(type, mCurrentWord.mCodes,
mCurrentWord.mXCoordinates, mCurrentWord.mYCoordinates,
mCurrentWord.mTypedWord.toString(),
- null == mCurrentWord.mAutoCorrection
- ? null : mCurrentWord.mAutoCorrection.toString());
+ (type != LastComposedWord.COMMIT_TYPE_DECIDED_WORD)
+ || (null == mCurrentWord.mAutoCorrection)
+ ? null : mCurrentWord.mAutoCorrection.toString());
// TODO: improve performance by swapping buffers instead of creating a new object.
mCurrentWord = new CharacterStore();
return lastComposedWord;
}
- public boolean hasWordKeptForSuggestionResuming() {
- return null != mCommittedWordSavedForSuggestionResuming;
- }
-
- public void resumeSuggestionOnKeptWord() {
- mCurrentWord = mCommittedWordSavedForSuggestionResuming;
- mCommittedWordSavedForSuggestionResuming = null;
+ public void resumeSuggestionOnLastComposedWord(final LastComposedWord lastComposedWord) {
+ mCurrentWord.mCodes = lastComposedWord.mCodes;
+ mCurrentWord.mXCoordinates = lastComposedWord.mXCoordinates;
+ mCurrentWord.mYCoordinates = lastComposedWord.mYCoordinates;
+ mCurrentWord.mTypedWord.setLength(0);
+ mCurrentWord.mTypedWord.append(lastComposedWord.mTypedWord);
+ mCurrentWord.mAutoCorrection = lastComposedWord.mAutoCorrection;
}
}