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

@OnPermissionDenied and @OnNeverAskAgain not working properly #57

Closed
sibelius opened this issue Dec 9, 2015 · 8 comments
Closed

@OnPermissionDenied and @OnNeverAskAgain not working properly #57

sibelius opened this issue Dec 9, 2015 · 8 comments

Comments

@sibelius
Copy link
Contributor

sibelius commented Dec 9, 2015

When I try to use @OnPermisionDenied like this:

@OnPermissionDenied({
            Manifest.permission.READ_PHONE_STATE,
            Manifest.permission.READ_EXTERNAL_STORAGE,
            Manifest.permission.WRITE_EXTERNAL_STORAGE,
            Manifest.permission.ACCESS_FINE_LOCATION,
            Manifest.permission.RECORD_AUDIO})
public void showDeniedMessage() {}

It doesn't generate the correct code, and not even reference my method from PermissionDispatcher.
The behavior that I expected is to call showDeniedMessage for any of these permissions.

The same happens for @OnNeverAskAgain

I will try to work on this tomorrow

@hotchemi
Copy link
Member

No, specification of the library is not such.
@OnPermissionDenied is called when request of @NeedsPermission which has same string array as arguments is denied.

@mannodermaus
Copy link
Contributor

Yeah, as @hotchemi said, your example would trigger these callbacks for a permission request that asks for ALL of these permissions at once. It would be ambiguous to the code generator if it were an "any-of" relationship, since there would be cases where it didn't know which callback to connect to the @NeedsPermission call.

@sibelius
Copy link
Contributor Author

We can have another annotation for this case or another parameter that will determine the behavior of the code generator

@hotchemi
Copy link
Member

@sibeliusseraphini We have no plan to do that. Why do you need it?

@sibelius
Copy link
Contributor Author

My use case is this:

My app will only work if the user enable all 3 permissions that my app needs.
When the permission is denied the app will show the same message to the user explaining the these permissions are really required, and when user type check never ask again the app will ask the user to go to the Settings to enable the permissions for the app

We could have a default method for OnPermissionDenied and NeverAskAgain

This will reduce some boilerplate code

@hotchemi thanks for this great library, I think we should have more annotated library like this to reduce boilerplate code in android and java in general

@mannodermaus
Copy link
Contributor

In this case, why don't you specify a @NeedsPermission method that requires all of the permissions you need, and then mirror this signature in your catch-all @OnPermissionDenied and @OnNeverAskAgain callbacks? This way, you can check for all permissions at the same time, and fall back to a single callback in case of denial.

@sibelius
Copy link
Contributor Author

@aurae thank, I will try that

@ubarua123
Copy link

I had a small doubt regarding chaining permissions. I have a method with @NeedsPermission with multiple permissions and another method with @OnPermissionDenied with the same signature of permissions. Question is, how will I know which ones got denied, which ones got accepted?

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

4 participants