From 1a4d815b0bba824cb6893ad9f6ef0597c9740378 Mon Sep 17 00:00:00 2001 From: Keisuke Kuroyanagi Date: Fri, 13 Jun 2014 18:39:29 +0900 Subject: [PATCH] Contextual dictionary updater. Bug: 14161647 Change-Id: I8106419678d5d26a4debec7bbef43af079c1ab18 --- .../android/inputmethod/latin/LatinIME.java | 9 ++++- .../ContextualDictionaryUpdater.java | 36 +++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 java/src/com/android/inputmethod/latin/personalization/ContextualDictionaryUpdater.java diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index b0774c49d..e5e070058 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -69,6 +69,7 @@ import com.android.inputmethod.latin.Suggest.OnGetSuggestedWordsCallback; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.define.ProductionFlag; import com.android.inputmethod.latin.inputlogic.InputLogic; +import com.android.inputmethod.latin.personalization.ContextualDictionaryUpdater; import com.android.inputmethod.latin.personalization.DictionaryDecayBroadcastReciever; import com.android.inputmethod.latin.personalization.PersonalizationDictionaryUpdater; import com.android.inputmethod.latin.personalization.PersonalizationHelper; @@ -125,6 +126,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // TODO: Move from LatinIME. private final PersonalizationDictionaryUpdater mPersonalizationDictionaryUpdater = new PersonalizationDictionaryUpdater(this /* context */, mDictionaryFacilitator); + private final ContextualDictionaryUpdater mContextualDictionaryUpdater = + new ContextualDictionaryUpdater(this /* context */, mDictionaryFacilitator); private final InputLogic mInputLogic = new InputLogic(this /* LatinIME */, this /* SuggestionStripViewAccessor */, mDictionaryFacilitator); // We expect to have only one decoder in almost all cases, hence the default capacity of 1. @@ -552,8 +555,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mPersonalizationDictionaryUpdater.onLoadSettings( currentSettingsValues.mUsePersonalizedDicts, mSubtypeSwitcher.isSystemLocaleSameAsLocaleOfAllEnabledSubtypesOfEnabledImes()); + mContextualDictionaryUpdater.onLoadSettings(currentSettingsValues.mUsePersonalizedDicts); final boolean shouldKeepUserHistoryDictionaries; - if (mSettings.getCurrent().mUsePersonalizedDicts) { + if (currentSettingsValues.mUsePersonalizedDicts) { shouldKeepUserHistoryDictionaries = true; } else { shouldKeepUserHistoryDictionaries = false; @@ -623,6 +627,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen public void onDestroy() { mDictionaryFacilitator.closeDictionaries(); mPersonalizationDictionaryUpdater.onDestroy(); + mContextualDictionaryUpdater.onDestroy(); mSettings.onDestroy(); unregisterReceiver(mConnectivityAndRingerModeChangeReceiver); unregisterReceiver(mDictionaryPackInstallReceiver); @@ -864,6 +869,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen currentSettingsValues.mGestureTrailEnabled, currentSettingsValues.mGestureFloatingPreviewTextEnabled); + // Contextual dictionary should be updated for the current application. + mContextualDictionaryUpdater.onStartInputView(editorInfo.packageName); if (TRACE) Debug.startMethodTracing("/data/trace/latinime"); } diff --git a/java/src/com/android/inputmethod/latin/personalization/ContextualDictionaryUpdater.java b/java/src/com/android/inputmethod/latin/personalization/ContextualDictionaryUpdater.java new file mode 100644 index 000000000..2cccf1615 --- /dev/null +++ b/java/src/com/android/inputmethod/latin/personalization/ContextualDictionaryUpdater.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.latin.personalization; + +import android.content.Context; + +import com.android.inputmethod.latin.DictionaryFacilitator; + +public class ContextualDictionaryUpdater { + public ContextualDictionaryUpdater(final Context context, + final DictionaryFacilitator dictionaryFacilitator) { + } + + public void onLoadSettings(final boolean usePersonalizedDicts) { + } + + public void onStartInputView(final String packageName) { + } + + public void onDestroy() { + } +}