diff --git a/src/com/fsck/k9/activity/Accounts.java b/src/com/fsck/k9/activity/Accounts.java index 1f31be48f..5c3b70a13 100644 --- a/src/com/fsck/k9/activity/Accounts.java +++ b/src/com/fsck/k9/activity/Accounts.java @@ -66,7 +66,6 @@ import com.fsck.k9.mail.internet.MimeUtility; import com.fsck.k9.mail.store.StorageManager; import com.fsck.k9.view.ColorChip; import com.fsck.k9.preferences.StorageExporter; -import com.fsck.k9.preferences.StorageFormat; public class Accounts extends K9ListActivity implements OnItemClickListener, OnClickListener { @@ -1173,8 +1172,8 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC dir.mkdirs(); File file = Utility.createUniqueFile(dir, "settings.k9s"); mFileName = file.getAbsolutePath(); - StorageExporter.exportPreferences(Accounts.this, StorageFormat.ENCRYPTED_XML_FILE, - mIncludeGlobals, mAccountUuids, mFileName, mEncryptionKey); + StorageExporter.exportPreferences(Accounts.this, mIncludeGlobals, + mAccountUuids, mFileName, mEncryptionKey); } catch (Exception e) { Log.w(K9.LOG_TAG, "Exception during export", e); return false; diff --git a/src/com/fsck/k9/preferences/StorageExporter.java b/src/com/fsck/k9/preferences/StorageExporter.java index 9535b990a..4d52d9f28 100644 --- a/src/com/fsck/k9/preferences/StorageExporter.java +++ b/src/com/fsck/k9/preferences/StorageExporter.java @@ -11,19 +11,15 @@ import android.app.Activity; import android.util.Log; import com.fsck.k9.K9; -import com.fsck.k9.R; public class StorageExporter { - private static void exportPreferences(Activity activity, String storageFormat, boolean includeGlobals, Set accountUuids, String fileName, OutputStream os, String encryptionKey) throws StorageImportExportException { + private static void exportPreferences(Activity activity, boolean includeGlobals, Set accountUuids, String fileName, OutputStream os, String encryptionKey) throws StorageImportExportException { try { - IStorageExporter storageExporter = StorageFormat.createExporter(storageFormat); - if (storageExporter == null) { - throw new StorageImportExportException(activity.getString(R.string.settings_unknown_version, storageFormat), null); - } + IStorageExporter storageExporter = new StorageExporterEncryptedXml(); if (storageExporter.needsKey() && encryptionKey == null) { throw new StorageImportExportException("Encryption key required, but none supplied"); } else { - finishExport(activity, storageFormat, storageExporter, includeGlobals, accountUuids, fileName, os, encryptionKey); + finishExport(activity, storageExporter, includeGlobals, accountUuids, fileName, os, encryptionKey); } } catch (Exception e) { @@ -32,11 +28,11 @@ public class StorageExporter { } } - public static void exportPreferences(Activity activity, String storageFormat, boolean includeGlobals, Set accountUuids, String fileName, String encryptionKey) throws StorageImportExportException { - exportPreferences(activity, storageFormat, includeGlobals, accountUuids, fileName, null, encryptionKey); + public static void exportPreferences(Activity activity, boolean includeGlobals, Set accountUuids, String fileName, String encryptionKey) throws StorageImportExportException { + exportPreferences(activity, includeGlobals, accountUuids, fileName, null, encryptionKey); } - private static void finishExport(Activity activity, String storageFormat, IStorageExporter storageExporter, boolean includeGlobals, Set accountUuids, String fileName, OutputStream os, String encryptionKey) throws StorageImportExportException { + private static void finishExport(Activity activity, IStorageExporter storageExporter, boolean includeGlobals, Set accountUuids, String fileName, OutputStream os, String encryptionKey) throws StorageImportExportException { boolean needToClose = false; try { // This needs to be after the password prompt. If the user cancels the password, we do not want @@ -52,7 +48,7 @@ public class StorageExporter { PrintWriter pf = new PrintWriter(sw); pf.println(""); - pf.println(""); + pf.println(""); pf.flush(); storageExporter.exportPreferences(activity, includeGlobals, accountUuids, os, encryptionKey); diff --git a/src/com/fsck/k9/preferences/StorageFormat.java b/src/com/fsck/k9/preferences/StorageFormat.java deleted file mode 100644 index 4c472edcb..000000000 --- a/src/com/fsck/k9/preferences/StorageFormat.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.fsck.k9.preferences; - -import java.util.HashMap; -import java.util.Map; - - -public class StorageFormat { - // Never, ever re-use these numbers! - public static final String ENCRYPTED_XML_FILE = "1"; - - public static Map storageFormatMap = new HashMap(); - static { - storageFormatMap.put(ENCRYPTED_XML_FILE, new StorageFormat(StorageImporterEncryptedXml.class, StorageExporterEncryptedXml.class, true)); - } - - 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 storageFormat) throws InstantiationException, IllegalAccessException { - StorageFormat storageVersion = storageFormatMap.get(storageFormat); - if (storageVersion == null) { - return null; - } - return storageVersion.exporterClass.newInstance(); - } - - public static Boolean needsKey(String storageFormat) { - StorageFormat storageVersion = storageFormatMap.get(storageFormat); - if (storageVersion == null) { - return null; - } - return storageVersion.needsKey; - } - - - private final Class importerClass; - private final Class exporterClass; - private final boolean needsKey; - - private StorageFormat(Class imclass, Class exclass, boolean nk) { - importerClass = imclass; - exporterClass = exclass; - needsKey = nk; - } -} diff --git a/src/com/fsck/k9/preferences/StorageImporter.java b/src/com/fsck/k9/preferences/StorageImporter.java index e40b7708c..e1142e19f 100644 --- a/src/com/fsck/k9/preferences/StorageImporter.java +++ b/src/com/fsck/k9/preferences/StorageImporter.java @@ -42,10 +42,7 @@ public class StorageImporter { String storageFormat = dataset.attributes.get("version"); Log.i(K9.LOG_TAG, "Got settings file version " + storageFormat); - IStorageImporter storageImporter = StorageFormat.createImporter(storageFormat); - if (storageImporter == null) { - throw new StorageImportExportException(activity.getString(R.string.settings_unknown_version, storageFormat)); - } + IStorageImporter storageImporter = new StorageImporterEncryptedXml(); if (storageImporter.needsKey() && providedEncryptionKey == null) { gatherPassword(activity, storageImporter, dataset, listener); } else {