Merge "Send the dictionaries descriptions to the dict pack"
This commit is contained in:
commit
0f3c05cd6b
2 changed files with 16 additions and 3 deletions
|
@ -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<DictionaryInfo> dictList,
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue