Popularity
0.7
Stable
Activity
0.0
Stable
7
2
1

Description

Android Library for easy permission management using Coroutines

Programming language: Kotlin
Tags: Kotlin     Permission     Coroutines    
Latest version: v1.1.0

CoroutinesPermission alternatives and similar packages

Based on the "Kotlin" category.
Alternatively, view CoroutinesPermission alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of CoroutinesPermission or a related project?

Add another 'Kotlin' Package

README

CoroutinesPermission

Android library Android Library for easy permission management

Install

Gradle

  1. Add the JitPack repository to your project level build.gradle file
allprojects {
    repositories {
            ...
        maven { url 'https://jitpack.io' }
    }
}
  1. Add the dependency to your app level build.gradle file
implementation 'com.github.wooooooak:CoroutinesPermission:version'

Since this library uses coroutine, it is recommended to add the [following library](<https://developer.android.com/topic/libraries/architecture/coroutines>) for convenience.

implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0"

The latest version is 1.0.2. Checkout here

Usage

We will use kotlin DSL for request permission.

yourCoroutineScope.launch {
    val result = CoroutinesPermissionManager.requestPermission(activity) {
        permissionList = listOf(Manifest.permission.CAMERA, or something..)
        Rationale {
            title = "Alert"
            message = "In order to use the app, camera permission is required."
        }
                            ...
    }
    when (result) {
        is PermissionResult.Granted -> {}
        is PermissionResult.Denied -> {}
    }
}

You can set the following items.

  • permissionLIst (required) : List of permission to acquire.

  • rationaleTitle (option) : Title for Rationale dialog.

  • rationaleMessage (option) : Message for Rationale dialog.

  • rationaleConfirmText (option) : Confirm button Text for Rationale dialog.

  • rationaleCancelText (option) : Cancel button Text for Rationale dialog.

Rationale example

Result

Result is an Sealed Class.

sealed class PermissionResult {

    object Granted : PermissionResult()

    class Denied(
        val deniedList: List,
        val permanentlyDeniedList: List
    ) : PermissionResult()

    override fun toString(): String {
        return when (this) {
            is Granted -> "All Permission granted"
            is Denied -> "Some Permission denied : \ndenied - $deniedList, \npermanentlyDeniedList-$permanentlyDeniedList"
        }
    }
}

Therefore, if the permission acquisition fails, it is possible to know which permission was not obtained and which permission was permanently denied.

License

Copyright 2020 wooooooak

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.


*Note that all licence references and agreements mentioned in the CoroutinesPermission README section above are relevant to that project's source code only.