This commit is contained in:
gedoor 2021-11-18 18:48:24 +08:00
parent 0766477f4b
commit 3e7069af3a
9 changed files with 27 additions and 20 deletions

View File

@ -4,6 +4,7 @@ import android.content.Context
import android.net.Uri
import androidx.documentfile.provider.DocumentFile
import io.legado.app.R
import io.legado.app.constant.AppLog
import io.legado.app.constant.PreferKey
import io.legado.app.data.appDb
import io.legado.app.help.DefaultData
@ -51,7 +52,8 @@ object Backup {
Coroutine.async {
backup(context, context.getPrefString(PreferKey.backupPath) ?: "", true)
}.onError {
appCtx.toastOnUi(R.string.autobackup_fail)
AppLog.put("备份出错\n${it.localizedMessage}", it)
appCtx.toastOnUi(appCtx.getString(R.string.autobackup_fail, it.localizedMessage))
}
}
}

View File

@ -15,6 +15,7 @@ import androidx.preference.ListPreference
import androidx.preference.Preference
import io.legado.app.R
import io.legado.app.base.BasePreferenceFragment
import io.legado.app.constant.AppLog
import io.legado.app.constant.PreferKey
import io.legado.app.help.AppConfig
import io.legado.app.help.LocalConfig
@ -47,8 +48,8 @@ class BackupConfigFragment : BasePreferenceFragment(),
}
}
}
private val backupDir = registerForActivityResult(HandleFileContract()) {
it.uri?.let { uri ->
private val backupDir = registerForActivityResult(HandleFileContract()) { result ->
result.uri?.let { uri ->
if (uri.isContentScheme()) {
AppConfig.backupPath = uri.toString()
Coroutine.async {
@ -56,7 +57,8 @@ class BackupConfigFragment : BasePreferenceFragment(),
}.onSuccess {
appCtx.toastOnUi(R.string.backup_success)
}.onError {
appCtx.toastOnUi(R.string.backup_fail)
AppLog.put("备份出错\n${it.localizedMessage}", it)
appCtx.toastOnUi(getString(R.string.backup_fail, it.localizedMessage))
}
} else {
uri.path?.let { path ->
@ -66,7 +68,8 @@ class BackupConfigFragment : BasePreferenceFragment(),
}.onSuccess {
appCtx.toastOnUi(R.string.backup_success)
}.onError {
appCtx.toastOnUi(R.string.backup_fail)
AppLog.put("备份出错\n${it.localizedMessage}", it)
appCtx.toastOnUi(getString(R.string.backup_fail, it.localizedMessage))
}
}
}
@ -242,7 +245,8 @@ class BackupConfigFragment : BasePreferenceFragment(),
}.onSuccess {
appCtx.toastOnUi(R.string.backup_success)
}.onError {
appCtx.toastOnUi(R.string.backup_fail)
AppLog.put("备份出错\n${it.localizedMessage}", it)
appCtx.toastOnUi(getString(R.string.backup_fail, it.localizedMessage))
}
} else {
backupDir.launch(null)
@ -264,7 +268,8 @@ class BackupConfigFragment : BasePreferenceFragment(),
}.onSuccess {
appCtx.toastOnUi(R.string.backup_success)
}.onError {
appCtx.toastOnUi(R.string.backup_fail)
AppLog.put("备份出错\n${it.localizedMessage}", it)
appCtx.toastOnUi(getString(R.string.backup_fail, it.localizedMessage))
}
}
.request()

View File

@ -114,7 +114,7 @@
<string name="restore_confirmation">Confirmar restauración</string>
<string name="restore_message">La restauración de los datos de la estantería reemplazará a los datos de la actual.</string>
<string name="backup_success">Respaldo completado</string>
<string name="backup_fail">Error de respaldo</string>
<string name="backup_fail">Error de respaldo\n%s</string>
<string name="on_restore">Restaurando</string>
<string name="restore_success">Restauración completada</string>
<string name="restore_fail">Restauración fallida</string>
@ -857,7 +857,7 @@
<string name="check_source_show_debug_message">La fuente del libro de cheques muestra un mensaje de depuración</string>
<string name="check_source_show_debug_message_summary">Muestra los pasos y el tiempo de la solicitud de red durante la verificación de la fuente del libro</string>
<string name="export_no_chapter_name">No export chapter names</string>
<string name="autobackup_fail">Autobackup failed</string>
<string name="autobackup_fail">Autobackup failed\n%s</string>
<string name="background_image_blurring">Background image blurring</string>
<string name="background_image_blurring_radius">Blurring radius</string>
<string name="background_image_hint">Disabled when 0, enable range from 1 to 25\nThe greater the radius, the stronger the effect of blurring</string>

View File

@ -118,7 +118,7 @@
<string name="restore_confirmation">Restore confirmation</string>
<string name="restore_message">Restoring the bookshelf data will overwrite the current Bookshelf.</string>
<string name="backup_success">Backup succeed</string>
<string name="backup_fail">Backup failed</string>
<string name="backup_fail">Backup failed\n%s</string>
<string name="on_restore">Restoring</string>
<string name="restore_success">Restore succeed</string>
<string name="restore_fail">Backup failed</string>
@ -861,7 +861,7 @@
<string name="read_aloud_by_page_summary">及时翻页,翻页时会停顿一下</string>
<string name="check_source_show_debug_message">Check book source shows debug message</string>
<string name="check_source_show_debug_message_summary">Show network status and timestamp during source checking</string>
<string name="autobackup_fail">Autobackup failed</string>
<string name="autobackup_fail">Autobackup failed\n%s</string>
<string name="background_image_blurring">Background image blurring</string>
<string name="background_image_blurring_radius">Blurring radius</string>
<string name="background_image_hint">Disabled when 0, enable range from 1 to 25\nThe greater the radius, the stronger the effect of blurring</string>

View File

@ -118,7 +118,7 @@
<string name="restore_confirmation">Confirmação da Restauração</string>
<string name="restore_message">A restauração dos dados da estante irá substituir a estante atual.</string>
<string name="backup_success">Backup bem sucedido</string>
<string name="backup_fail">O Backup falhou</string>
<string name="backup_fail">O Backup falhou\n%s</string>
<string name="on_restore">Restaurando</string>
<string name="restore_success">Restauração bem sucedida</string>
<string name="restore_fail">A restauração falhou</string>
@ -861,7 +861,7 @@
<string name="check_source_show_debug_message">Marcando a fonte do livro mostra uma mensagem de depuração</string>
<string name="check_source_show_debug_message_summary">Mostrar o status da rede com a data e hora durante a verificação da fonte</string>
<string name="export_no_chapter_name">Não há nomes de capítulos de exportação</string>
<string name="autobackup_fail">Auto-Backup falhou</string>
<string name="autobackup_fail">Auto-Backup falhou\n%s</string>
<string name="background_image_blurring">Desfocagem da imagem de fundo</string>
<string name="background_image_blurring_radius">Raio da desfocagem</string>
<string name="background_image_hint">Desativado quando 0, Ativado entre 1 e 25\n Quanto maior o raio, mais forte o efeito de desfocagem</string>

View File

@ -115,7 +115,7 @@
<string name="restore_confirmation">確認還原嗎?</string>
<string name="restore_message">還原成功會覆蓋原有書架。</string>
<string name="backup_success">備份成功</string>
<string name="backup_fail">備份失敗</string>
<string name="backup_fail">備份失敗\n%s</string>
<string name="on_restore">正在還原</string>
<string name="restore_success">還原成功</string>
<string name="restore_fail">還原失敗</string>

View File

@ -117,7 +117,7 @@
<string name="restore_confirmation">確認復原嗎?</string>
<string name="restore_message">復原書架會覆蓋現有書架。</string>
<string name="backup_success">備份成功</string>
<string name="backup_fail">備份失敗</string>
<string name="backup_fail">備份失敗\n%s</string>
<string name="on_restore">正在復原</string>
<string name="restore_success">復原成功</string>
<string name="restore_fail">復原失敗</string>
@ -856,7 +856,7 @@
<string name="null_url">url為空</string>
<string name="dict">字典</string>
<string name="unknown_error">未知錯誤</string>
<string name="autobackup_fail">自動備份失敗</string>
<string name="autobackup_fail">自動備份失敗\n%s</string>
<string name="end">結束</string>
<string name="custom_group_summary">關閉取代分組/開啟添加分組</string>
<string name="pref_media_button_per_next">媒體按鈕•上一首|下一首</string>

View File

@ -117,7 +117,7 @@
<string name="restore_confirmation">确认恢复吗?</string>
<string name="restore_message">恢复书架会覆盖现有书架。</string>
<string name="backup_success">备份成功</string>
<string name="backup_fail">备份失败</string>
<string name="backup_fail">备份失败\n%s</string>
<string name="on_restore">正在恢复</string>
<string name="restore_success">恢复成功</string>
<string name="restore_fail">恢复失败</string>
@ -856,7 +856,7 @@
<string name="null_url">url为空</string>
<string name="dict">字典</string>
<string name="unknown_error">未知错误</string>
<string name="autobackup_fail">自动备份失败</string>
<string name="autobackup_fail">自动备份失败\n%s</string>
<string name="end">结束</string>
<string name="custom_group_summary">关闭替换分组/开启添加分组</string>
<string name="pref_media_button_per_next">媒体按钮•上一首|下一首</string>

View File

@ -118,7 +118,7 @@
<string name="restore_confirmation">Restore confirmation</string>
<string name="restore_message">Restoring the bookshelf data will overwrite the current Bookshelf.</string>
<string name="backup_success">Backup succeed</string>
<string name="backup_fail">Backup failed</string>
<string name="backup_fail">Backup failed\n%s</string>
<string name="on_restore">Restoring</string>
<string name="restore_success">Restore succeed</string>
<string name="restore_fail">Backup failed</string>
@ -858,7 +858,7 @@
<string name="dict">dict</string>
<string name="unknown_error">unknown error</string>
<string name="export_no_chapter_name">No export chapter names</string>
<string name="autobackup_fail">Autobackup failed</string>
<string name="autobackup_fail">Autobackup failed\n%s</string>
<string name="end">end</string>
<string name="custom_group_summary">关闭替换分组/开启添加分组</string>
<string name="pref_media_button_per_next">媒体按钮•上一首|下一首</string>