Skip to content

Commit

Permalink
make permission item fully touchable
Browse files Browse the repository at this point in the history
  • Loading branch information
gayatriii0803 committed Jun 3, 2024
1 parent 1928dd0 commit ec7b282
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,18 @@ class PermissionItem(context: Context, attrs: AttributeSet) : FrameLayout(contex
}
}
}

setOnClickListener {
if (!isGranted) {
listener?.invoke()
} else {
switch.isChecked = !switch.isChecked
}
}
}

private var listener: (() -> Unit)? = null

/**
* Checks the switch if the permission is granted,
* or uncheck if not
Expand All @@ -97,6 +107,7 @@ class PermissionItem(context: Context, attrs: AttributeSet) : FrameLayout(contex
* The listener isn't invoked if the permission is already granted
* */
fun setOnSwitchClickListener(listener: () -> Unit) {
this.listener = listener
switch.setOnClickListener {
if (!isGranted) {
Timber.i("permission switch pressed")
Expand Down

0 comments on commit ec7b282

Please sign in to comment.