GithubHelp home page GithubHelp logo

f2006116 / permissionhelper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from k0shk0sh/permissionhelper

0.0 2.0 0.0 1.88 MB

Android Library to help you with your runtime Permissions.

Home Page: http://k0shk0sh.github.io/PermissionHelper/

License: Apache License 2.0

Java 100.00%

permissionhelper's Introduction

PermissionHelper

Android Library to help you with your runtime Permissions.

Demo

Android M Watch it in action.
Pre M Watch it in action. Nexus 6 (M)

Nexus 6

Nexus 7 (L)

ScreenShot

Nexus 10 (L)

ScreenShot

Installation

Gradle

    compile 'com.github.k0shk0sh:PermissionHelper:1.1.0'

Maven

<dependency>
  <groupId>com.github.k0shk0sh</groupId>
  <artifactId>PermissionHelper</artifactId>
  <version>1.1.0</version>
  <type>aar</type>
</dependency>

Usage

Ask Permissions in Style

Have you wondered what will give you a higher chance of letting the user accepts your permission?

The answer is simple: (Educating UI) that explains why you need to use that particular permission.

Notice

You still can use the library to explain why you used the permission in your app, the library will never try ask the permission if Android is smaller than M, it will just do like any Intro library does. as you can see in Nexus 7 & Nexus 10 screens running Android L, request button is hidden ;).

For Better Understanding, please have a look at the example code at SamplePagerActivity

Take Control.

Your Activity/Fragment/Presenter should implement OnPermissionCallback which in return will give you access to

    void onPermissionGranted(String[] permissionName);

    void onPermissionDeclined(String[] permissionName);

    void onPermissionPreGranted(String permissionsName);

    void onPermissionNeedExplanation(String permissionName);  
    
    void onPermissionReallyDeclined(String permissionName);//user has ticked don't show again and deny the permission

    void onNoPermissionNeeded(); // fallback to api < M

to request a permission all you have to do is:

  • Activity
permissionHelper
     .setForceAccepting(false)// true if you had like force reshowing the permission dialog on Deny (not recommended)
     .request(isSingle ? SINGLE_PERMISSION : MULTIPLE_PERMISSIONS);
  • Fragment
permissionFragmentHelper
     .setForceAccepting(false)// true if you had like force reshowing the permission dialog on Deny (not recommended)
     .request(isSingle ? SINGLE_PERMISSION : MULTIPLE_PERMISSIONS);

and finally in your Activity/Fragment

onRequestPermissionsResult(....)

call

permissionHelper.onRequestPermissionsResult(....)

Extra Activity/Fragment

  • Depends on whether you using PermissionHelper or PermissionFragmentHelper you can call these methods
public static String declinedPermission(@NonNull Context/Fragment context, @NonNull String[])
public static String[] declinedPermissions(@NonNull Context/Fragment context, @NonNull String[] permissions)
public static boolean isPermissionGranted(@NonNull Context/Fragment context, @NonNull String permission)
public static boolean isPermissionDeclined(@NonNull Context/Fragment context, @NonNull String permission)
public static boolean isExplanationNeeded(@NonNull Activity/Fragment context, @NonNull String permissionName)
public static boolean permissionExists(@NonNull Context/Fragment context, @NonNull String permissionName)
public static boolean isPermissionPermanentlyDenied(@NonNull Activity/Fragment context, @NonNull String permission)
public static void openSettingsScreen(Context/Fragment context)//useful when we can't request for the permission due to user ticked don't show again.
@TargetApi(Build.VERSION_CODES.M)
public static boolean isSystemAlertGranted(@NonNull Context/Fragment context)// special case for SYSTEM_ALERT_WINDOW permission.

all of the above static methods you can still access them with PermissionHelper or PermissionFragmentHelper instance.

Why this library?

  • Its simple to use.
  • Its Unique, Customizable & read back first point.
  • You have two choices, do it your way through callbacks, or let the Library do it for you with your look & Feel.
  • Minimum API is 14, but it'll probably work in API 11 and above, just make sure you test it out.

If you're using this library drop me an email at [email protected] to include in the list.

Dependency

Android Support library v24.2.1

CirclePageIndicator by JakeWharton (integrated within the library).

Images

Images used inside the demo are by Maximilian Keppeler

Copyright Notice

Copyright (C) 2015 Kosh. Licensed under the Apache 2.0 license (see the LICENSE file).

permissionhelper's People

Contributors

allsimon avatar flydiverny avatar louiscad avatar robderijk avatar yuyakaido avatar

Watchers

 avatar  avatar

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.