From 7acc1d616692aaeb59d724b6b9fcb8140bcac09e Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 31 Oct 2020 09:26:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/local/ImportBookActivity.kt | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt index 58cb56e13..64b6e76a4 100644 --- a/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt @@ -119,31 +119,30 @@ class ImportBookActivity : VMBaseActivity(R.layout.activity } private fun upRootDoc() { - AppConfig.importBookPath?.let { lastPath -> - when { - lastPath.isContentPath() -> { - val rootUri = Uri.parse(lastPath) - rootDoc = DocumentFile.fromTreeUri(this, rootUri) + val lastPath = AppConfig.importBookPath + when { + lastPath.isNullOrEmpty() -> { + FilePicker.selectFolder(this, requestCodeSelectFolder) + } + 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() + path = lastPath upPath() } - Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q -> { - 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) - } + .request() } }