All Projects → canelmas → Let

canelmas / Let

Licence: apache-2.0
Annotation based simple API flavored with AOP to handle new Android runtime permission model

Programming Languages

java
68154 projects - #9 most used programming language
kotlin
9241 projects

Projects that are alternatives of or similar to Let

Laziertracker
本项目通过Android字节码插桩插件实现Android端无埋点(或自动埋点),并且支持根据配置文件实现业务数据的自动采集。
Stars: ✭ 485 (-8.83%)
Mutual labels:  gradle, gradle-plugin, aop
Click Debounce
Using ASM to handle Android's click debounce, specially a quick double click.
Stars: ✭ 175 (-67.11%)
Mutual labels:  gradle, gradle-plugin, aop
Javapackager
📦 Gradle/Maven plugin to package Java applications as native Windows, Mac OS X, or GNU/Linux executables and create installers for them.
Stars: ✭ 285 (-46.43%)
Mutual labels:  gradle, gradle-plugin
Swagger Gradle Codegen
💫 A Gradle Plugin to generate your networking code from Swagger
Stars: ✭ 330 (-37.97%)
Mutual labels:  gradle, gradle-plugin
Axion Release Plugin
Gradle release & version management plugin.
Stars: ✭ 372 (-30.08%)
Mutual labels:  gradle, gradle-plugin
Gradle Aws Plugin
Gradle plugin to manage Amazon Web Services
Stars: ✭ 269 (-49.44%)
Mutual labels:  gradle, gradle-plugin
Gradle Unused Resources Remover Plugin
Gradle Plugin that removes unused resources in Android projects.
Stars: ✭ 282 (-46.99%)
Mutual labels:  gradle, gradle-plugin
Calces Gradle Plugin
Android构建工具集:包含快速实现组件化构建脚本,快速实现屏幕最小宽度适配脚本
Stars: ✭ 366 (-31.2%)
Mutual labels:  gradle, gradle-plugin
change-tracker-plugin
A Gradle plugin to help analyse the dependency between modules and run tasks only on modules impacted by specific set of changes.
Stars: ✭ 103 (-80.64%)
Mutual labels:  gradle, gradle-plugin
Javafx Gradle Plugin
Gradle plugin for JavaFX
Stars: ✭ 425 (-20.11%)
Mutual labels:  gradle, gradle-plugin
Gradle Static Analysis Plugin
Easy setup of static analysis tools for Android and Java projects.
Stars: ✭ 398 (-25.19%)
Mutual labels:  gradle, gradle-plugin
Bnd
Bnd/Bndtools. Tooling to build OSGi bundles including Eclipse, Maven, and Gradle plugins.
Stars: ✭ 446 (-16.17%)
Mutual labels:  gradle, gradle-plugin
T Mvp
Android AOP Architecture by Apt, AspectJ, Javassisit, based on Realm+Databinding+MVP+Retrofit+Rxjava2
Stars: ✭ 2,740 (+415.04%)
Mutual labels:  gradle, aop
Animatefx
A library of +70 ready-to-use animations for JavaFX
Stars: ✭ 254 (-52.26%)
Mutual labels:  gradle, library
Gradle Code Quality Tools Plugin
Gradle plugin that generates ErrorProne, Findbugs, Checkstyle, PMD, CPD, Lint, Detekt & Ktlint Tasks for every subproject.
Stars: ✭ 282 (-46.99%)
Mutual labels:  gradle, gradle-plugin
schema-registry-plugin
Gradle plugin to interact with Confluent Schema-Registry.
Stars: ✭ 60 (-88.72%)
Mutual labels:  gradle, gradle-plugin
Gradle Android Command Plugin
Handy commands for testing Android on CI
Stars: ✭ 349 (-34.4%)
Mutual labels:  gradle, gradle-plugin
jooq-plugin
Plugin for generating jOOQ classes using dockerized databases
Stars: ✭ 55 (-89.66%)
Mutual labels:  gradle, gradle-plugin
gradle-console-reporter
Gradle plugin to report various kinds of summaries to console.
Stars: ✭ 49 (-90.79%)
Mutual labels:  gradle, gradle-plugin
Androidautotrack
Android Asm 插桩 教学
Stars: ✭ 378 (-28.95%)
Mutual labels:  gradle, gradle-plugin

Let

Android Arsenal Join the chat at https://gitter.im/canelmas/let

Annotation based simple API flavoured with AOP to handle new Android runtime permission model.

If you check Google's Samples about the new permission model, you'll see a lot of boiler plate code for requesting, handling and retrying the request for required permissions.

Let will minimize the boiler plate code you have to write for requesting and handling permissions and hence help you keep your code more readable.

Let let Handle

Annotate your methods requiring permissions with @AskPermission and let Let handle the rest.

@AskPermission(ACCESS_FINE_LOCATION)
private void getUserLocationAndDoSomething() {
    Toast.makeText(
        SampleActivity.this, 
        "Now that I have the permission I need, I'll get your location and do something with it", 
        Toast.LENGTH_SHORT
    ).show();
    ...
}
@AskPermission({
            Manifest.permission.READ_CONTACTS,
            Manifest.permission.CALL_PHONE,
            Manifest.permission.CAMERA
})
private void skipTutorial() {
    // permissions needed for the best app experience are granted; let's go to the app's home screen
    startActivity(new Intent(this, HomeActivity.class));
}

Let will check these annotated methods and execute them unless the permissions required are granted; otherwise Let will put on hold the method execution and request these permissions at runtime. After examining the permission request result, Let will execute the method already put on hold only if the permissions are granted by user.

Let will also inform about the rationales before making any permission request and tell about denied permissions; whether they're simply denied or with 'Never Ask Again' checked.

Just make sure to override the onRequestPermissionsResult in your Activity or Fragment, where your @AskPermission annotated methods are located:

@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
    Let.handle(this, requestCode, permissions, grantResults);
}

And make sure your Activity or Fragment implements RuntimePermissionListener in order to get notified about denied permissions and rationales:

public class SampleActivity extends AppCompatActivity implements RuntimePermissionListener {
    
    // ....
    
    @Override
    public void onShowPermissionRationale(List<String> permissions, final RuntimePermissionRequest request) {
        /**
        * you may show permission rationales in a dialog, wait for user confirmation and retry the permission 
        * request by calling request.retry()    
        */               
    }
  
    @Override
    public void onPermissionDenied(List<DeniedPermission> deniedPermissionList) {
        /**
        * Do whatever you need to do about denied permissions:
        *   - update UI
        *   - if permission is denied with 'Never Ask Again', prompt a dialog to tell user
        *   to go to the app settings screen in order to grant again the permission denied 
        */              
    }
    
    //  ...
}

Usage

Add it to your project today!

buildscript {
    repositories {                    
        jcenter()        
    }

    dependencies {        
        classpath 'com.canelmas.let:let-plugin:0.1.11'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'let'

repositories {        
    jcenter()
}

For kotlin :

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.canelmas.let:let-plugin:1.0.0-beta1'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'let'

repositories {
    jcenter()
}

Proguard

Make sure your proguard rule set includes following lines:

-keep class com.canelmas.let.** { *; }
-keepnames class * implements com.canelmas.let.RuntimePermissionListener

-keepclassmembers class * implements com.canelmas.let.RuntimePermissionListener {
    public void onRequestPermissionsResult(***);
}

-keepclasseswithmembernames class * {
    @com.canelmas.let.* <methods>;
}

License

Copyright 2016 Can Elmas

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