Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android x support #494

Merged
merged 17 commits into from
Jul 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android:
components:
- tools
- platform-tools
- build-tools-27.0.3
- android-26
- 28.0.0-rc2
- android-28
- extra-google-google_play_services
- extra-android-m2repository
- extra-android-support
Expand All @@ -20,7 +20,9 @@ jdk:
- oraclejdk8

before_install:
- echo "sdk.dir=$ANDROID_HOME" > local.properties
- echo "sdk.dir=$ANDROID_HOME" > local.properties
- mkdir "$ANDROID_HOME/licenses" || true
- cp ./android-sdk-licenses/* "$ANDROID_HOME/licenses/"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might not need this change because of bintray-release plugin

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀


branches:
except:
Expand Down
2 changes: 2 additions & 0 deletions android-sdk-licenses/android-sdk-license
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
8933bad161af4178b1185d1a37fbf41ea5269c55
d56f5187479451eabf01fb78af6dfcb131a6481e
1 change: 1 addition & 0 deletions android-sdk-licenses/android-sdk-preview-license
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
84831b9409646a918e30573bab4c9c91346d8abd
38 changes: 29 additions & 9 deletions annotation/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
apply plugin: 'java-library'
apply plugin: 'com.novoda.bintray-release'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'

targetCompatibility = JavaVersion.VERSION_1_6
sourceCompatibility = JavaVersion.VERSION_1_6

publish {
userOrg = USER
groupId = GROUP_ID
artifactId = ARTIFACT_ID_ANNOTATION
version = VERSION
desc = DESCRIPTION
website = WEBSITE
licences = LICENCES
publishing {
publications {
MyPublication(MavenPublication) {
from components.java
groupId GROUP_ID
artifactId ARTIFACT_ID_ANNOTATION
version VERSION
}
}
}

bintray {
publications = ['MyPublication']
user = bintrayUser
key = bintrayKey
dryRun = dryRun
pkg {
repo = REPO
userOrg = USER
name = ARTIFACT_ID_PROCESSOR
vcsUrl = VCS_URL
licenses = LICENCES
version {
name = VERSION
desc = DESCRIPTION
}
}
}

// Non-Android project: Artifactory Plugin adds only 1 publication
Expand Down
5 changes: 4 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
buildscript {
apply from: "${rootDir.absolutePath}/ext.gradle"

repositories {
mavenCentral()
google()
Expand All @@ -7,7 +9,8 @@ buildscript {
dependencies {
classpath "com.android.tools.build:gradle:$GRADLE_PLUGIN_VERSION"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_VERSION"
classpath "com.novoda:bintray-release:$BINTRAY_PLUGIN_VERSION"
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:$JFROG_PLUGIN_VERSION"
}
}
Expand Down
5 changes: 5 additions & 0 deletions ext.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ext {
bintrayUser = System.getenv("bintrayUser")
bintrayKey = System.getenv("bintrayKey")
dryRun = System.getenv("dryRun") == "true"
}
16 changes: 11 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ ARTIFACT_ID_LIBRARY = permissionsdispatcher
ARTIFACT_ID_PROCESSOR = permissionsdispatcher-processor
ARTIFACT_ID_ANNOTATION = permissionsdispatcher-annotation
VERSION = 4.0.0-SNAPSHOT
REPO = maven
DESCRIPTION = Annotation-based library for generating runtime permissions dispatcher.
WEBSITE = https://github.com/hotchemi/PermissionsDispatcher
VCS_URL = https://github.com/hotchemi/PermissionsDispatcher.git
LICENCES = ['Apache-2.0']

# Plugin versions
GRADLE_PLUGIN_VERSION = 3.1.0
GRADLE_PLUGIN_VERSION = 3.2.0-beta01
KOTLIN_VERSION = 1.2.50
BINTRAY_PLUGIN_VERSION = 0.8.0
CONFIG_PLUGIN_VERSION = 2.2.2
JFROG_PLUGIN_VERSION = 4.1.1
SUPPORT_LIBRARY_VERSION = 27.0.2
ANDROIDX_LIBRARY_VERSION= 1.0.0-alpha3
JAVAPOET_VERSION = 1.9.0
KOTLINPOET_VERSION = 0.6.0
JUNIT_VERSION = 4.12
Expand All @@ -29,11 +31,15 @@ ROBOLECTRIC_VERSION = 3.3.2
COMMONS_IO_VERSION = 2.6

# Android configuration
COMPILE_SDK_VERSION = android-26
BUILD_TOOLS_VERSION = 27.0.3
TARGET_SDK_VERSION = 25
COMPILE_SDK_VERSION = android-28
BUILD_TOOLS_VERSION = 28.0.0-rc2
TARGET_SDK_VERSION = 28
MIN_SDK_VERSION = 14

# Gradle parameters
org.gradle.daemon = true
org.gradle.jvmargs = -XX:MaxPermSize=1024m -XX:+CMSClassUnloadingEnabled -XX:+HeapDumpOnOutOfMemoryError -Xmx2048m

# AndroidX
android.useAndroidX = true
android.enableJetifier = true
2 changes: 1 addition & 1 deletion gradle/gradle-artifactory-upload.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ artifactory {
}
defaults {
publishArtifacts = true
publications(project.ext.publicationName)
publications([project.ext.publicationName])
}
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
59 changes: 48 additions & 11 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
group = GROUP_ID
version = VERSION

apply plugin: 'com.android.library'
apply plugin: 'com.novoda.bintray-release'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.github.dcendents.android-maven'

android {
compileSdkVersion COMPILE_SDK_VERSION
Expand All @@ -24,8 +28,10 @@ configurations {
}

dependencies {
implementation "com.android.support:support-compat:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:support-v13:$SUPPORT_LIBRARY_VERSION"
implementation "androidx.core:core:$ANDROIDX_LIBRARY_VERSION"
implementation "androidx.fragment:fragment:$ANDROIDX_LIBRARY_VERSION"
implementation "androidx.collection:collection:$ANDROIDX_LIBRARY_VERSION"
implementation "androidx.legacy:legacy-support-v13:$ANDROIDX_LIBRARY_VERSION"

testImplementation "junit:junit:$JUNIT_VERSION"
testImplementation "org.mockito:mockito-core:$MOCKITO_VERSION"
Expand All @@ -36,14 +42,45 @@ dependencies {
lintChecks project(path: ':lint', configuration: 'lintChecks')
}

publish {
userOrg = USER
groupId = GROUP_ID
artifactId = ARTIFACT_ID_LIBRARY
version = VERSION
desc = DESCRIPTION
website = WEBSITE
licences = LICENCES
bintray {
configurations = ['archives']
user = bintrayUser
key = bintrayKey
dryRun = dryRun

pkg {
repo = REPO
userOrg = USER
name = ARTIFACT_ID_LIBRARY
vcsUrl = VCS_URL
licenses = LICENCES
websiteUrl = WEBSITE
version {
name = VERSION
desc = DESCRIPTION
}
}
}

install {
repositories.mavenInstaller {
pom.project {
packaging 'aar'
name ARTIFACT_ID_LIBRARY
url WEBSITE

licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
scm {
connection "${WEBSITE}.git"
url WEBSITE
}
}
}
}

task sourcesJar(type: Jar) {
Expand Down
19 changes: 10 additions & 9 deletions library/src/main/java/permissions/dispatcher/PermissionUtils.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package permissions.dispatcher;

import android.app.Activity;
import android.app.Fragment;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Process;
import android.support.v13.app.FragmentCompat;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.AppOpsManagerCompat;
import android.support.v4.content.PermissionChecker;
import android.support.v4.util.SimpleArrayMap;

import androidx.collection.SimpleArrayMap;
import androidx.core.app.ActivityCompat;
import androidx.core.app.AppOpsManagerCompat;
import androidx.core.content.PermissionChecker;
import androidx.fragment.app.Fragment;
import androidx.legacy.app.FragmentCompat;

public final class PermissionUtils {
// Map of dangerous permissions introduced in later framework versions.
Expand Down Expand Up @@ -135,7 +136,7 @@ public static boolean shouldShowRequestPermissionRationale(Activity activity, St
* @param permissions permission list
* @return returns true if one of the permission is needed to show rationale.
*/
public static boolean shouldShowRequestPermissionRationale(android.support.v4.app.Fragment fragment, String... permissions) {
public static boolean shouldShowRequestPermissionRationale(Fragment fragment, String... permissions) {
for (String permission : permissions) {
if (fragment.shouldShowRequestPermissionRationale(permission)) {
return true;
Expand All @@ -152,7 +153,7 @@ public static boolean shouldShowRequestPermissionRationale(android.support.v4.ap
* @return returns true if one of the permission is needed to show rationale.
*/
@Deprecated
public static boolean shouldShowRequestPermissionRationale(Fragment fragment, String... permissions) {
public static boolean shouldShowRequestPermissionRationale(android.app.Fragment fragment, String... permissions) {
for (String permission : permissions) {
if (FragmentCompat.shouldShowRequestPermissionRationale(fragment, permission)) {
return true;
Expand All @@ -169,7 +170,7 @@ public static boolean shouldShowRequestPermissionRationale(Fragment fragment, St
* @param requestCode Request code connected to the permission request
*/
@Deprecated
public static void requestPermissions(Fragment fragment, String[] permissions, int requestCode) {
public static void requestPermissions(android.app.Fragment fragment, String[] permissions, int requestCode) {
FragmentCompat.requestPermissions(fragment, permissions, requestCode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Build;
import android.support.v4.content.PermissionChecker;

import org.junit.Before;
import org.junit.Test;
Expand All @@ -18,6 +17,8 @@
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

import androidx.core.content.PermissionChecker;

import static android.os.Build.VERSION_CODES.GINGERBREAD;
import static android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH;
import static android.os.Build.VERSION_CODES.JELLY_BEAN;
Expand Down
3 changes: 3 additions & 0 deletions lint/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ dependencies {
compile "com.android.tools.lint:lint-checks:$LINT_VERSION"
compile "com.android.tools.lint:lint:$LINT_VERSION"

implementation "androidx.core:core:$ANDROIDX_LIBRARY_VERSION"
implementation "androidx.fragment:fragment:$ANDROIDX_LIBRARY_VERSION"

testCompile "junit:junit:$JUNIT_VERSION"
testCompile "com.android.tools.lint:lint-tests:$LINT_VERSION"
testCompile "com.android.tools:testutils:$LINT_VERSION"
Expand Down
43 changes: 32 additions & 11 deletions processor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import permissions.dispatcher.AndroidJarDependencyPlugin
import permissions.dispatcher.AarToJarConversionPlugin

apply plugin: 'kotlin'
apply plugin: 'com.novoda.bintray-release'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
apply plugin: AndroidJarDependencyPlugin
apply plugin: AarToJarConversionPlugin

Expand Down Expand Up @@ -36,19 +37,39 @@ dependencies {
testCompile "commons-io:commons-io:$COMMONS_IO_VERSION"
testCompile androidJar()
testCompile files(Jvm.current().getToolsJar())
testCompileAar "com.android.support:support-v4:$SUPPORT_LIBRARY_VERSION"
testCompileAar "com.android.support:support-v13:$SUPPORT_LIBRARY_VERSION"
testCompileAar "androidx.legacy:legacy-support-v4:$ANDROIDX_LIBRARY_VERSION"
testCompileAar "androidx.legacy:legacy-support-v13:$ANDROIDX_LIBRARY_VERSION"
testCompileAar project(path: ":library", configuration: "default")
}

publish {
userOrg = USER
groupId = GROUP_ID
artifactId = ARTIFACT_ID_PROCESSOR
version = VERSION
desc = DESCRIPTION
website = WEBSITE
licences = LICENCES
publishing {
publications {
MyPublication(MavenPublication) {
from components.java
groupId GROUP_ID
artifactId ARTIFACT_ID_PROCESSOR
version VERSION
}
}
}

bintray {
publications = ['MyPublication']
user = bintrayUser
key = bintrayKey
dryRun = dryRun

pkg {
repo = REPO
userOrg = USER
name = ARTIFACT_ID_PROCESSOR
vcsUrl = VCS_URL
licenses = LICENCES
version {
name = VERSION
desc = DESCRIPTION
}
}
}

// Non-Android project: Artifactory Plugin adds only 1 publication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package permissions.dispatcher.processor.impl.java

import com.squareup.javapoet.ClassName
import com.squareup.javapoet.MethodSpec
import permissions.dispatcher.processor.util.*
import permissions.dispatcher.processor.util.typeMirrorOf
import javax.annotation.processing.Messager
import javax.lang.model.type.TypeMirror

Expand All @@ -11,7 +11,7 @@ import javax.lang.model.type.TypeMirror
*/
class JavaActivityProcessorUnit(messager: Messager) : JavaBaseProcessorUnit(messager) {

private val ACTIVITY_COMPAT = ClassName.get("android.support.v4.app", "ActivityCompat")
private val ACTIVITY_COMPAT = ClassName.get("androidx.core.app", "ActivityCompat")

override fun isDeprecated(): Boolean = false

Expand Down