Skip to content

🎯 An easy way to implement modern permission instructions popup.

License

Notifications You must be signed in to change notification settings

hamidfathi1998/Digi-Permission

Repository files navigation

Digi Permission- An easy way to implement modern permission instructions popup.

platform API

Digi Permission is an extension Android library, easy way to implement modern permission instructions popup.You can use it for basic permission request occasions or handle more complex conditions

💥 Setup

Add these to your build.gradle file

repositories {
  google()
  mavenCentral()
}
dependencies {
    implementation 'com.github.hamidfathi1998:Digi-Permission:@VERSION'
}

⚡ Usage

Use Digi-Permission to request Android runtime permissions is extremely simple.

For example. If you want to request ACCESS_FINE_LOCATION, BLUETOOTH, BLUETOOTH_ADMIN and INTERNET permissions, declared them in the AndroidManifest.xml first.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.permissionx.app">

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.INTERNET" />

</manifest>

Then you can use below codes to request.

DigiPermission.initialize(this)
    .addPermissions(ACCESS_FINE_LOCATION, BLUETOOTH, BLUETOOTH_ADMIN)
    .permissionResult { allGranted, grantedList, deniedList ->
        if (allGranted) {
            Toast.makeText(
                this,
                "Permissions Are Granted \n$grantedList",
                Toast.LENGTH_LONG
            ).show()
        } else {
            Toast.makeText(
                this,
                "Permissions Are Denied: \n$deniedList",
                Toast.LENGTH_LONG
            ).show()
        }
    }

Pass any instance of FragmentActivity or Fragment into init method, and specify the permissions that you want to request in the permissions method, then call request method for actual request. The request result will be callback in the request lambda. allGranted means if all permissions that you requested are granted by user, maybe true or false. grantedList holds all granted permissions and deniedList holds all denied permissions.

If this project helps you in anyway, show your love ❤️ by putting a ⭐ on this project ✌️

Contributing

Please fork this repository and contribute back using pull requests.

Any contributions, large or small, major features, bug fixes, are welcomed and appreciated but will be thoroughly reviewed .

- Contact - Let's become friend