Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: inconsistent sample code for AfterPermissionGranted annotation #354

Open
freitzzz opened this issue Jan 2, 2023 · 0 comments
Open

Comments

@freitzzz
Copy link

freitzzz commented Jan 2, 2023

Basic Information

Device type: any
OS version: any
EasyPermissions version: 3.0.0

Describe the problem

The library sample code states that methods annotated with @AfterPermissionGranted for a specific request code are called when all requested permissions are granted, which can be confirmed in the library source code. However, in the README sample code, there is a check if the requested permissions have been granted, which is completely confusing and should be considered dead code.

Code and logs

README Sample Code

@AfterPermissionGranted(RC_CAMERA_AND_LOCATION)
private void methodRequiresTwoPermission() {
    String[] perms = {Manifest.permission.CAMERA, Manifest.permission.ACCESS_FINE_LOCATION};
    if (EasyPermissions.hasPermissions(this, perms)) {
        // Already have permission, do the thing
        // ...
    } else {
        // Do not have permissions, request them now
        EasyPermissions.requestPermissions(this, getString(R.string.camera_and_location_rationale),
                RC_CAMERA_AND_LOCATION, perms);
    }
}

Library permissions grant check to call annotated methods

if (!granted.isEmpty() && denied.isEmpty()) {
runAnnotatedMethods(object, requestCode);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant