All Projects → zhanghai → EffortlessPermissions

zhanghai / EffortlessPermissions

Licence: other
An Android permission library extending Google's EasyPermissions with convenient additions.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to EffortlessPermissions

easypermissions-ktx
🔓 Kotlin version of the popular google/easypermissions wrapper library to simplify basic system permissions logic on Android M or higher.
Stars: ✭ 324 (+285.71%)
Mutual labels:  permissions, runtime-permissions
permissionUtil
Simple permission helper
Stars: ✭ 64 (-23.81%)
Mutual labels:  permissions, runtime-permissions
startask-permissions
Is a library that helps to handle runtime permissions on Android, entirely written using Kotlin language.
Stars: ✭ 39 (-53.57%)
Mutual labels:  permissions, runtime-permissions
fastapi-auth0
FastAPI authentication and authorization using auth0.com
Stars: ✭ 104 (+23.81%)
Mutual labels:  permissions
LocationFetcher
Easy Location fetching for Android apps.
Stars: ✭ 33 (-60.71%)
Mutual labels:  permissions
pstore
🔧 Middleware for keeping track of users, login states and permissions, using the HSTORE feature in PostgreSQL
Stars: ✭ 28 (-66.67%)
Mutual labels:  permissions
itag
iTag tracker manager for real people
Stars: ✭ 35 (-58.33%)
Mutual labels:  adnroid
django-improved-permissions
Django application made to make django's default permission system more robust.
Stars: ✭ 14 (-83.33%)
Mutual labels:  permissions
permissionary
Tiny and framework-agnostic role-based permission management using composition over inheritance
Stars: ✭ 19 (-77.38%)
Mutual labels:  permissions
permer
🔑 A basic abstraction for handling flags using bitwise
Stars: ✭ 41 (-51.19%)
Mutual labels:  permissions
SimpleToDo
Task management app for Android ✔️
Stars: ✭ 104 (+23.81%)
Mutual labels:  adnroid
permissionbolt
🔩 Middleware for keeping track of users, login states and permissions
Stars: ✭ 81 (-3.57%)
Mutual labels:  permissions
DexClassLoaderDemo
通过加载其他应用的 .dex 文件破解关键数据。
Stars: ✭ 18 (-78.57%)
Mutual labels:  adnroid
cypress-browser-permissions
A Cypress plugin to set launched browser preferences including permissions like Geolocation, Notifications, Microphone, etc.
Stars: ✭ 40 (-52.38%)
Mutual labels:  permissions
react-abac
Attribute Based Access Control for React
Stars: ✭ 54 (-35.71%)
Mutual labels:  permissions
feathers-casl
feathers.js + casl: hooks & channels
Stars: ✭ 25 (-70.24%)
Mutual labels:  permissions
ios-permissions-service
An easy way to do permissions requests & handling automatically.
Stars: ✭ 25 (-70.24%)
Mutual labels:  permissions
django-graphene-permissions
DGP - A DRF like permission system for django graphene
Stars: ✭ 29 (-65.48%)
Mutual labels:  permissions
deadbolt
Dead simple permissions for Laravel
Stars: ✭ 13 (-84.52%)
Mutual labels:  permissions
PermissionManager
android6.0之后开始会有权限使用的问题。这个项目演示了如何在代码中动态申请权限。尤其是"存储"这一个在6.0之前不需要申请的权限,本项目以这个作为例子。
Stars: ✭ 21 (-75%)
Mutual labels:  permissions

EffortlessPermissions

Icon

An Android permission library extending Google's EasyPermissions with convenient additions.

Don't say very easy, say effortless. —— 128 Words to Use Instead of "Very"

Google Play

Sample APK

Why EffortlessPermissions?

  • Used as a drop-in replacement for Google's EasyPermissions and based on its battle-tested implementation.
  • Added an @AfterPermissionDenied annotation for methods to run automatically after denial.
  • Included consumer ProGuard rules missing in EasyPermissions which fixes your release build.
  • Added more method overloads which make coding easier.
  • Added another DialogFragment to open app detail settings which you have more control upon, e.g. dialog title can be hidden now.

In a word, just start with EffortlessPermissions instead of EasyPermissions.

Integration

Gradle:

compile 'me.zhanghai.android.effortlesspermissions:library:1.1.0'

Usage

Just use EffortlessPermission wherever you would use EasyPermissions (documentation), and explore the improvements listed above!

And here is a fully-working sample implementation, handling permission requesting both normally and after permanent denial:

public class MainActivity extends AppCompatActivity {

    private static final int REQUEST_CODE_SAVE_FILE_PERMISSION = 1;
    private static final String[] PERMISSIONS_SAVE_FILE = {
            Manifest.permission.WRITE_EXTERNAL_STORAGE
    };

    ...

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
                                           @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);

        // Dispatch to our library.
        EffortlessPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults,
                this);
    }

    // Call back to the same method so that we'll check and proceed.
    @AfterPermissionGranted(REQUEST_CODE_SAVE_FILE_PERMISSION)
    private void saveFile() {
        if (EffortlessPermissions.hasPermissions(this, PERMISSIONS_SAVE_FILE)) {
            // We've got the permission.
            saveFileWithPermission();
        } else {
            // Request the permissions.
            EffortlessPermissions.requestPermissions(this,
                    R.string.save_file_permission_request_message,
                    REQUEST_CODE_SAVE_FILE_PERMISSION, PERMISSIONS_SAVE_FILE);
        }
    }

    @AfterPermissionDenied(REQUEST_CODE_SAVE_FILE_PERMISSION)
    private void onSaveFilePermissionDenied() {
        if (EffortlessPermissions.somePermissionPermanentlyDenied(this, PERMISSIONS_SAVE_FILE)) {
            // Some permission is permanently denied so we cannot request them normally.
            OpenAppDetailsDialogFragment.show(
                    R.string.save_file_permission_permanently_denied_message,
                    R.string.open_settings, this);
        } else {
            // User denied at least some of the required permissions, report the error.
            Toast.makeText(this, R.string.save_file_permission_denied, Toast.LENGTH_SHORT).show();
        }
    }

    private void saveFileWithPermission() {
        // It's show time!
        Toast.makeText(this, R.string.save_file_show_time, Toast.LENGTH_SHORT).show();
    }
}

Without EffortlessPermissions, you would have to make your activity implement PermissionCallbacks, check request code and call permission denied callback manually. You would also need to remember writing the ProGuard rules for every project or you'll end up debugging your release build to find it out. But now, only the truly necessary code is written. Cheers!

ProGuard

The AAR of this library has already included a consumer ProGuard file to retain the annotations and annotated methods.

License

Copyright 2017 Zhang Hai

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