QuickPermissions / QuickPermissions-Kotlin

The most easiest way to handle Android Runtime Permissions in Kotlin
Apache License 2.0
313 stars 35 forks source link

Callback is called if you call runWithPremissions twice #5

Closed mariciv closed 5 years ago

mariciv commented 5 years ago

Hi there. I ran into an issue.

After revoking the permission from app settings screen I can't get to the system permission dialog anymore. The lib automatically calls callback function even though permission is not allowed.

Here is the code:

runWithPermissions(permission,
                        options = QuickPermissionsOptions(
                            handlePermanentlyDenied = true,
                            handleRationale = true,
                            permanentDeniedMethod = { denyFunction.invoke() },
                            permissionsDeniedMethod = { denyFunction.invoke() },
                            rationaleMethod = {
                                // We call this since on permission denied is not called
                                denyFunction.invoke()
                            }),
                        callback = { Timber.d("Permission callback") })
mariciv commented 5 years ago

One extra information. I found a bug in my logic which caused this issue. runWithPermissions method from my previous comment was called twice in a row. The end behaviour was that I would get the system permission dialog but at the same time the callback function would execute.

kirtan403 commented 5 years ago

Hi @mariciv . So your issue is resolved now? Or you are still facing some unexpected behavior?

mariciv commented 5 years ago

@kirtan403 I was able to resolve my issue, but I think library could handle this case a bit better. So if runWithPermissions method is called twice, before user denies or allows permission in the system dialog, action callback shouldn't be called.

I've edited the title so it better reflects the real issue.

kirtan403 commented 5 years ago

Thanks, @mariciv . Actually it works on the singleton objects for the requests and response. That's why that happened. I'll add this to the enhancement. Thanks for making things clear 😄

kirtan403 commented 5 years ago

Fixed (Ref: 62f54a41)

kirtan403 commented 5 years ago

New version released with fix: https://github.com/QuickPermissions/QuickPermissions-Kotlin/releases/tag/0.4.0