checkWriteStoragePermissions

fun checkWriteStoragePermissions(view: View, onPermissionDenied: () -> Unit = { }, onPermissionGranted: () -> Unit)

Checks is Manifest.permission.WRITE_EXTERNAL_STORAGE is needed an requests if necessary. Permission will be requested on versions below Build.VERSION_CODES.Q or if legacy external storage is enabled. Simply runs onPermissionGranted if the permission is not needed.

The method is being used to get access to external download folder used by download attachment process.

Parameters

view

The view used to obtain context and show the snackbar.

onPermissionDenied

Lambda to be run when permission is denied.

onPermissionGranted

Lambda to be run when permission is granted.