From 6e40b288800731648d68d0721ed8e0aaadd758ae Mon Sep 17 00:00:00 2001
From: NineWorlds <1365887550@qq.com>
Date: Fri, 30 Jul 2021 10:55:54 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A4=87=E4=BB=BD=E5=A4=B1=E8=B4=A5=E6=97=B6?=
=?UTF-8?q?=E5=8F=8A=E6=97=B6=E6=8F=90=E9=86=92?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/src/main/java/io/legado/app/help/storage/Backup.kt | 3 +++
.../java/io/legado/app/ui/config/BackupConfigFragment.kt | 8 ++++++++
app/src/main/res/values-zh/strings.xml | 1 +
app/src/main/res/values/strings.xml | 1 +
4 files changed, 13 insertions(+)
diff --git a/app/src/main/java/io/legado/app/help/storage/Backup.kt b/app/src/main/java/io/legado/app/help/storage/Backup.kt
index fac7826be..6bd8cd01c 100644
--- a/app/src/main/java/io/legado/app/help/storage/Backup.kt
+++ b/app/src/main/java/io/legado/app/help/storage/Backup.kt
@@ -3,6 +3,7 @@ package io.legado.app.help.storage
import android.content.Context
import android.net.Uri
import androidx.documentfile.provider.DocumentFile
+import io.legado.app.R
import io.legado.app.constant.PreferKey
import io.legado.app.data.appDb
import io.legado.app.help.DefaultData
@@ -49,6 +50,8 @@ object Backup {
if (lastBackup + TimeUnit.DAYS.toMillis(1) < System.currentTimeMillis()) {
Coroutine.async {
backup(context, context.getPrefString(PreferKey.backupPath) ?: "", true)
+ }.onError {
+ appCtx.toastOnUi(R.string.autobackup_fail)
}
}
}
diff --git a/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt
index 1b6c8ba45..18c274561 100644
--- a/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt
+++ b/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt
@@ -52,6 +52,8 @@ class BackupConfigFragment : BasePreferenceFragment(),
Backup.backup(appCtx, uri.toString())
}.onSuccess {
appCtx.toastOnUi(R.string.backup_success)
+ }.onError {
+ appCtx.toastOnUi(R.string.backup_fail)
}
} else {
uri.path?.let { path ->
@@ -60,6 +62,8 @@ class BackupConfigFragment : BasePreferenceFragment(),
Backup.backup(appCtx, path)
}.onSuccess {
appCtx.toastOnUi(R.string.backup_success)
+ }.onError {
+ appCtx.toastOnUi(R.string.backup_fail)
}
}
}
@@ -231,6 +235,8 @@ class BackupConfigFragment : BasePreferenceFragment(),
Backup.backup(requireContext(), backupPath)
}.onSuccess {
toastOnUi(R.string.backup_success)
+ }.onError {
+ toastOnUi(R.string.backup_fail)
}
} else {
backupDir.launch(null)
@@ -251,6 +257,8 @@ class BackupConfigFragment : BasePreferenceFragment(),
Backup.backup(requireContext(), path)
}.onSuccess {
toastOnUi(R.string.backup_success)
+ }.onError {
+ toastOnUi(R.string.backup_fail)
}
}
.request()
diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml
index 502e9f89d..910663504 100644
--- a/app/src/main/res/values-zh/strings.xml
+++ b/app/src/main/res/values-zh/strings.xml
@@ -846,5 +846,6 @@
url为空
字典
未知错误
+ 自动备份失败
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 89624f0ec..92954b0a0 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -848,5 +848,6 @@
Null url
字典
未知错误
+ Autobackup failed