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 a986af5
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,21 @@ class PermissionItem(context: Context, attrs: AttributeSet) : FrameLayout(contex
}
}
}

setOnClickListener {
if (!isGranted) {
Timber.i("Permission item clicked, requesting permission")
listener?.invoke()
} else {
switch.isChecked = !switch.isChecked
}
}

updateSwitchCheckedStatus()
}

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

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

0 comments on commit a986af5

Please sign in to comment.