Skip to content
This repository was archived by the owner on Oct 3, 2024. It is now read-only.

Commit 7c0b7b5

Browse files
committed
New methods to check if some permission has denied
1 parent bb23a02 commit 7c0b7b5

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

easypermissions/src/main/java/pub/devrel/easypermissions/EasyPermissions.java

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -405,16 +405,33 @@ private static boolean shouldShowRationale(@NonNull Object object, @NonNull Stri
405405

406406
/**
407407
* @param activity Activity
408+
* @param perms Array of permissions
408409
* @return true if the user has previously denied any of the {@code perms} and we should show a
409410
* rationale, false otherwise.
410411
*/
411-
public static boolean shouldShowRationale(@NonNull Activity activity, @NonNull String[] perms) {
412-
boolean shouldShowRationale = false;
413-
for (String perm : perms) {
414-
shouldShowRationale =
415-
shouldShowRationale || shouldShowRequestPermissionRationale(activity, perm);
416-
}
417-
return shouldShowRationale;
412+
public static boolean somePermissionDenied(@NonNull Activity activity, @NonNull String[] perms) {
413+
return shouldShowRationale(activity, perms);
414+
}
415+
416+
/**
417+
* @param fragment Fragment
418+
* @param perms Array of permissions
419+
* @return true if the user has previously denied any of the {@code perms} and we should show a
420+
* rationale, false otherwise.
421+
*/
422+
public static boolean somePermissionDenied(@NonNull Fragment fragment, @NonNull String[] perms) {
423+
return shouldShowRationale(fragment, perms);
424+
}
425+
426+
/**
427+
* @param fragment Fragment
428+
* @param perms Array of permissions
429+
* @return true if the user has previously denied any of the {@code perms} and we should show a
430+
* rationale, false otherwise.
431+
*/
432+
@RequiresApi(api = Build.VERSION_CODES.M)
433+
public static boolean somePermissionDenied(@NonNull android.app.Fragment fragment, @NonNull String[] perms) {
434+
return shouldShowRationale(fragment, perms);
418435
}
419436

420437
private static boolean shouldShowRequestPermissionRationale(@NonNull Object object,

0 commit comments

Comments
 (0)