diff --git a/granter/build.gradle b/granter/build.gradle index 99929b6..a8035b0 100644 --- a/granter/build.gradle +++ b/granter/build.gradle @@ -12,7 +12,6 @@ android { versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" - } buildTypes { @@ -26,11 +25,5 @@ android { dependencies { implementation 'com.android.support:appcompat-v7:26.0.2' - annotationProcessor "android.arch.lifecycle:compiler:1.0.0-alpha9" - - implementation 'android.arch.lifecycle:runtime:1.0.0-alpha9' - implementation 'android.arch.lifecycle:extensions:1.0.0-alpha9' - api 'pub.devrel:easypermissions:1.0.0' - } diff --git a/granter/src/main/java/se/eelde/granter/Stolen.java b/granter/src/main/java/se/eelde/granter/Stolen.java index 33d92b2..159cb8b 100644 --- a/granter/src/main/java/se/eelde/granter/Stolen.java +++ b/granter/src/main/java/se/eelde/granter/Stolen.java @@ -11,6 +11,10 @@ import pub.devrel.easypermissions.AfterPermissionGranted; import pub.devrel.easypermissions.EasyPermissions; +/** + * "Stolen" from EasyPermissions. If the time presents itself we should arrange a PR + * towards Easypermissions to provide this functionality. + */ class Stolen { static void callGrantedCallback(Object callee, int requestCode, List perms) { if (callee instanceof EasyPermissions.PermissionCallbacks) { @@ -26,16 +30,13 @@ static void callDeniedCallback(Object callee, int requestCode, List perm static void callAnnotations(Object object, int requestCode) { Class clazz = object.getClass(); - if (isUsingAndroidAnnotations(object)) { - clazz = clazz.getSuperclass(); - } while (clazz != null) { for (Method method : clazz.getDeclaredMethods()) { - AfterPermissionGranted ann = method.getAnnotation(AfterPermissionGranted.class); - if (ann != null) { + AfterPermissionGranted annotation = method.getAnnotation(AfterPermissionGranted.class); + if (annotation != null) { // Check for annotated methods with matching request code. - if (ann.value() == requestCode) { + if (annotation.value() == requestCode) { // Method must be void so that we can invoke it if (method.getParameterTypes().length > 0) { throw new RuntimeException( @@ -59,21 +60,6 @@ static void callAnnotations(Object object, int requestCode) { } } - /** - * Determine if the project is using the AndroidAnnotations library. - */ - private static boolean isUsingAndroidAnnotations(@NonNull Object object) { - if (!object.getClass().getSimpleName().endsWith("_")) { - return false; - } - try { - Class clazz = Class.forName("org.androidannotations.api.view.HasViews"); - return clazz.isInstance(object); - } catch (ClassNotFoundException e) { - return false; - } - } - static boolean shouldShowRationale(Fragment fragment, String[] permissions) { for (String permission : permissions) { if (fragment.shouldShowRequestPermissionRationale(permission)) {