mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-30 13:12:25 -05:00
Rename StorageVersioning to StorageFormat
This commit is contained in:
parent
18cefedf32
commit
4bdc20c127
@ -7,12 +7,12 @@ import android.content.DialogInterface;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.fsck.k9.R;
|
import com.fsck.k9.R;
|
||||||
import com.fsck.k9.preferences.StorageVersioning;
|
import com.fsck.k9.preferences.StorageFormat;
|
||||||
|
|
||||||
public class ExportHelper {
|
public class ExportHelper {
|
||||||
public static void exportSettings(final Activity activity, final HashSet<String> accountUuids, final ExportListener listener) {
|
public static void exportSettings(final Activity activity, final HashSet<String> accountUuids, final ExportListener listener) {
|
||||||
// Once there are more versions, build a UI to select which one to use. For now, use the encrypted/encoded version:
|
// Once there are more versions, build a UI to select which one to use. For now, use the encrypted/encoded version:
|
||||||
String version = StorageVersioning.ENCRYPTED_XML_FILE;
|
String version = StorageFormat.ENCRYPTED_XML_FILE;
|
||||||
AsyncUIProcessor.getInstance(activity.getApplication()).exportSettings(activity, version, accountUuids, new ExportListener() {
|
AsyncUIProcessor.getInstance(activity.getApplication()).exportSettings(activity, version, accountUuids, new ExportListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -17,7 +17,7 @@ import com.fsck.k9.activity.PasswordEntryDialog;
|
|||||||
public class StorageExporter {
|
public class StorageExporter {
|
||||||
private static void exportPreferences(Activity activity, String version, HashSet<String> accountUuids, String fileName, OutputStream os, String encryptionKey, final ExportListener listener) {
|
private static void exportPreferences(Activity activity, String version, HashSet<String> accountUuids, String fileName, OutputStream os, String encryptionKey, final ExportListener listener) {
|
||||||
try {
|
try {
|
||||||
IStorageExporter storageExporter = StorageVersioning.createExporter(version);
|
IStorageExporter storageExporter = StorageFormat.createExporter(version);
|
||||||
if (storageExporter == null) {
|
if (storageExporter == null) {
|
||||||
throw new StorageImportExportException(activity.getString(R.string.settings_unknown_version, version), null);
|
throw new StorageImportExportException(activity.getString(R.string.settings_unknown_version, version), null);
|
||||||
}
|
}
|
||||||
|
@ -4,17 +4,17 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
public class StorageVersioning {
|
public class StorageFormat {
|
||||||
// Never, ever re-use these numbers!
|
// Never, ever re-use these numbers!
|
||||||
public static final String ENCRYPTED_XML_FILE = "1";
|
public static final String ENCRYPTED_XML_FILE = "1";
|
||||||
|
|
||||||
public static Map<String, StorageVersioning> versionMap = new HashMap<String, StorageVersioning>();
|
public static Map<String, StorageFormat> versionMap = new HashMap<String, StorageFormat>();
|
||||||
static {
|
static {
|
||||||
versionMap.put(ENCRYPTED_XML_FILE, new StorageVersioning(StorageImporterVersion1.class, StorageExporterVersion1.class, true));
|
versionMap.put(ENCRYPTED_XML_FILE, new StorageFormat(StorageImporterVersion1.class, StorageExporterVersion1.class, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IStorageImporter createImporter(String version) throws InstantiationException, IllegalAccessException {
|
public static IStorageImporter createImporter(String version) throws InstantiationException, IllegalAccessException {
|
||||||
StorageVersioning storageVersion = versionMap.get(version);
|
StorageFormat storageVersion = versionMap.get(version);
|
||||||
if (storageVersion == null) {
|
if (storageVersion == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -22,7 +22,7 @@ public class StorageVersioning {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static IStorageExporter createExporter(String version) throws InstantiationException, IllegalAccessException {
|
public static IStorageExporter createExporter(String version) throws InstantiationException, IllegalAccessException {
|
||||||
StorageVersioning storageVersion = versionMap.get(version);
|
StorageFormat storageVersion = versionMap.get(version);
|
||||||
if (storageVersion == null) {
|
if (storageVersion == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -30,7 +30,7 @@ public class StorageVersioning {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Boolean needsKey(String version) {
|
public static Boolean needsKey(String version) {
|
||||||
StorageVersioning storageVersion = versionMap.get(version);
|
StorageFormat storageVersion = versionMap.get(version);
|
||||||
if (storageVersion == null) {
|
if (storageVersion == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ public class StorageVersioning {
|
|||||||
private final Class <? extends IStorageExporter > exporterClass;
|
private final Class <? extends IStorageExporter > exporterClass;
|
||||||
private final boolean needsKey;
|
private final boolean needsKey;
|
||||||
|
|
||||||
private StorageVersioning(Class <? extends IStorageImporter > imclass, Class <? extends IStorageExporter > exclass, boolean nk) {
|
private StorageFormat(Class <? extends IStorageImporter > imclass, Class <? extends IStorageExporter > exclass, boolean nk) {
|
||||||
importerClass = imclass;
|
importerClass = imclass;
|
||||||
exporterClass = exclass;
|
exporterClass = exclass;
|
||||||
needsKey = nk;
|
needsKey = nk;
|
@ -42,7 +42,7 @@ public class StorageImporter {
|
|||||||
String version = dataset.attributes.get("version");
|
String version = dataset.attributes.get("version");
|
||||||
Log.i(K9.LOG_TAG, "Got settings file version " + version);
|
Log.i(K9.LOG_TAG, "Got settings file version " + version);
|
||||||
|
|
||||||
IStorageImporter storageImporter = StorageVersioning.createImporter(version);
|
IStorageImporter storageImporter = StorageFormat.createImporter(version);
|
||||||
if (storageImporter == null) {
|
if (storageImporter == null) {
|
||||||
throw new StorageImportExportException(activity.getString(R.string.settings_unknown_version, version));
|
throw new StorageImportExportException(activity.getString(R.string.settings_unknown_version, version));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user