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

Commit bb23a02

Browse files
committed
New public method to verify if we should show the rationale dialog
1 parent dd4bc88 commit bb23a02

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,20 @@ private static boolean shouldShowRationale(@NonNull Object object, @NonNull Stri
403403
return shouldShowRationale;
404404
}
405405

406+
/**
407+
* @param activity Activity
408+
* @return true if the user has previously denied any of the {@code perms} and we should show a
409+
* rationale, false otherwise.
410+
*/
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;
418+
}
419+
406420
private static boolean shouldShowRequestPermissionRationale(@NonNull Object object,
407421
@NonNull String perm) {
408422
if (object instanceof Activity) {

0 commit comments

Comments
 (0)