Overview
Permissions Dialog is DialogFragment (non-fullscreen popup window) with buttons for request permissions and show granted status for them.
To start dialog from your activity or fragment use the code below:
Copy private var permsFragment: PermissionsDialogFragment ? = null
override fun onCreate (savedInstanceState: Bundle ?) {
super . onCreate (savedInstanceState)
permsFragment = PermissionsDialogFragment. newInstants (dismissIfAllGranted =
false )
permsFragment?. setPermissionsGrantedListener ( object :
PermissionsDialogFragment. PermissionsGrantedListener {
override fun onGrantedStatus (allPermsGranted: Boolean ) {
if (allPermsGranted) enableSDK () // enabled SDK if not enabled
}
})
}
private fun showPermissionsDialog () {
permsFragment?. let {
if (!permsFragment!!.isVisible) permsFragment?.show(supportFragmentManager, PermissionsDialogFragment.PERMISSION_FRAGMENT_TAG)
}
}
Where dismissIfAllGranted flag you set to true and dialog will be dismissed (closed) automatically when all permissions are granted. If flag is false dialog will not be disappeared when all permissions granted, user can do it by himself.
Customizing
Colors
values\colors.xml
Copy <!-- Permission Dialog Fragment -->
<color name="colorTelematicsDialogBackground">#fff</color>
<color name="colorTelematicsDialogPrimaryText">#494949</color>
<color name="colorTelematicsDialogSecondaryText">#80464646</color>
<color name="colorTelematicsDialogButtonText">#494949</color>
<color name="colorTelematicsDialogButtonNorm">#fff</color>
<color name="colorTelematicsDialogButtonPressed">#80464646</color>
Dimens
values\dimens.xml
values-xhdpi\dimens.xml
values-xxhdpi\dimens.xml
Copy <!-- Overrided DialogFragment SDK resources -->
<dimen name="dialog_telematics_view_bubble_corners">20dp</dimen>
<dimen name="dialog_telematics_button_corners">35dp</dimen>
Copy <!-- Overrided Wizard SDK resources -->
<dimen name="wizard_telematics_button_corners">5dp</dimen>
Drawables
values/drawable-xxxhdpi
Granted permission image:
Location permission image:
Physical activity permission image:
Background optimization permission screen: