Send the dictionaries descriptions to the dict pack
Bug: 8255795
Change-Id: I12a5922f50c2d2e3aa639457abcc1483e6a48721
diff --git a/java/src/com/android/inputmethod/latin/DictionaryInfoUtils.java b/java/src/com/android/inputmethod/latin/DictionaryInfoUtils.java
index 2823465..dcfa483 100644
--- a/java/src/com/android/inputmethod/latin/DictionaryInfoUtils.java
+++ b/java/src/com/android/inputmethod/latin/DictionaryInfoUtils.java
@@ -49,17 +49,20 @@
private static final String LOCALE_COLUMN = "locale";
private static final String WORDLISTID_COLUMN = "id";
private static final String LOCAL_FILENAME_COLUMN = "filename";
+ private static final String DESCRIPTION_COLUMN = "description";
private static final String DATE_COLUMN = "date";
private static final String FILESIZE_COLUMN = "filesize";
private static final String VERSION_COLUMN = "version";
+ public final String mId;
public final Locale mLocale;
+ public final String mDescription;
public final AssetFileAddress mFileAddress;
public final int mVersion;
- public final String mId;
- public DictionaryInfo(final String id, final Locale locale,
+ public DictionaryInfo(final String id, final Locale locale, final String description,
final AssetFileAddress fileAddress, final int version) {
mId = id;
mLocale = locale;
+ mDescription = description;
mFileAddress = fileAddress;
mVersion = version;
}
@@ -67,6 +70,7 @@
final ContentValues values = new ContentValues();
values.put(WORDLISTID_COLUMN, mId);
values.put(LOCALE_COLUMN, mLocale.toString());
+ values.put(DESCRIPTION_COLUMN, mDescription);
values.put(LOCAL_FILENAME_COLUMN, mFileAddress.mFilename);
values.put(DATE_COLUMN,
new File(mFileAddress.mFilename).lastModified() / DateUtils.SECOND_IN_MILLIS);
@@ -283,8 +287,9 @@
new File(fileAddress.mFilename), fileAddress.mOffset, fileAddress.mLength);
final String id = header.getId();
final Locale locale = LocaleUtils.constructLocaleFromString(header.getLocaleString());
+ final String description = header.getDescription();
final String version = header.getVersion();
- return new DictionaryInfo(id, locale, fileAddress, Integer.parseInt(version));
+ return new DictionaryInfo(id, locale, description, fileAddress, Integer.parseInt(version));
}
private static void addOrUpdateDictInfo(final ArrayList<DictionaryInfo> dictList,
diff --git a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java
index 60ba66e..e1e5e55 100644
--- a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java
+++ b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java
@@ -259,6 +259,7 @@
private static final String DICTIONARY_VERSION_ATTRIBUTE = "version";
private static final String DICTIONARY_LOCALE_ATTRIBUTE = "locale";
private static final String DICTIONARY_ID_ATTRIBUTE = "dictionary";
+ private static final String DICTIONARY_DESCRIPTION_ATTRIBUTE = "description";
public FileHeader(final int headerSize, final DictionaryOptions dictionaryOptions,
final FormatOptions formatOptions) {
mHeaderSize = headerSize;
@@ -280,6 +281,13 @@
public String getId() {
return mDictionaryOptions.mAttributes.get(FileHeader.DICTIONARY_ID_ATTRIBUTE);
}
+
+ // Helper method to get the description
+ public String getDescription() {
+ // TODO: Right now each dictionary file comes with a description in its own language.
+ // It will display as is no matter the device's locale. It should be internationalized.
+ return mDictionaryOptions.mAttributes.get(FileHeader.DICTIONARY_DESCRIPTION_ATTRIBUTE);
+ }
}
private FormatSpec() {