pull/457/head
gedoor 4 years ago
parent 44c7a38e3d
commit 7acc1d6166
  1. 43
      app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt

@ -119,31 +119,30 @@ class ImportBookActivity : VMBaseActivity<ImportBookViewModel>(R.layout.activity
} }
private fun upRootDoc() { private fun upRootDoc() {
AppConfig.importBookPath?.let { lastPath -> val lastPath = AppConfig.importBookPath
when { when {
lastPath.isContentPath() -> { lastPath.isNullOrEmpty() -> {
val rootUri = Uri.parse(lastPath) FilePicker.selectFolder(this, requestCodeSelectFolder)
rootDoc = DocumentFile.fromTreeUri(this, rootUri) }
lastPath.isContentPath() -> {
val rootUri = Uri.parse(lastPath)
rootDoc = DocumentFile.fromTreeUri(this, rootUri)
subDocs.clear()
upPath()
}
Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q -> {
FilePicker.selectFolder(this, requestCodeSelectFolder)
}
else -> PermissionsCompat.Builder(this)
.addPermissions(*Permissions.Group.STORAGE)
.rationale(R.string.tip_perm_request_storage)
.onGranted {
rootDoc = null
subDocs.clear() subDocs.clear()
path = lastPath
upPath() upPath()
} }
Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q -> { .request()
FilePicker.selectFolder(this, requestCodeSelectFolder)
}
lastPath.isNotBlank() -> {
PermissionsCompat.Builder(this)
.addPermissions(*Permissions.Group.STORAGE)
.rationale(R.string.tip_perm_request_storage)
.onGranted {
rootDoc = null
subDocs.clear()
path = lastPath
upPath()
}
.request()
}
else -> FilePicker.selectFolder(this, requestCodeSelectFolder)
}
} }
} }

Loading…
Cancel
Save