Git Product home page Git Product logo

tedpermission's Introduction

Release Android Arsenal

#What is TedPermission?

After Android Marshmallow, you have to not only decalare permisions in AndroidManifest.xml but request permissions at runtime.
Furthermore anytime user can on/off permissions at application setting.
When you use dangerous permissons(ex. CAMERA, READ_CONTACTS, READ_PHONE_STATE), you have to check and request permissions runtime.
(See dangerous permissions)

You can make check function yourself.
(How to Requesting Permissions at RunTime)

But original check function is so complex and hard..
(checkSelfPermission(), requestPermissions(), onRequestPermissionsResult(), onActivityResult() ...)

TedPermission is simple permission check helper.



##Demo

Screenshot

  1. Request Permissions.
  2. If user denied permissions, we will show message dialog with Setting button.



##Setup

#####Gradle Get library from jitpack.io

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

}

dependencies {
    compile 'com.github.ParkSangGwon:TedPermission:v1.0.11'
}



##How to use

#####1. Make PermissionListener We will use PermissionListener for Permission Result. You will get result to onPermissionGranted(), onPermissionDenied()

    PermissionListener permissionlistener = new PermissionListener() {
        @Override
        public void onPermissionGranted() {
            Toast.makeText(MainActivity.this, "Permission Granted", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onPermissionDenied(ArrayList<String> deniedPermissions) {
            Toast.makeText(MainActivity.this, "Permission Denied\n" + deniedPermissions.toString(), Toast.LENGTH_SHORT).show();
        }


    };

#####2. Start TedPermission TedPermission class need `setPermissionListener()`, `setPermissions()`. and `check()` will start check permissions

setRationaleMessage(),setDeniedMessage() is optional method.

    new TedPermission(this)
    .setPermissionListener(permissionlistener)
    .setDeniedMessage("If you reject permission,you can not use this service\n\nPlease turn on permissions at [Setting] > [Permission]")
    .setPermissions(Manifest.permission.READ_CONTACTS, Manifest.permission.ACCESS_FINE_LOCATION)
    .check();

##Customize You can customize something ...

#####Function

  • setGotoSettingButton(boolean) (default: true)
  • setRationaleMessage(R.string.xxx or String)
  • setRationaleConfirmText(R.string.xxx or String) (default: confirm / 확인)
  • setDeniedMessage(R.string.xxx or String)
  • setDeniedCloseButtonText(R.string.xxx or String) (default: close / 닫기)
  • setGotoSettingButtonText(R.string.xxx or String) (default: setting / 설정)



##Number of Cases

  1. Check permissions -> have permissions
    : onPermissionGranted() called

  2. Check permissions -> don't have permissions
    : show request dialog
    Screenshot

  3. show request dialog -> granted permissions
    : onPermissionGranted() called

  4. show request dialog -> denied permissions
    : show denied dialog
    Screenshot

  5. show denied dialog -> close
    : onPermissionDenied() called

  6. show denied dialog -> setting
    : startActivityForResult() to setting activity
    Screenshot

  7. setting activity -> onActivityResult()
    : check permission

  8. check permission -> granted permissions
    : onPermissionGranted() called

  9. check permission -> denied permissions
    : onPermissionDenied() called



Screenshot

##Thanks

  • Otto - An enhanced Guava-based event bus with emphasis on Android support



##License

Copyright 2016 Ted Park

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

tedpermission's People

Contributors

gun0912 avatar parksanggwon avatar

Watchers

 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.