am 1b7c1cd5: Merge "Add PersionalizationDictionaryRegister"
* commit '1b7c1cd513c53e1d1f07a328405c71509a0ecb6c': Add PersionalizationDictionaryRegistermain
commit
39acbaeeaa
|
@ -74,6 +74,7 @@ import com.android.inputmethod.keyboard.MainKeyboardView;
|
|||
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
|
||||
import com.android.inputmethod.latin.define.ProductionFlag;
|
||||
import com.android.inputmethod.latin.personalization.PersonalizationDictionaryHelper;
|
||||
import com.android.inputmethod.latin.personalization.PersonalizationDictionarySessionRegister;
|
||||
import com.android.inputmethod.latin.personalization.PersonalizationPredictionDictionary;
|
||||
import com.android.inputmethod.latin.personalization.UserHistoryPredictionDictionary;
|
||||
import com.android.inputmethod.latin.settings.Settings;
|
||||
|
@ -470,6 +471,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
KeyboardSwitcher.init(this);
|
||||
AudioAndHapticFeedbackManager.init(this);
|
||||
AccessibilityUtils.init(this);
|
||||
PersonalizationDictionarySessionRegister.init(this);
|
||||
|
||||
super.onCreate();
|
||||
|
||||
|
@ -650,6 +652,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
|
|||
mOptionsDialog.dismiss();
|
||||
}
|
||||
}
|
||||
PersonalizationDictionarySessionRegister.onConfigurationChanged(this, conf);
|
||||
super.onConfigurationChanged(conf);
|
||||
}
|
||||
|
||||
|
|
|
@ -402,7 +402,11 @@ public abstract class DynamicPredictionDictionaryBase extends ExpandableDictiona
|
|||
}
|
||||
|
||||
public void registerUpdateSession(PersonalizationDictionaryUpdateSession session) {
|
||||
session.setDictionary(this);
|
||||
session.setPredictionDictionary(mLocale, this);
|
||||
mSessions.add(session);
|
||||
}
|
||||
|
||||
public void unRegisterUpdateSession(PersonalizationDictionaryUpdateSession session) {
|
||||
mSessions.remove(session);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,9 +59,8 @@ public class PersonalizationDictionaryHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public static void
|
||||
registerPersonalizationDictionaryUpdateSession(final Context context,
|
||||
final PersonalizationDictionaryUpdateSession session) {
|
||||
public static void registerPersonalizationDictionaryUpdateSession(final Context context,
|
||||
final PersonalizationDictionaryUpdateSession session) {
|
||||
final PersonalizationPredictionDictionary dictionary =
|
||||
getPersonalizationPredictionDictionary(context,
|
||||
context.getResources().getConfiguration().locale.toString(),
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (C) 2013 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 android.content.res.Configuration;
|
||||
|
||||
public class PersonalizationDictionarySessionRegister {
|
||||
public static void init(Context context) {
|
||||
}
|
||||
|
||||
public static void onConfigurationChanged(final Context context, final Configuration conf) {
|
||||
}
|
||||
}
|
|
@ -43,18 +43,36 @@ public abstract class PersonalizationDictionaryUpdateSession {
|
|||
}
|
||||
|
||||
// TODO: Use a dynamic binary dictionary instead
|
||||
public WeakReference<DynamicPredictionDictionaryBase> mDictionary;
|
||||
public WeakReference<DynamicPredictionDictionaryBase> mPredictionDictionary;
|
||||
public String mLocale;
|
||||
|
||||
public abstract void onDictionaryReady();
|
||||
|
||||
public void setDictionary(DynamicPredictionDictionaryBase dictionary) {
|
||||
mDictionary = new WeakReference<DynamicPredictionDictionaryBase>(dictionary);
|
||||
public void setPredictionDictionary(String locale, DynamicPredictionDictionaryBase dictionary) {
|
||||
mPredictionDictionary = new WeakReference<DynamicPredictionDictionaryBase>(dictionary);
|
||||
mLocale = locale;
|
||||
}
|
||||
|
||||
protected DynamicPredictionDictionaryBase getPredictionDictionary() {
|
||||
return mPredictionDictionary == null ? null : mPredictionDictionary.get();
|
||||
}
|
||||
|
||||
private void unsetPredictionDictionary() {
|
||||
final DynamicPredictionDictionaryBase dictionary = getPredictionDictionary();
|
||||
if (dictionary == null) {
|
||||
return;
|
||||
}
|
||||
dictionary.unRegisterUpdateSession(this);
|
||||
}
|
||||
|
||||
|
||||
public void closeSession() {
|
||||
unsetPredictionDictionary();
|
||||
}
|
||||
|
||||
public void addToPersonalizationDictionary(
|
||||
final ArrayList<PersonalizationLanguageModelParam> lmParams) {
|
||||
final DynamicPredictionDictionaryBase dictionary = mDictionary == null
|
||||
? null : mDictionary.get();
|
||||
final DynamicPredictionDictionaryBase dictionary = getPredictionDictionary();
|
||||
if (dictionary == null) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue