From 8bfc8c46ffc755752dbf11a105ef40b8fc5ae390 Mon Sep 17 00:00:00 2001 From: Keisuke Kuroyanagi Date: Tue, 3 Dec 2013 19:22:17 +0900 Subject: Add required header attributes for user/contacts dictionary. Bug: 11973488 Change-Id: I91ef720a24633aec0f4e81cd4f7c49c749805c49 --- .../DecayingExpandableBinaryDictionaryBase.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java') diff --git a/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java b/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java index dbf6d0046..8f26f8442 100644 --- a/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java +++ b/java/src/com/android/inputmethod/latin/personalization/DecayingExpandableBinaryDictionaryBase.java @@ -35,7 +35,9 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; +import java.util.Locale; import java.util.Map; +import java.util.concurrent.TimeUnit; /** * This class is a base class of a dictionary that supports decaying for the personalized language @@ -55,7 +57,7 @@ public abstract class DecayingExpandableBinaryDictionaryBase extends ExpandableB public static final int REQUIRED_BINARY_DICTIONARY_VERSION = 4; /** Locale for which this user history dictionary is storing words */ - private final String mLocale; + private final Locale mLocale; private final String mFileName; @@ -66,11 +68,11 @@ public abstract class DecayingExpandableBinaryDictionaryBase extends ExpandableB @UsedForTesting boolean mIsTest = false; /* package */ DecayingExpandableBinaryDictionaryBase(final Context context, - final String locale, final String dictionaryType, final String fileName) { - super(context, fileName, dictionaryType, true); + final Locale locale, final String dictionaryType, final String fileName) { + super(context, fileName, locale, dictionaryType, true); mLocale = locale; mFileName = fileName; - if (mLocale != null && mLocale.length() > 1) { + if (mLocale != null && mLocale.toString().length() > 1) { reloadDictionaryIfRequired(); } } @@ -93,7 +95,9 @@ public abstract class DecayingExpandableBinaryDictionaryBase extends ExpandableB attributeMap.put(FormatSpec.FileHeader.USES_FORGETTING_CURVE_ATTRIBUTE, FormatSpec.FileHeader.ATTRIBUTE_VALUE_TRUE); attributeMap.put(FormatSpec.FileHeader.DICTIONARY_ID_ATTRIBUTE, mFileName); - attributeMap.put(FormatSpec.FileHeader.DICTIONARY_LOCALE_ATTRIBUTE, mLocale); + attributeMap.put(FormatSpec.FileHeader.DICTIONARY_LOCALE_ATTRIBUTE, mLocale.toString()); + attributeMap.put(FormatSpec.FileHeader.DICTIONARY_VERSION_ATTRIBUTE, + String.valueOf(TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()))); return attributeMap; } @@ -164,10 +168,6 @@ public abstract class DecayingExpandableBinaryDictionaryBase extends ExpandableB // Never loaded to memory in Java side. } - protected String getLocale() { - return mLocale; - } - public void registerUpdateSession(PersonalizationDictionaryUpdateSession session) { session.setPredictionDictionary(this); mSessions.add(session); -- cgit v1.2.3-83-g751a