Move "Choose what to sync" out of "Sync now" (#1264)
This commit is contained in:
parent
2cb8f8f872
commit
19bc08659b
@ -394,11 +394,23 @@ object SettingsDataScreen : SearchableSettings {
|
|||||||
syncServiceType: SyncManager.SyncService,
|
syncServiceType: SyncManager.SyncService,
|
||||||
syncPreferences: SyncPreferences,
|
syncPreferences: SyncPreferences,
|
||||||
): List<Preference> {
|
): List<Preference> {
|
||||||
return when (syncServiceType) {
|
val navigator = LocalNavigator.currentOrThrow
|
||||||
|
val preferences = when (syncServiceType) {
|
||||||
SyncManager.SyncService.NONE -> emptyList()
|
SyncManager.SyncService.NONE -> emptyList()
|
||||||
SyncManager.SyncService.SYNCYOMI -> getSelfHostPreferences(syncPreferences)
|
SyncManager.SyncService.SYNCYOMI -> getSelfHostPreferences(syncPreferences)
|
||||||
SyncManager.SyncService.GOOGLE_DRIVE -> getGoogleDrivePreferences()
|
SyncManager.SyncService.GOOGLE_DRIVE -> getGoogleDrivePreferences()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return if (syncServiceType != SyncManager.SyncService.NONE) {
|
||||||
|
preferences + Preference.PreferenceItem.TextPreference(
|
||||||
|
title = stringResource(SYMR.strings.pref_choose_what_to_sync),
|
||||||
|
onClick = {
|
||||||
|
navigator.push(SyncSettingsSelector())
|
||||||
|
},
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
preferences
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -515,7 +527,7 @@ object SettingsDataScreen : SearchableSettings {
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun getSyncNowPref(): Preference.PreferenceGroup {
|
private fun getSyncNowPref(): Preference.PreferenceGroup {
|
||||||
val navigator = LocalNavigator.currentOrThrow
|
val context = LocalContext.current
|
||||||
return Preference.PreferenceGroup(
|
return Preference.PreferenceGroup(
|
||||||
title = stringResource(SYMR.strings.pref_sync_now_group_title),
|
title = stringResource(SYMR.strings.pref_sync_now_group_title),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
@ -524,7 +536,11 @@ object SettingsDataScreen : SearchableSettings {
|
|||||||
title = stringResource(SYMR.strings.pref_sync_now),
|
title = stringResource(SYMR.strings.pref_sync_now),
|
||||||
subtitle = stringResource(SYMR.strings.pref_sync_now_subtitle),
|
subtitle = stringResource(SYMR.strings.pref_sync_now_subtitle),
|
||||||
onClick = {
|
onClick = {
|
||||||
navigator.push(SyncSettingsSelector())
|
if (!SyncDataJob.isRunning(context)) {
|
||||||
|
SyncDataJob.startNow(context)
|
||||||
|
} else {
|
||||||
|
context.toast(SYMR.strings.sync_in_progress)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -5,7 +5,6 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.runtime.Immutable
|
import androidx.compose.runtime.Immutable
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.ui.platform.LocalContext
|
|
||||||
import cafe.adriel.voyager.core.model.StateScreenModel
|
import cafe.adriel.voyager.core.model.StateScreenModel
|
||||||
import cafe.adriel.voyager.core.model.rememberScreenModel
|
import cafe.adriel.voyager.core.model.rememberScreenModel
|
||||||
import cafe.adriel.voyager.navigator.LocalNavigator
|
import cafe.adriel.voyager.navigator.LocalNavigator
|
||||||
@ -16,7 +15,6 @@ import eu.kanade.presentation.components.AppBar
|
|||||||
import eu.kanade.presentation.util.Screen
|
import eu.kanade.presentation.util.Screen
|
||||||
import eu.kanade.tachiyomi.data.backup.create.BackupOptions
|
import eu.kanade.tachiyomi.data.backup.create.BackupOptions
|
||||||
import eu.kanade.tachiyomi.data.sync.SyncDataJob
|
import eu.kanade.tachiyomi.data.sync.SyncDataJob
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
|
||||||
import kotlinx.collections.immutable.ImmutableList
|
import kotlinx.collections.immutable.ImmutableList
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
import tachiyomi.i18n.MR
|
import tachiyomi.i18n.MR
|
||||||
@ -32,7 +30,6 @@ import uy.kohesive.injekt.api.get
|
|||||||
class SyncSettingsSelector : Screen() {
|
class SyncSettingsSelector : Screen() {
|
||||||
@Composable
|
@Composable
|
||||||
override fun Content() {
|
override fun Content() {
|
||||||
val context = LocalContext.current
|
|
||||||
val navigator = LocalNavigator.currentOrThrow
|
val navigator = LocalNavigator.currentOrThrow
|
||||||
val model = rememberScreenModel { SyncSettingsSelectorModel() }
|
val model = rememberScreenModel { SyncSettingsSelectorModel() }
|
||||||
val state by model.state.collectAsState()
|
val state by model.state.collectAsState()
|
||||||
@ -48,15 +45,10 @@ class SyncSettingsSelector : Screen() {
|
|||||||
) { contentPadding ->
|
) { contentPadding ->
|
||||||
LazyColumnWithAction(
|
LazyColumnWithAction(
|
||||||
contentPadding = contentPadding,
|
contentPadding = contentPadding,
|
||||||
actionLabel = stringResource(SYMR.strings.label_sync),
|
actionLabel = stringResource(MR.strings.action_save),
|
||||||
actionEnabled = state.options.canCreate(),
|
actionEnabled = true,
|
||||||
onClickAction = {
|
onClickAction = {
|
||||||
if (!SyncDataJob.isRunning(context)) {
|
navigator.pop()
|
||||||
model.syncNow(context)
|
|
||||||
navigator.pop()
|
|
||||||
} else {
|
|
||||||
context.toast(SYMR.strings.sync_in_progress)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
item {
|
item {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user