mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-22 12:48:15 +03:00
Shorten restore warning message a bit
This commit is contained in:
parent
5bba7af24a
commit
f3b7eaf4a3
2 changed files with 26 additions and 27 deletions
|
@ -92,7 +92,7 @@ class RestoreBackupScreen(
|
|||
}
|
||||
|
||||
if (state.error != null) {
|
||||
errorMessageItem(state, model)
|
||||
errorMessageItem(state.error)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,8 +118,7 @@ class RestoreBackupScreen(
|
|||
}
|
||||
|
||||
private fun LazyListScope.errorMessageItem(
|
||||
state: RestoreBackupScreenModel.State,
|
||||
model: RestoreBackupScreenModel,
|
||||
error: Any?,
|
||||
) {
|
||||
item {
|
||||
SectionCard {
|
||||
|
@ -127,23 +126,23 @@ class RestoreBackupScreen(
|
|||
modifier = Modifier.padding(horizontal = MaterialTheme.padding.medium),
|
||||
verticalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small),
|
||||
) {
|
||||
when (val err = state.error) {
|
||||
when (error) {
|
||||
is MissingRestoreComponents -> {
|
||||
val msg = buildString {
|
||||
append(stringResource(MR.strings.backup_restore_content_full))
|
||||
if (err.sources.isNotEmpty()) {
|
||||
if (error.sources.isNotEmpty()) {
|
||||
append("\n\n")
|
||||
append(stringResource(MR.strings.backup_restore_missing_sources))
|
||||
err.sources.joinTo(
|
||||
error.sources.joinTo(
|
||||
this,
|
||||
separator = "\n- ",
|
||||
prefix = "\n- ",
|
||||
)
|
||||
}
|
||||
if (err.trackers.isNotEmpty()) {
|
||||
if (error.trackers.isNotEmpty()) {
|
||||
append("\n\n")
|
||||
append(stringResource(MR.strings.backup_restore_missing_trackers))
|
||||
err.trackers.joinTo(
|
||||
error.trackers.joinTo(
|
||||
this,
|
||||
separator = "\n- ",
|
||||
prefix = "\n- ",
|
||||
|
@ -159,13 +158,13 @@ class RestoreBackupScreen(
|
|||
Text(text = stringResource(MR.strings.invalid_backup_file))
|
||||
|
||||
SelectionContainer {
|
||||
Text(text = listOfNotNull(err.uri, err.message).joinToString("\n\n"))
|
||||
Text(text = listOfNotNull(error.uri, error.message).joinToString("\n\n"))
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
SelectionContainer {
|
||||
Text(text = err.toString())
|
||||
Text(text = error.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -184,6 +183,22 @@ private class RestoreBackupScreenModel(
|
|||
validate(uri)
|
||||
}
|
||||
|
||||
fun toggle(setter: (RestoreOptions, Boolean) -> RestoreOptions, enabled: Boolean) {
|
||||
mutableState.update {
|
||||
it.copy(
|
||||
options = setter(it.options, enabled),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun startRestore() {
|
||||
BackupRestoreJob.start(
|
||||
context = context,
|
||||
uri = uri,
|
||||
options = state.value.options,
|
||||
)
|
||||
}
|
||||
|
||||
private fun validate(uri: Uri) {
|
||||
val results = try {
|
||||
BackupFileValidator(context).validate(uri)
|
||||
|
@ -206,22 +221,6 @@ private class RestoreBackupScreenModel(
|
|||
setError(error = null, canRestore = true)
|
||||
}
|
||||
|
||||
fun toggle(setter: (RestoreOptions, Boolean) -> RestoreOptions, enabled: Boolean) {
|
||||
mutableState.update {
|
||||
it.copy(
|
||||
options = setter(it.options, enabled),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun startRestore() {
|
||||
BackupRestoreJob.start(
|
||||
context = context,
|
||||
uri = uri,
|
||||
options = state.value.options,
|
||||
)
|
||||
}
|
||||
|
||||
private fun setError(error: Any?, canRestore: Boolean) {
|
||||
mutableState.update {
|
||||
it.copy(
|
||||
|
|
|
@ -497,7 +497,7 @@
|
|||
<string name="invalid_backup_file_missing_manga">Backup does not contain any library entries.</string>
|
||||
<string name="backup_restore_missing_sources">Missing sources:</string>
|
||||
<string name="backup_restore_missing_trackers">Trackers not logged into:</string>
|
||||
<string name="backup_restore_content_full">Data from the backup file will be restored.\n\nYou may need to install any missing extensions and log in to tracking services afterwards to use them.</string>
|
||||
<string name="backup_restore_content_full">You may need to install any missing extensions and log in to tracking services afterwards to use them.</string>
|
||||
<string name="restore_completed">Restore completed</string>
|
||||
<string name="restore_duration">%02d min, %02d sec</string>
|
||||
<string name="backup_in_progress">Backup is already in progress</string>
|
||||
|
|
Loading…
Reference in a new issue