diff --git a/CHANGELOG.md b/CHANGELOG.md index 5309afd..6c4cd2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,17 @@ Change Log ========== +Version 1.0.0-beta1 *(2017-09-04)* +---------------------------------- +* Use Transform API for weaving [#23](https://github.com/canelmas/let/issues/23) +* Support Kotlin [#17](https://github.com/canelmas/let/issues/17) +* Remove logger [#20](https://github.com/canelmas/let/issues/20) + +Version 0.1.11 *(2016-06-07)* +----------------------------- +* Fix the potential java.lang.IllegalArgumentException: Can only use lower +8 bits for requestCode [#11](https://github.com/canelmas/let/issues/11) + Version 0.1.10 *(2016-03-20)* ----------------------------- * Change: Set `@AskPermission` retention policy to `RUNTIME` (again) diff --git a/README.md b/README.md index 8686993..e5f0c60 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ Let [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Let-green.svg?style=true)](https://android-arsenal.com/details/1/2843) [![](https://img.shields.io/badge/AndroidWeekly-%23182-red.svg)](http://androidweekly.net/issues/issue-182) [![Join the chat at https://gitter.im/canelmas/let](https://badges.gitter.im/canelmas/let.svg)](https://gitter.im/canelmas/let?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -Annotation based simple API flavoured with [AOP] (https://en.wikipedia.org/wiki/Aspect-oriented_programming) to handle new Android runtime permission model. +Annotation based simple API flavoured with [AOP](https://en.wikipedia.org/wiki/Aspect-oriented_programming) to handle new Android runtime permission model. -If you check [Google's Samples] (https://github.com/googlesamples/android-RuntimePermissions/blob/master/Application/src/main/java/com/example/android/system/runtimepermissions/MainActivity.java) +If you check [Google's Samples](https://github.com/googlesamples/android-RuntimePermissions/blob/master/Application/src/main/java/com/example/android/system/runtimepermissions/MainActivity.java) about the new permission model, you'll see a lot of boiler plate code for requesting, handling and retrying the request for required permissions. @@ -106,7 +106,6 @@ buildscript { } } - apply plugin: 'com.android.application' apply plugin: 'let' @@ -115,28 +114,28 @@ repositories { } ``` -For SNAPSHOT version : - +For kotlin : ```groovy buildscript { - repositories { - maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + repositories { + jcenter() } - dependencies { - classpath 'com.canelmas.let:let-plugin:0.1.11-SNAPSHOT' + dependencies { + classpath 'com.canelmas.let:let-plugin:1.0.0-beta1' } } apply plugin: 'com.android.application' apply plugin: 'let' -repositories { - maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } +repositories { + jcenter() } ``` + Proguard ==== diff --git a/build.gradle b/build.gradle index 446ee03..f2fb66b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,34 +1,46 @@ buildscript { + ext.versions = [ + compileSdkVersion : 26, + buildToolsVersion : '26.0.1', + minSdkVersion : 14, + targetSdkVersion : 26, + supportLibrary : '26.0.1', + aspectjrt : '1.8.9', + aspectjtools : '1.8.9', + androidPlugin : '3.0.0-beta4', + androidMavenPlugin: '1.2' + ] + + ext.deps = [ + supportAnnotations : "com.android.support:support-annotations:${versions.supportLibrary}", + supportDesign : "com.android.support:design:${versions.supportLibrary}", + appCompatv7 : "com.android.support:appcompat-v7:${versions.supportLibrary}", + aspectjrt : "org.aspectj:aspectjrt:${versions.aspectjrt}", + aspectjtools : "org.aspectj:aspectjtools:${versions.aspectjtools}", + androidGradlePlugin: "com.android.tools.build:gradle:${versions.androidPlugin}", + androidMavenPlugin : "com.github.dcendents:android-maven-plugin:${versions.androidMavenPlugin}", + junit : 'junit:junit:4.12' + ] + repositories { jcenter() + google() } dependencies { - classpath 'com.android.tools.build:gradle:1.3.0' + classpath deps.androidGradlePlugin classpath 'org.gradle.api.plugins:gradle-nexus-plugin:0.7' - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' } } allprojects { repositories { jcenter() + google() } group = GROUP version = VERSION_NAME } - -ext { - compileSdkVersion = 23 - buildToolsVersion = '22.0.1' - minSdkVersion = 10 - targetSdkVersion = 23 -} - -ext.deps = [ - supportAnnotations : 'com.android.support:support-annotations:23.0.1', - supportDesign : 'com.android.support:design:23.0.1', - appCompatv7 : 'com.android.support:appcompat-v7:23.0.1', -] diff --git a/gradle.properties b/gradle.properties index cc5c4b6..2dcc5cd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,7 +14,7 @@ # org.gradle.parallel=true #Tue Sep 22 16:15:19 EEST 2015 -VERSION_NAME=0.1.11 +VERSION_NAME=1.0.0-beta1 GROUP=com.canelmas.let POM_DESCRIPTION=Annotation based simple API flavoured with AOP to handle new Android runtime permission model diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f9f2677..854e1c2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip diff --git a/let-plugin/build.gradle b/let-plugin/build.gradle index d1a5f6b..788f5a1 100644 --- a/let-plugin/build.gradle +++ b/let-plugin/build.gradle @@ -23,9 +23,9 @@ sourceCompatibility = JavaVersion.VERSION_1_7 dependencies { compile gradleApi() compile localGroovy() - compile 'com.android.tools.build:gradle:1.3.0' - compile 'org.aspectj:aspectjtools:1.8.6' - compile 'org.aspectj:aspectjrt:1.8.6' + compile deps.androidGradlePlugin + compile deps.aspectjtools + compile deps.aspectjrt } modifyPom { diff --git a/let-plugin/src/main/groovy/com/canelmas/let/LetPlugin.groovy b/let-plugin/src/main/groovy/com/canelmas/let/LetPlugin.groovy index db6c9d7..c8a8ad2 100644 --- a/let-plugin/src/main/groovy/com/canelmas/let/LetPlugin.groovy +++ b/let-plugin/src/main/groovy/com/canelmas/let/LetPlugin.groovy @@ -1,11 +1,11 @@ /* - * Copyright (C) 2015 Can Elmas + * Copyright (C) 2017 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 + * 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, @@ -18,71 +18,32 @@ package com.canelmas.let import com.android.build.gradle.AppPlugin import com.android.build.gradle.LibraryPlugin -import org.aspectj.bridge.IMessage -import org.aspectj.bridge.MessageHandler -import org.aspectj.tools.ajc.Main import org.gradle.api.Plugin import org.gradle.api.Project -import org.gradle.api.tasks.compile.JavaCompile class LetPlugin implements Plugin { - @Override void apply(Project project) { - def hasApp = project.plugins.withType(AppPlugin) - def hasLib = project.plugins.withType(LibraryPlugin) - if (!hasApp && !hasLib) { - throw new IllegalStateException("'android' or 'android-library' plugin required.") - } + @Override + void apply(Project project) { - final def log = project.logger - final def variants - if (hasApp) { - variants = project.android.applicationVariants - } else { - variants = project.android.libraryVariants - } + makeSureProjectIsAndroidAppOrLib(project) + + project.android.registerTransform(new LetTransform(project)) project.dependencies { - compile 'com.canelmas.let:let-runtime:0.1.11' - compile 'org.aspectj:aspectjrt:1.8.6' - compile 'com.canelmas.let:let-annotations:0.1.11' + implementation 'org.aspectj:aspectjrt:1.8.9' + implementation 'com.canelmas.let:let-runtime:1.0.0-beta1' + implementation 'com.canelmas.let:let-annotations:1.0.0-beta1' } + } - variants.all { variant -> - JavaCompile javaCompile = variant.javaCompile - javaCompile.doLast { - String[] args = [ - "-showWeaveInfo", - "-1.5", - "-inpath", javaCompile.destinationDir.toString(), - "-aspectpath", javaCompile.classpath.asPath, - "-d", javaCompile.destinationDir.toString(), - "-classpath", javaCompile.classpath.asPath, - "-bootclasspath", project.android.bootClasspath.join(File.pathSeparator) - ] - log.debug "ajc args: " + Arrays.toString(args) + private void makeSureProjectIsAndroidAppOrLib(Project project) { + def hasApp = project.plugins.withType(AppPlugin) + def hasLib = project.plugins.withType(LibraryPlugin) - MessageHandler handler = new MessageHandler(true); - new Main().run(args, handler); - for (IMessage message : handler.getMessages(null, true)) { - switch (message.getKind()) { - case IMessage.ABORT: - case IMessage.ERROR: - case IMessage.FAIL: - log.error message.message, message.thrown - break; - case IMessage.WARNING: - log.warn message.message, message.thrown - break; - case IMessage.INFO: - log.info message.message, message.thrown - break; - case IMessage.DEBUG: - log.debug message.message, message.thrown - break; - } - } - } + if (!hasApp && !hasLib) { + throw new IllegalStateException("'android' or 'android-library' plugin required.") } } + } \ No newline at end of file diff --git a/let-plugin/src/main/groovy/com/canelmas/let/LetTransform.groovy b/let-plugin/src/main/groovy/com/canelmas/let/LetTransform.groovy new file mode 100644 index 0000000..d664380 --- /dev/null +++ b/let-plugin/src/main/groovy/com/canelmas/let/LetTransform.groovy @@ -0,0 +1,150 @@ +/* + * Copyright (C) 2017 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. + */ + +package com.canelmas.let + +import com.android.annotations.NonNull +import com.android.build.api.transform.* +import com.google.common.base.Joiner +import com.google.common.base.Strings +import com.google.common.collect.Lists +import com.google.common.collect.Sets +import org.aspectj.bridge.IMessage +import org.aspectj.bridge.MessageHandler +import org.aspectj.tools.ajc.Main +import org.gradle.api.GradleException +import org.gradle.api.Project +import org.gradle.api.logging.Logger + +class LetTransform extends Transform { + + private Project project + + LetTransform(Project project) { + this.project = project + } + + @Override + void transform(TransformInvocation transformInvocation) throws TransformException, InterruptedException, IOException { + + List files = Lists.newArrayList() + List classpathFiles = Lists.newArrayList() + Logger logger = project.logger + + TransformOutputProvider outputProvider = transformInvocation.getOutputProvider() + + // clean + outputProvider.deleteAll() + + // Referenced Inputs to classpath + for (TransformInput input : transformInvocation.getReferencedInputs()) { + input.directoryInputs.each { + classpathFiles.add(it.file) + } + + input.jarInputs.each { + classpathFiles.add(it.file) + } + } + + // Scope inputs + for (TransformInput input : transformInvocation.getInputs()) { + + for (DirectoryInput folder : input.directoryInputs) { + files.add(folder.file) + } + + for (JarInput jar : input.jarInputs) { + files.add(jar.file) + } + } + + // Evaluate class paths + final String inpath = Joiner.on(File.pathSeparator).join(files) + final String classpath = Joiner.on(File.pathSeparator).join( + classpathFiles.collect { it.absolutePath }) + final String bootpath = Joiner.on(File.pathSeparator).join(project.android.bootClasspath) + final File output = outputProvider.getContentLocation("main", outputTypes, Sets.immutableEnumSet(QualifiedContent.Scope.PROJECT), Format.DIRECTORY) + + // Weaving args + def args = [ + "-source", "1.6", + "-target", "1.6", + "-showWeaveInfo", + "-inpath", inpath, + "-d", output.absolutePath, + "-bootclasspath", bootpath] + + // Append classpath argument if any + if (!Strings.isNullOrEmpty(classpath)) { + args << '-classpath' + args << classpath + } + + // run aspectj + MessageHandler handler = new MessageHandler(true) + new Main().run(args as String[], handler) + + for (IMessage message : handler.getMessages(null, true)) { + + if (IMessage.ERROR.isSameOrLessThan(message.kind)) { + logger.error(message.message, message.thrown) + throw new GradleException(message.message, message.thrown) + } else if (IMessage.WARNING.isSameOrLessThan(message.kind)) { + logger.warn message.message + } else if (IMessage.DEBUG.isSameOrLessThan(message.kind)) { + logger.info message.message + } else { + logger.debug message.message + } + } + + } + + @NonNull + @Override + String getName() { + "let" + } + + @NonNull + @Override + Set getInputTypes() { + return Sets.immutableEnumSet(QualifiedContent.DefaultContentType.CLASSES) + } + + @NonNull + @Override + Set getScopes() { + return Sets.immutableEnumSet(QualifiedContent.Scope.PROJECT, + QualifiedContent.Scope.EXTERNAL_LIBRARIES) + } + + @Override + Set getReferencedScopes() { + return Sets.immutableEnumSet( + QualifiedContent.Scope.SUB_PROJECTS, + QualifiedContent.Scope.EXTERNAL_LIBRARIES, + QualifiedContent.Scope.PROVIDED_ONLY + ) + } + + @Override + boolean isIncremental() { + false + } + +} \ No newline at end of file diff --git a/let-runtime/build.gradle b/let-runtime/build.gradle index e21831c..c7640da 100644 --- a/let-runtime/build.gradle +++ b/let-runtime/build.gradle @@ -23,8 +23,8 @@ buildscript { } dependencies { - classpath 'org.aspectj:aspectjtools:1.8.6' - classpath 'com.github.dcendents:android-maven-plugin:1.2' + classpath deps.aspectjtools + classpath deps.androidMavenPlugin } } @@ -33,21 +33,21 @@ apply plugin: 'com.github.dcendents.android-maven' apply from: '../gradle-mvn-push.gradle' dependencies { - compile 'org.aspectj:aspectjrt:1.8.6' - compile project(':let-annotations') + implementation deps.aspectjrt + implementation project(':let-annotations') - compile deps.appCompatv7 - compile deps.supportAnnotations + implementation deps.appCompatv7 + implementation deps.supportAnnotations - testCompile 'junit:junit:4.12' + testImplementation deps.junit } android { - compileSdkVersion rootProject.ext.compileSdkVersion - buildToolsVersion rootProject.ext.buildToolsVersion + compileSdkVersion versions.compileSdkVersion + buildToolsVersion versions.buildToolsVersion defaultConfig { - minSdkVersion rootProject.ext.minSdkVersion + minSdkVersion versions.minSdkVersion } compileOptions { diff --git a/let-runtime/src/main/java/com/canelmas/let/DelayedTasks.java b/let-runtime/src/main/java/com/canelmas/let/DelayedTasks.java index 9b4ef5f..2a69c11 100644 --- a/let-runtime/src/main/java/com/canelmas/let/DelayedTasks.java +++ b/let-runtime/src/main/java/com/canelmas/let/DelayedTasks.java @@ -16,6 +16,8 @@ package com.canelmas.let; +import android.annotation.SuppressLint; + import org.aspectj.lang.ProceedingJoinPoint; import java.util.Collections; @@ -24,11 +26,9 @@ import java.util.Map; import java.util.concurrent.Callable; -/** - * Created by can on 27/10/15. - */ -public final class DelayedTasks { +final class DelayedTasks { + @SuppressLint("UseSparseArrays") private static Map tasks = Collections.synchronizedMap(new HashMap()); static Task get(final int requestCode) { diff --git a/let-runtime/src/main/java/com/canelmas/let/DeniedPermission.java b/let-runtime/src/main/java/com/canelmas/let/DeniedPermission.java index 1067056..097182c 100644 --- a/let-runtime/src/main/java/com/canelmas/let/DeniedPermission.java +++ b/let-runtime/src/main/java/com/canelmas/let/DeniedPermission.java @@ -16,9 +16,6 @@ package com.canelmas.let; -/** - * Created by can on 21/10/15. - */ public final class DeniedPermission { final String permission; diff --git a/let-runtime/src/main/java/com/canelmas/let/Let.java b/let-runtime/src/main/java/com/canelmas/let/Let.java index e031edc..d5eb9d7 100644 --- a/let-runtime/src/main/java/com/canelmas/let/Let.java +++ b/let-runtime/src/main/java/com/canelmas/let/Let.java @@ -22,9 +22,6 @@ import java.util.ArrayList; import java.util.List; -/** - * Created by can on 31/08/15. - */ public final class Let { /** @@ -60,7 +57,6 @@ public static void handle(Object source, int requestCode, String[] permissions, deniedPermissions.add(new DeniedPermission(permissions[k], neverAskAgain)); - Logger.log("\t" + permissions[k] + " denied" + (neverAskAgain ? " with Never Ask Again checked." : "")); } } @@ -68,7 +64,6 @@ public static void handle(Object source, int requestCode, String[] permissions, if (deniedPermissions.isEmpty()) { try { - Logger.log("<<< Required permissions granted"); delayedTask.execute(); } catch (Exception e) { throw new LetException("Delayed Execution Failed!", e); @@ -79,14 +74,11 @@ public static void handle(Object source, int requestCode, String[] permissions, RuntimePermissionListener listener = RuntimePermissionListener.class.isInstance(source) ? (RuntimePermissionListener) source : null; if (null != listener) { - Logger.log("<<< should handle denied permissions"); listener.onPermissionDenied(deniedPermissions); } } - } else { - Logger.log("No delayed task to execute."); } } diff --git a/let-runtime/src/main/java/com/canelmas/let/LetAspect.java b/let-runtime/src/main/java/com/canelmas/let/LetAspect.java index 850ea4d..464143d 100644 --- a/let-runtime/src/main/java/com/canelmas/let/LetAspect.java +++ b/let-runtime/src/main/java/com/canelmas/let/LetAspect.java @@ -22,9 +22,6 @@ import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; -/** - * Created by can on 31/08/15. - */ @Aspect public final class LetAspect { diff --git a/let-runtime/src/main/java/com/canelmas/let/LetContext.java b/let-runtime/src/main/java/com/canelmas/let/LetContext.java index 53233b9..a8da329 100644 --- a/let-runtime/src/main/java/com/canelmas/let/LetContext.java +++ b/let-runtime/src/main/java/com/canelmas/let/LetContext.java @@ -16,13 +16,11 @@ package com.canelmas.let; +import android.annotation.SuppressLint; import android.app.Activity; import android.app.Fragment; import android.support.v4.app.ActivityCompat; -/** - * Created by can on 30/10/15. - */ public final class LetContext { private final Object source; @@ -31,7 +29,8 @@ public LetContext(final Object source) { this.source = source; } - public void requestPermissions(String[] permissions, int requestCode) { + @SuppressLint("NewApi") + void requestPermissions(String[] permissions, int requestCode) { if (source instanceof Activity) { @@ -49,7 +48,7 @@ public void requestPermissions(String[] permissions, int requestCode) { } - public Activity getActivity() { + Activity getActivity() { if (source instanceof Activity) { diff --git a/let-runtime/src/main/java/com/canelmas/let/LetException.java b/let-runtime/src/main/java/com/canelmas/let/LetException.java index 6e430ae..ac4d788 100644 --- a/let-runtime/src/main/java/com/canelmas/let/LetException.java +++ b/let-runtime/src/main/java/com/canelmas/let/LetException.java @@ -16,9 +16,6 @@ package com.canelmas.let; -/** - * Created by can on 27/09/15. - */ final class LetException extends RuntimeException { public LetException(String detailMessage) { diff --git a/let-runtime/src/main/java/com/canelmas/let/Logger.java b/let-runtime/src/main/java/com/canelmas/let/Logger.java deleted file mode 100644 index f1deb1d..0000000 --- a/let-runtime/src/main/java/com/canelmas/let/Logger.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2015 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. - */ - -package com.canelmas.let; - -import android.util.Log; - -/** - * Created by can on 31/08/15. - */ -final class Logger { - - private static final String TAG = "Let"; - - private Logger() {} - - public static void log(String text) { - Log.d(TAG, text); - } - - public static void log(String text, Throwable t) { - Log.e(TAG, text, t); - } - -} diff --git a/let-runtime/src/main/java/com/canelmas/let/RuntimePermissionListener.java b/let-runtime/src/main/java/com/canelmas/let/RuntimePermissionListener.java index d6641f6..7c5549b 100644 --- a/let-runtime/src/main/java/com/canelmas/let/RuntimePermissionListener.java +++ b/let-runtime/src/main/java/com/canelmas/let/RuntimePermissionListener.java @@ -18,9 +18,6 @@ import java.util.List; -/** - * Created by can on 22/10/15. - */ public interface RuntimePermissionListener { void onShowPermissionRationale(final List permissionList, final RuntimePermissionRequest permissionRequest); diff --git a/let-runtime/src/main/java/com/canelmas/let/RuntimePermissionRequest.java b/let-runtime/src/main/java/com/canelmas/let/RuntimePermissionRequest.java index c1aba2d..b4fd5df 100644 --- a/let-runtime/src/main/java/com/canelmas/let/RuntimePermissionRequest.java +++ b/let-runtime/src/main/java/com/canelmas/let/RuntimePermissionRequest.java @@ -29,9 +29,6 @@ import java.util.List; import java.util.concurrent.atomic.AtomicInteger; -/** - * Created by can on 07/10/15. - */ public final class RuntimePermissionRequest { private static final AtomicInteger PERMISSIONS_REQUEST_CODE = new AtomicInteger(); @@ -39,7 +36,7 @@ public final class RuntimePermissionRequest { final Object source; final ProceedingJoinPoint joinPoint; - public RuntimePermissionRequest(ProceedingJoinPoint joinPoint, Object source) { + RuntimePermissionRequest(ProceedingJoinPoint joinPoint, Object source) { this.source = source; this.joinPoint = joinPoint; } @@ -48,7 +45,7 @@ public void retry() { proceed(true); } - protected Object proceed() { + Object proceed() { return proceed(false); } @@ -60,8 +57,6 @@ private Object proceed(final boolean retry) { final String[] permissionList = method.getAnnotation(AskPermission.class).value(); - Logger.log(">>> " + signature.getName() + "() requires " + permissionList.length + " permission"); - // Permissions to ask and to show rationales final List permissionsToAsk = new ArrayList<>(); final List permissionsToExplain = new ArrayList<>(); @@ -70,20 +65,15 @@ private Object proceed(final boolean retry) { for (String permission : permissionList) { - Logger.log("\t" + permission); - if (!isPermissionValid(permission)) { throw new LetException("Permission name not valid!"); } else { final int permissionResult = ContextCompat.checkSelfPermission(letContext.getActivity(), permission); - Logger.log("\t\talreadyGranted=" + String.valueOf(permissionResult != -1)); - if (permissionResult != PackageManager.PERMISSION_GRANTED) { final boolean showRationale = ActivityCompat.shouldShowRequestPermissionRationale(letContext.getActivity(), permission); - Logger.log("\t\tshowRationale=" + showRationale); if (showRationale && !retry) { permissionsToExplain.add(permission); @@ -107,8 +97,6 @@ private Object proceed(final boolean retry) { if (!permissionsToExplain.isEmpty()) { - Logger.log("<<< Should show Rationale"); - if (null != listener) { listener.onShowPermissionRationale(permissionsToExplain, new RuntimePermissionRequest(joinPoint, source)); } else { @@ -119,8 +107,6 @@ private Object proceed(final boolean retry) { } else if (!permissionsToAsk.isEmpty()) { - Logger.log("<<< Making permission request"); - final int requestCode = PERMISSIONS_REQUEST_CODE.getAndIncrement() & 0xff; DelayedTasks.add(new DelayedTasks.Task(permissionsToAsk, requestCode, joinPoint)); @@ -131,8 +117,6 @@ private Object proceed(final boolean retry) { } else { - Logger.log("<<< Permissions granted"); - try { return joinPoint.proceed(); } catch (Throwable t) { diff --git a/let-sample/build.gradle b/let-sample/build.gradle index 972c4b5..46b434b 100644 --- a/let-sample/build.gradle +++ b/let-sample/build.gradle @@ -13,34 +13,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + buildscript { repositories { jcenter() -// mavenLocal() -// maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + google() } dependencies { - classpath 'com.canelmas.let:let-plugin:0.1.11' + classpath 'com.canelmas.let:let-plugin:1.0.0-beta1' } } apply plugin: 'com.android.application' apply plugin: 'let' -repositories { - jcenter() -// mavenLocal() -// maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } -} - android { - compileSdkVersion rootProject.ext.compileSdkVersion - buildToolsVersion rootProject.ext.buildToolsVersion + compileSdkVersion versions.compileSdkVersion + buildToolsVersion versions.buildToolsVersion defaultConfig { applicationId "com.canelmas.let.sample" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion + minSdkVersion versions.minSdkVersion + targetSdkVersion versions.targetSdkVersion versionCode 1 versionName "1.0" } @@ -59,12 +53,10 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - - compile deps.appCompatv7 - compile deps.supportDesign + implementation fileTree(dir: 'libs', include: ['*.jar']) - testCompile 'junit:junit:4.12' + implementation deps.appCompatv7 + implementation deps.supportDesign - compile 'com.android.tools:annotations:24.3.0' + testImplementation deps.junit }