Show an error if backup file URI isn't returned to app when attempting restore
Related to #10028 (cherry picked from commit e572abb041cc0c410842fda1ed703f1b80a94d96)
This commit is contained in:
parent
ab04d07b3f
commit
07f34281c7
@ -242,7 +242,7 @@ object SettingsBackupScreen : SearchableSettings {
|
|||||||
AlertDialog(
|
AlertDialog(
|
||||||
onDismissRequest = onDismissRequest,
|
onDismissRequest = onDismissRequest,
|
||||||
title = { Text(text = stringResource(R.string.invalid_backup_file)) },
|
title = { Text(text = stringResource(R.string.invalid_backup_file)) },
|
||||||
text = { Text(text = "${err.uri}\n\n${err.message}") },
|
text = { Text(text = listOfNotNull(err.uri, err.message).joinToString("\n\n")) },
|
||||||
dismissButton = {
|
dismissButton = {
|
||||||
TextButton(
|
TextButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
@ -314,7 +314,11 @@ object SettingsBackupScreen : SearchableSettings {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
if (it != null) {
|
if (it == null) {
|
||||||
|
error = InvalidRestore(message = context.getString(R.string.file_null_uri_error))
|
||||||
|
return@rememberLauncherForActivityResult
|
||||||
|
}
|
||||||
|
|
||||||
val results = try {
|
val results = try {
|
||||||
BackupFileValidator().validate(context, it)
|
BackupFileValidator().validate(context, it)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@ -329,7 +333,6 @@ object SettingsBackupScreen : SearchableSettings {
|
|||||||
|
|
||||||
error = MissingRestoreComponents(it, results.missingSources, results.missingTrackers)
|
error = MissingRestoreComponents(it, results.missingSources, results.missingTrackers)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return Preference.PreferenceItem.TextPreference(
|
return Preference.PreferenceItem.TextPreference(
|
||||||
title = stringResource(R.string.pref_restore_backup),
|
title = stringResource(R.string.pref_restore_backup),
|
||||||
@ -425,6 +428,6 @@ private data class MissingRestoreComponents(
|
|||||||
)
|
)
|
||||||
|
|
||||||
private data class InvalidRestore(
|
private data class InvalidRestore(
|
||||||
val uri: Uri,
|
val uri: Uri? = null,
|
||||||
val message: String,
|
val message: String,
|
||||||
)
|
)
|
||||||
|
@ -871,6 +871,7 @@
|
|||||||
<string name="file_select_cover">Select cover image</string>
|
<string name="file_select_cover">Select cover image</string>
|
||||||
<string name="file_select_backup">Select backup file</string>
|
<string name="file_select_backup">Select backup file</string>
|
||||||
<string name="file_picker_error">No file picker app found</string>
|
<string name="file_picker_error">No file picker app found</string>
|
||||||
|
<string name="file_null_uri_error">File picker failed to return file to app</string>
|
||||||
|
|
||||||
<!--UpdateCheck-->
|
<!--UpdateCheck-->
|
||||||
<string name="update_check_confirm">Download</string>
|
<string name="update_check_confirm">Download</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user