Theo

Additional

Language
Java
Version
1.3.1 (Dec 12, 2016)
Created
Nov 20, 2016
Updated
Apr 3, 2020 (Retired)
Owner
Xavier Bauquet (xbauquet)
Contributor
Xavier Bauquet (xbauquet)
1
Activity
Badge
Generate
Download
Source code

Theo

Theo is a plugin that provides annotations for each 'dangerous android permission'.

Use

Use annotations to ask for permissions

@Camera
public void cameraMethod() {
    // Do something
}

@Permissions({Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.CAMERA})
public void permissionsMethod(){
    // Do something
}

For the complete list of annotation see the MainActivity in theo-example

Theo also provide methods to check if permissions are granted or not

Theo.checkPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION);
Theo.checkPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION, false);
Theo.checkPermission(activity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.CAMERA});
Theo.checkPermission(activity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.CAMERA}, false);

if(Theo.checkPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION)){
    // do something
}

This method is returning a boolean and can be used directly inside a if(). The last boolean is used to enable or disable the snack bar that is shown if a permission is not granted.

Gradle

buildscript {
  repositories {
    maven {
            url  "http://dl.bintray.com/xavier-bauquet/Android"
    }
  }

  dependencies {
    classpath 'com.xavierbauquet.theo:theo-plugin:1.3.1'
  }
}

apply plugin: 'com.android.application'
apply plugin: 'com.xavierbauquet.theo'

License

Copyright 2016 Xavier Bauquet

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.