|
40 | 40 | */ |
41 | 41 | public class EasyPermissions { |
42 | 42 |
|
| 43 | + /** |
| 44 | + * Callback interface to receive the results of {@code EasyPermissions.requestPermissions()} |
| 45 | + * calls. |
| 46 | + */ |
43 | 47 | public interface PermissionCallbacks extends ActivityCompat.OnRequestPermissionsResultCallback { |
44 | 48 |
|
45 | 49 | void onPermissionsGranted(int requestCode, List<String> perms); |
@@ -434,6 +438,12 @@ public static boolean somePermissionDenied(@NonNull android.app.Fragment fragmen |
434 | 438 | return shouldShowRationale(fragment, perms); |
435 | 439 | } |
436 | 440 |
|
| 441 | + /** |
| 442 | + * Determine if rationale should be shown before asking for the given permission. |
| 443 | + * @param object the Fragment or Activity. |
| 444 | + * @param perm the permission. |
| 445 | + * @return {@code true} if rationale should be shown, {@code false} otherwise. |
| 446 | + */ |
437 | 447 | private static boolean shouldShowRequestPermissionRationale(@NonNull Object object, |
438 | 448 | @NonNull String perm) { |
439 | 449 | if (object instanceof Activity) { |
@@ -467,6 +477,12 @@ private static void showRationaleDialogFragment(@NonNull android.app.FragmentMan |
467 | 477 | .show(fragmentManager, DIALOG_TAG); |
468 | 478 | } |
469 | 479 |
|
| 480 | + /** |
| 481 | + * Find all methods annotated with {@link AfterPermissionGranted} on a given object with the |
| 482 | + * correc requestCode argument. |
| 483 | + * @param object the object with annotated methods. |
| 484 | + * @param requestCode the requestCode passed to the annotation. |
| 485 | + */ |
470 | 486 | private static void runAnnotatedMethods(@NonNull Object object, int requestCode) { |
471 | 487 | Class clazz = object.getClass(); |
472 | 488 | if (isUsingAndroidAnnotations(object)) { |
@@ -504,6 +520,9 @@ private static void runAnnotatedMethods(@NonNull Object object, int requestCode) |
504 | 520 | } |
505 | 521 | } |
506 | 522 |
|
| 523 | + /** |
| 524 | + * Determine if the project is using the AndroidAnnoations library. |
| 525 | + */ |
507 | 526 | private static boolean isUsingAndroidAnnotations(@NonNull Object object) { |
508 | 527 | if (!object.getClass().getSimpleName().endsWith("_")) { |
509 | 528 | return false; |
|
0 commit comments