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

Commit 4ae46a8

Browse files
authored
Merge pull request #92 from lucmousinho/master
New public method to verify if we should show the rationale dialog
2 parents dd4bc88 + 7c0b7b5 commit 4ae46a8

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

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

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

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

0 commit comments

Comments
 (0)