All Projects → permissions-dispatcher → Permissionsdispatcher

permissions-dispatcher / Permissionsdispatcher

Licence: apache-2.0
A declarative API to handle Android runtime permissions.

Programming Languages

java
68154 projects - #9 most used programming language
kotlin
9241 projects
groovy
2714 projects

Projects that are alternatives of or similar to Permissionsdispatcher

Xxpermissions
Android 权限请求框架,已适配 Android 12
Stars: ✭ 2,971 (-72.62%)
Mutual labels:  permissions, permission, permission-android
easypermissions-ktx
🔓 Kotlin version of the popular google/easypermissions wrapper library to simplify basic system permissions logic on Android M or higher.
Stars: ✭ 324 (-97.01%)
Mutual labels:  permissions, permission, permissions-android
PermissionManager
android6.0之后开始会有权限使用的问题。这个项目演示了如何在代码中动态申请权限。尤其是"存储"这一个在6.0之前不需要申请的权限,本项目以这个作为例子。
Stars: ✭ 21 (-99.81%)
Mutual labels:  permissions, permission, permission-android
Vakt
Attribute-based access control (ABAC) SDK for Python
Stars: ✭ 92 (-99.15%)
Mutual labels:  permissions, permission
Voice Overlay Android
🗣 An overlay that gets your user’s voice permission and input as text in a customizable UI
Stars: ✭ 189 (-98.26%)
Mutual labels:  permissions, permission
Guardian
Eloquent Guardian is a simple permissions system for your users. While there are many other packages for permissions, this one solves everything in the most eloquent way.
Stars: ✭ 121 (-98.88%)
Mutual labels:  permissions, permission
Easypermission
一个非常轻便而且可用的Android动态权限申请库
Stars: ✭ 192 (-98.23%)
Mutual labels:  permissions, permission
sentry
A lightweight (23KB) wrapper for inline Android permission checks/requests.
Stars: ✭ 22 (-99.8%)
Mutual labels:  permissions, permissions-android
HeimGuard
🛡 A simple library that allows you to easily manage permissions in your .NET projects.
Stars: ✭ 77 (-99.29%)
Mutual labels:  permissions, permission
Simplify-Permissions
Android library to simplifies the android permission request at runtime.
Stars: ✭ 22 (-99.8%)
Mutual labels:  permission, permission-android
Sppermissions
Ask permissions with ready-use interface. You can check status permission and if it has been requested before. Support SwiftUI.
Stars: ✭ 4,701 (-56.68%)
Mutual labels:  permissions, permission
CustomPermissionsDialogue
Custom Permissions Dialogue is the only permissions library that supports ALL permission request scenarios. This library handles multiple edge cases such as not enabling all permissions or permanently rejecting a permission request.
Stars: ✭ 51 (-99.53%)
Mutual labels:  permissions, permission
Ziggurat foundations
Framework agnostic set of sqlalchemy classes that make building applications that require permissions an easy task.
Stars: ✭ 67 (-99.38%)
Mutual labels:  permissions, permission
Bepasty Server
binary pastebin server
Stars: ✭ 111 (-98.98%)
Mutual labels:  permissions
Easypermissions
Simplify Android M system permissions
Stars: ✭ 9,346 (-13.87%)
Mutual labels:  permissions
Django Rules
Awesome Django authorization, without the database
Stars: ✭ 1,255 (-88.43%)
Mutual labels:  permissions
Urpm
urpm 是一套基于Laravel封装的后台用户管理权限系统,能够让开发者不用再关心权限问题,实现后台功能的快速开发。
Stars: ✭ 118 (-98.91%)
Mutual labels:  permission
Publishcommunity Master
仿微博,QQ空间,论坛 ,九宫格图文混排发表说说,动态,帖子
Stars: ✭ 107 (-99.01%)
Mutual labels:  permission
Mpermissionutils
Android6.0 运行时权限处理工具类
Stars: ✭ 84 (-99.23%)
Mutual labels:  permission
Casbin
An authorization library that supports access control models like ACL, RBAC, ABAC in Golang
Stars: ✭ 10,872 (+0.19%)
Mutual labels:  permission

PermissionsDispatcher CI for pull request PermissionsDispatcher

PermissionsDispatcher provides a simple annotation-based API to handle runtime permissions.

This library lifts the burden that comes with writing a bunch of check statements whether a permission has been granted or not from you, in order to keep your code clean and safe.

Usage

  • Kotlin: You can pick either of ktx or kapt.
  • Java: apt

Here's a minimum example, in which you register a MainActivity which requires Manifest.permission.CAMERA.

0. Prepare AndroidManifest

Add the following line to AndroidManifest.xml:

<uses-permission android:name="android.permission.CAMERA" />

1. Attach annotations

PermissionsDispatcher introduces only a few annotations, keeping its general API concise:

NOTE: Annotated methods must not be private.

Annotation Required Description
@RuntimePermissions Register an Activity or Fragment to handle permissions
@NeedsPermission Annotate a method which performs the action that requires one or more permissions
@OnShowRationale Annotate a method which explains why the permissions are needed. It passes in a PermissionRequest object which can be used to continue or abort the current permission request upon user input. If you don't specify any argument for the method compiler will generate process${NeedsPermissionMethodName}ProcessRequest and cancel${NeedsPermissionMethodName}ProcessRequest. You can use those methods in place of PermissionRequest(ex: with DialogFragment)
@OnPermissionDenied Annotate a method which is invoked if the user doesn't grant the permissions
@OnNeverAskAgain Annotate a method which is invoked if the user chose to have the device "never ask again" about a permission
@RuntimePermissions
class MainActivity : AppCompatActivity(), View.OnClickListener {

    @NeedsPermission(Manifest.permission.CAMERA)
    fun showCamera() {
        supportFragmentManager.beginTransaction()
                .replace(R.id.sample_content_fragment, CameraPreviewFragment.newInstance())
                .addToBackStack("camera")
                .commitAllowingStateLoss()
    }

    @OnShowRationale(Manifest.permission.CAMERA)
    fun showRationaleForCamera(request: PermissionRequest) {
        showRationaleDialog(R.string.permission_camera_rationale, request)
    }

    @OnPermissionDenied(Manifest.permission.CAMERA)
    fun onCameraDenied() {
        Toast.makeText(this, R.string.permission_camera_denied, Toast.LENGTH_SHORT).show()
    }

    @OnNeverAskAgain(Manifest.permission.CAMERA)
    fun onCameraNeverAskAgain() {
        Toast.makeText(this, R.string.permission_camera_never_askagain, Toast.LENGTH_SHORT).show()
    }
}

2. Delegate to generated functions

Now generated functions become much more concise and intuitive than Java version!

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        findViewById(R.id.button_camera).setOnClickListener {
            // NOTE: delegate the permission handling to generated function
            showCameraWithPermissionCheck()
        }
    }

    override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults)
        // NOTE: delegate the permission handling to generated function
        onRequestPermissionsResult(requestCode, grantResults)
    }

Check out the sample for more details.

Other features/plugins

Installation

NOTE:

  • If you're using jCenter we've moved on to MavenCentral, see migration guide.
  • 4.x only supports Jetpack. If you still use appcompat 3.x is the way to go.

To add PermissionsDispatcher to your project, include the following in your app module build.gradle file:

${latest.version} is Download

dependencies {
  implementation "com.github.permissions-dispatcher:permissionsdispatcher:${latest.version}"
  annotationProcessor "com.github.permissions-dispatcher:permissionsdispatcher-processor:${latest.version}"
}

With Kotlin:

apply plugin: 'kotlin-kapt'

dependencies {
  implementation "com.github.permissions-dispatcher:permissionsdispatcher:${latest.version}"
  kapt "com.github.permissions-dispatcher:permissionsdispatcher-processor:${latest.version}"
}

License

Copyright 2016 Shintaro Katafuchi, Marcel Schnelle, Yoshinori Isogai

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 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].