Skip to content

Commit ced60e3

Browse files
authored
Merge pull request #56 from jobot0/migrate_to_android_q
Migrate to Android Q
2 parents a3700cc + 818c339 commit ced60e3

35 files changed

Lines changed: 197 additions & 186 deletions

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ android {
2222
dependencies {
2323
implementation fileTree(include: ['*.jar'], dir: 'libs')
2424
implementation project(':trustkit')
25-
implementation "com.android.support:appcompat-v7:$rootProject.libVersions.android.appCompat"
26-
implementation "com.android.support:design:$rootProject.libVersions.android.appCompat"
25+
implementation "androidx.appcompat:appcompat:$rootProject.libVersions.androidx.appcompat"
26+
implementation "com.google.android.material:material:$rootProject.libVersions.google.material"
2727
}

app/src/main/java/com/datatheorem/android/trustkit/demoapp/DemoMainActivity.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import android.content.IntentFilter;
44
import android.os.AsyncTask;
55
import android.os.Bundle;
6-
import android.support.v4.content.LocalBroadcastManager;
7-
import android.support.v7.app.AppCompatActivity;
8-
import android.support.v7.widget.Toolbar;
6+
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
7+
import androidx.appcompat.app.AppCompatActivity;
8+
import androidx.appcompat.widget.Toolbar;
99
import android.util.Log;
1010
import android.view.Menu;
1111
import android.view.MenuItem;
@@ -25,15 +25,16 @@
2525
public class DemoMainActivity extends AppCompatActivity {
2626

2727
protected static final String DEBUG_TAG = "TrustKit-Demo";
28-
private static final PinningFailureReportBroadcastReceiver pinningFailureReportBroadcastReceiver = new PinningFailureReportBroadcastReceiver();
28+
private static final PinningFailureReportBroadcastReceiver pinningFailureReportBroadcastReceiver
29+
= new PinningFailureReportBroadcastReceiver();
2930

3031
@Override
3132
protected void onCreate(Bundle savedInstanceState) {
3233
super.onCreate(savedInstanceState);
3334
setContentView(R.layout.activity_demo_main);
34-
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
35+
Toolbar toolbar = findViewById(R.id.toolbar);
3536
setSupportActionBar(toolbar);
36-
TextView textView = (TextView) findViewById(R.id.textview);
37+
TextView textView = findViewById(R.id.textview);
3738

3839
// Initialize TrustKit with the default path for the Network Security Configuration which is
3940
// res/xml/network_security_config.xml
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<android.support.design.widget.CoordinatorLayout
2+
<androidx.coordinatorlayout.widget.CoordinatorLayout
33
xmlns:android="http://schemas.android.com/apk/res/android"
44
xmlns:app="http://schemas.android.com/apk/res-auto"
55
xmlns:tools="http://schemas.android.com/tools"
@@ -8,28 +8,28 @@
88
android:fitsSystemWindows="true"
99
tools:applicationContext="com.datatheorem.android.trustkit.demoapp.DemoMainActivity">
1010

11-
<android.support.design.widget.AppBarLayout
11+
<com.google.android.material.appbar.AppBarLayout
1212
android:layout_width="match_parent"
1313
android:layout_height="wrap_content"
1414
android:theme="@style/AppTheme.AppBarOverlay">
1515

16-
<android.support.v7.widget.Toolbar
16+
<androidx.appcompat.widget.Toolbar
1717
android:id="@+id/toolbar"
1818
android:layout_width="match_parent"
1919
android:layout_height="?attr/actionBarSize"
2020
android:background="?attr/colorPrimary"
2121
app:popupTheme="@style/AppTheme.PopupOverlay"/>
2222

23-
</android.support.design.widget.AppBarLayout>
23+
</com.google.android.material.appbar.AppBarLayout>
2424

2525
<include layout="@layout/content_demo_main"/>
2626

27-
<android.support.design.widget.FloatingActionButton
27+
<com.google.android.material.floatingactionbutton.FloatingActionButton
2828
android:id="@+id/fab"
2929
android:layout_width="wrap_content"
3030
android:layout_height="wrap_content"
3131
android:layout_gravity="bottom|end"
3232
android:layout_margin="@dimen/fab_margin"
3333
android:src="@android:drawable/ic_dialog_email"/>
3434

35-
</android.support.design.widget.CoordinatorLayout>
35+
</androidx.coordinatorlayout.widget.CoordinatorLayout>

build.gradle

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,19 @@ ext{
5151
android: '1.10.19'
5252
],
5353
dexmaker : '1.4',
54-
android : [
55-
appCompat : '28.0.0',
56-
testRunner: '0.5'
54+
androidx : [
55+
annotation: '1.0.0',
56+
test: '1.1.0',
57+
legacySupport: '1.0.0',
58+
appcompat: '1.0.2',
59+
preference: '1.0.0'
5760
],
5861
testing: [
5962
okhttp3: '3.11.0',
6063
'playServicesBase': '11.0.0',
64+
],
65+
google: [
66+
material: '1.0.0'
6167
]
6268
]
6369

demoappkotlin/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ android {
2525

2626
dependencies {
2727
implementation fileTree(include: ['*.jar'], dir: 'libs')
28-
implementation "com.android.support:appcompat-v7:$libVersions.android.appCompat"
29-
implementation "com.android.support:design:$libVersions.android.appCompat"
28+
implementation "androidx.appcompat:appcompat:$rootProject.libVersions.androidx.appcompat"
29+
implementation "com.google.android.material:material:$rootProject.libVersions.google.material"
3030
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
3131
implementation project(path: ':trustkit')
3232
}

demoappkotlin/src/main/java/com/datatheorem/android/trustkit/demoappkotlin/DemoMainActivity.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package com.datatheorem.android.trustkit.demoappkotlin
33
import android.content.IntentFilter
44
import android.os.AsyncTask
55
import android.os.Bundle
6-
import android.support.v4.content.LocalBroadcastManager
7-
import android.support.v7.app.AppCompatActivity
8-
import android.support.v7.widget.Toolbar
6+
import androidx.localbroadcastmanager.content.LocalBroadcastManager
7+
import androidx.appcompat.app.AppCompatActivity
8+
import androidx.appcompat.widget.Toolbar
99
import android.util.Log
1010
import android.view.Menu
1111
import android.view.MenuItem
@@ -44,7 +44,7 @@ class DemoMainActivity : AppCompatActivity() {
4444
pinningFailureReportBroadcastReceiver = PinningFailureReportBroadcastReceiver()
4545
val intentFilter = IntentFilter(BackgroundReporter.REPORT_VALIDATION_EVENT)
4646
LocalBroadcastManager.getInstance(this.applicationContext)
47-
.registerReceiver(pinningFailureReportBroadcastReceiver,intentFilter)
47+
.registerReceiver(pinningFailureReportBroadcastReceiver,intentFilter)
4848
}
4949

5050
override fun onDestroy() {
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools"
44
android:layout_width="match_parent"
55
android:layout_height="match_parent"
66
android:fitsSystemWindows="true"
77
tools:applicationContext="com.datatheorem.android.trustkit.demoapp.DemoMainActivity">
88

9-
<android.support.design.widget.AppBarLayout
9+
<com.google.android.material.appbar.AppBarLayout
1010
android:layout_width="match_parent"
1111
android:layout_height="wrap_content"
1212
>
1313

14-
<android.support.v7.widget.Toolbar
14+
<androidx.appcompat.widget.Toolbar
1515
android:id="@+id/toolbar"
1616
android:layout_width="match_parent"
1717
android:layout_height="50dp"
1818
android:background="@color/colorPrimary"
1919
/>
2020

21-
</android.support.design.widget.AppBarLayout>
21+
</com.google.android.material.appbar.AppBarLayout>
2222

2323
<include layout="@layout/content_demo_main"/>
2424

25-
<android.support.design.widget.FloatingActionButton
25+
<com.google.android.material.floatingactionbutton.FloatingActionButton
2626
android:id="@+id/fab"
2727
android:layout_width="wrap_content"
2828
android:layout_height="wrap_content"
2929
android:layout_gravity="bottom|end"
3030
android:layout_margin="16dp"
3131
android:src="@android:drawable/ic_dialog_email"/>
3232

33-
</android.support.design.widget.CoordinatorLayout>
33+
</androidx.coordinatorlayout.widget.CoordinatorLayout>

gradle.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@
1515
# When configured, Gradle will run in incubating parallel mode.
1616
# This option should only be used with decoupled projects. More details, visit
1717
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18-
# org.gradle.parallel=true
18+
# org.gradle.parallel=true
19+
android.enableJetifier=true
20+
android.useAndroidX=true

trustkit/build.gradle

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ repositories {
2626
mavenCentral()
2727
}
2828
dependencies {
29-
implementation "com.android.support:support-annotations:$rootProject.libVersions.android.appCompat"
30-
implementation "com.android.support:support-v4:$rootProject.libVersions.android.appCompat"
29+
implementation "androidx.annotation:annotation:$rootProject.libVersions.androidx.annotation"
30+
implementation "androidx.legacy:legacy-support-v4:$rootProject.libVersions.androidx.legacySupport"
31+
implementation "androidx.preference:preference:$rootProject.libVersions.androidx.preference"
3132

3233
androidTestImplementation "junit:junit:$rootProject.libVersions.junit"
33-
androidTestImplementation "com.android.support.test:runner:$rootProject.libVersions.android.testRunner"
34-
androidTestImplementation "com.android.support.test:rules:$rootProject.libVersions.android.testRunner"
34+
androidTestImplementation "androidx.test:runner:$rootProject.libVersions.androidx.test"
35+
androidTestImplementation "androidx.test:rules:$rootProject.libVersions.androidx.test"
3536
androidTestImplementation "org.mockito:mockito-core:$rootProject.libVersions.mockito.android"
3637
androidTestImplementation "org.awaitility:awaitility:3.1.6"
3738
androidTestImplementation "com.crittercism.dexmaker:dexmaker:$rootProject.libVersions.dexmaker"
@@ -48,7 +49,7 @@ android {
4849
minSdkVersion toolVersions.android.minSdk
4950
versionCode trustkitVersionCode
5051
versionName trustkitVersionName
51-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
52+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
5253
}
5354
}
5455

trustkit/src/androidTest/java/com/datatheorem/android/trustkit/HttpLibrariesTest.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import static org.mockito.Matchers.eq;
55
import static org.mockito.Mockito.verify;
66

7+
import androidx.test.platform.app.InstrumentationRegistry;
78
import android.os.Build;
8-
import android.support.annotation.RequiresApi;
9-
import android.support.test.InstrumentationRegistry;
10-
import android.support.test.runner.AndroidJUnit4;
9+
import androidx.annotation.RequiresApi;
10+
1111
import com.datatheorem.android.trustkit.pinning.PinningValidationResult;
1212
import com.datatheorem.android.trustkit.reporting.BackgroundReporter;
1313
import java.io.IOException;
@@ -23,12 +23,10 @@
2323
import okhttp3.Request;
2424
import org.junit.Before;
2525
import org.junit.Test;
26-
import org.junit.runner.RunWith;
2726
import org.mockito.Mock;
2827
import org.mockito.MockitoAnnotations;
2928

3029
@SuppressWarnings("unchecked")
31-
@RunWith(AndroidJUnit4.class)
3230
public class HttpLibrariesTest {
3331

3432
@Mock
@@ -58,7 +56,7 @@ public void testHttpsUrlConnectionWithTrustKit() throws MalformedURLException {
5856
}
5957
// Initialize TrustKit
6058
TestableTrustKit.initializeWithNetworkSecurityConfiguration(
61-
InstrumentationRegistry.getContext(), reporter);
59+
InstrumentationRegistry.getInstrumentation().getContext(), reporter);
6260

6361
// Test a connection
6462
HttpsURLConnection connection = null;
@@ -109,7 +107,7 @@ public void testHttpsUrlConnectionWithTrustKitApiLevelUnder17() throws IOExcepti
109107
}
110108
// Initialize TrustKit
111109
TestableTrustKit.initializeWithNetworkSecurityConfiguration(
112-
InstrumentationRegistry.getContext(), reporter);
110+
InstrumentationRegistry.getInstrumentation().getContext(), reporter);
113111

114112
// Test a connection
115113
// Although the pins are invalid, the connection should succeed because TrustKit's pinning
@@ -145,7 +143,7 @@ public void testOkhttp3WithTrustKit() throws MalformedURLException {
145143
}
146144
// Initialize TrustKit
147145
TestableTrustKit.initializeWithNetworkSecurityConfiguration(
148-
InstrumentationRegistry.getContext(), reporter);
146+
InstrumentationRegistry.getInstrumentation().getContext(), reporter);
149147

150148
// Test a connection
151149
boolean didReceiveHandshakeError = false;
@@ -191,7 +189,7 @@ public void testOkhttp3WithTrustKitOldBuilder() throws MalformedURLException {
191189
}
192190
// Initialize TrustKit
193191
TestableTrustKit.initializeWithNetworkSecurityConfiguration(
194-
InstrumentationRegistry.getContext(), reporter);
192+
InstrumentationRegistry.getInstrumentation().getContext(), reporter);
195193

196194
// Test a connection
197195
boolean didReceiveHandshakeError = false;

0 commit comments

Comments
 (0)