aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java
diff options
context:
space:
mode:
authorKeisuke Kuroyanagi <ksk@google.com>2013-12-03 19:22:17 +0900
committerKeisuke Kuroyanagi <ksk@google.com>2013-12-03 19:22:17 +0900
commit8bfc8c46ffc755752dbf11a105ef40b8fc5ae390 (patch)
tree41a183e85ad20025247144808754161c7e7fade4 /java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java
parentb6764c51ab6acc8b5acf3ce3513e30c9ce82d02c (diff)
downloadlatinime-8bfc8c46ffc755752dbf11a105ef40b8fc5ae390.tar.gz
latinime-8bfc8c46ffc755752dbf11a105ef40b8fc5ae390.tar.xz
latinime-8bfc8c46ffc755752dbf11a105ef40b8fc5ae390.zip
Add required header attributes for user/contacts dictionary.
Bug: 11973488 Change-Id: I91ef720a24633aec0f4e81cd4f7c49c749805c49
Diffstat (limited to 'java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java')
-rw-r--r--java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java18
1 files changed, 13 insertions, 5 deletions
diff --git a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java
index 17cb7151d..154e9b58b 100644
--- a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java
@@ -33,8 +33,10 @@ import com.android.inputmethod.latin.utils.StringUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
@@ -99,6 +101,9 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
*/
private final String mFilename;
+ /** Dictionary locale */
+ private final Locale mLocale;
+
/** Whether to support dynamically updating the dictionary */
private final boolean mIsUpdatable;
@@ -183,15 +188,17 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
* @param context The application context of the parent.
* @param filename The filename for this binary dictionary. Multiple dictionaries with the same
* filename is supported.
+ * @param locale the dictionary locale.
* @param dictType the dictionary type, as a human-readable string
* @param isUpdatable whether to support dynamically updating the dictionary. Please note that
* dynamic dictionary has negative effects on memory space and computation time.
*/
public ExpandableBinaryDictionary(final Context context, final String filename,
- final String dictType, final boolean isUpdatable) {
+ final Locale locale, final String dictType, final boolean isUpdatable) {
super(dictType);
mFilename = filename;
mContext = context;
+ mLocale = locale;
mIsUpdatable = isUpdatable;
mBinaryDictionary = null;
mFilenameDictionaryUpdateController = getDictionaryUpdateController(filename);
@@ -199,8 +206,8 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
mDictionaryWriter = getDictionaryWriter(context, dictType, isUpdatable);
}
- protected static String getFilenameWithLocale(final String name, final String localeStr) {
- return name + "." + localeStr + DICT_FILE_EXTENSION;
+ protected static String getFilenameWithLocale(final String name, final Locale locale) {
+ return name + "." + locale.toString() + DICT_FILE_EXTENSION;
}
/**
@@ -237,9 +244,10 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
protected Map<String, String> getHeaderAttributeMap() {
HashMap<String, String> attributeMap = new HashMap<String, String>();
- attributeMap.put(FormatSpec.FileHeader.SUPPORTS_DYNAMIC_UPDATE_ATTRIBUTE,
- SUPPORTS_DYNAMIC_UPDATE);
attributeMap.put(FormatSpec.FileHeader.DICTIONARY_ID_ATTRIBUTE, mFilename);
+ 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;
}