diff --git a/src/com/fsck/k9/activity/AsyncUIProcessor.java b/src/com/fsck/k9/activity/AsyncUIProcessor.java index 52d047296..7c9baa55c 100644 --- a/src/com/fsck/k9/activity/AsyncUIProcessor.java +++ b/src/com/fsck/k9/activity/AsyncUIProcessor.java @@ -41,7 +41,7 @@ public class AsyncUIProcessor { public void execute(Runnable runnable) { threadPool.execute(runnable); } - public void exportSettings(final Activity activity, final String version, final HashSet accountUuids, final ExportListener listener) { + public void exportSettings(final Activity activity, final String storageFormat, final HashSet accountUuids, final ExportListener listener) { threadPool.execute(new Runnable() { @Override @@ -54,7 +54,7 @@ public class AsyncUIProcessor { dir.mkdirs(); File file = Utility.createUniqueFile(dir, "settings.k9s"); String fileName = file.getAbsolutePath(); - StorageExporter.exportPreferences(activity, version, accountUuids, fileName, null, listener); + StorageExporter.exportPreferences(activity, storageFormat, accountUuids, fileName, null, listener); } catch (Exception e) { Log.w(K9.LOG_TAG, "Exception during export", e); listener.failure(e.getLocalizedMessage(), e); diff --git a/src/com/fsck/k9/activity/ExportHelper.java b/src/com/fsck/k9/activity/ExportHelper.java index c3414c667..385908001 100644 --- a/src/com/fsck/k9/activity/ExportHelper.java +++ b/src/com/fsck/k9/activity/ExportHelper.java @@ -11,9 +11,9 @@ import com.fsck.k9.preferences.StorageFormat; public class ExportHelper { public static void exportSettings(final Activity activity, final HashSet 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: - String version = StorageFormat.ENCRYPTED_XML_FILE; - AsyncUIProcessor.getInstance(activity.getApplication()).exportSettings(activity, version, accountUuids, new ExportListener() { + // Once there are more file formats, build a UI to select which one to use. For now, use the encrypted/encoded format: + String storageFormat = StorageFormat.ENCRYPTED_XML_FILE; + AsyncUIProcessor.getInstance(activity.getApplication()).exportSettings(activity, storageFormat, accountUuids, new ExportListener() { @Override public void canceled() { diff --git a/src/com/fsck/k9/preferences/StorageExporter.java b/src/com/fsck/k9/preferences/StorageExporter.java index 01c606df7..4f5ea6359 100644 --- a/src/com/fsck/k9/preferences/StorageExporter.java +++ b/src/com/fsck/k9/preferences/StorageExporter.java @@ -15,11 +15,11 @@ import com.fsck.k9.activity.ExportListener; import com.fsck.k9.activity.PasswordEntryDialog; public class StorageExporter { - private static void exportPreferences(Activity activity, String version, HashSet accountUuids, String fileName, OutputStream os, String encryptionKey, final ExportListener listener) { + private static void exportPreferences(Activity activity, String storageFormat, HashSet accountUuids, String fileName, OutputStream os, String encryptionKey, final ExportListener listener) { try { - IStorageExporter storageExporter = StorageFormat.createExporter(version); + IStorageExporter storageExporter = StorageFormat.createExporter(storageFormat); 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, storageFormat), null); } if (storageExporter.needsKey() && encryptionKey == null) { gatherPassword(activity, storageExporter, accountUuids, fileName, os, listener); @@ -35,12 +35,12 @@ public class StorageExporter { } } - public static void exportPreferences(Activity activity, String version, HashSet accountUuids, String fileName, String encryptionKey, final ExportListener listener) throws StorageImportExportException { - exportPreferences(activity, version, accountUuids, fileName, null, encryptionKey, listener); + public static void exportPreferences(Activity activity, String storageFormat, HashSet accountUuids, String fileName, String encryptionKey, final ExportListener listener) throws StorageImportExportException { + exportPreferences(activity, storageFormat, accountUuids, fileName, null, encryptionKey, listener); } - public static void exportPrefererences(Activity activity, String version, HashSet accountUuids, OutputStream os, String encryptionKey, final ExportListener listener) throws StorageImportExportException { - exportPreferences(activity, version, accountUuids, null, os, encryptionKey, listener); + public static void exportPrefererences(Activity activity, String storageFormat, HashSet accountUuids, OutputStream os, String encryptionKey, final ExportListener listener) throws StorageImportExportException { + exportPreferences(activity, storageFormat, accountUuids, null, os, encryptionKey, listener); } private static void gatherPassword(final Activity activity, final IStorageExporter storageExporter, final HashSet accountUuids, final String fileName, final OutputStream os, final ExportListener listener) { diff --git a/src/com/fsck/k9/preferences/StorageExporterVersion1.java b/src/com/fsck/k9/preferences/StorageExporterEncryptedXml.java similarity index 97% rename from src/com/fsck/k9/preferences/StorageExporterVersion1.java rename to src/com/fsck/k9/preferences/StorageExporterEncryptedXml.java index 742b7896b..ca08c09cc 100644 --- a/src/com/fsck/k9/preferences/StorageExporterVersion1.java +++ b/src/com/fsck/k9/preferences/StorageExporterEncryptedXml.java @@ -14,7 +14,7 @@ import com.fsck.k9.Account; import com.fsck.k9.K9; import com.fsck.k9.Preferences; -public class StorageExporterVersion1 implements IStorageExporter { +public class StorageExporterEncryptedXml implements IStorageExporter { public void exportPreferences(Context context, HashSet accountUuids, OutputStream os, String encryptionKey) throws StorageImportExportException { try { Log.i(K9.LOG_TAG, "Exporting preferences"); diff --git a/src/com/fsck/k9/preferences/StorageFormat.java b/src/com/fsck/k9/preferences/StorageFormat.java index 6d63254cf..4c472edcb 100644 --- a/src/com/fsck/k9/preferences/StorageFormat.java +++ b/src/com/fsck/k9/preferences/StorageFormat.java @@ -8,29 +8,29 @@ public class StorageFormat { // Never, ever re-use these numbers! public static final String ENCRYPTED_XML_FILE = "1"; - public static Map versionMap = new HashMap(); + public static Map storageFormatMap = new HashMap(); static { - versionMap.put(ENCRYPTED_XML_FILE, new StorageFormat(StorageImporterVersion1.class, StorageExporterVersion1.class, true)); + storageFormatMap.put(ENCRYPTED_XML_FILE, new StorageFormat(StorageImporterEncryptedXml.class, StorageExporterEncryptedXml.class, true)); } - public static IStorageImporter createImporter(String version) throws InstantiationException, IllegalAccessException { - StorageFormat storageVersion = versionMap.get(version); + public static IStorageImporter createImporter(String storageFormat) throws InstantiationException, IllegalAccessException { + StorageFormat storageVersion = storageFormatMap.get(storageFormat); if (storageVersion == null) { return null; } return storageVersion.importerClass.newInstance(); } - public static IStorageExporter createExporter(String version) throws InstantiationException, IllegalAccessException { - StorageFormat storageVersion = versionMap.get(version); + public static IStorageExporter createExporter(String storageFormat) throws InstantiationException, IllegalAccessException { + StorageFormat storageVersion = storageFormatMap.get(storageFormat); if (storageVersion == null) { return null; } return storageVersion.exporterClass.newInstance(); } - public static Boolean needsKey(String version) { - StorageFormat storageVersion = versionMap.get(version); + public static Boolean needsKey(String storageFormat) { + StorageFormat storageVersion = storageFormatMap.get(storageFormat); if (storageVersion == null) { return null; } diff --git a/src/com/fsck/k9/preferences/StorageImporter.java b/src/com/fsck/k9/preferences/StorageImporter.java index e6917156e..e40b7708c 100644 --- a/src/com/fsck/k9/preferences/StorageImporter.java +++ b/src/com/fsck/k9/preferences/StorageImporter.java @@ -39,12 +39,12 @@ public class StorageImporter { xr.parse(new InputSource(is)); ImportElement dataset = handler.getRootElement(); - String version = dataset.attributes.get("version"); - Log.i(K9.LOG_TAG, "Got settings file version " + version); + String storageFormat = dataset.attributes.get("version"); + Log.i(K9.LOG_TAG, "Got settings file version " + storageFormat); - IStorageImporter storageImporter = StorageFormat.createImporter(version); + IStorageImporter storageImporter = StorageFormat.createImporter(storageFormat); if (storageImporter == null) { - throw new StorageImportExportException(activity.getString(R.string.settings_unknown_version, version)); + throw new StorageImportExportException(activity.getString(R.string.settings_unknown_version, storageFormat)); } if (storageImporter.needsKey() && providedEncryptionKey == null) { gatherPassword(activity, storageImporter, dataset, listener); diff --git a/src/com/fsck/k9/preferences/StorageImporterVersion1.java b/src/com/fsck/k9/preferences/StorageImporterEncryptedXml.java similarity index 98% rename from src/com/fsck/k9/preferences/StorageImporterVersion1.java rename to src/com/fsck/k9/preferences/StorageImporterEncryptedXml.java index 1a8c28a7f..f09836fc3 100644 --- a/src/com/fsck/k9/preferences/StorageImporterVersion1.java +++ b/src/com/fsck/k9/preferences/StorageImporterEncryptedXml.java @@ -16,7 +16,7 @@ import com.fsck.k9.K9; import com.fsck.k9.Preferences; import com.fsck.k9.preferences.StorageImporter.ImportElement; -public class StorageImporterVersion1 implements IStorageImporter { +public class StorageImporterEncryptedXml implements IStorageImporter { public int importPreferences(Preferences preferences, SharedPreferences.Editor editor, ImportElement dataset, String encryptionKey) throws StorageImportExportException { try {