diff --git a/app/core/src/main/java/com/fsck/k9/CoreResourceProvider.kt b/app/core/src/main/java/com/fsck/k9/CoreResourceProvider.kt index 097221557..ca191b099 100644 --- a/app/core/src/main/java/com/fsck/k9/CoreResourceProvider.kt +++ b/app/core/src/main/java/com/fsck/k9/CoreResourceProvider.kt @@ -6,9 +6,6 @@ interface CoreResourceProvider { fun defaultSignature(): String fun defaultIdentityDescription(): String - fun internalStorageProviderName(): String - fun externalStorageProviderName(): String - fun contactDisplayNamePrefix(): String fun contactUnknownSender(): String fun contactUnknownRecipient(): String diff --git a/app/core/src/main/java/com/fsck/k9/mailstore/StorageManager.java b/app/core/src/main/java/com/fsck/k9/mailstore/StorageManager.java index 021f298ba..6aece52ec 100644 --- a/app/core/src/main/java/com/fsck/k9/mailstore/StorageManager.java +++ b/app/core/src/main/java/com/fsck/k9/mailstore/StorageManager.java @@ -6,12 +6,11 @@ import java.util.Arrays; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Set; import android.content.Context; import android.os.Environment; -import com.fsck.k9.CoreResourceProvider; -import com.fsck.k9.DI; /** * Manager for different {@link StorageProvider} -classes that abstract access @@ -56,14 +55,6 @@ public class StorageManager { */ void init(Context context); - /** - * @param context - * Never null. - * @return A user displayable, localized name for this provider. Never - * null. - */ - String getName(Context context); - /** * Some implementations may not be able to return valid File handles * because the device doesn't provide the denoted storage. You can check @@ -120,12 +111,6 @@ public class StorageManager { public static class InternalStorageProvider implements StorageProvider { public static final String ID = "InternalStorage"; - private final CoreResourceProvider resourceProvider; - - public InternalStorageProvider(CoreResourceProvider resourceProvider) { - this.resourceProvider = resourceProvider; - } - @Override public String getId() { return ID; @@ -135,11 +120,6 @@ public class StorageManager { public void init(Context context) { } - @Override - public String getName(Context context) { - return resourceProvider.internalStorageProviderName(); - } - @Override public boolean isSupported(Context context) { return true; @@ -178,18 +158,12 @@ public class StorageManager { public static class ExternalStorageProvider implements StorageProvider { public static final String ID = "ExternalStorage"; - private final CoreResourceProvider resourceProvider; - /** * Chosen base directory. */ private File mApplicationDirectory; - public ExternalStorageProvider(CoreResourceProvider resourceProvider) { - this.resourceProvider = resourceProvider; - } - @Override public String getId() { return ID; @@ -200,11 +174,6 @@ public class StorageManager { mApplicationDirectory = context.getExternalFilesDir(null); } - @Override - public String getName(Context context) { - return resourceProvider.externalStorageProviderName(); - } - @Override public boolean isSupported(Context context) { return true; @@ -233,8 +202,7 @@ public class StorageManager { public static synchronized StorageManager getInstance(final Context context) { if (instance == null) { Context applicationContext = context.getApplicationContext(); - CoreResourceProvider resourceProvider = DI.get(CoreResourceProvider.class); - instance = new StorageManager(applicationContext, resourceProvider); + instance = new StorageManager(applicationContext); } return instance; } @@ -245,7 +213,7 @@ public class StorageManager { * @throws NullPointerException * If context is null. */ - protected StorageManager(final Context context, CoreResourceProvider resourceProvider) throws NullPointerException { + protected StorageManager(final Context context) throws NullPointerException { if (context == null) { throw new NullPointerException("No Context given"); } @@ -262,8 +230,9 @@ public class StorageManager { * be considered as the default provider !!! */ final List allProviders = Arrays.asList( - new InternalStorageProvider(resourceProvider), - new ExternalStorageProvider(resourceProvider)); + new InternalStorageProvider(), + new ExternalStorageProvider() + ); for (final StorageProvider provider : allProviders) { // check for provider compatibility if (provider.isSupported(context)) { @@ -319,17 +288,7 @@ public class StorageManager { return provider.getAttachmentDirectory(context, dbName); } - /** - * @return A map of available providers names, indexed by their ID. Never - * null. - * @see StorageManager - * @see StorageProvider#isSupported(Context) - */ - public Map getAvailableProviders() { - final Map result = new LinkedHashMap<>(); - for (final Map.Entry entry : mProviders.entrySet()) { - result.put(entry.getKey(), entry.getValue().getName(context)); - } - return result; + public Set getAvailableProviders() { + return mProviders.keySet(); } } diff --git a/app/core/src/main/java/com/fsck/k9/preferences/AccountSettingsDescriptions.java b/app/core/src/main/java/com/fsck/k9/preferences/AccountSettingsDescriptions.java index 4c281006d..f3e578084 100644 --- a/app/core/src/main/java/com/fsck/k9/preferences/AccountSettingsDescriptions.java +++ b/app/core/src/main/java/com/fsck/k9/preferences/AccountSettingsDescriptions.java @@ -413,8 +413,8 @@ public class AccountSettingsDescriptions { @Override public String fromString(String value) { StorageManager storageManager = StorageManager.getInstance(context); - Map providers = storageManager.getAvailableProviders(); - if (providers.containsKey(value)) { + Set providers = storageManager.getAvailableProviders(); + if (providers.contains(value)) { return value; } throw new RuntimeException("Validation failed"); diff --git a/app/core/src/test/java/com/fsck/k9/TestCoreResourceProvider.kt b/app/core/src/test/java/com/fsck/k9/TestCoreResourceProvider.kt index d3052bf46..36e47248d 100644 --- a/app/core/src/test/java/com/fsck/k9/TestCoreResourceProvider.kt +++ b/app/core/src/test/java/com/fsck/k9/TestCoreResourceProvider.kt @@ -7,14 +7,6 @@ class TestCoreResourceProvider : CoreResourceProvider { override fun defaultIdentityDescription() = "initial identity" - override fun internalStorageProviderName(): String { - throw UnsupportedOperationException("not implemented") - } - - override fun externalStorageProviderName(): String { - throw UnsupportedOperationException("not implemented") - } - override fun contactDisplayNamePrefix() = "To:" override fun contactUnknownSender() = "" override fun contactUnknownRecipient() = "" diff --git a/app/k9mail-jmap/src/main/java/com/fsck/k9/resources/K9CoreResourceProvider.kt b/app/k9mail-jmap/src/main/java/com/fsck/k9/resources/K9CoreResourceProvider.kt index 8f2f61fa2..5a11b2251 100644 --- a/app/k9mail-jmap/src/main/java/com/fsck/k9/resources/K9CoreResourceProvider.kt +++ b/app/k9mail-jmap/src/main/java/com/fsck/k9/resources/K9CoreResourceProvider.kt @@ -9,12 +9,6 @@ class K9CoreResourceProvider(private val context: Context) : CoreResourceProvide override fun defaultSignature(): String = context.getString(R.string.default_signature) override fun defaultIdentityDescription(): String = context.getString(R.string.default_identity_description) - override fun internalStorageProviderName(): String = - context.getString(R.string.local_storage_provider_internal_label) - - override fun externalStorageProviderName(): String = - context.getString(R.string.local_storage_provider_external_label) - override fun contactDisplayNamePrefix(): String = context.getString(R.string.message_to_label) override fun contactUnknownSender(): String = context.getString(R.string.unknown_sender) override fun contactUnknownRecipient(): String = context.getString(R.string.unknown_recipient) diff --git a/app/k9mail/src/main/java/com/fsck/k9/resources/K9CoreResourceProvider.kt b/app/k9mail/src/main/java/com/fsck/k9/resources/K9CoreResourceProvider.kt index cd2603adb..23b07d805 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/resources/K9CoreResourceProvider.kt +++ b/app/k9mail/src/main/java/com/fsck/k9/resources/K9CoreResourceProvider.kt @@ -9,12 +9,6 @@ class K9CoreResourceProvider(private val context: Context) : CoreResourceProvide override fun defaultSignature(): String = context.getString(R.string.default_signature) override fun defaultIdentityDescription(): String = context.getString(R.string.default_identity_description) - override fun internalStorageProviderName(): String = - context.getString(R.string.local_storage_provider_internal_label) - - override fun externalStorageProviderName(): String = - context.getString(R.string.local_storage_provider_external_label) - override fun contactDisplayNamePrefix(): String = context.getString(R.string.message_to_label) override fun contactUnknownSender(): String = context.getString(R.string.unknown_sender) override fun contactUnknownRecipient(): String = context.getString(R.string.unknown_recipient) diff --git a/app/ui/legacy/src/main/res/values/strings.xml b/app/ui/legacy/src/main/res/values/strings.xml index 91015f75e..7a99ea7ed 100644 --- a/app/ui/legacy/src/main/res/values/strings.xml +++ b/app/ui/legacy/src/main/res/values/strings.xml @@ -406,9 +406,6 @@ Please submit bug reports, contribute new features and ask questions at Wi-Fi Other - External storage (SD card) - Regular internal storage - Erase deleted messages on server Immediately When polling diff --git a/app/ui/legacy/src/test/java/com/fsck/k9/TestCoreResourceProvider.kt b/app/ui/legacy/src/test/java/com/fsck/k9/TestCoreResourceProvider.kt index 7198f637b..a8fc1c07b 100644 --- a/app/ui/legacy/src/test/java/com/fsck/k9/TestCoreResourceProvider.kt +++ b/app/ui/legacy/src/test/java/com/fsck/k9/TestCoreResourceProvider.kt @@ -7,10 +7,6 @@ class TestCoreResourceProvider : CoreResourceProvider { override fun defaultIdentityDescription() = throw UnsupportedOperationException("not implemented") - override fun internalStorageProviderName() = throw UnsupportedOperationException("not implemented") - - override fun externalStorageProviderName() = throw UnsupportedOperationException("not implemented") - override fun contactDisplayNamePrefix() = throw UnsupportedOperationException("not implemented") override fun contactUnknownSender() = throw UnsupportedOperationException("not implemented") override fun contactUnknownRecipient() = throw UnsupportedOperationException("not implemented")