diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index d4362f79e..8a5fc495e 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -470,7 +470,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // Note that the calling sequence of onCreate() and onCurrentInputMethodSubtypeChanged() // is not guaranteed. It may even be called at the same time on a different thread. if (null == mPrefs) mPrefs = PreferenceManager.getDefaultSharedPreferences(this); - mUserHistoryDictionary = UserHistoryDictionary.getInstance(this, localeStr, mPrefs); + mUserHistoryDictionary = UserHistoryDictionary.getInstance( + this, localeStr, Suggest.DIC_USER_HISTORY, mPrefs); mSuggest.setUserHistoryDictionary(mUserHistoryDictionary); } @@ -498,7 +499,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // If the locale has changed then recreate the contacts dictionary. This // allows locale dependent rules for handling bigram name predictions. oldContactsDictionary.close(); - dictionaryToUse = new ContactsBinaryDictionary(this, locale); + dictionaryToUse = new ContactsBinaryDictionary( + this, Suggest.DIC_CONTACTS, locale); } else { // Make sure the old contacts dictionary is opened. If it is already open, // this is a no-op, so it's safe to call it anyways. @@ -506,7 +508,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen dictionaryToUse = oldContactsDictionary; } } else { - dictionaryToUse = new ContactsBinaryDictionary(this, locale); + dictionaryToUse = new ContactsBinaryDictionary(this, Suggest.DIC_CONTACTS, locale); } } @@ -887,6 +889,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen applicationSuggestedWords, false /* typedWordValid */, false /* hasAutoCorrectionCandidate */, + false /* allowsToBeAutoCorrected */, false /* isPunctuationSuggestions */, false /* isObsoleteSuggestions */, false /* isPrediction */); @@ -1684,9 +1687,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } public void updateSuggestions() { - mHandler.cancelUpdateSuggestions(); - mHandler.cancelUpdateBigramPredictions(); - // Check if we have a suggestion engine attached. if ((mSuggest == null || !mCurrentSettings.isSuggestionsRequested(mDisplayOrientation))) { if (mWordComposer.isComposingWord()) { @@ -1696,8 +1696,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen return; } + mHandler.cancelUpdateSuggestions(); + mHandler.cancelUpdateBigramPredictions(); + if (!mWordComposer.isComposingWord()) { - // This is dead code: we can't come here with an empty word composer. setPunctuationSuggestions(); return; } @@ -1708,7 +1710,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // getSuggestedWords handles gracefully a null value of prevWord final SuggestedWords suggestedWords = mSuggest.getSuggestedWords(mWordComposer, prevWord, mKeyboardSwitcher.getKeyboard().getProximityInfo(), - mCurrentSettings.mCorrectionEnabled, false); + mCurrentSettings.mCorrectionEnabled); // Basically, we update the suggestion strip only when suggestion count > 1. However, // there is an exception: We update the suggestion strip whenever typed word's length @@ -1717,7 +1719,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // need to clear the previous state when the user starts typing a word (i.e. typed word's // length == 1). if (suggestedWords.size() > 1 || typedWord.length() == 1 - || !suggestedWords.mTypedWordValid + || !suggestedWords.mAllowsToBeAutoCorrected || mSuggestionsView.isShowingAddToDictionaryHint()) { showSuggestions(suggestedWords, typedWord); } else { @@ -1732,6 +1734,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen new SuggestedWords(typedWordAndPreviousSuggestions, false /* typedWordValid */, false /* hasAutoCorrectionCandidate */, + false /* allowsToBeAutoCorrected */, false /* isPunctuationSuggestions */, true /* isObsoleteSuggestions */, false /* isPrediction */); @@ -1742,7 +1745,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen public void showSuggestions(final SuggestedWords suggestedWords, final CharSequence typedWord) { final CharSequence autoCorrection; if (suggestedWords.size() > 0) { - if (suggestedWords.mWillAutoCorrect) { + if (suggestedWords.hasAutoCorrectionWord()) { autoCorrection = suggestedWords.getWord(1); } else { autoCorrection = typedWord; @@ -1907,16 +1910,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } public void updateBigramPredictions() { - mHandler.cancelUpdateSuggestions(); - mHandler.cancelUpdateBigramPredictions(); - - if (mSuggest == null || !mCurrentSettings.isSuggestionsRequested(mDisplayOrientation)) { - if (mWordComposer.isComposingWord()) { - Log.w(TAG, "Called updateBigramPredictions but suggestions were not requested!"); - mWordComposer.setAutoCorrection(mWordComposer.getTypedWord()); - } + if (mSuggest == null || !mCurrentSettings.isSuggestionsRequested(mDisplayOrientation)) return; - } if (!mCurrentSettings.mBigramPredictionEnabled) { setPunctuationSuggestions(); @@ -1927,9 +1922,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (mCurrentSettings.mCorrectionEnabled) { final CharSequence prevWord = mConnection.getThisWord(mCurrentSettings.mWordSeparators); if (!TextUtils.isEmpty(prevWord)) { - suggestedWords = mSuggest.getSuggestedWords(mWordComposer, - prevWord, mKeyboardSwitcher.getKeyboard().getProximityInfo(), - mCurrentSettings.mCorrectionEnabled, true); + suggestedWords = mSuggest.getBigramPredictions(prevWord); } else { suggestedWords = null; } |