mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-15 15:02:49 +01:00
refactor: move it into it's own function and use data and storage label.
Signed-off-by: KaiserBh <kaiserbh@proton.me>
This commit is contained in:
parent
1a185375b7
commit
389336b823
@ -144,7 +144,7 @@ fun MoreScreen(
|
|||||||
}
|
}
|
||||||
item {
|
item {
|
||||||
TextPreferenceWidget(
|
TextPreferenceWidget(
|
||||||
title = stringResource(MR.strings.label_backup_and_sync),
|
title = stringResource(MR.strings.label_data_storage),
|
||||||
icon = Icons.Outlined.Storage,
|
icon = Icons.Outlined.Storage,
|
||||||
onPreferenceClick = onClickDataAndStorage,
|
onPreferenceClick = onClickDataAndStorage,
|
||||||
)
|
)
|
||||||
|
@ -65,7 +65,7 @@ object SettingsDataScreen : SearchableSettings {
|
|||||||
|
|
||||||
@ReadOnlyComposable
|
@ReadOnlyComposable
|
||||||
@Composable
|
@Composable
|
||||||
override fun getTitleRes() = MR.strings.label_backup_and_sync
|
override fun getTitleRes() = MR.strings.label_data_storage
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
override fun getPreferences(): List<Preference> {
|
override fun getPreferences(): List<Preference> {
|
||||||
@ -79,23 +79,7 @@ object SettingsDataScreen : SearchableSettings {
|
|||||||
return listOf(
|
return listOf(
|
||||||
getBackupAndRestoreGroup(backupPreferences = backupPreferences),
|
getBackupAndRestoreGroup(backupPreferences = backupPreferences),
|
||||||
getDataGroup(),
|
getDataGroup(),
|
||||||
) + listOf(
|
) + getSyncPreferences(syncPreferences = syncPreferences, syncService = syncService)
|
||||||
Preference.PreferenceGroup(
|
|
||||||
title = stringResource(MR.strings.label_sync),
|
|
||||||
preferenceItems = listOf(
|
|
||||||
Preference.PreferenceItem.ListPreference(
|
|
||||||
pref = syncPreferences.syncService(),
|
|
||||||
title = stringResource(MR.strings.pref_sync_service),
|
|
||||||
entries = mapOf(
|
|
||||||
SyncManager.SyncService.NONE.value to stringResource(MR.strings.off),
|
|
||||||
SyncManager.SyncService.SYNCYOMI.value to stringResource(MR.strings.syncyomi),
|
|
||||||
SyncManager.SyncService.GOOGLE_DRIVE.value to stringResource(MR.strings.google_drive),
|
|
||||||
),
|
|
||||||
onValueChanged = { true },
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
) + getSyncServicePreferences(syncPreferences, syncService)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ -342,21 +326,51 @@ object SettingsDataScreen : SearchableSettings {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun getSyncPreferences(syncPreferences: SyncPreferences, syncService: Int): List<Preference> {
|
||||||
|
return listOf(
|
||||||
|
Preference.PreferenceItem.ListPreference(
|
||||||
|
pref = syncPreferences.syncService(),
|
||||||
|
title = stringResource(MR.strings.pref_sync_service),
|
||||||
|
entries = mapOf(
|
||||||
|
SyncManager.SyncService.NONE.value to stringResource(MR.strings.off),
|
||||||
|
SyncManager.SyncService.SYNCYOMI.value to stringResource(MR.strings.syncyomi),
|
||||||
|
SyncManager.SyncService.GOOGLE_DRIVE.value to stringResource(MR.strings.google_drive),
|
||||||
|
),
|
||||||
|
onValueChanged = { true },
|
||||||
|
),
|
||||||
|
) + getSyncServicePreferences(syncPreferences, syncService)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
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)
|
||||||
|
|
||||||
|
val basePreferences = getBasePreferences(syncServiceType, syncPreferences)
|
||||||
|
|
||||||
|
return if (syncServiceType != SyncManager.SyncService.NONE) {
|
||||||
|
basePreferences + getAdditionalPreferences(syncPreferences)
|
||||||
|
} else {
|
||||||
|
basePreferences
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun getBasePreferences(syncServiceType: SyncManager.SyncService, syncPreferences: SyncPreferences): List<Preference> {
|
||||||
return when (syncServiceType) {
|
return 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()
|
||||||
} +
|
}
|
||||||
if (syncServiceType == SyncManager.SyncService.NONE) {
|
}
|
||||||
emptyList()
|
|
||||||
} else {
|
@Composable
|
||||||
listOf(getSyncNowPref(), getAutomaticSyncGroup(syncPreferences))
|
private fun getAdditionalPreferences(syncPreferences: SyncPreferences): List<Preference> {
|
||||||
}
|
return listOf(getSyncNowPref(), getAutomaticSyncGroup(syncPreferences))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
@ -209,7 +209,7 @@ object SettingsMainScreen : Screen() {
|
|||||||
screen = SettingsBrowseScreen,
|
screen = SettingsBrowseScreen,
|
||||||
),
|
),
|
||||||
Item(
|
Item(
|
||||||
titleRes = MR.strings.label_backup_and_sync,
|
titleRes = MR.strings.label_data_storage,
|
||||||
subtitleRes = MR.strings.pref_backup_summary,
|
subtitleRes = MR.strings.pref_backup_summary,
|
||||||
icon = Icons.Outlined.Storage,
|
icon = Icons.Outlined.Storage,
|
||||||
screen = SettingsDataScreen,
|
screen = SettingsDataScreen,
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
<string name="label_sources">Sources</string>
|
<string name="label_sources">Sources</string>
|
||||||
<string name="label_data_storage">Data and storage</string>
|
<string name="label_data_storage">Data and storage</string>
|
||||||
<string name="label_backup">Backup</string>
|
<string name="label_backup">Backup</string>
|
||||||
<string name="label_backup_and_sync">Backup and Sync</string>
|
|
||||||
<string name="label_sync">Sync</string>
|
<string name="label_sync">Sync</string>
|
||||||
<string name="label_stats">Statistics</string>
|
<string name="label_stats">Statistics</string>
|
||||||
<string name="label_migration">Migrate</string>
|
<string name="label_migration">Migrate</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user