Added constants for (export) file format version and "settings version"
This commit is contained in:
parent
33ae5ff7d0
commit
f2a3752930
2 changed files with 27 additions and 4 deletions
|
@ -20,6 +20,19 @@ import com.fsck.k9.K9;
|
|||
*/
|
||||
|
||||
public class Settings {
|
||||
/**
|
||||
* Version number of global and account settings.
|
||||
*
|
||||
* <p>
|
||||
* This value is used as "version" attribute in the export file. It needs to be incremented
|
||||
* when a global or account setting is added or removed, or when the format of a setting
|
||||
* is changed (e.g. add a value to an enum).
|
||||
* </p>
|
||||
*
|
||||
* @see StorageExporter
|
||||
*/
|
||||
public static final int VERSION = 1;
|
||||
|
||||
public static final IDefaultValue EXCEPTION_DEFAULT_VALUE = new ExceptionDefaultValue();
|
||||
|
||||
public static final ISettingValidator BOOLEAN_VALIDATOR = new BooleanValidator();
|
||||
|
|
|
@ -34,6 +34,17 @@ import com.fsck.k9.mail.store.LocalStore;
|
|||
public class StorageExporter {
|
||||
private static final String EXPORT_FILENAME = "settings.k9s";
|
||||
|
||||
/**
|
||||
* File format version number.
|
||||
*
|
||||
* <p>
|
||||
* Increment this if you need to change the structure of the settings file. When you do this
|
||||
* remember that we also have to be able to handle old file formats. So have fun adding support
|
||||
* for that to {@link StorageImporter} :)
|
||||
* </p>
|
||||
*/
|
||||
public static final int FILE_FORMAT_VERSION = 1;
|
||||
|
||||
public static final String ROOT_ELEMENT = "k9settings";
|
||||
public static final String VERSION_ATTRIBUTE = "version";
|
||||
public static final String FILE_FORMAT_ATTRIBUTE = "format";
|
||||
|
@ -160,10 +171,9 @@ public class StorageExporter {
|
|||
serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
|
||||
|
||||
serializer.startTag(null, ROOT_ELEMENT);
|
||||
//TODO: write content version number here
|
||||
serializer.attribute(null, VERSION_ATTRIBUTE, "x");
|
||||
//TODO: set file format version to "1" once the feature is stable and about to be merged into master
|
||||
serializer.attribute(null, FILE_FORMAT_ATTRIBUTE, "y");
|
||||
serializer.attribute(null, VERSION_ATTRIBUTE, Integer.toString(Settings.VERSION));
|
||||
serializer.attribute(null, FILE_FORMAT_ATTRIBUTE,
|
||||
Integer.toString(FILE_FORMAT_VERSION));
|
||||
|
||||
Log.i(K9.LOG_TAG, "Exporting preferences");
|
||||
|
||||
|
|
Loading…
Reference in a new issue