From 598022661bdd50ed7300aad6bc67cfba864a8a5a Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 16 Feb 2020 20:19:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/config/BackupRestoreUi.kt | 16 +++++++++++----- .../legado/app/ui/download/DownloadActivity.kt | 18 +++++++++++++----- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt b/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt index ba1b8dd5a..16fd3941b 100644 --- a/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt +++ b/app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt @@ -183,11 +183,17 @@ object BackupRestoreUi { } } 2 -> { - FileChooserDialog.show( - fragment.childFragmentManager, - oldDataRequestCode, - mode = FileChooserDialog.DIRECTORY - ) + PermissionsCompat.Builder(fragment) + .addPermissions(*Permissions.Group.STORAGE) + .rationale(R.string.tip_perm_request_storage) + .onGranted { + FileChooserDialog.show( + fragment.childFragmentManager, + oldDataRequestCode, + mode = FileChooserDialog.DIRECTORY + ) + } + .request() } } } diff --git a/app/src/main/java/io/legado/app/ui/download/DownloadActivity.kt b/app/src/main/java/io/legado/app/ui/download/DownloadActivity.kt index 6e1779d62..4daa6272d 100644 --- a/app/src/main/java/io/legado/app/ui/download/DownloadActivity.kt +++ b/app/src/main/java/io/legado/app/ui/download/DownloadActivity.kt @@ -15,6 +15,8 @@ import io.legado.app.constant.EventBus import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter import io.legado.app.help.BookHelp +import io.legado.app.help.permission.Permissions +import io.legado.app.help.permission.PermissionsCompat import io.legado.app.service.help.Download import io.legado.app.ui.filechooser.FileChooserDialog import io.legado.app.utils.ACache @@ -145,11 +147,17 @@ class DownloadActivity : VMBaseActivity(R.layout.activity_dow } } 2 -> { - FileChooserDialog.show( - supportFragmentManager, - exportRequestCode, - mode = FileChooserDialog.DIRECTORY - ) + PermissionsCompat.Builder(this@DownloadActivity) + .addPermissions(*Permissions.Group.STORAGE) + .rationale(R.string.tip_perm_request_storage) + .onGranted { + FileChooserDialog.show( + supportFragmentManager, + exportRequestCode, + mode = FileChooserDialog.DIRECTORY + ) + } + .request() } } }