From 7e52c19e656db7795dff7f352a27f186e6785054 Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 18 Jan 2023 22:53:57 +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 --- .../java/io/legado/app/lib/permission/Permissions.kt | 2 +- .../main/java/io/legado/app/lib/permission/Request.kt | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/lib/permission/Permissions.kt b/app/src/main/java/io/legado/app/lib/permission/Permissions.kt index 301cafc6f..ebf753b5f 100644 --- a/app/src/main/java/io/legado/app/lib/permission/Permissions.kt +++ b/app/src/main/java/io/legado/app/lib/permission/Permissions.kt @@ -43,7 +43,7 @@ object Permissions { object Group { val STORAGE = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { - arrayOf(READ_EXTERNAL_STORAGE, MANAGE_EXTERNAL_STORAGE) + arrayOf(MANAGE_EXTERNAL_STORAGE) } else { arrayOf(READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE) } diff --git a/app/src/main/java/io/legado/app/lib/permission/Request.kt b/app/src/main/java/io/legado/app/lib/permission/Request.kt index f97f2e76e..4327d1d79 100644 --- a/app/src/main/java/io/legado/app/lib/permission/Request.kt +++ b/app/src/main/java/io/legado/app/lib/permission/Request.kt @@ -2,6 +2,7 @@ package io.legado.app.lib.permission import android.content.pm.PackageManager import android.os.Build +import android.os.Environment import androidx.annotation.StringRes import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity @@ -123,7 +124,13 @@ internal class Request : OnRequestPermissionsResultCallback { if (permissions != null) { val deniedPermissionList = ArrayList() for (permission in permissions) { - if ( + if (permission == Permissions.MANAGE_EXTERNAL_STORAGE) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + if (!Environment.isExternalStorageManager()) { + deniedPermissionList.add(permission) + } + } + } else if ( ContextCompat.checkSelfPermission(context, permission) != PackageManager.PERMISSION_GRANTED ) {