am d91268ad: Initialize dictionaries at onStartInputView

* commit 'd91268ad9fb69b4733044b4e466e1d33f6c4725f':
  Initialize dictionaries at onStartInputView
main
Jean Chalard 2013-04-18 09:24:45 -07:00 committed by Android Git Automerger
commit a5d2da82a6
2 changed files with 11 additions and 5 deletions

View File

@ -439,6 +439,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
mHandler.onCreate(); mHandler.onCreate();
DEBUG = LatinImeLogger.sDBG; DEBUG = LatinImeLogger.sDBG;
// TODO: Resolve mutual dependencies of {@link #loadSettings()} and {@link #initSuggest()}.
loadSettings(); loadSettings();
initSuggest(); initSuggest();
@ -476,6 +477,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
final InputAttributes inputAttributes = final InputAttributes inputAttributes =
new InputAttributes(getCurrentInputEditorInfo(), isFullscreenMode()); new InputAttributes(getCurrentInputEditorInfo(), isFullscreenMode());
mSettings.loadSettings(locale, inputAttributes); mSettings.loadSettings(locale, inputAttributes);
// May need to reset the contacts dictionary depending on the user settings.
resetContactsDictionary(null == mSuggest ? null : mSuggest.getContactsDictionary()); resetContactsDictionary(null == mSuggest ? null : mSuggest.getContactsDictionary());
} }
@ -745,6 +747,11 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
mRecapitalizeStatus.deactivate(); mRecapitalizeStatus.deactivate();
mCurrentlyPressedHardwareKeys.clear(); mCurrentlyPressedHardwareKeys.clear();
// Note: the following does a round-trip IPC on the main thread: be careful
final Locale currentLocale = mSubtypeSwitcher.getCurrentSubtypeLocale();
if (null != mSuggest && null != currentLocale && !currentLocale.equals(mSuggest.mLocale)) {
initSuggest();
}
if (mSuggestionStripView != null) { if (mSuggestionStripView != null) {
// This will set the punctuation suggestions if next word suggestion is off; // This will set the punctuation suggestions if next word suggestion is off;
// otherwise it will clear the suggestion strip. // otherwise it will clear the suggestion strip.
@ -797,8 +804,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
// to the user dictionary. // to the user dictionary.
if (null != mPositionalInfoForUserDictPendingAddition if (null != mPositionalInfoForUserDictPendingAddition
&& mPositionalInfoForUserDictPendingAddition.tryReplaceWithActualWord( && mPositionalInfoForUserDictPendingAddition.tryReplaceWithActualWord(
mConnection, editorInfo, mLastSelectionEnd, mConnection, editorInfo, mLastSelectionEnd, currentLocale)) {
mSubtypeSwitcher.getCurrentSubtypeLocale())) {
mPositionalInfoForUserDictPendingAddition = null; mPositionalInfoForUserDictPendingAddition = null;
} }
// If tryReplaceWithActualWord returns false, we don't know what word was // If tryReplaceWithActualWord returns false, we don't know what word was
@ -2577,8 +2583,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
// Outside LatinIME, only used by the {@link InputTestsBase} test suite. // Outside LatinIME, only used by the {@link InputTestsBase} test suite.
@UsedForTesting @UsedForTesting
void loadKeyboard() { void loadKeyboard() {
// When the device locale is changed in SetupWizard etc., this method may get called via // TODO: Why are we calling {@link #loadSettings()} and {@link #initSuggest()} in a
// onConfigurationChanged before SoftInputWindow is shown. // different order than in {@link #onStartInputView}?
initSuggest(); initSuggest();
loadSettings(); loadSettings();
if (mKeyboardSwitcher.getMainKeyboardView() != null) { if (mKeyboardSwitcher.getMainKeyboardView() != null) {

View File

@ -68,7 +68,7 @@ public final class Suggest {
private float mAutoCorrectionThreshold; private float mAutoCorrectionThreshold;
// Locale used for upper- and title-casing words // Locale used for upper- and title-casing words
private final Locale mLocale; public final Locale mLocale;
public Suggest(final Context context, final Locale locale, public Suggest(final Context context, final Locale locale,
final SuggestInitializationListener listener) { final SuggestInitializationListener listener) {