To get a Git project into your build:
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.stonybean:sbpermission:1.0.3'
}
// Start checkPermission
val permissionBuilder = PermissionBuilder(context)
permissionBuilder.checkPermissions()
val permissionBuilder = PermissionBuilder(context)
// Add Listener
val permissionListener = object : PermissionListener {
override fun onPermissionGranted(grantedPermissions: ArrayList<String>) {
// Do somthing..
for (grantedPermission in grantedPermissions) {
if (grantedPermission == Manifest.permission.CAMERA) {
// do something..
}
...
}
}
override fun onPermissionDenied(deniedPermissions: ArrayList<String>) {
// Do somthing..
for (deniedPermission in deniedPermissions) {
if (deniedPermission == Manifest.permission.CAMERA) {
// do something..
}
...
}
}
}
// Start checkPemission with options
permissionBuilder.setWindowPermission(true)
.setWindowDialogMessage("message..")
.setDeniedDialog(true)
.setDeniedDialogMessage(R.string.deniedDialogMessage)
.setPermissions(
Manifest.permission.CAMERA,
Manifest.permission.CALL_PHONE,
Manifest.permission.READ_CONTACTS
)
.setPermissionListener("MyListener", permissionListener)
.checkPermissions()
setWindowPermission(Boolean)
: Set up a overlay permission
setWindowDialogMessage(String or R.string.xxx)
(default getString(R.string.windowDialogMessage))
: Set up a dialog message when setting up overlay permission
setDeniedDialog(Boolean)
: Show dialog when rejecting to set up a permission
setDeniedDialogMessage(String or R.string.xxx)
(default getString(R.string.deniedDialogMessage))
: Set up a dialog message when rejecting to set up a permission
setPermissions(vararg String)
(If you do not add permissions, it will be added default all dangerous permissions automatically.)
: Add permission list you need
setPermissionListener(String, PermissionListener)
: Set permission listener
checkPermissions
: Start checkPermissions