From 2f6edf6b4b247cfbd6e303816963d64119dbc486 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Fri, 3 May 2024 15:59:28 -0300 Subject: [PATCH] Rename StoragePluginEnum to StoragePluginType --- .../seedvault/plugins/StoragePluginManager.kt | 6 +++--- .../seedvault/settings/SettingsManager.kt | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/stevesoltys/seedvault/plugins/StoragePluginManager.kt b/app/src/main/java/com/stevesoltys/seedvault/plugins/StoragePluginManager.kt index 784ed882..509c0f5d 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/plugins/StoragePluginManager.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/plugins/StoragePluginManager.kt @@ -14,7 +14,7 @@ import com.stevesoltys.seedvault.plugins.saf.DocumentsStorage import com.stevesoltys.seedvault.plugins.saf.SafFactory import com.stevesoltys.seedvault.plugins.webdav.WebDavFactory import com.stevesoltys.seedvault.settings.SettingsManager -import com.stevesoltys.seedvault.settings.StoragePluginEnum +import com.stevesoltys.seedvault.settings.StoragePluginType class StoragePluginManager( private val context: Context, @@ -48,7 +48,7 @@ class StoragePluginManager( init { when (settingsManager.storagePluginType) { - StoragePluginEnum.SAF -> { + StoragePluginType.SAF -> { val safStorage = settingsManager.getSafStorage() ?: error("No SAF storage saved") val documentsStorage = DocumentsStorage(context, settingsManager, safStorage) mAppPlugin = safFactory.createAppStoragePlugin(safStorage, documentsStorage) @@ -56,7 +56,7 @@ class StoragePluginManager( mStorageProperties = safStorage } - StoragePluginEnum.WEB_DAV -> { + StoragePluginType.WEB_DAV -> { val webDavProperties = settingsManager.webDavProperties ?: error("No WebDAV config saved") mAppPlugin = webDavFactory.createAppStoragePlugin(webDavProperties.config) diff --git a/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsManager.kt b/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsManager.kt index d6e977c0..966276bf 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsManager.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsManager.kt @@ -26,7 +26,7 @@ internal const val PREF_KEY_SCHED_CHARGING = "scheduling_charging" private const val PREF_KEY_STORAGE_PLUGIN = "storagePlugin" -internal enum class StoragePluginEnum { // don't rename, will break existing installs +internal enum class StoragePluginType { // don't rename, will break existing installs SAF, WEB_DAV, } @@ -101,7 +101,7 @@ class SettingsManager(private val context: Context) { token = newToken } - internal val storagePluginType: StoragePluginEnum? + internal val storagePluginType: StoragePluginType? get() { val savedType = prefs.getString(PREF_KEY_STORAGE_PLUGIN, null) return if (savedType == null) { @@ -109,13 +109,13 @@ class SettingsManager(private val context: Context) { // this check could be removed after a reasonable migration time (added 2024) if (prefs.getString(PREF_KEY_STORAGE_URI, null) != null) { prefs.edit() - .putString(PREF_KEY_STORAGE_PLUGIN, StoragePluginEnum.SAF.name) + .putString(PREF_KEY_STORAGE_PLUGIN, StoragePluginType.SAF.name) .apply() - StoragePluginEnum.SAF + StoragePluginType.SAF } else null } else savedType.let { try { - StoragePluginEnum.valueOf(it) + StoragePluginType.valueOf(it) } catch (e: IllegalArgumentException) { null } @@ -124,8 +124,8 @@ class SettingsManager(private val context: Context) { fun setStoragePlugin(plugin: StoragePlugin<*>) { val value = when (plugin) { - is DocumentsProviderStoragePlugin -> StoragePluginEnum.SAF - is WebDavStoragePlugin -> StoragePluginEnum.WEB_DAV + is DocumentsProviderStoragePlugin -> StoragePluginType.SAF + is WebDavStoragePlugin -> StoragePluginType.WEB_DAV else -> error("Unsupported plugin: ${plugin::class.java.simpleName}") }.name prefs.edit()