kpermissions icon indicating copy to clipboard operation
kpermissions copied to clipboard

onNeverAskAgain gets called when touch outside of permission dialog

Open TurKurT656 opened this issue 4 years ago • 2 comments

Description

When the permission dialog pops up, if user touches outside of the permission dialog, it.anyPermanentlyDenied() returns true while user didn't pressed Don't ask again checkbox/


KPermissions version: 3.2.1

API level: 30

How to reproduce it:

  • Ask for a permission with permission.send()
  • After the dialog pops up, touch outside of the dialog's area

Sample code:

val p = permissionsBuilder(Manifest.permission.CAMERA)
            .build()
            .apply {
                addListener {
                    when {
                        it.allGranted() -> {
                            Logger.d("askForPermission::onPermissionAccepted")
                            onPermissionAccepted()
                        }
                        it.anyShouldShowRationale() -> {
                            Logger.d("askForPermission::onShowRationale")
                            onShowRationale?.invoke()
                        }
                        it.anyPermanentlyDenied() -> {
                            Logger.d("askForPermission::onNeverAskAgain")
                            onNeverAskAgain?.invoke()
                        }
                        it.anyDenied() -> {
                            Logger.d("askForPermission::onPermissionDenied")
                            onPermissionDenied?.invoke()
                        }
                    }
                }
            }
p.send()

TurKurT656 avatar Sep 03 '21 15:09 TurKurT656

Thanks for submitting this issue. I'll investigate this and get back to you!

fondesa avatar Sep 03 '21 15:09 fondesa

I still have not found any way to detect if the user denied the permissions permanently or clicked outside the dialog.

In both cases, shouldShowPermissionsRationale is false and the permissions are denied.

I'll continue to search for a solution, if anyone have an idea on how to identify those two events separately, it would be helpful.

fondesa avatar Sep 06 '21 15:09 fondesa

@TurKurT656 In my opinion, I don't think this issue as a bug in this library.

The permission dialog is shown to the user by the Android OS. And this library or our code cannot manipulate it. So if the user is clicking outside the dialog & closing the dialog -> then its Android OS' behaviour.

@fondesa You may close this issue. 👍🏼 Btw, very good library!! ❤️ ❤️ ❤️

RahulSDeshpande avatar Aug 15 '23 17:08 RahulSDeshpande

Closing this since as @RahulSDeshpande explained, this is the Android OS' behaviour, so it's probably better to not perform any workaround to enable this.

fondesa avatar Oct 15 '23 21:10 fondesa