pull/67/head
kunfei 5 years ago
parent e0c8322ae5
commit c106782995
  1. 44
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt

@ -18,9 +18,11 @@ import io.legado.app.R
import io.legado.app.base.VMBaseActivity import io.legado.app.base.VMBaseActivity
import io.legado.app.constant.Bus import io.legado.app.constant.Bus
import io.legado.app.constant.PreferKey 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.Permissions
import io.legado.app.help.permission.PermissionsCompat import io.legado.app.help.permission.PermissionsCompat
import io.legado.app.help.storage.Backup import io.legado.app.help.storage.Backup
import io.legado.app.help.storage.Restore
import io.legado.app.help.storage.WebDavHelp import io.legado.app.help.storage.WebDavHelp
import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ATH
import io.legado.app.service.BaseReadAloudService import io.legado.app.service.BaseReadAloudService
@ -162,7 +164,31 @@ class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main),
} }
private fun backup(uri: Uri) { 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() { fun restore() {
@ -173,6 +199,10 @@ class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main),
.request() .request()
} }
fun restore(uri: Uri) {
}
private fun selectBackupFolder() { private fun selectBackupFolder() {
try { try {
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE) val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
@ -187,6 +217,20 @@ class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main),
} }
} }
private fun selectRestoreFolder() {
try {
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
startActivityForResult(intent, restoreSelectRequestCode)
} catch (e: java.lang.Exception) {
PermissionsCompat.Builder(this)
.addPermissions(*Permissions.Group.STORAGE)
.rationale(R.string.tip_perm_request_storage)
.onGranted { Restore.restore() }
.request()
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data) super.onActivityResult(requestCode, resultCode, data)
when (requestCode) { when (requestCode) {

Loading…
Cancel
Save