From c6799ffeab17d3e0dc54a1718dad9890e5493ae0 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Sat, 23 Feb 2013 01:35:21 -0800 Subject: [PATCH] Send the dictionaries descriptions to the dict pack Bug: 8255795 Change-Id: I12a5922f50c2d2e3aa639457abcc1483e6a48721 --- .../inputmethod/latin/DictionaryInfoUtils.java | 11 ++++++++--- .../inputmethod/latin/makedict/FormatSpec.java | 8 ++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/DictionaryInfoUtils.java b/java/src/com/android/inputmethod/latin/DictionaryInfoUtils.java index 28234659d..dcfa483f8 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryInfoUtils.java +++ b/java/src/com/android/inputmethod/latin/DictionaryInfoUtils.java @@ -49,17 +49,20 @@ public class DictionaryInfoUtils { 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 @@ public class DictionaryInfoUtils { 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 @@ public class DictionaryInfoUtils { 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 dictList, diff --git a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java index 60ba66e27..e1e5e5500 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 @@ public final class FormatSpec { 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 final class FormatSpec { 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() {