First step at replacing the term "version" with "storageFormat"

This commit is contained in:
cketti 2011-03-26 07:19:20 +01:00
parent 4bdc20c127
commit 087feb478b
7 changed files with 26 additions and 26 deletions

View File

@ -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<String> accountUuids, final ExportListener listener) {
public void exportSettings(final Activity activity, final String storageFormat, final HashSet<String> 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);

View File

@ -11,9 +11,9 @@ import com.fsck.k9.preferences.StorageFormat;
public class ExportHelper {
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:
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() {

View File

@ -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<String> accountUuids, String fileName, OutputStream os, String encryptionKey, final ExportListener listener) {
private static void exportPreferences(Activity activity, String storageFormat, HashSet<String> 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<String> 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<String> 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<String> 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<String> 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<String> accountUuids, final String fileName, final OutputStream os, final ExportListener listener) {

View File

@ -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<String> accountUuids, OutputStream os, String encryptionKey) throws StorageImportExportException {
try {
Log.i(K9.LOG_TAG, "Exporting preferences");

View File

@ -8,29 +8,29 @@ public class StorageFormat {
// Never, ever re-use these numbers!
public static final String ENCRYPTED_XML_FILE = "1";
public static Map<String, StorageFormat> versionMap = new HashMap<String, StorageFormat>();
public static Map<String, StorageFormat> storageFormatMap = new HashMap<String, StorageFormat>();
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;
}

View File

@ -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);

View File

@ -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 {