From 75d69cb249510f24c3ee38b44cf558bbaabeaea4 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 4 Jan 2020 22:02:17 +0800 Subject: [PATCH] up --- .../java/io/legado/app/help/storage/Backup.kt | 31 +++++++++++++++++ .../io/legado/app/ui/main/MainActivity.kt | 33 ++----------------- 2 files changed, 33 insertions(+), 31 deletions(-) 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 529deb629..f6c7a4953 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 @@ -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) diff --git a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt index e9a139283..88cc89b8a 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt @@ -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(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(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) {