mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-15 15:02:49 +01:00
refactor: remove the none/off choice default to google drive.
Signed-off-by: KaiserBh <kaiserbh@proton.me>
This commit is contained in:
parent
ad17884dec
commit
c0d43590ad
@ -86,9 +86,8 @@ object SettingsBackupAndSyncScreen : SearchableSettings {
|
||||
pref = syncPreferences.syncService(),
|
||||
title = stringResource(R.string.pref_sync_service),
|
||||
entries = mapOf(
|
||||
SyncManager.SyncService.NONE.value to stringResource(R.string.off),
|
||||
SyncManager.SyncService.SYNCYOMI.value to stringResource(R.string.syncyomi),
|
||||
SyncManager.SyncService.GOOGLE_DRIVE.value to stringResource(R.string.google_drive),
|
||||
SyncManager.SyncService.SYNCYOMI.value to stringResource(R.string.syncyomi),
|
||||
),
|
||||
onValueChanged = { true },
|
||||
),
|
||||
@ -424,15 +423,12 @@ object SettingsBackupAndSyncScreen : SearchableSettings {
|
||||
private fun getSyncServicePreferences(syncPreferences: SyncPreferences, syncService: Int): List<Preference> {
|
||||
val syncServiceType = SyncManager.SyncService.fromInt(syncService)
|
||||
return when (syncServiceType) {
|
||||
SyncManager.SyncService.NONE -> emptyList()
|
||||
SyncManager.SyncService.SYNCYOMI -> getSelfHostPreferences(syncPreferences)
|
||||
SyncManager.SyncService.GOOGLE_DRIVE -> getGoogleDrivePreferences()
|
||||
} +
|
||||
if (syncServiceType == SyncManager.SyncService.NONE) {
|
||||
else -> {
|
||||
emptyList()
|
||||
} else {
|
||||
listOf(getSyncNowPref(), getAutomaticSyncGroup(syncPreferences))
|
||||
}
|
||||
} + listOf(getSyncNowPref(), getAutomaticSyncGroup(syncPreferences))
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
@ -57,13 +57,12 @@ class SyncManager(
|
||||
private val backupRestorer: BackupRestorer = BackupRestorer(context, backupNotify)
|
||||
|
||||
enum class SyncService(val value: Int) {
|
||||
NONE(0),
|
||||
SYNCYOMI(1),
|
||||
GOOGLE_DRIVE(2),
|
||||
GOOGLE_DRIVE(1),
|
||||
SYNCYOMI(2),
|
||||
;
|
||||
|
||||
companion object {
|
||||
fun fromInt(value: Int) = values().firstOrNull { it.value == value } ?: NONE
|
||||
fun fromInt(value: Int) = entries.firstOrNull { it.value == value } ?: 1
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ class SyncPreferences(
|
||||
|
||||
fun deviceName() = preferenceStore.getString("device_name", android.os.Build.MANUFACTURER + android.os.Build.PRODUCT)
|
||||
|
||||
fun syncService() = preferenceStore.getInt("sync_service", 0)
|
||||
fun syncService() = preferenceStore.getInt("sync_service", 1)
|
||||
|
||||
private fun googleDriveAccessToken() = preferenceStore.getString("google_drive_access_token", "")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user