Giter Club home page Giter Club logo

androidannotationspermissionsdispatcherplugin's Introduction

AndroidAnnotationsPermissionsDispatcherPlugin

Plugin for AndroidAnnotations allowing to use it together with PermissionsDispatcher. All you have to do is to include it in your dependencies.

Usage

Add it in your root build.gradle at the end of repositories:

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

Add the dependency

dependencies {
    compile 'com.github.hotchemi:permissionsdispatcher:2.4.0'
    annotationProcessor 'com.github.hotchemi:permissionsdispatcher-processor:2.4.0'
    compile 'org.androidannotations:androidannotations-api:4.3.1'
    annotationProcessor 'org.androidannotations:androidannotations:4.3.1'
    annotationProcessor 'com.github.AleksanderMielczarek:AndroidAnnotationsPermissionsDispatcherPlugin:2.0.3'
}

Example

@EActivity(R.layout.activity_main)
@RuntimePermissions
public class MainActivity extends AppCompatActivity {

    @Click(R.id.permissionButton)
    protected void askForPermission() {
        showCamera();
    }

    @NeedsPermission(Manifest.permission.CAMERA)
    protected void showCamera() {
        Toast.makeText(this, "Permission for camera granted", Toast.LENGTH_SHORT).show();
    }

    @OnPermissionDenied(Manifest.permission.CAMERA)
    protected void onPermissionDeniedCamera() {
        Toast.makeText(this, "@OnPermissionDenied for camera", Toast.LENGTH_SHORT).show();
    }
    
    @OnShowRationale(Manifest.permission.CAMERA)
    protected void showRationaleForCamera(PermissionRequest request) {
        Toast.makeText(this, "OnShowRationale for camera", Toast.LENGTH_SHORT).show();
        request.proceed();
    }

    @OnNeverAskAgain(Manifest.permission.CAMERA)
    protected void showNeverAskForCamera() {
        Toast.makeText(this, "OnNeverAskAgain for camera", Toast.LENGTH_SHORT).show();
    }

}

Migrating to 2.x.x

Finally, you should not call the PermissionsDispatcher delegate class static methods anymore, this plugin will generate those calls for you. Just call the method which was annotated with @NeedsPermission. Overriding onRequestPermissionsResult and onActivtyResult (special permissions) should also be removed completely. See the example project for code.

Thanks

  • WonderCsabo for integrating plugin completely with PermissionsDispatcher

Changelog

2.0.3 (2017-08-09)

  • fix generating duplicated dispatchers (#10)

2.0.2 (2017-08-08)

  • fix special permissions handling (#9)

2.0.1 (2017-08-03)

  • fix not compiling code when AA is running first (#7)

2.0.0 (2017-07-12)

  • fully integration with PermissionsDispatcher

1.0.0 (2017-07-02)

  • rename module name
  • update dependencies

License

Copyright 2016 Aleksander Mielczarek

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.

androidannotationspermissionsdispatcherplugin's People

Contributors

aleksandermielczarek avatar vincentnock avatar wondercsabo 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.