Merge "Contextual dictionary updater."

main
Keisuke Kuroyanagi 2014-06-16 02:39:42 +00:00 committed by Android (Google) Code Review
commit a4f2e8eee0
2 changed files with 44 additions and 1 deletions

View File

@ -69,6 +69,7 @@ import com.android.inputmethod.latin.Suggest.OnGetSuggestedWordsCallback;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.define.ProductionFlag; import com.android.inputmethod.latin.define.ProductionFlag;
import com.android.inputmethod.latin.inputlogic.InputLogic; 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.DictionaryDecayBroadcastReciever;
import com.android.inputmethod.latin.personalization.PersonalizationDictionaryUpdater; import com.android.inputmethod.latin.personalization.PersonalizationDictionaryUpdater;
import com.android.inputmethod.latin.personalization.PersonalizationHelper; import com.android.inputmethod.latin.personalization.PersonalizationHelper;
@ -125,6 +126,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// TODO: Move from LatinIME. // TODO: Move from LatinIME.
private final PersonalizationDictionaryUpdater mPersonalizationDictionaryUpdater = private final PersonalizationDictionaryUpdater mPersonalizationDictionaryUpdater =
new PersonalizationDictionaryUpdater(this /* context */, mDictionaryFacilitator); new PersonalizationDictionaryUpdater(this /* context */, mDictionaryFacilitator);
private final ContextualDictionaryUpdater mContextualDictionaryUpdater =
new ContextualDictionaryUpdater(this /* context */, mDictionaryFacilitator);
private final InputLogic mInputLogic = new InputLogic(this /* LatinIME */, private final InputLogic mInputLogic = new InputLogic(this /* LatinIME */,
this /* SuggestionStripViewAccessor */, mDictionaryFacilitator); this /* SuggestionStripViewAccessor */, mDictionaryFacilitator);
// We expect to have only one decoder in almost all cases, hence the default capacity of 1. // 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( mPersonalizationDictionaryUpdater.onLoadSettings(
currentSettingsValues.mUsePersonalizedDicts, currentSettingsValues.mUsePersonalizedDicts,
mSubtypeSwitcher.isSystemLocaleSameAsLocaleOfAllEnabledSubtypesOfEnabledImes()); mSubtypeSwitcher.isSystemLocaleSameAsLocaleOfAllEnabledSubtypesOfEnabledImes());
mContextualDictionaryUpdater.onLoadSettings(currentSettingsValues.mUsePersonalizedDicts);
final boolean shouldKeepUserHistoryDictionaries; final boolean shouldKeepUserHistoryDictionaries;
if (mSettings.getCurrent().mUsePersonalizedDicts) { if (currentSettingsValues.mUsePersonalizedDicts) {
shouldKeepUserHistoryDictionaries = true; shouldKeepUserHistoryDictionaries = true;
} else { } else {
shouldKeepUserHistoryDictionaries = false; shouldKeepUserHistoryDictionaries = false;
@ -623,6 +627,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
public void onDestroy() { public void onDestroy() {
mDictionaryFacilitator.closeDictionaries(); mDictionaryFacilitator.closeDictionaries();
mPersonalizationDictionaryUpdater.onDestroy(); mPersonalizationDictionaryUpdater.onDestroy();
mContextualDictionaryUpdater.onDestroy();
mSettings.onDestroy(); mSettings.onDestroy();
unregisterReceiver(mConnectivityAndRingerModeChangeReceiver); unregisterReceiver(mConnectivityAndRingerModeChangeReceiver);
unregisterReceiver(mDictionaryPackInstallReceiver); unregisterReceiver(mDictionaryPackInstallReceiver);
@ -864,6 +869,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
currentSettingsValues.mGestureTrailEnabled, currentSettingsValues.mGestureTrailEnabled,
currentSettingsValues.mGestureFloatingPreviewTextEnabled); currentSettingsValues.mGestureFloatingPreviewTextEnabled);
// Contextual dictionary should be updated for the current application.
mContextualDictionaryUpdater.onStartInputView(editorInfo.packageName);
if (TRACE) Debug.startMethodTracing("/data/trace/latinime"); if (TRACE) Debug.startMethodTracing("/data/trace/latinime");
} }

View File

@ -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() {
}
}