Giter VIP home page Giter VIP logo

permissionutil's Introduction

Android Arsenal GitHub license API CircleCI

permissionUtil

A simple easy-to-use permission helper for Android. No need to handle result in onActivityResult and passing it to fragment or model. PermissionUtil can be used from any place with context only (Activity, Fragment,ViewModel).

//Easy to use
PermissionUtil.locationBoth(context, requestPermissionListener);

Callback

Added new CallbackBuilder so now you can build PermissionCallback with or without granted or denied calls. Also you can set resources for rationale explanation.

new CallbackBuilder()
                .onGranted(()->yourGrantedCall())
                .onDenied(()->yourDeniedCall())
                .withRationale(titleId,messageId)
                .build();

Simplified callback. Just override method that you need and that's it.

public abstract class ShortPerCallback implements PermissionCallback {

    @Override
    public void onPermissionGranted() {
    }

    @Override
    public void onPermissionDenied() {
    }
   
}

If you need to show rationale explanation - you may use CallbackBuilder or you need to override getRationaleTitleId() and getRationaleMessageId() of PermissionCallback class if you don't wan't to use builder . Dialog won't be shown if getRationaleMessageId() will return 0.

    // default implementation 
    
    int getRationaleTitleId() {
        return 0;
    }
    
    int getRationaleMessageId() {
        return 0;
    }

Actions

You can directly use prepared requests like :

PermissionUtil.locationFine(context, requestPermissionListener);
PermissionUtil.locationCoarse(context, requestPermissionListener);

Or you can request multiple permissions with your group :

PermissionUtil.checkGroup(context, requestPermissionListener,new String[]{Manifest.permission.READ_PHONE_STATE});

List of permissions that could be requested according to Dangerous permissions :

  • contactsRead
  • contactsWrite
  • contactsRW
  • calendarRead
  • calendarWrite
  • calendarRW
  • storageRead
  • storageWrite
  • storageRW
  • locationFine
  • locationCoarse
  • locationBoth
  • camera
  • microphone
  • phoneReadState
  • phoneCall
  • phoneReadCallLog
  • phoneWriteCallLog
  • phoneAddVoiceMail
  • phoneSip
  • phoneOutgoing
  • phoneAll
  • sensors
  • smsSend
  • smsReceive
  • smsRead
  • smsWap
  • smsMms
  • smsAll
  • checkGroup

Download

Download

repositories {
    // yo can use 
    mavenCentral() // or jcenter()
    
    //or direct link to repository or jitpack
    maven { url  "http://dl.bintray.com/euzee/Libs" } // or maven { url "https://jitpack.io" }
}
(with gradle plugin less then v3 use 'compile' instead of implementation) 
implementation 'com.github.euzee:permissionUtil:1.0.7'

License

Copyright 2017 Euzee, Inc.

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.

permissionutil's People

Contributors

ciklumdol avatar euzee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

permissionutil's Issues

Wrong call of PermissionGranted Callback

After granting the permission for the first time, the onPermissionDenied() is called. After restarting the app we will end up in onPermissionGarnted() directly.

This is the case when trying to retreive permissions for locationBoth(), but one of them is not set in the Android Manifest

android:allowBackup

After add "implementation 'com.github.euzee:permissionUtil:1.0.5'" to build.gradle

Error: Attribute application@allowBackup value=(true) from AndroidManifest.xml:34:9-35
	is also present at [com.github.euzee:permissionUtil:1.0.5] AndroidManifest.xml:13:9-36 value=(false).
	Suggestion: add 'tools:replace="android:allowBackup"' to <application> element at AndroidManifest.xml:32:5-87:19 to override.

It have a suggestion, but i don`t want to do this (tools, replace and other not neccessary actions).
Can you do something? Remove "allowBackup" from manifest, or something?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.