diff options
author | 2012-08-08 11:41:58 +0900 | |
---|---|---|
committer | 2012-08-09 11:55:41 +0900 | |
commit | 8335c59ea7715f3dbc6625f128a7a038f314a89f (patch) | |
tree | 97df9113b76753b823ec9330007a661797b542e6 /java/src/com/android/inputmethod/latin/LatinIME.java | |
parent | 732f27984e3e9c98748aee4726dc9eaed7a14776 (diff) | |
download | latinime-8335c59ea7715f3dbc6625f128a7a038f314a89f.tar.gz latinime-8335c59ea7715f3dbc6625f128a7a038f314a89f.tar.xz latinime-8335c59ea7715f3dbc6625f128a7a038f314a89f.zip |
Fix NPE and don't call UI API from non-UI thread
This change also reverts I29ec3e9f10484f30288fac76f0c45b3707bc2259
Bug: 6956969
Bug: 6891020
Bug: 6947253
Change-Id: I7901c0f9489b4deb79314c2c903b138611bfd78e
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 43901bab4..894b69b79 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -433,10 +433,14 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen resetContactsDictionary(null == mSuggest ? null : mSuggest.getContactsDictionary()); } + // Note that this method is called from a non-UI thread. @Override public void onUpdateMainDictionaryAvailability(boolean isMainDictionaryAvailable) { mIsMainDictionaryAvailable = isMainDictionaryAvailable; - updateKeyboardViewGestureHandlingModeByMainDictionaryAvailability(); + final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView(); + if (mainKeyboardView != null) { + mainKeyboardView.setMainDictionaryAvailability(isMainDictionaryAvailable); + } } private void initSuggest() { @@ -701,7 +705,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } switcher.loadKeyboard(editorInfo, mCurrentSettings); - updateKeyboardViewGestureHandlingModeByMainDictionaryAvailability(); } setSuggestionStripShownInternal( isSuggestionsStripVisible(), /* needsInputViewShown */ false); @@ -721,6 +724,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mainKeyboardView.setKeyPreviewPopupEnabled(mCurrentSettings.mKeyPreviewPopupOn, mCurrentSettings.mKeyPreviewPopupDismissDelay); + mainKeyboardView.setGestureHandlingEnabledByUser(mCurrentSettings.mGestureInputEnabled); + mainKeyboardView.setGesturePreviewMode(mCurrentSettings.mGesturePreviewTrailEnabled, + mCurrentSettings.mGestureFloatingPreviewTextEnabled); if (TRACE) Debug.startMethodTracing("/data/trace/latinime"); } @@ -2103,7 +2109,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (mKeyboardSwitcher.getMainKeyboardView() != null) { // Reload keyboard because the current language has been changed. mKeyboardSwitcher.loadKeyboard(getCurrentInputEditorInfo(), mCurrentSettings); - updateKeyboardViewGestureHandlingModeByMainDictionaryAvailability(); } // 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 @@ -2111,17 +2116,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mHandler.postUpdateSuggestionStrip(); } - private void updateKeyboardViewGestureHandlingModeByMainDictionaryAvailability() { - final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView(); - if (mainKeyboardView != null) { - final boolean shouldHandleGesture = mCurrentSettings.mGestureInputEnabled - && mIsMainDictionaryAvailable; - mainKeyboardView.setGestureHandlingMode(shouldHandleGesture, - mCurrentSettings.mGesturePreviewTrailEnabled, - mCurrentSettings.mGestureFloatingPreviewTextEnabled); - } - } - // TODO: Remove this method from {@link LatinIME} and move {@link FeedbackManager} to // {@link KeyboardSwitcher}. Called from KeyboardSwitcher public void hapticAndAudioFeedback(final int primaryCode) { |