All Projects → k-kagurazaka → async-permissions

k-kagurazaka / async-permissions

Licence: MIT license
Easy handling for Android-M permission based on async/await

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to async-permissions

Lock Laravel
This package is a Laravel 5 driver for Lock
Stars: ✭ 161 (+544%)
Mutual labels:  permissions
Adonis Acl
demo app: https://github.com/enniel/adonis-acl-blog-demo
Stars: ✭ 195 (+680%)
Mutual labels:  permissions
Graphql Shield
🛡 A GraphQL tool to ease the creation of permission layer.
Stars: ✭ 3,121 (+12384%)
Mutual labels:  permissions
Rxpermission
Reactive permissions for Android
Stars: ✭ 182 (+628%)
Mutual labels:  permissions
Sanic Jwt
Authentication, JWT, and permission scoping for Sanic
Stars: ✭ 189 (+656%)
Mutual labels:  permissions
Appy
🚀 A full stack boilerplate web app
Stars: ✭ 225 (+800%)
Mutual labels:  permissions
React Permissible
👮‍♂️Making the permission management for React components easier.
Stars: ✭ 145 (+480%)
Mutual labels:  permissions
awaitwhat
Await, What?
Stars: ✭ 48 (+92%)
Mutual labels:  async-await
Easypermission
一个非常轻便而且可用的Android动态权限申请库
Stars: ✭ 192 (+668%)
Mutual labels:  permissions
Spring Boot Start Current
Spring Boot 脚手架 Mybatis Spring Security JWT 权限 Spring Cache + Redis
Stars: ✭ 246 (+884%)
Mutual labels:  permissions
Keycloak Nodejs Example
A simply step by step Keycloak, MySQL and Node.js integration tutorial. There are some docker examples as well.
Stars: ✭ 183 (+632%)
Mutual labels:  permissions
Voice Overlay Android
🗣 An overlay that gets your user’s voice permission and input as text in a customizable UI
Stars: ✭ 189 (+656%)
Mutual labels:  permissions
Vue Router User Roles
A Vue.js plugin that protects routes based on user roles. Add your own authentication.
Stars: ✭ 237 (+848%)
Mutual labels:  permissions
Xxpermissions
Android 权限请求框架,已适配 Android 12
Stars: ✭ 2,971 (+11784%)
Mutual labels:  permissions
Kpermissions
A Kotlin library which helps to request runtime permissions in Android.
Stars: ✭ 253 (+912%)
Mutual labels:  permissions
Think Authz
An authorization library that supports access control models like ACL, RBAC, ABAC in ThinkPHP 6.0 .
Stars: ✭ 155 (+520%)
Mutual labels:  permissions
Drf Access Policy
Declarative access policies/permissions modeled after AWS' IAM policies.
Stars: ✭ 200 (+700%)
Mutual labels:  permissions
pyfuseki
A library that uses Python to connect and manipulate Jena Fuseki, which provides sync and async methods.
Stars: ✭ 22 (-12%)
Mutual labels:  async-await
Rbac
Hierarchical Role-Based Access Control for Node.js
Stars: ✭ 254 (+916%)
Mutual labels:  permissions
Bouncer
Eloquent roles and abilities.
Stars: ✭ 2,763 (+10952%)
Mutual labels:  permissions

AsyncPermissions

Easy handling for Android-M permission based on async/await

Download

repositories {
    maven { url "https://jitpack.io" }
}

dependencies {
    compile 'com.github.k-kagurazaka:async-permissions:0.0.2-alpha'
}

Usage

Create AsyncPermissions instance and request permission(s) in the UI coroutine scope.

// in Activity

override fun onCreate() {
    ...
    val permissions = AsyncPermissions(this)
    // Kick a new coroutine since AsyncPermissions.request is a suspending function
    launch (UI) {
        permissions.request(Manifest.permission.CAMERA)
                .let { handlePermissionResult(it) }
    }
}

suspend fun handlePermissionResult(result: PermissionResult) {
    when (result) {
        is PermissionResult.Granted -> {
            // when the permission is granted
        }
        is PermissionResult.Denied -> {
            // when the permission is denied
        }
        is PermissionResult.NeverAskAgain -> {
            // when the permission is denied with "never ask again" check
        }
        is PermissionResult.ShouldShowRationale -> {
            // when you should show rationale of acquiring the permission
            showRationale(result)
        }
    }
}

You can continue permission acquiring process after showing rationale:

fun showRationale(result: PermissionResult.ShouldShowRationale) {
    AlertDialog.Builder(this)
            .setPositiveButton("Allow") { _, _ ->
                launch(UI) { result.proceed().let { handlePermissionResult(it) } }
            }
            .setNegativeButton("Deny") { _, _ ->
                launch(UI) { result.cancel().let { handlePermissionResult(it) } }
            }
            .setCancelable(false)
            .setMessage("You should explain why your app requests the permissions.")
            .show()
}

License

The MIT License (MIT)

Copyright (c) 2017 Keita Kagurazaka

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].