Revert "refactor: remove the none/off choice default to google drive."

This reverts commit c0d43590ad.
This commit is contained in:
KaiserBh 2023-10-23 22:53:48 +11:00
parent c0d43590ad
commit 69669bcf67
No known key found for this signature in database
GPG Key ID: 14D73B142042BBA9
3 changed files with 12 additions and 7 deletions

View File

@ -86,8 +86,9 @@ object SettingsBackupAndSyncScreen : SearchableSettings {
pref = syncPreferences.syncService(), pref = syncPreferences.syncService(),
title = stringResource(R.string.pref_sync_service), title = stringResource(R.string.pref_sync_service),
entries = mapOf( entries = mapOf(
SyncManager.SyncService.GOOGLE_DRIVE.value to stringResource(R.string.google_drive), SyncManager.SyncService.NONE.value to stringResource(R.string.off),
SyncManager.SyncService.SYNCYOMI.value to stringResource(R.string.syncyomi), SyncManager.SyncService.SYNCYOMI.value to stringResource(R.string.syncyomi),
SyncManager.SyncService.GOOGLE_DRIVE.value to stringResource(R.string.google_drive),
), ),
onValueChanged = { true }, onValueChanged = { true },
), ),
@ -423,12 +424,15 @@ object SettingsBackupAndSyncScreen : SearchableSettings {
private fun getSyncServicePreferences(syncPreferences: SyncPreferences, syncService: Int): List<Preference> { private fun getSyncServicePreferences(syncPreferences: SyncPreferences, syncService: Int): List<Preference> {
val syncServiceType = SyncManager.SyncService.fromInt(syncService) val syncServiceType = SyncManager.SyncService.fromInt(syncService)
return when (syncServiceType) { return when (syncServiceType) {
SyncManager.SyncService.NONE -> emptyList()
SyncManager.SyncService.SYNCYOMI -> getSelfHostPreferences(syncPreferences) SyncManager.SyncService.SYNCYOMI -> getSelfHostPreferences(syncPreferences)
SyncManager.SyncService.GOOGLE_DRIVE -> getGoogleDrivePreferences() SyncManager.SyncService.GOOGLE_DRIVE -> getGoogleDrivePreferences()
else -> { } +
if (syncServiceType == SyncManager.SyncService.NONE) {
emptyList() emptyList()
} else {
listOf(getSyncNowPref(), getAutomaticSyncGroup(syncPreferences))
} }
} + listOf(getSyncNowPref(), getAutomaticSyncGroup(syncPreferences))
} }
@Composable @Composable

View File

@ -57,12 +57,13 @@ class SyncManager(
private val backupRestorer: BackupRestorer = BackupRestorer(context, backupNotify) private val backupRestorer: BackupRestorer = BackupRestorer(context, backupNotify)
enum class SyncService(val value: Int) { enum class SyncService(val value: Int) {
GOOGLE_DRIVE(1), NONE(0),
SYNCYOMI(2), SYNCYOMI(1),
GOOGLE_DRIVE(2),
; ;
companion object { companion object {
fun fromInt(value: Int) = entries.firstOrNull { it.value == value } ?: 1 fun fromInt(value: Int) = values().firstOrNull { it.value == value } ?: NONE
} }
} }

View File

@ -14,7 +14,7 @@ class SyncPreferences(
fun deviceName() = preferenceStore.getString("device_name", android.os.Build.MANUFACTURER + android.os.Build.PRODUCT) fun deviceName() = preferenceStore.getString("device_name", android.os.Build.MANUFACTURER + android.os.Build.PRODUCT)
fun syncService() = preferenceStore.getInt("sync_service", 1) fun syncService() = preferenceStore.getInt("sync_service", 0)
private fun googleDriveAccessToken() = preferenceStore.getString("google_drive_access_token", "") private fun googleDriveAccessToken() = preferenceStore.getString("google_drive_access_token", "")