Rename StoragePluginEnum to StoragePluginType
This commit is contained in:
parent
4651ad5eb3
commit
2f6edf6b4b
2 changed files with 10 additions and 10 deletions
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue