aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-07-05 16:41:16 +0900
committerJean Chalard <jchalard@google.com>2012-07-09 15:06:15 +0900
commit146bd2e456befc2132e10e0c6cf3eb19ed70051a (patch)
tree65baa1ec580ad32718595a0c5b8e2630f7d90369 /java/src
parent60dbe0be43ce8d8e1254c9c80d9fc012c0c28bdf (diff)
downloadlatinime-146bd2e456befc2132e10e0c6cf3eb19ed70051a.tar.gz
latinime-146bd2e456befc2132e10e0c6cf3eb19ed70051a.tar.xz
latinime-146bd2e456befc2132e10e0c6cf3eb19ed70051a.zip
Pass the value we really want to pass to update functions (A67)
Change-Id: Ica9b875d119dea2f8dc237fd63e5b4eaa5e1c400
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java35
1 files changed, 25 insertions, 10 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index a2ba7bbfb..de2ecd348 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -219,6 +219,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// isComposing is always true
public void postUpdateSuggestions(final boolean isComposing) {
+ // TODO: remove this test
+ if (!isComposing) throw new RuntimeException("We are not composing a word");
cancelUpdateSuggestionStrip();
sendMessageDelayed(obtainMessage(MSG_UPDATE_SUGGESTIONS), mDelayUpdateSuggestions);
}
@@ -243,6 +245,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// isComposing is always false
public void postUpdateBigramPredictions(final boolean isComposing) {
+ // TODO: remove this test
+ if (isComposing) throw new RuntimeException("We are composing a word");
cancelUpdateSuggestionStrip();
sendMessageDelayed(obtainMessage(MSG_SET_BIGRAM_PREDICTIONS), mDelayUpdateSuggestions);
}
@@ -1400,10 +1404,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// isComposingWord() any more.
if (!mWordComposer.isComposingWord()) {
// Not composing word any more, so we can show bigrams.
- mHandler.postUpdateBigramPredictions(false);
+ mHandler.postUpdateBigramPredictions(mWordComposer.isComposingWord());
} else {
// Still composing a word, so we still have letters to deduce a suggestion from.
- mHandler.postUpdateSuggestions(true);
+ mHandler.postUpdateSuggestions(mWordComposer.isComposingWord());
}
} else {
mConnection.deleteSurroundingText(1, 0);
@@ -1547,7 +1551,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
getCurrentAutoCapsState() != Constants.TextUtils.CAP_MODE_OFF);
}
mConnection.setComposingText(getTextWithUnderline(mWordComposer.getTypedWord()), 1);
- mHandler.postUpdateSuggestions(true);
+ // We just added a character, so isComposingWord() is true
+ mHandler.postUpdateSuggestions(mWordComposer.isComposingWord());
} else {
final boolean swapWeakSpace = maybeStripSpace(primaryCode,
spaceState, KeyboardActionListener.SUGGESTION_STRIP_COORDINATE == x);
@@ -1561,7 +1566,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// We may need to update predictions, if the "add to dictionary" hint was displayed
// for example.
if (null != mSuggestionsView) mSuggestionsView.dismissAddToDictionaryHint();
- mHandler.postUpdateBigramPredictions(false);
+ // Here we know we are not composing a word: if we were, then we can't come here because
+ // isComposingWord is still true; if we weren't, and we now are, then isComposingWord
+ // has been turned to true, so we can't come here either.
+ mHandler.postUpdateBigramPredictions(mWordComposer.isComposingWord());
}
Utils.Stats.onNonSeparator((char)primaryCode, x, y);
}
@@ -1604,7 +1612,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mHandler.startDoubleSpacesTimer();
if (!mConnection.isCursorTouchingWord(mCurrentSettings)) {
- mHandler.postUpdateBigramPredictions(false);
+ // We know mWordComposer.isComposingWord() is false here, since if it was true,
+ // we committed the text, making it false.
+ mHandler.postUpdateBigramPredictions(mWordComposer.isComposingWord());
}
} else {
if (swapWeakSpace) {
@@ -1889,7 +1899,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mSuggestionsView.showAddToDictionaryHint(suggestion, mCurrentSettings.mHintToSaveText);
} else {
// If we're not showing the "Touch again to save", then show predictions.
- mHandler.postUpdateBigramPredictions(false);
+ // We just called commitChosenWord, which ensures mWordComposer#isComposingWord()
+ // returns false.
+ mHandler.postUpdateBigramPredictions(mWordComposer.isComposingWord());
}
}
@@ -1981,7 +1993,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
ResearchLogger.latinIME_deleteSurroundingText(length);
}
mConnection.setComposingText(word, 1);
- mHandler.postUpdateSuggestions(true);
+ // We just set a composing word, so isComposingWord() is true
+ mHandler.postUpdateSuggestions(mWordComposer.isComposingWord());
}
private void revertCommit() {
@@ -2026,7 +2039,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// separator.
mLastComposedWord = LastComposedWord.NOT_A_COMPOSED_WORD;
// We have a separator between the word and the cursor: we should show predictions.
- mHandler.postUpdateBigramPredictions(false);
+ // We know we are not composing a word here (there is even a test that throws an exception
+ // in debug mode in here)
+ mHandler.postUpdateBigramPredictions(mWordComposer.isComposingWord());
}
public boolean isWordSeparator(int code) {
@@ -2052,9 +2067,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// we are currently composing. If we are not composing anything, we may want to display
// predictions or punctuation signs (which is done by updateBigramPredictions anyway).
if (mWordComposer.isComposingWord()) {
- mHandler.postUpdateSuggestions(true);
+ mHandler.postUpdateSuggestions(mWordComposer.isComposingWord());
} else {
- mHandler.postUpdateBigramPredictions(false);
+ mHandler.postUpdateBigramPredictions(mWordComposer.isComposingWord());
}
}