Skip to content

Commit

Permalink
Merge pull request #222 from shiraji/221_fix_for_1.6_type
Browse files Browse the repository at this point in the history
Support Java 1.6
  • Loading branch information
hotchemi committed Nov 25, 2016
2 parents 50d9def + d4a2366 commit b90696c
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 65 deletions.
9 changes: 4 additions & 5 deletions art/MainActivityPermissionsDispatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
package permissions.dispatcher.sample;

import android.support.v4.app.ActivityCompat;
import java.lang.Override;
import java.lang.String;
import java.lang.ref.WeakReference;
import permissions.dispatcher.PermissionRequest;
import permissions.dispatcher.PermissionUtils;

import java.lang.ref.WeakReference;

final class MainActivityPermissionsDispatcher {
private static final int REQUEST_SHOWCAMERA = 0;

Expand Down Expand Up @@ -78,7 +77,7 @@ private static final class ShowCameraPermissionRequest implements PermissionRequ
private final WeakReference<MainActivity> weakTarget;

private ShowCameraPermissionRequest(MainActivity target) {
this.weakTarget = new WeakReference<>(target);
this.weakTarget = new WeakReference<MainActivity>(target);
}

@Override
Expand All @@ -100,7 +99,7 @@ private static final class ShowContactsPermissionRequest implements PermissionRe
private final WeakReference<MainActivity> weakTarget;

private ShowContactsPermissionRequest(MainActivity target) {
this.weakTarget = new WeakReference<>(target);
this.weakTarget = new WeakReference<MainActivity>(target);
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}

packagingOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public final class PermissionUtils {
private static final SimpleArrayMap<String, Integer> MIN_SDK_PERMISSIONS;

static {
MIN_SDK_PERMISSIONS = new SimpleArrayMap<>(8);
MIN_SDK_PERMISSIONS = new SimpleArrayMap<String, Integer>(8);
MIN_SDK_PERMISSIONS.put("com.android.voicemail.permission.ADD_VOICEMAIL", 14);
MIN_SDK_PERMISSIONS.put("android.permission.BODY_SENSORS", 20);
MIN_SDK_PERMISSIONS.put("android.permission.READ_CALL_LOG", 16);
Expand Down
4 changes: 2 additions & 2 deletions lint/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'java'

targetCompatibility = JavaVersion.VERSION_1_7
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_6
sourceCompatibility = JavaVersion.VERSION_1_6

configurations {
lintChecks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class CallNeedsPermissionDetector extends Detector implements Detector.Ja
Severity.ERROR,
new Implementation(CallNeedsPermissionDetector.class, EnumSet.of(Scope.ALL_JAVA_FILES)));

static List<String> generatedClassNames = new ArrayList<>();
static List<String> generatedClassNames = new ArrayList<String>();

@Override
public AstVisitor createJavaVisitor(JavaContext context) {
Expand All @@ -54,7 +54,7 @@ private static class AnnotationChecker extends ForwardingAstVisitor {
private AnnotationChecker(JavaContext context) {
this.context = context;

matchingAnnotationTypeNames = new HashSet<>();
matchingAnnotationTypeNames = new HashSet<String>();
matchingAnnotationTypeNames.add("RuntimePermissions");
matchingAnnotationTypeNames.add("permissions.dispatcher.RuntimePermissions");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ static class AnnotationChecker extends ForwardingAstVisitor {
private AnnotationChecker(JavaContext context) {
this.context = context;

needsPermissionAnnotations = new HashSet<>();
onShowRationaleAnnotations = new HashSet<>();
needsPermissionAnnotations = new HashSet<Annotation>();
onShowRationaleAnnotations = new HashSet<Annotation>();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ abstract class BaseProcessorUnit : ProcessorUnit {
val constructorBuilder = MethodSpec.constructorBuilder()
.addModifiers(Modifier.PRIVATE)
.addParameter(targetType, targetParam)
.addStatement("this.\$L = new WeakReference<>(\$N)", weakFieldName, targetParam)
.addStatement("this.\$L = new WeakReference<\$T>(\$N)", weakFieldName, targetType, targetParam)
needsMethod.parameters.forEach {
val fieldName = it.simpleString()
constructorBuilder
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ protected String[] getExpectSource() {
" private static final class ShowCameraPermissionRequest implements PermissionRequest {",
" private final WeakReference<MyFragment> weakTarget;",
" private ShowCameraPermissionRequest(MyFragment target) {",
" this.weakTarget = new WeakReference<>(target);",
" this.weakTarget = new WeakReference<MyFragment>(target);",
" }",
" @Override",
" public void proceed() {",
Expand Down Expand Up @@ -328,7 +328,7 @@ protected String[] getExpectSource() {
" private static final class ShowCameraPermissionRequest implements PermissionRequest {",
" private final WeakReference<MyFragment> weakTarget;",
" private ShowCameraPermissionRequest(MyFragment target) {",
" this.weakTarget = new WeakReference<>(target);",
" this.weakTarget = new WeakReference<MyFragment>(target);",
" }",
" @Override",
" public void proceed() {",
Expand Down Expand Up @@ -427,7 +427,7 @@ protected String[] getExpectSource() {
" private static final class ShowCameraPermissionRequest implements PermissionRequest {",
" private final WeakReference<MyFragment> weakTarget;",
" private ShowCameraPermissionRequest(MyFragment target) {",
" this.weakTarget = new WeakReference<>(target);",
" this.weakTarget = new WeakReference<MyFragment>(target);",
" }",
" @Override",
" public void proceed() {",
Expand Down Expand Up @@ -723,7 +723,7 @@ protected String[] getExpectSource() {
" private static final class ShowCameraPermissionRequest implements PermissionRequest {",
" private final WeakReference<MyFragment> weakTarget;",
" private ShowCameraPermissionRequest(MyFragment target) {",
" this.weakTarget = new WeakReference<>(target);",
" this.weakTarget = new WeakReference<MyFragment>(target);",
" }",
" @Override",
" public void proceed() {",
Expand Down Expand Up @@ -808,7 +808,7 @@ protected String[] getExpectSource() {
" private final WeakReference<MyFragment> weakTarget;",
" private final int[] values;",
" private ShowCameraPermissionRequest(MyFragment target, int[] values) {",
" this.weakTarget = new WeakReference<>(target);",
" this.weakTarget = new WeakReference<MyFragment>(target);",
" this.values = values;",
" }",
" @Override",
Expand Down Expand Up @@ -906,7 +906,7 @@ protected String[] getExpectSource() {
" private final WeakReference<MyFragment> weakTarget;",
" private final int[] values;",
" private ShowCameraPermissionRequest(MyFragment target, int[] values) {",
" this.weakTarget = new WeakReference<>(target);",
" this.weakTarget = new WeakReference<MyFragment>(target);",
" this.values = values;",
" }",
" @Override",
Expand Down Expand Up @@ -1003,7 +1003,7 @@ protected String[] getExpectSource() {
" private final WeakReference<MyFragment> weakTarget;",
" private final List<String> values;",
" private ShowCameraPermissionRequest(MyFragment target, List<String> values) {",
" this.weakTarget = new WeakReference<>(target);",
" this.weakTarget = new WeakReference<MyFragment>(target);",
" this.values = values;",
" }",
" @Override",
Expand Down Expand Up @@ -1110,7 +1110,7 @@ protected String[] getExpectSource() {
" private final WeakReference<MyFragment> weakTarget;",
" private final int[] values;",
" private ShowCameraPermissionRequest(MyFragment target, int[] values) {",
" this.weakTarget = new WeakReference<>(target);",
" this.weakTarget = new WeakReference<MyFragment>(target);",
" this.values = values;",
" }",
" @Override",
Expand Down Expand Up @@ -1301,7 +1301,7 @@ protected String[] getExpectSource() {
" private static final class ShowCameraPermissionRequest implements PermissionRequest {",
" private final WeakReference<MyFragment> weakTarget;",
" private ShowCameraPermissionRequest(MyFragment target) {",
" this.weakTarget = new WeakReference<>(target);",
" this.weakTarget = new WeakReference<MyFragment>(target);",
" }",
" @Override",
" public void proceed() {",
Expand All @@ -1316,7 +1316,7 @@ protected String[] getExpectSource() {
" private static final class ShowCamera2PermissionRequest implements PermissionRequest {",
" private final WeakReference<MyFragment> weakTarget;",
" private ShowCamera2PermissionRequest(MyFragment target) {",
" this.weakTarget = new WeakReference<>(target);",
" this.weakTarget = new WeakReference<MyFragment>(target);",
" }",
" @Override",
" public void proceed() {",
Expand Down Expand Up @@ -1513,7 +1513,7 @@ protected String[] getExpectSource() {
" private static final class ShowCameraPermissionRequest implements PermissionRequest {",
" private final WeakReference<MyFragment> weakTarget;",
" private ShowCameraPermissionRequest(MyFragment target) {",
" this.weakTarget = new WeakReference<>(target);",
" this.weakTarget = new WeakReference<MyFragment>(target);",
" }",
" @Override",
" public void proceed() {",
Expand All @@ -1531,7 +1531,7 @@ protected String[] getExpectSource() {
" private static final class ShowCamera2PermissionRequest implements PermissionRequest {",
" private final WeakReference<MyFragment> weakTarget;",
" private ShowCamera2PermissionRequest(MyFragment target) {",
" this.weakTarget = new WeakReference<>(target);",
" this.weakTarget = new WeakReference<MyFragment>(target);",
" }",
" @Override",
" public void proceed() {",
Expand Down Expand Up @@ -1636,7 +1636,7 @@ protected String[] getExpectSource() {
" private static final class WriteSettingsPermissionRequest implements PermissionRequest {",
" private final WeakReference<MyFragment> weakTarget;",
" private WriteSettingsPermissionRequest(MyFragment target) {",
" this.weakTarget = new WeakReference<>(target);",
" this.weakTarget = new WeakReference<MyFragment>(target);",
" }",
" @Override",
" public void proceed() {",
Expand Down Expand Up @@ -1742,7 +1742,7 @@ protected String[] getExpectSource() {
" private static final class SystemAlertWindowPermissionRequest implements PermissionRequest {",
" private final WeakReference<MyFragment> weakTarget;",
" private SystemAlertWindowPermissionRequest(MyFragment target) {",
" this.weakTarget = new WeakReference<>(target);",
" this.weakTarget = new WeakReference<MyFragment>(target);",
" }",
" @Override",
" public void proceed() {",
Expand Down

0 comments on commit b90696c

Please sign in to comment.