Skip to content

Adding permissions manager #34

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

Merged
merged 3 commits into from
Aug 13, 2020
Merged

Conversation

amaury901130
Copy link
Collaborator

Description

  • Adding permissions manager and util functions for permissions.

Screen Shot 2020-08-11 at 14 57 38

@amaury901130 amaury901130 linked an issue Aug 11, 2020 that may be closed by this pull request
Copy link
Contributor

@ximenaperez ximenaperez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

Copy link
Contributor

@mato2593 mato2593 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this idea of encapsulating permissions logic in one place, good job!

Comment on lines 25 to 26
permissionListener = listener
requestPermission(arrayOf(permission))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd call checkPermissions(arrayOf(permission), listener) to keep the logic in one place.

return
}

val permissionDenied = mutableListOf<String>()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd call this deniedPermissions.

}
}

val granted = permissionDenied.size == 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use isEmpty or something equivalent instead?

Comment on lines 57 to 62
for (s in permissionDenied) {
if (!ActivityCompat.shouldShowRequestPermissionRationale(this, s)) {
listener.foreverDenied()
return
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (s in permissionDenied) {
if (!ActivityCompat.shouldShowRequestPermissionRationale(this, s)) {
listener.foreverDenied()
return
}
}
for (deniedPermission in deniedPermission) {
if (!ActivityCompat.shouldShowRequestPermissionRationale(this, deniedPermission)) {
listener.foreverDenied()
return
}
}

Comment on lines 24 to 27
fun checkPermission(permission: String, listener: PermissionResponse) {
permissionListener = listener
requestPermission(arrayOf(permission))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here as in the activity.

return
}

val permissionDenied = mutableListOf<String>()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, deniedPermissions.

when {
granted -> listener.granted()
else -> {
for (s in permissionDenied) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, we should give the constant a more descriptive name than s. It should be called deniedPermission.

amaury901130 and others added 2 commits August 13, 2020 10:35
…ssionManager.kt

Co-authored-by: Mathías Cabano <cabanomathias@gmail.com>
@amaury901130 amaury901130 merged commit f6505b1 into master Aug 13, 2020
@CamilaMoscatelli CamilaMoscatelli deleted the feature/permission_manager branch November 17, 2020 21:03
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

Successfully merging this pull request may close these issues.

Permission Manager
3 participants