Skip to content

Commit

Permalink
Migrate to AndroidX & Update dependencies (openid#508)
Browse files Browse the repository at this point in the history
* gradle update to 5.4.1

* gradle plugin update to 3.5.3

* minor bintray update

* bump compile sdk to 29

- this requires bumping build tools to 29
- also updating the gradlewrapper (again, fully) to 5.4.1

* Migrate to AndroidX

This required changes to checkstyle & javadocs gradle files
(perhaps because of jetifier? not sure tbh)
Also mockito now can mock all final classes

* Fix compiler warning

* update travis build tools to 29.0.2 to align with build.gradle

* update travis android sdk version to 29 to align with build.gradle
  • Loading branch information
blundell authored Jun 17, 2020
1 parent a773043 commit eed3eef
Show file tree
Hide file tree
Showing 65 changed files with 331 additions and 276 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
language: android
android:
components:
- build-tools-27.0.3
- android-27
- build-tools-29.0.2
- android-29
script:
- ./gradlew check jacoco assemble
- bash <(curl -s https://codecov.io/bash)
Expand Down
12 changes: 5 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,16 @@ android {
}
}

project.ext.glideVersion = '4.7.1'

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':library')
implementation "com.android.support:appcompat-v7:${rootProject.supportLibVersion}"
implementation "com.android.support:design:${rootProject.supportLibVersion}"
implementation "com.github.bumptech.glide:glide:${project.glideVersion}"
implementation "androidx.appcompat:appcompat:1.1.0"
implementation 'androidx.annotation:annotation:1.1.0'
implementation "com.google.android.material:material:1.0.0"
implementation "com.github.bumptech.glide:glide:4.10.0"
implementation 'com.squareup.okio:okio:1.14.1'
implementation 'joda-time:joda-time:2.10'

annotationProcessor "com.github.bumptech.glide:compiler:${project.glideVersion}"
annotationProcessor "com.github.bumptech.glide:compiler:4.10.0"
}

apply from: '../config/style.gradle'
2 changes: 1 addition & 1 deletion app/java/net/openid/appauthdemo/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

package net.openid.appauthdemo;

import android.support.v7.app.AppCompatDelegate;
import androidx.appcompat.app.AppCompatDelegate;

/**
* Application object; ensures that the support library is correctly configured for use of
Expand Down
7 changes: 4 additions & 3 deletions app/java/net/openid/appauthdemo/AuthStateManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@

import android.content.Context;
import android.content.SharedPreferences;
import android.support.annotation.AnyThread;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;

import androidx.annotation.AnyThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import net.openid.appauth.AuthState;
import net.openid.appauth.AuthorizationException;
import net.openid.appauth.AuthorizationResponse;
Expand Down
3 changes: 2 additions & 1 deletion app/java/net/openid/appauthdemo/BrowserSelectionAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@
import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import net.openid.appauth.browser.BrowserDescriptor;
import net.openid.appauth.browser.BrowserSelector;

Expand Down
6 changes: 4 additions & 2 deletions app/java/net/openid/appauthdemo/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import net.openid.appauth.connectivity.ConnectionBuilder;
import net.openid.appauth.connectivity.DefaultConnectionBuilder;

Expand All @@ -37,6 +38,7 @@
import java.lang.ref.WeakReference;
import java.nio.charset.Charset;


/**
* Reads and validates the demo app configuration from `res/raw/auth_config.json`. Configuration
* changes are detected by comparing the hash of the last known configuration to the read
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@

import android.annotation.SuppressLint;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import net.openid.appauth.Preconditions;
import net.openid.appauth.connectivity.ConnectionBuilder;

Expand Down
21 changes: 12 additions & 9 deletions app/java/net/openid/appauthdemo/LoginActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.AnyThread;
import android.support.annotation.ColorRes;
import android.support.annotation.MainThread;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.WorkerThread;
import android.support.customtabs.CustomTabsIntent;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
Expand All @@ -42,6 +33,17 @@
import android.widget.Spinner;
import android.widget.TextView;

import androidx.annotation.AnyThread;
import androidx.annotation.ColorRes;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
import androidx.appcompat.app.AppCompatActivity;
import androidx.browser.customtabs.CustomTabsIntent;

import com.google.android.material.snackbar.Snackbar;

import net.openid.appauth.AppAuthConfiguration;
import net.openid.appauth.AuthState;
import net.openid.appauth.AuthorizationException;
Expand Down Expand Up @@ -171,6 +173,7 @@ protected void onDestroy() {

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
displayAuthOptions();
if (resultCode == RESULT_CANCELED) {
displayAuthCancelled();
Expand Down
13 changes: 8 additions & 5 deletions app/java/net/openid/appauthdemo/TokenActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.MainThread;
import android.support.annotation.Nullable;
import android.support.annotation.WorkerThread;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.MainThread;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
import androidx.appcompat.app.AppCompatActivity;

import com.google.android.material.snackbar.Snackbar;

import net.openid.appauth.AppAuthConfiguration;
import net.openid.appauth.AuthState;
import net.openid.appauth.AuthorizationException;
Expand All @@ -54,6 +56,7 @@
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicReference;


/**
* Displays the authorized state of the user. This activity is provided with the outcome of the
* authorization flow, which it uses to negotiate the final authorized state,
Expand Down
14 changes: 7 additions & 7 deletions app/res/layout/activity_login.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
Expand All @@ -9,7 +9,7 @@
android:layout_height="match_parent"
android:fitsSystemWindows="true" >

<android.support.v4.widget.NestedScrollView
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
Expand Down Expand Up @@ -86,19 +86,19 @@
android:layout_marginTop="16dp"
style="@style/Base.TextAppearance.AppCompat.Subhead" />

<android.support.design.widget.TextInputLayout
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp">

<android.support.design.widget.TextInputEditText
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/login_hint_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:hint="@string/login_hint_value"/>

</android.support.design.widget.TextInputLayout>
</com.google.android.material.textfield.TextInputLayout>

<TextView
android:layout_width="match_parent"
Expand Down Expand Up @@ -170,5 +170,5 @@

</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
4 changes: 2 additions & 2 deletions app/res/layout/activity_token.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
Expand Down Expand Up @@ -192,4 +192,4 @@
</LinearLayout>
</LinearLayout>
</ScrollView>
</android.support.design.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
9 changes: 4 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'org.ajoberstar:gradle-git:1.7.2'
}
}
Expand Down Expand Up @@ -40,9 +40,8 @@ try {
}

project.ext.minSdkVersion = 16
project.ext.compileSdkVersion = 27
project.ext.buildToolsVersion = '27.0.3'
project.ext.supportLibVersion = '27.1.1'
project.ext.compileSdkVersion = 29
project.ext.buildToolsVersion = '29.0.2'

task showVersion {
doLast {
Expand Down
14 changes: 8 additions & 6 deletions config/coverage.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ task jacocoTestReport(type: JacocoReport, dependsOn: "testDebugUnitTest") {
html.enabled = true
}
// Class R is used, but usage will not be covered, so ignore this class from report
classDirectories = fileTree(
dir: 'build/intermediates/classes/debug',
excludes: ['**/BuildConfig.class']
)
sourceDirectories = files('java')
executionData = files('build/jacoco/testDebugUnitTest.exec')
afterEvaluate {
classDirectories = fileTree(
dir: 'build/intermediates/classes/debug',
excludes: ['**/BuildConfig.class']
)
sourceDirectories = files('java')
executionData = files('build/jacoco/testDebugUnitTest.exec')
}
}
26 changes: 14 additions & 12 deletions config/javadoc.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,29 @@ dependencies {
}

task androidJavadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
title = "AppAuth for Android"
classpath += files(project.android.getBootClasspath())
options {
doclet "org.jdrupes.mdoclet.MDoclet"
docletpath(*configurations.mdDoclet.files.asType(List))
links "http://docs.oracle.com/javase/7/docs/api/"
linksOffline "http://d.android.com/reference","${android.sdkDirectory}/docs/reference"
afterEvaluate {
source = android.sourceSets.main.java.srcDirs
title = "AppAuth for Android"
classpath += files(project.android.getBootClasspath())
options {
doclet "org.jdrupes.mdoclet.MDoclet"
docletpath(*configurations.mdDoclet.files.asType(List))
links "http://docs.oracle.com/javase/7/docs/api/"
linksOffline "http://d.android.com/reference", "${android.sdkDirectory}/docs/reference"
}
exclude '**/BuildConfig.java'
exclude '**/R.java'
}
exclude '**/BuildConfig.java'
exclude '**/R.java'
}

task javadocJar(type: Jar, dependsOn:androidJavadoc) {
task javadocJar(type: Jar, dependsOn: androidJavadoc) {
classifier = 'javadoc'
from androidJavadoc.destinationDir
}

afterEvaluate {
// fixes issue where javadoc can't find android symbols ref: http://stackoverflow.com/a/34572606
androidJavadoc.classpath += files(android.libraryVariants.collect { variant ->
variant.javaCompile.classpath.files
variant.javaCompileProvider.get().classpath.files
})
}
8 changes: 5 additions & 3 deletions config/style.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ checkstyle {
}

task checkAllSource(type: Checkstyle) {
source 'java'
include '**/*.java'
classpath = files project.configurations.compile.files
afterEvaluate {
source 'java'
include '**/*.java'
classpath = files project.configurations.compile.files
}
}

task failOnCheckstyleWarning {
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
android.enableJetifier=true
android.useAndroidX=true
org.gradle.daemon=true
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Fri Apr 06 13:27:13 PDT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
Loading

0 comments on commit eed3eef

Please sign in to comment.