mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 03:01:52 +01:00
Shorten restore warning message a bit
This commit is contained in:
parent
5bba7af24a
commit
f3b7eaf4a3
@ -92,7 +92,7 @@ class RestoreBackupScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (state.error != null) {
|
if (state.error != null) {
|
||||||
errorMessageItem(state, model)
|
errorMessageItem(state.error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,8 +118,7 @@ class RestoreBackupScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun LazyListScope.errorMessageItem(
|
private fun LazyListScope.errorMessageItem(
|
||||||
state: RestoreBackupScreenModel.State,
|
error: Any?,
|
||||||
model: RestoreBackupScreenModel,
|
|
||||||
) {
|
) {
|
||||||
item {
|
item {
|
||||||
SectionCard {
|
SectionCard {
|
||||||
@ -127,23 +126,23 @@ class RestoreBackupScreen(
|
|||||||
modifier = Modifier.padding(horizontal = MaterialTheme.padding.medium),
|
modifier = Modifier.padding(horizontal = MaterialTheme.padding.medium),
|
||||||
verticalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small),
|
verticalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small),
|
||||||
) {
|
) {
|
||||||
when (val err = state.error) {
|
when (error) {
|
||||||
is MissingRestoreComponents -> {
|
is MissingRestoreComponents -> {
|
||||||
val msg = buildString {
|
val msg = buildString {
|
||||||
append(stringResource(MR.strings.backup_restore_content_full))
|
append(stringResource(MR.strings.backup_restore_content_full))
|
||||||
if (err.sources.isNotEmpty()) {
|
if (error.sources.isNotEmpty()) {
|
||||||
append("\n\n")
|
append("\n\n")
|
||||||
append(stringResource(MR.strings.backup_restore_missing_sources))
|
append(stringResource(MR.strings.backup_restore_missing_sources))
|
||||||
err.sources.joinTo(
|
error.sources.joinTo(
|
||||||
this,
|
this,
|
||||||
separator = "\n- ",
|
separator = "\n- ",
|
||||||
prefix = "\n- ",
|
prefix = "\n- ",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (err.trackers.isNotEmpty()) {
|
if (error.trackers.isNotEmpty()) {
|
||||||
append("\n\n")
|
append("\n\n")
|
||||||
append(stringResource(MR.strings.backup_restore_missing_trackers))
|
append(stringResource(MR.strings.backup_restore_missing_trackers))
|
||||||
err.trackers.joinTo(
|
error.trackers.joinTo(
|
||||||
this,
|
this,
|
||||||
separator = "\n- ",
|
separator = "\n- ",
|
||||||
prefix = "\n- ",
|
prefix = "\n- ",
|
||||||
@ -159,13 +158,13 @@ class RestoreBackupScreen(
|
|||||||
Text(text = stringResource(MR.strings.invalid_backup_file))
|
Text(text = stringResource(MR.strings.invalid_backup_file))
|
||||||
|
|
||||||
SelectionContainer {
|
SelectionContainer {
|
||||||
Text(text = listOfNotNull(err.uri, err.message).joinToString("\n\n"))
|
Text(text = listOfNotNull(error.uri, error.message).joinToString("\n\n"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
SelectionContainer {
|
SelectionContainer {
|
||||||
Text(text = err.toString())
|
Text(text = error.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -184,6 +183,22 @@ private class RestoreBackupScreenModel(
|
|||||||
validate(uri)
|
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) {
|
private fun validate(uri: Uri) {
|
||||||
val results = try {
|
val results = try {
|
||||||
BackupFileValidator(context).validate(uri)
|
BackupFileValidator(context).validate(uri)
|
||||||
@ -206,22 +221,6 @@ private class RestoreBackupScreenModel(
|
|||||||
setError(error = null, canRestore = true)
|
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) {
|
private fun setError(error: Any?, canRestore: Boolean) {
|
||||||
mutableState.update {
|
mutableState.update {
|
||||||
it.copy(
|
it.copy(
|
||||||
|
@ -497,7 +497,7 @@
|
|||||||
<string name="invalid_backup_file_missing_manga">Backup does not contain any library entries.</string>
|
<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_sources">Missing sources:</string>
|
||||||
<string name="backup_restore_missing_trackers">Trackers not logged into:</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_completed">Restore completed</string>
|
||||||
<string name="restore_duration">%02d min, %02d sec</string>
|
<string name="restore_duration">%02d min, %02d sec</string>
|
||||||
<string name="backup_in_progress">Backup is already in progress</string>
|
<string name="backup_in_progress">Backup is already in progress</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user