aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-07-05 01:50:44 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-07-05 01:50:44 -0700
commit21524c755c97f93f451bbdf4106bf2906aa31ea9 (patch)
tree10c33979208d1629ecc13aaeb26346cda6d72fee /java/src
parent71d7fc91b70085c0857dee2b8165e0f4d17e9d62 (diff)
parentea80794dd43d44fe53884b4b8f4567af3d0e8331 (diff)
downloadlatinime-21524c755c97f93f451bbdf4106bf2906aa31ea9.tar.gz
latinime-21524c755c97f93f451bbdf4106bf2906aa31ea9.tar.xz
latinime-21524c755c97f93f451bbdf4106bf2906aa31ea9.zip
Merge "Put some more code in common (A51)"
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java41
1 files changed, 18 insertions, 23 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 017292f9b..3b6c34499 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1705,16 +1705,27 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
final CharSequence typedWord;
+ final SuggestedWords suggestions;
if (isPredictions || !mWordComposer.isComposingWord()) {
+ if (!mCurrentSettings.mBigramPredictionEnabled) {
+ setPunctuationSuggestions();
+ return;
+ }
typedWord = "";
- updateBigramPredictions(typedWord);
+ suggestions = updateBigramPredictions(typedWord);
} else {
typedWord = mWordComposer.getTypedWord();
- updateSuggestions(typedWord);
+ suggestions = updateSuggestions(typedWord);
+ }
+
+ if (null != suggestions && suggestions.size() > 0) {
+ showSuggestions(suggestions, typedWord);
+ } else {
+ clearSuggestions();
}
}
- private void updateSuggestions(final CharSequence typedWord) {
+ private SuggestedWords updateSuggestions(final CharSequence typedWord) {
// TODO: May need a better way of retrieving previous word
final CharSequence prevWord = mConnection.getPreviousWord(mCurrentSettings.mWordSeparators);
// getSuggestedWords handles gracefully a null value of prevWord
@@ -1731,8 +1742,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
if (suggestedWords.size() > 1 || typedWord.length() == 1
|| !suggestedWords.mTypedWordValid
|| mSuggestionsView.isShowingAddToDictionaryHint()) {
- // We know suggestedWords.size() > 1
- showSuggestions(suggestedWords, typedWord);
+ return suggestedWords;
} else {
SuggestedWords previousSuggestions = mSuggestionsView.getSuggestions();
if (previousSuggestions == mCurrentSettings.mSuggestPuncList) {
@@ -1741,16 +1751,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
final ArrayList<SuggestedWords.SuggestedWordInfo> typedWordAndPreviousSuggestions =
SuggestedWords.getTypedWordAndPreviousSuggestions(
typedWord, previousSuggestions);
- final SuggestedWords obsoleteSuggestedWords =
- new SuggestedWords(typedWordAndPreviousSuggestions,
+ return new SuggestedWords(typedWordAndPreviousSuggestions,
false /* typedWordValid */,
false /* hasAutoCorrectionCandidate */,
false /* isPunctuationSuggestions */,
true /* isObsoleteSuggestions */,
false /* isPrediction */);
- // getTypedWordAndPreviousSuggestions never returns an empty array, so we know we have
- // at least one element here.
- showSuggestions(obsoleteSuggestedWords, typedWord);
}
}
@@ -1923,12 +1929,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
separatorCode, prevWord);
}
- private void updateBigramPredictions(final CharSequence typedWord) {
- if (!mCurrentSettings.mBigramPredictionEnabled) {
- setPunctuationSuggestions();
- return;
- }
-
+ private SuggestedWords updateBigramPredictions(final CharSequence typedWord) {
final SuggestedWords suggestedWords;
if (mCurrentSettings.mCorrectionEnabled) {
final CharSequence prevWord = mConnection.getThisWord(mCurrentSettings.mWordSeparators);
@@ -1943,13 +1944,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
suggestedWords = null;
}
- if (null != suggestedWords && suggestedWords.size() > 0) {
- // Typed word is always empty. We pass it because the no-second-arg version of
- // showSuggestions will retrieve the word near the cursor, and we don't want that here
- showSuggestions(suggestedWords, typedWord);
- } else {
- clearSuggestions();
- }
+ return suggestedWords;
}
public void setPunctuationSuggestions() {