-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add new builder API and support customizing rationale dialog theme #180
Conversation
Signed-off-by: Alex Saveau <[email protected]>
@SUPERCILEX this is a nice API but I am wary of making a breaking change for this (relatively) minor feature request of theme changing. The API right now is simple and has a lot of users. Is there anything else you think we'd add to the API in the future if it was |
@samtstern Nope, I can't think of anything. However, here's my reasoning:
@samtstern Maybe I've changed your mind? 😄 If not, we need to decide which overloads to add. |
Ok I agree with you completely, I hate all the overloads and they're not scalable. So maybe let's take a middle-road approach:
|
@samtstern I like it, that's a perfect compromise! 😄 |
Signed-off-by: Alex Saveau <[email protected]>
Signed-off-by: Alex Saveau <[email protected]>
import pub.devrel.easypermissions.helper.PermissionHelper; | ||
|
||
/** | ||
* An immutable model representing a permission request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we can probably say something more descriptive here like "A model object that holds all of the parameters associate with a permission request, such as the request code or the rationale"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Signed-off-by: Alex Saveau <[email protected]>
} else { | ||
if (host instanceof AppCompatActivity) | ||
//noinspection unchecked Hmmm... not sure what's going on here | ||
return (PermissionHelper<Activity>) (Object) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's up with the double cast? (PermissionHelper<Activity>) (Object)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Figured it out.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { | ||
return new LowApiPermissionsHelper(host); | ||
return new LowApiPermissionsHelper<>(host); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surprised to see the <>
here, do we get a warning without that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I added a type T
to the helper.
Signed-off-by: Alex Saveau <[email protected]>
@SUPERCILEX awesome! I think all that's left is the |
Signed-off-by: Alex Saveau <[email protected]>
Sweet! (Thanks for reminding me, I'd forgotten 😄) |
README.md
Outdated
@@ -66,6 +66,14 @@ private void methodRequiresTwoPermission() { | |||
// Do not have permissions, request them now | |||
EasyPermissions.requestPermissions(this, getString(R.string.camera_and_location_rationale), | |||
RC_CAMERA_AND_LOCATION, perms); | |||
// OR for finer control over the rationale dialog |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last comment:
Developers tend to copy-and-paste so I'd avoid putting both of these in the same snippet as developers will end up with double requests.
I'd say:
// old snippet here
Or for finer control over the rationale dialog, use PermissionRequest
:
// new snippet here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Raises hand. Haha, yeah, I've done that too. It should be fixed now.
Signed-off-by: Alex Saveau <[email protected]>
#174
@samtstern What do you think of this PR? I'm using our new builder style to add the theme option. If you think the idea is good, I'll add documentation and all that good stuff and prep this PR for merging.