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.saf.SafFactory
|
||||||
import com.stevesoltys.seedvault.plugins.webdav.WebDavFactory
|
import com.stevesoltys.seedvault.plugins.webdav.WebDavFactory
|
||||||
import com.stevesoltys.seedvault.settings.SettingsManager
|
import com.stevesoltys.seedvault.settings.SettingsManager
|
||||||
import com.stevesoltys.seedvault.settings.StoragePluginEnum
|
import com.stevesoltys.seedvault.settings.StoragePluginType
|
||||||
|
|
||||||
class StoragePluginManager(
|
class StoragePluginManager(
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
|
@ -48,7 +48,7 @@ class StoragePluginManager(
|
||||||
|
|
||||||
init {
|
init {
|
||||||
when (settingsManager.storagePluginType) {
|
when (settingsManager.storagePluginType) {
|
||||||
StoragePluginEnum.SAF -> {
|
StoragePluginType.SAF -> {
|
||||||
val safStorage = settingsManager.getSafStorage() ?: error("No SAF storage saved")
|
val safStorage = settingsManager.getSafStorage() ?: error("No SAF storage saved")
|
||||||
val documentsStorage = DocumentsStorage(context, settingsManager, safStorage)
|
val documentsStorage = DocumentsStorage(context, settingsManager, safStorage)
|
||||||
mAppPlugin = safFactory.createAppStoragePlugin(safStorage, documentsStorage)
|
mAppPlugin = safFactory.createAppStoragePlugin(safStorage, documentsStorage)
|
||||||
|
@ -56,7 +56,7 @@ class StoragePluginManager(
|
||||||
mStorageProperties = safStorage
|
mStorageProperties = safStorage
|
||||||
}
|
}
|
||||||
|
|
||||||
StoragePluginEnum.WEB_DAV -> {
|
StoragePluginType.WEB_DAV -> {
|
||||||
val webDavProperties =
|
val webDavProperties =
|
||||||
settingsManager.webDavProperties ?: error("No WebDAV config saved")
|
settingsManager.webDavProperties ?: error("No WebDAV config saved")
|
||||||
mAppPlugin = webDavFactory.createAppStoragePlugin(webDavProperties.config)
|
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"
|
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,
|
SAF,
|
||||||
WEB_DAV,
|
WEB_DAV,
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ class SettingsManager(private val context: Context) {
|
||||||
token = newToken
|
token = newToken
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val storagePluginType: StoragePluginEnum?
|
internal val storagePluginType: StoragePluginType?
|
||||||
get() {
|
get() {
|
||||||
val savedType = prefs.getString(PREF_KEY_STORAGE_PLUGIN, null)
|
val savedType = prefs.getString(PREF_KEY_STORAGE_PLUGIN, null)
|
||||||
return if (savedType == 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)
|
// this check could be removed after a reasonable migration time (added 2024)
|
||||||
if (prefs.getString(PREF_KEY_STORAGE_URI, null) != null) {
|
if (prefs.getString(PREF_KEY_STORAGE_URI, null) != null) {
|
||||||
prefs.edit()
|
prefs.edit()
|
||||||
.putString(PREF_KEY_STORAGE_PLUGIN, StoragePluginEnum.SAF.name)
|
.putString(PREF_KEY_STORAGE_PLUGIN, StoragePluginType.SAF.name)
|
||||||
.apply()
|
.apply()
|
||||||
StoragePluginEnum.SAF
|
StoragePluginType.SAF
|
||||||
} else null
|
} else null
|
||||||
} else savedType.let {
|
} else savedType.let {
|
||||||
try {
|
try {
|
||||||
StoragePluginEnum.valueOf(it)
|
StoragePluginType.valueOf(it)
|
||||||
} catch (e: IllegalArgumentException) {
|
} catch (e: IllegalArgumentException) {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
@ -124,8 +124,8 @@ class SettingsManager(private val context: Context) {
|
||||||
|
|
||||||
fun setStoragePlugin(plugin: StoragePlugin<*>) {
|
fun setStoragePlugin(plugin: StoragePlugin<*>) {
|
||||||
val value = when (plugin) {
|
val value = when (plugin) {
|
||||||
is DocumentsProviderStoragePlugin -> StoragePluginEnum.SAF
|
is DocumentsProviderStoragePlugin -> StoragePluginType.SAF
|
||||||
is WebDavStoragePlugin -> StoragePluginEnum.WEB_DAV
|
is WebDavStoragePlugin -> StoragePluginType.WEB_DAV
|
||||||
else -> error("Unsupported plugin: ${plugin::class.java.simpleName}")
|
else -> error("Unsupported plugin: ${plugin::class.java.simpleName}")
|
||||||
}.name
|
}.name
|
||||||
prefs.edit()
|
prefs.edit()
|
||||||
|
|
Loading…
Reference in a new issue