permissions-dispatcher / PermissionsDispatcher

A declarative API to handle Android runtime permissions.
https://github.com/permissions-dispatcher/PermissionsDispatcher
Apache License 2.0
11.21k stars 1.44k forks source link

Hope the anonymous function 'Func' in TypeAliasesKt can add params #671

Closed Gslullaby closed 4 years ago

Gslullaby commented 4 years ago

We may need permissions that be denied by user to do some extra work. So, I hope the PermissionsRequestFragment's field 'onNeverAskAgain' and 'onPermissionDenied' can return the denied permissions back.

Related Code:

internal typealias Func = () -> Unit    

override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults)
        if (requestCode == this.requestCode) {
            if (verifyPermissions(*grantResults)) {
                requiresPermission?.invoke()
            } else {
                if (!PermissionUtils.shouldShowRequestPermissionRationale(this, *permissions)) {
                    onNeverAskAgain?.invoke()
                } else {
                    onPermissionDenied?.invoke()
                }
            }
        }
        dismiss()
    }
hotchemi commented 4 years ago

in my understanding you can easily detect which permission is denied because you explicitly set to a certainwithPermissionsCheck as an argument right?

Gslullaby commented 4 years ago

@hotchemi Yes, but i think we can get denied permissions while verifyPermissions called, then return it by onNeverAskAgain or onPermissionDenied. May be more reasonable and convenient

hotchemi commented 4 years ago

@LiPengW Could you elaborate why it's reasonable and convenient if you're seriously proposing the idea? we have not provided the hint even in stable version and we have not got such kind of feedback so. https://github.com/permissions-dispatcher/PermissionsDispatcher#1-attach-annotations

Gslullaby commented 4 years ago

@hotchemi From my (a ktx lib user) point of view. It is lib's responsablity to tell me Which permissons i applied has be denied, rather than verify by myself. If you don't think so ,i just close it

hotchemi commented 4 years ago

Thank you and sorry for the late. After glancing overall your proposal might make sense and let try to come up with a new API interface later on with taking it into account!

Gslullaby commented 4 years ago

@hotchemi thx