pull/67/head
kunfei 5 years ago
parent c106782995
commit 75d69cb249
  1. 31
      app/src/main/java/io/legado/app/help/storage/Backup.kt
  2. 33
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt

@ -1,5 +1,8 @@
package io.legado.app.help.storage
import android.content.Context
import android.net.Uri
import androidx.documentfile.provider.DocumentFile
import io.legado.app.App
import io.legado.app.R
import io.legado.app.help.FileHelp
@ -27,6 +30,34 @@ object Backup {
legadoPath + File.separator + "Export"
}
fun backup(context: Context, uri: Uri) {
DocumentFile.fromTreeUri(context, uri)?.listFiles()?.forEach { doc ->
when (doc.name) {
"bookshelf.json" -> {
}
"bookGroup.json" -> {
}
"bookSource.json" -> {
}
"rssSource.json" -> {
}
"replaceRule.json" -> {
}
ReadBookConfig.readConfigFileName -> {
}
"config.xml" -> {
}
}
}
}
private fun pBackup(path: String = legadoPath) {
backupBookshelf(path)
backupBookGroup(path)

@ -18,7 +18,6 @@ import io.legado.app.R
import io.legado.app.base.VMBaseActivity
import io.legado.app.constant.Bus
import io.legado.app.constant.PreferKey
import io.legado.app.help.ReadBookConfig
import io.legado.app.help.permission.Permissions
import io.legado.app.help.permission.PermissionsCompat
import io.legado.app.help.storage.Backup
@ -156,41 +155,13 @@ class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main),
val uri = Uri.parse(backupPath)
val doc = DocumentFile.fromTreeUri(this, uri)
if (doc?.canWrite() == true) {
backup(uri)
Backup.backup(this, uri)
} else {
selectBackupFolder()
}
}
}
private fun backup(uri: Uri) {
DocumentFile.fromTreeUri(this, uri)?.listFiles()?.forEach { doc ->
when (doc.name) {
"bookshelf.json" -> {
}
"bookGroup.json" -> {
}
"bookSource.json" -> {
}
"rssSource.json" -> {
}
"replaceRule.json" -> {
}
ReadBookConfig.readConfigFileName -> {
}
"config.xml" -> {
}
}
}
}
fun restore() {
PermissionsCompat.Builder(this)
.addPermissions(*Permissions.Group.STORAGE)
@ -240,7 +211,7 @@ class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main),
uri,
Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
)
backup(uri)
Backup.backup(this, uri)
}
}
restoreSelectRequestCode -> if (resultCode == Activity.RESULT_OK) {

Loading…
Cancel
Save