From 6554490bb94897f765746411c99c3ed38a6ce3dc Mon Sep 17 00:00:00 2001 From: ted-prnd Date: Wed, 14 Aug 2024 11:29:29 +0900 Subject: [PATCH] Determine partial access granted is granted status --- .../tedpermission/TedPermissionActivity.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tedpermission/src/main/java/com/gun0912/tedpermission/TedPermissionActivity.java b/tedpermission/src/main/java/com/gun0912/tedpermission/TedPermissionActivity.java index 7fb5605..817b3de 100644 --- a/tedpermission/src/main/java/com/gun0912/tedpermission/TedPermissionActivity.java +++ b/tedpermission/src/main/java/com/gun0912/tedpermission/TedPermissionActivity.java @@ -259,7 +259,12 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis super.onRequestPermissionsResult(requestCode, permissions, grantResults); List deniedPermissions = TedPermissionUtil.getDeniedPermissions(permissions); - + for (String permission : deniedPermissions) { + if (isMediaPartialAccessGranted(permission)) { + deniedPermissions.remove(permission); + break; + } + } if (deniedPermissions.isEmpty()) { permissionResult(null); } else { @@ -267,6 +272,13 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis } } + private boolean isMediaPartialAccessGranted(@NonNull String permission) { + if (!permission.equals(Manifest.permission.READ_MEDIA_IMAGES) && !permission.equals(Manifest.permission.READ_MEDIA_VIDEO)) { + return false; + } + return TedPermissionUtil.isMediaFullOrPartialGranted(permission); + } + public void showPermissionDenyDialog(final List deniedPermissions) { if (TextUtils.isEmpty(denyMessage)) {