From c0d43590adb3f15ccaaf3b183d06bcaa0ee6b37e Mon Sep 17 00:00:00 2001 From: KaiserBh Date: Mon, 23 Oct 2023 22:43:35 +1100 Subject: [PATCH] refactor: remove the none/off choice default to google drive. Signed-off-by: KaiserBh --- .../settings/screen/SettingsBackupAndSyncScreen.kt | 10 +++------- .../java/eu/kanade/tachiyomi/data/sync/SyncManager.kt | 7 +++---- .../main/java/tachiyomi/domain/sync/SyncPreferences.kt | 2 +- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsBackupAndSyncScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsBackupAndSyncScreen.kt index cd7ca1c04..42190ca80 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsBackupAndSyncScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsBackupAndSyncScreen.kt @@ -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 { 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 diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/sync/SyncManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/sync/SyncManager.kt index 7dcee9851..388d5973a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/sync/SyncManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/sync/SyncManager.kt @@ -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 } } diff --git a/domain/src/main/java/tachiyomi/domain/sync/SyncPreferences.kt b/domain/src/main/java/tachiyomi/domain/sync/SyncPreferences.kt index 8e7fa8499..bbc48d275 100644 --- a/domain/src/main/java/tachiyomi/domain/sync/SyncPreferences.kt +++ b/domain/src/main/java/tachiyomi/domain/sync/SyncPreferences.kt @@ -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", "")