diff options
author | 2014-03-03 04:00:23 +0000 | |
---|---|---|
committer | 2014-03-03 04:00:24 +0000 | |
commit | e76c273502612c978761e32fe68402cab3db8ca6 (patch) | |
tree | 0cda63e931176c3e2ef671804efd3d7e6f003bf0 /java/src/com/android/inputmethod/latin/LatinIME.java | |
parent | 858045b41c589e178bef8b8269bb423f231f77e6 (diff) | |
parent | 1aac28a2b9e1013970e737639872ffb9cd7b26b0 (diff) | |
download | latinime-e76c273502612c978761e32fe68402cab3db8ca6.tar.gz latinime-e76c273502612c978761e32fe68402cab3db8ca6.tar.xz latinime-e76c273502612c978761e32fe68402cab3db8ca6.zip |
Merge changes I20ce61c4,I2edab4e3
* changes:
Remove "Use only personalization dictionary".
Remove redundant creation of dictionary facilitator.
Diffstat (limited to 'java/src/com/android/inputmethod/latin/LatinIME.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index bfc578082..4c2454c32 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -530,27 +530,31 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen final EditorInfo editorInfo = getCurrentInputEditorInfo(); final InputAttributes inputAttributes = new InputAttributes(editorInfo, isFullscreenMode()); mSettings.loadSettings(this, locale, inputAttributes); - AudioAndHapticFeedbackManager.getInstance().onSettingsChanged(mSettings.getCurrent()); - // To load the keyboard we need to load all the settings once, but resetting the - // contacts dictionary should be deferred until after the new layout has been displayed - // to improve responsivity. In the language switching process, we post a reopenDictionaries - // message, then come here to read the settings for the new language before we change - // the layout; at this time, we need to skip resetting the contacts dictionary. It will - // be done later inside {@see #initSuggest()} when the reopenDictionaries message is - // processed. final SettingsValues currentSettingsValues = mSettings.getCurrent(); - final Suggest suggest = mInputLogic.mSuggest; - if (!mHandler.hasPendingReopenDictionaries() && suggest != null) { + AudioAndHapticFeedbackManager.getInstance().onSettingsChanged(currentSettingsValues); + // This method is called on startup and language switch, before the new layout has + // been displayed. Opening dictionaries never affects responsivity as dictionaries are + // asynchronously loaded. + initOrResetSuggestForSettingsValues(mInputLogic.mSuggest, locale, currentSettingsValues); + } + + private void initOrResetSuggestForSettingsValues(final Suggest oldSuggest, + final Locale locale, final SettingsValues settingsValues) { + if (!mHandler.hasPendingReopenDictionaries() && oldSuggest != null) { // May need to reset dictionaries depending on the user settings. final DictionaryFacilitatorForSuggest oldDictionaryFacilitator = - suggest.mDictionaryFacilitator; + oldSuggest.mDictionaryFacilitator; + if (!oldDictionaryFacilitator.needsToBeRecreated(locale, settingsValues)) { + // Continue to use the same dictionary facilitator if no configuration has changed. + refreshPersonalizationDictionarySession(); + return; + } final DictionaryFacilitatorForSuggest dictionaryFacilitator = - new DictionaryFacilitatorForSuggest(currentSettingsValues, - oldDictionaryFacilitator); + new DictionaryFacilitatorForSuggest(settingsValues, oldDictionaryFacilitator); // Create Suggest instance with the new dictionary facilitator. - resetSuggest(new Suggest(suggest /* oldSuggest */, dictionaryFacilitator)); - } else if (suggest == null) { - initSuggestForLocale(locale); + replaceSuggest(new Suggest(oldSuggest, dictionaryFacilitator)); + } else if (oldSuggest == null) { + initSuggestForLocale(oldSuggest, locale); } } @@ -610,13 +614,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen } else { subtypeLocale = switcherSubtypeLocale; } - initSuggestForLocale(subtypeLocale); + initSuggestForLocale(mInputLogic.mSuggest, subtypeLocale); } - private void initSuggestForLocale(final Locale locale) { + private void initSuggestForLocale(final Suggest oldSuggest, final Locale locale) { final SettingsValues settingsValues = mSettings.getCurrent(); final DictionaryFacilitatorForSuggest oldDictionaryFacilitator = - (mInputLogic.mSuggest == null) ? null : mInputLogic.mSuggest.mDictionaryFacilitator; + (oldSuggest == null) ? null : oldSuggest.mDictionaryFacilitator; // Creates new dictionary facilitator for the new locale. final DictionaryFacilitatorForSuggest dictionaryFacilitator = new DictionaryFacilitatorForSuggest(this /* context */, locale, settingsValues, @@ -625,7 +629,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen if (settingsValues.mCorrectionEnabled) { newSuggest.setAutoCorrectionThreshold(settingsValues.mAutoCorrectionThreshold); } - resetSuggest(newSuggest); + replaceSuggest(newSuggest); } /* package private */ void resetSuggestMainDict() { @@ -633,10 +637,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mInputLogic.mSuggest.mDictionaryFacilitator; final DictionaryFacilitatorForSuggest dictionaryFacilitator = new DictionaryFacilitatorForSuggest(this /* listener */, oldDictionaryFacilitator); - resetSuggest(new Suggest(mInputLogic.mSuggest /* oldSuggest */, dictionaryFacilitator)); + replaceSuggest(new Suggest(mInputLogic.mSuggest /* oldSuggest */, dictionaryFacilitator)); } - private void resetSuggest(final Suggest newSuggest) { + private void replaceSuggest(final Suggest newSuggest) { if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { ResearchLogger.getInstance().initDictionary(newSuggest.mDictionaryFacilitator); } @@ -1733,7 +1737,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen final DictionaryFacilitatorForSuggest dictionaryFacilitator = new DictionaryFacilitatorForSuggest(this, locale, mSettings.getCurrent(), this /* listener */, oldDictionaryFacilitator); - resetSuggest(new Suggest(locale, dictionaryFacilitator)); + replaceSuggest(new Suggest(locale, dictionaryFacilitator)); } // DO NOT USE THIS for any other purpose than testing. |