pull/940/head
gedoor 4 years ago
parent bd3e196688
commit 83d1da4947
  1. 5
      app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt
  2. 5
      app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt
  3. 16
      app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt
  4. 6
      app/src/main/java/io/legado/app/ui/document/FilePickerActivity.kt

@ -1,6 +1,5 @@
package io.legado.app.ui.book.cache
import android.content.Intent
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
@ -42,10 +41,6 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
private val exportDir = registerForActivityResult(FilePicker()) { uri ->
uri ?: return@registerForActivityResult
if (uri.isContentScheme()) {
contentResolver.takePersistableUriPermission(
uri,
Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
)
ACache.get(this@CacheActivity).put(exportBookPathKey, uri.toString())
startExport(uri.toString())
} else {

@ -1,6 +1,5 @@
package io.legado.app.ui.book.local
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
@ -46,10 +45,6 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV
private val selectFolder = registerForActivityResult(FilePicker()) { uri ->
uri ?: return@registerForActivityResult
if (uri.isContentScheme()) {
contentResolver.takePersistableUriPermission(
uri,
Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
)
AppConfig.importBookPath = uri.toString()
initRootDoc()
} else {

@ -1,6 +1,5 @@
package io.legado.app.ui.config
import android.content.Intent
import android.content.SharedPreferences
import android.net.Uri
import android.os.Bundle
@ -40,11 +39,6 @@ class BackupConfigFragment : BasePreferenceFragment(),
private val selectBackupPath = registerForActivityResult(FilePicker()) { uri ->
uri ?: return@registerForActivityResult
if (uri.isContentScheme()) {
appCtx.contentResolver.takePersistableUriPermission(
uri,
Intent.FLAG_GRANT_READ_URI_PERMISSION
or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
)
AppConfig.backupPath = uri.toString()
} else {
AppConfig.backupPath = uri.path
@ -53,11 +47,6 @@ class BackupConfigFragment : BasePreferenceFragment(),
private val backupDir = registerForActivityResult(FilePicker()) { uri ->
uri ?: return@registerForActivityResult
if (uri.isContentScheme()) {
appCtx.contentResolver.takePersistableUriPermission(
uri,
Intent.FLAG_GRANT_READ_URI_PERMISSION
or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
)
AppConfig.backupPath = uri.toString()
Coroutine.async {
Backup.backup(appCtx, uri.toString())
@ -78,11 +67,6 @@ class BackupConfigFragment : BasePreferenceFragment(),
private val restoreDir = registerForActivityResult(FilePicker()) { uri ->
uri ?: return@registerForActivityResult
if (uri.isContentScheme()) {
appCtx.contentResolver.takePersistableUriPermission(
uri,
Intent.FLAG_GRANT_READ_URI_PERMISSION
or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
)
AppConfig.backupPath = uri.toString()
Coroutine.async {
Restore.restore(appCtx, uri.toString())

@ -23,6 +23,12 @@ class FilePickerActivity :
private val selectDocTree =
registerForActivityResult(ActivityResultContracts.OpenDocumentTree()) {
if (it.isContentScheme()) {
contentResolver.takePersistableUriPermission(
it,
Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
)
}
onResult(Intent().setData(it))
}

Loading…
Cancel
Save