CoroutinesPermission - Android Library for easy permission management using Coroutines

Overview

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'

The latest version is 1.0.2. Checkout here

Since this library uses coroutine, it is recommended to add the following library for convenience.

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

check version 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.
You might also like...
🍭 GithubSearchKMM - Github Repos Search - Android - iOS - Kotlin Multiplatform Mobile using Jetpack Compose, SwiftUI, FlowRedux, Coroutines Flow, Dagger Hilt, Koin Dependency Injection, shared KMP ViewModel, Clean Architecture
🍭 GithubSearchKMM - Github Repos Search - Android - iOS - Kotlin Multiplatform Mobile using Jetpack Compose, SwiftUI, FlowRedux, Coroutines Flow, Dagger Hilt, Koin Dependency Injection, shared KMP ViewModel, Clean Architecture

GithubSearchKMM Github Repos Search - Kotlin Multiplatform Mobile using Jetpack Compose, SwiftUI, FlowRedux, Coroutines Flow, Dagger Hilt, Koin Depend

Boilerplate code for implementing MVVM in Android using Jetpack libraries, coroutines, dependency injection and local persistance

MVVM Foundation This projects aims to speed up development of Android apps by providing a solid base to extend Libraries Jetpack Fragment Material3 :

An tool to help developer to use Retrofit elegantly while using kotlinx.coroutines.

one An tool to help developer to use Retrofit elegantly while using kotlinx.coroutines. Feature Transform different data structs to one. {errorCode, d

FaceTimeClone app that implements Coroutines , mvvm architecture , clean architecture , navigation component , hilt , etc.... using kotlin language
FaceTimeClone app that implements Coroutines , mvvm architecture , clean architecture , navigation component , hilt , etc.... using kotlin language

This repository contains a FaceTimeClone app that implements Coroutines , mvvm architecture , clean architecture , navigation component , hilt , etc.... using kotlin language

Architecture With MVI using Kotlin, Coroutines, Retrofit and Unit test
Architecture With MVI using Kotlin, Coroutines, Retrofit and Unit test

Architecture With MVI using Kotlin, Coroutines, Retrofit and Unit test MVI (Model-View-Intent) streamlines the process of creating and developing appl

A Clean Architecture App that uses clean Architecture (app, presentation, domain, data) packages to use coffee items API using MVVM Architecture, Coroutines, Retrofit2, Pagination, Live Data, Data Binding, Hilt , SOLID Principles , Navigation Component , RoomDb. Easy lightweight SharedPreferences library for Android in Kotlin using delegated properties
Easy lightweight SharedPreferences library for Android in Kotlin using delegated properties

Easy lightweight SharedPreferences library for Android in Kotlin using delegated properties Idea Delegated properties in Kotlin allow you to execute a

A Kotlin Android library for content provider queries with reactive streams and coroutines.

Pickpocket An Android library for content provider queries with reactive streams and coroutines. Calendar Contacts SMS MMS Files/Media Call Log Bookma

Android Library for requesting Permissions with Kotlin Coroutines or AndroidX LiveData

PEKO PErmissions with KOtlin Android Permissions with Kotlin Coroutines or LiveData No more callbacks, builders, listeners or verbose code for request

Releases(1.1.0)
Owner
LEE YONGJUN
💎 Android Developer
LEE YONGJUN
Recycler-coroutines - RecyclerView Auto Add Data Using Coroutines

Sample RecyclerView Auto Add With Coroutine Colaborator Very open to anyone, I'l

Faisal Amir 8 Dec 1, 2022
Permissionmanager is a small wrapper for handling permission requests.

Permissionmanager Permissionmanager is a small wrapper for handling permission requests. Installation Add jitpack to your repositories in Project buil

Thomas Cirksena 11 Nov 17, 2020
A simple, classic Kotlin MVI implementation based on coroutines with Android support, clean DSL and easy to understand logic

A simple, classic Kotlin MVI implementation based on coroutines with Android support, clean DSL and easy to understand logic

Nek.12 4 Oct 31, 2022
A local storage management library for Kotlin Multiplatform Mobile iOS and android

A local storage management library for Kotlin Multiplatform Mobile iOS and android Features iOS and Android local storage in one interface Provides ge

LINE 20 Oct 30, 2022
A tiny Kotlin multiplatform library that assists in saving and restoring objects to and from disk using kotlinx.coroutines, kotlinx.serialisation and okio

Store A tiny Kotlin multiplatform library that assists in saving and restoring objects to and from disk using kotlinx.coroutines, kotlinx.serialisatio

Isuru Rajapakse 98 Jan 3, 2023
Gestor is an innovative open-source application for universal Minecraft mod management.

Gestor Gestor is an innovative open-source application for universal Minecraft mod management. About It combines three types of tools into a single ap

GestorMC 11 Dec 9, 2021
Solid - A CLI that tries to cover a dry-run phase for liquibase database change management

solid a CLI that tries to cover a dry-run phase for liquibase database change ma

Giovanni Panice (mos_) 1 Jan 28, 2022
How to structure a growing Gradle project with smart dependency management?

How to set up a larger Gradle project This repo shows one possibility to structure a Gradle project when you want: Centralized and maintainable build

Jendrik Johannes 59 Jan 6, 2023
A kotlin multiplatform BLS12-381 implementation for chia key management

KBLS KBLS is a kotlin multiplatform BLS12-381 implementation built for creating cross platform chia applications. Tips are much appreciated and will d

ChiaChat 7 Nov 21, 2022
Example Multi module architecture Android project using MVVM, Dynamic Features, Dagger-Hilt, Coroutines and Navigation Components

ModularDynamicFeatureHilt An Android template project following a multi module approach with clean architecture. It has been built following Clean Arc

Mbuodile Obiosio 25 Nov 23, 2022