-
Notifications
You must be signed in to change notification settings - Fork 1.5k
add autoRequestPermission() API #216
Conversation
...mission we need to request permission,so this API will easy to use.
googlebot
commented
May 11, 2018
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
📝 Please visit https://cla.developers.google.com/ to sign.
Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.
What to do if you already signed the CLA
Individual signers
- It's possible we don't have your GitHub username or you're using a different email address on your commit. Check your existing CLA data and verify that your email is set on your git commits.
Corporate signers
- Your company has a Point of Contact who decides which employees are authorized to participate. Ask your POC to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the Google project maintainer to go/cla#troubleshoot (Public version).
- The email used to register you as an authorized contributor must be the email used for the Git commit. Check your existing CLA data and verify that your email is set on your git commits.
- The email used to register you as an authorized contributor must also be attached to your GitHub account.
I signed it!
googlebot
commented
May 11, 2018
CLAs look good, thanks!
This actually already exists! The request perms method takes a callback that will be notified immediately if the permission has already been granted.
@AfterPermissionGranted(RC_LOCATION_CONTACTS_PERM) public void locationAndContactsTask() { if (hasLocationAndContactsPermissions()) { // Have permissions, do the thing! Toast.makeText(this, "TODO: Location and Contacts things", Toast.LENGTH_LONG).show(); } else { // Ask for both permissions EasyPermissions.requestPermissions( this, getString(R.string.rationale_location_contacts), RC_LOCATION_CONTACTS_PERM, LOCATION_AND_CONTACTS); } }
In sample , we should use the API like that . I think that requesting permission when there is no permission is a very common situation,so ,if there is a API can do this make user avoid from the inconvenient if else is more easy to used.
@LeonChen1024 thank you for sending this pull request. In my opinion I don't believe the if/else form is inconvenient enough to make us add something like autoRequest. In the future please open an issue before sending a PR for a new feature so that we can discuss it and save you time!
Thanks again for sending such a well-formed PR though! Hope you understand the decision.
Thanks , I think i understand that , Sorry for wasting your time and never happen this mistake again.
@LeonChen1024 Don't worry about it! 😊 BTW, here's what I meant when I said this already existed:
public void start() { // This will call the annotation processor immediately if the permissions are granted, else request them EasyPermissions.requestPermissions( this, getString(R.string.rationale_location_contacts), RC_LOCATION_CONTACTS_PERM, LOCATION_AND_CONTACTS); } @AfterPermissionGranted(RC_LOCATION_CONTACTS_PERM) public void locationAndContactsTask() { Toast.makeText(this, "TODO: Location and Contacts things", Toast.LENGTH_LONG).show(); }
@LeonChen1024 definitely not a waste of our time! It was an interesting proposal
as usually if app don't have permission we need to request permission,so this API will easy to use.