aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/LatinIME.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java37
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 722f323a2..6e3540485 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -471,7 +471,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);
}
@@ -499,7 +500,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.
@@ -507,7 +509,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
dictionaryToUse = oldContactsDictionary;
}
} else {
- dictionaryToUse = new ContactsBinaryDictionary(this, locale);
+ dictionaryToUse = new ContactsBinaryDictionary(this, Suggest.DIC_CONTACTS, locale);
}
}
@@ -888,6 +890,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
applicationSuggestedWords,
false /* typedWordValid */,
false /* hasAutoCorrectionCandidate */,
+ false /* allowsToBeAutoCorrected */,
false /* isPunctuationSuggestions */,
false /* isObsoleteSuggestions */,
false /* isPrediction */);
@@ -1695,9 +1698,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()) {
@@ -1707,8 +1707,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;
}
@@ -1719,7 +1721,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
@@ -1728,7 +1730,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 {
@@ -1743,6 +1745,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
new SuggestedWords(typedWordAndPreviousSuggestions,
false /* typedWordValid */,
false /* hasAutoCorrectionCandidate */,
+ false /* allowsToBeAutoCorrected */,
false /* isPunctuationSuggestions */,
true /* isObsoleteSuggestions */,
false /* isPrediction */);
@@ -1753,7 +1756,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;
@@ -1918,16 +1921,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();
@@ -1938,9 +1933,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;
}