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.java31
1 files changed, 27 insertions, 4 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index d4b59c4cd..9f9d07b3a 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -82,7 +82,8 @@ import java.util.Locale;
* Input method implementation for Qwerty'ish keyboard.
*/
public class LatinIME extends InputMethodService implements KeyboardActionListener,
- SuggestionStripView.Listener, TargetApplicationGetter.OnTargetApplicationKnownListener {
+ SuggestionStripView.Listener, TargetApplicationGetter.OnTargetApplicationKnownListener,
+ Suggest.SuggestInitializationListener {
private static final String TAG = LatinIME.class.getSimpleName();
private static final boolean TRACE = false;
private static boolean DEBUG;
@@ -426,6 +427,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
resetContactsDictionary(null == mSuggest ? null : mSuggest.getContactsDictionary());
}
+ @Override
+ public void onUpdateMainDictionaryAvailability(boolean isMainDictionaryAvailable) {
+ mIsMainDictionaryAvailable = isMainDictionaryAvailable;
+ updateKeyboardViewGestureHandlingModeByMainDictionaryAvailability();
+ }
+
private void initSuggest() {
final Locale subtypeLocale = mSubtypeSwitcher.getCurrentSubtypeLocale();
final String localeStr = subtypeLocale.toString();
@@ -437,7 +444,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
} else {
oldContactsDictionary = null;
}
- mSuggest = new Suggest(this, subtypeLocale);
+ mSuggest = new Suggest(this /* Context */, subtypeLocale,
+ this /* SuggestInitializationListener */);
if (mCurrentSettings.mCorrectionEnabled) {
mSuggest.setAutoCorrectionThreshold(mCurrentSettings.mAutoCorrectionThreshold);
}
@@ -673,6 +681,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
switcher.loadKeyboard(editorInfo, mCurrentSettings);
+ updateKeyboardViewGestureHandlingModeByMainDictionaryAvailability();
if (mSuggestionStripView != null)
mSuggestionStripView.clear();
@@ -1334,6 +1343,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mWordComposer.setBatchInputPointers(batchPointers);
final SuggestedWords suggestedWords = getSuggestedWords();
showSuggestionStrip(suggestedWords, null);
+ final String gesturePreviewText = (suggestedWords.size() > 0)
+ ? suggestedWords.getWord(0) : null;
+ mKeyboardSwitcher.getKeyboardView().showGesturePreviewText(gesturePreviewText);
}
@Override
@@ -1341,6 +1353,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mWordComposer.setBatchInputPointers(batchPointers);
final SuggestedWords suggestedWords = getSuggestedWords();
showSuggestionStrip(suggestedWords, null);
+ mKeyboardSwitcher.getKeyboardView().showGesturePreviewText(null);
if (suggestedWords == null || suggestedWords.size() == 0) {
return;
}
@@ -2044,18 +2057,28 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
public void onRefreshKeyboard() {
// When the device locale is changed in SetupWizard etc., this method may get called via
// onConfigurationChanged before SoftInputWindow is shown.
+ initSuggest();
+ loadSettings();
if (mKeyboardSwitcher.getKeyboardView() != null) {
// Reload keyboard because the current language has been changed.
mKeyboardSwitcher.loadKeyboard(getCurrentInputEditorInfo(), mCurrentSettings);
+ updateKeyboardViewGestureHandlingModeByMainDictionaryAvailability();
}
- initSuggest();
- loadSettings();
// Since we just changed languages, we should re-evaluate suggestions with whatever word
// we are currently composing. If we are not composing anything, we may want to display
// predictions or punctuation signs (which is done by the updateSuggestionStrip anyway).
mHandler.postUpdateSuggestionStrip();
}
+ private void updateKeyboardViewGestureHandlingModeByMainDictionaryAvailability() {
+ final MainKeyboardView keyboardView = mKeyboardSwitcher.getKeyboardView();
+ if (keyboardView != null) {
+ final boolean shouldHandleGesture = mCurrentSettings.mGestureInputEnabled
+ && mIsMainDictionaryAvailable;
+ keyboardView.setGestureHandlingMode(shouldHandleGesture);
+ }
+ }
+
// TODO: Remove this method from {@link LatinIME} and move {@link FeedbackManager} to
// {@link KeyboardSwitcher}. Called from KeyboardSwitcher
public void hapticAndAudioFeedback(final int primaryCode) {