am 0f3c05cd: Merge "Send the dictionaries descriptions to the dict pack"

* commit '0f3c05cd6bee664e5ccaf632c35c34017eb1c5e9':
  Send the dictionaries descriptions to the dict pack
main
Jean Chalard 2013-02-23 02:20:34 -08:00 committed by Android Git Automerger
commit 6b909d38f3
2 changed files with 16 additions and 3 deletions

View File

@ -49,17 +49,20 @@ public class DictionaryInfoUtils {
private static final String LOCALE_COLUMN = "locale"; private static final String LOCALE_COLUMN = "locale";
private static final String WORDLISTID_COLUMN = "id"; private static final String WORDLISTID_COLUMN = "id";
private static final String LOCAL_FILENAME_COLUMN = "filename"; 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 DATE_COLUMN = "date";
private static final String FILESIZE_COLUMN = "filesize"; private static final String FILESIZE_COLUMN = "filesize";
private static final String VERSION_COLUMN = "version"; private static final String VERSION_COLUMN = "version";
public final String mId;
public final Locale mLocale; public final Locale mLocale;
public final String mDescription;
public final AssetFileAddress mFileAddress; public final AssetFileAddress mFileAddress;
public final int mVersion; public final int mVersion;
public final String mId; public DictionaryInfo(final String id, final Locale locale, final String description,
public DictionaryInfo(final String id, final Locale locale,
final AssetFileAddress fileAddress, final int version) { final AssetFileAddress fileAddress, final int version) {
mId = id; mId = id;
mLocale = locale; mLocale = locale;
mDescription = description;
mFileAddress = fileAddress; mFileAddress = fileAddress;
mVersion = version; mVersion = version;
} }
@ -67,6 +70,7 @@ public class DictionaryInfoUtils {
final ContentValues values = new ContentValues(); final ContentValues values = new ContentValues();
values.put(WORDLISTID_COLUMN, mId); values.put(WORDLISTID_COLUMN, mId);
values.put(LOCALE_COLUMN, mLocale.toString()); values.put(LOCALE_COLUMN, mLocale.toString());
values.put(DESCRIPTION_COLUMN, mDescription);
values.put(LOCAL_FILENAME_COLUMN, mFileAddress.mFilename); values.put(LOCAL_FILENAME_COLUMN, mFileAddress.mFilename);
values.put(DATE_COLUMN, values.put(DATE_COLUMN,
new File(mFileAddress.mFilename).lastModified() / DateUtils.SECOND_IN_MILLIS); new File(mFileAddress.mFilename).lastModified() / DateUtils.SECOND_IN_MILLIS);
@ -283,8 +287,9 @@ public class DictionaryInfoUtils {
new File(fileAddress.mFilename), fileAddress.mOffset, fileAddress.mLength); new File(fileAddress.mFilename), fileAddress.mOffset, fileAddress.mLength);
final String id = header.getId(); final String id = header.getId();
final Locale locale = LocaleUtils.constructLocaleFromString(header.getLocaleString()); final Locale locale = LocaleUtils.constructLocaleFromString(header.getLocaleString());
final String description = header.getDescription();
final String version = header.getVersion(); 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, private static void addOrUpdateDictInfo(final ArrayList<DictionaryInfo> dictList,

View File

@ -259,6 +259,7 @@ public final class FormatSpec {
private static final String DICTIONARY_VERSION_ATTRIBUTE = "version"; private static final String DICTIONARY_VERSION_ATTRIBUTE = "version";
private static final String DICTIONARY_LOCALE_ATTRIBUTE = "locale"; private static final String DICTIONARY_LOCALE_ATTRIBUTE = "locale";
private static final String DICTIONARY_ID_ATTRIBUTE = "dictionary"; private static final String DICTIONARY_ID_ATTRIBUTE = "dictionary";
private static final String DICTIONARY_DESCRIPTION_ATTRIBUTE = "description";
public FileHeader(final int headerSize, final DictionaryOptions dictionaryOptions, public FileHeader(final int headerSize, final DictionaryOptions dictionaryOptions,
final FormatOptions formatOptions) { final FormatOptions formatOptions) {
mHeaderSize = headerSize; mHeaderSize = headerSize;
@ -280,6 +281,13 @@ public final class FormatSpec {
public String getId() { public String getId() {
return mDictionaryOptions.mAttributes.get(FileHeader.DICTIONARY_ID_ATTRIBUTE); 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() { private FormatSpec() {