Merge pull request #1188 from JiuZhouWorlds/master

备份失败时及时提醒
pull/1191/head
kunfei 3 years ago committed by GitHub
commit 0f7e43985b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      app/src/main/java/io/legado/app/help/storage/Backup.kt
  2. 8
      app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt
  3. 1
      app/src/main/res/values-zh/strings.xml
  4. 1
      app/src/main/res/values/strings.xml

@ -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)
}
}
}

@ -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()

@ -846,5 +846,6 @@
<string name="null_url">url为空</string>
<string name="dict">字典</string>
<string name="unknown_error">未知错误</string>
<string name="autobackup_fail">自动备份失败</string>
</resources>

@ -848,5 +848,6 @@
<string name="null_url">Null url</string>
<string name="dict">字典</string>
<string name="unknown_error">未知错误</string>
<string name="autobackup_fail">Autobackup failed</string>
</resources>

Loading…
Cancel
Save