Skip to content
This repository was archived by the owner on Jun 28, 2019. It is now read-only.

Commit 96fb796

Browse files
committed
[update]AndroidX対応(targetSDK, minSDK引き上げ)
1 parent 43845db commit 96fb796

File tree

12 files changed

+118
-112
lines changed

12 files changed

+118
-112
lines changed

build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
buildscript {
44
ext.kotlin_version = '1.3.21'
55
ext.versions = [
6-
'compileSdk': 27,
7-
'minSdk': 16,
8-
'targetSdk': 27,
9-
'supportLibrary': '27.1.1',
6+
'compileSdk' : 28,
7+
'minSdk' : 21,
8+
'targetSdk' : 28,
9+
'appcompat' : '1.0.2',
1010
'constraintLayout': '1.1.3'
1111
]
1212
repositories {
1313
google()
1414
jcenter()
1515
}
1616
dependencies {
17-
classpath 'com.android.tools.build:gradle:3.4.0'
17+
classpath 'com.android.tools.build:gradle:3.4.1'
1818
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1919
}
2020
}

gradle.properties

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,11 @@ org.gradle.jvmargs=-Xmx1536m
1111
# This option should only be used with decoupled projects. More details, visit
1212
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1313
# org.gradle.parallel=true
14+
# AndroidX package structure to make it clearer which packages are bundled with the
15+
# Android operating system, and which are packaged with your app's APK
16+
# https://developer.android.com/topic/libraries/support-library/androidx-rn
17+
android.useAndroidX=true
18+
# Automatically convert third-party libraries to use AndroidX
19+
android.enableJetifier=true
20+
# Kotlin code style for this project: "official" or "obsolete":
21+
kotlin.code.style=official

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip

sdk-example-java/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ android {
1010
versionCode 1
1111
versionName "1.0"
1212

13-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1414

1515
}
1616

@@ -30,12 +30,12 @@ repositories {
3030
dependencies {
3131
implementation fileTree(dir: 'libs', include: ['*.jar'])
3232

33-
implementation "com.android.support:appcompat-v7:${versions.supportLibrary}"
34-
implementation "com.android.support.constraint:constraint-layout:${versions.constraintLayout}"
33+
implementation "androidx.appcompat:appcompat:${versions.appcompat}"
34+
implementation "androidx.constraintlayout:constraintlayout:${versions.constraintLayout}"
3535

3636
implementation 'jp.studyplus.android.sdk:studyplus-android-sdk2:2.2.1'
3737

3838
testImplementation 'junit:junit:4.12'
39-
androidTestImplementation 'com.android.support.test:runner:1.0.2'
40-
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
39+
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
40+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
4141
}

sdk-example-java/src/androidTest/java/jp/studyplus/android/sdk_example_java/ExampleInstrumentedTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package jp.studyplus.android.sdk_example_java;
22

33
import android.content.Context;
4-
import android.support.test.InstrumentationRegistry;
5-
import android.support.test.runner.AndroidJUnit4;
6-
4+
import androidx.test.core.app.ApplicationProvider;
5+
import androidx.test.ext.junit.runners.AndroidJUnit4;
76
import org.junit.Test;
87
import org.junit.runner.RunWith;
98

10-
import static org.junit.Assert.*;
9+
import static org.junit.Assert.assertEquals;
1110

1211
/**
1312
* Instrumented test, which will execute on an Android device.
@@ -19,7 +18,7 @@ public class ExampleInstrumentedTest {
1918
@Test
2019
public void useAppContext() {
2120
// Context of the app under test.
22-
Context appContext = InstrumentationRegistry.getTargetContext();
21+
Context appContext = ApplicationProvider.getApplicationContext();
2322

2423
assertEquals("jp.studyplus.android.sdk_example_java", appContext.getPackageName());
2524
}

sdk-example-java/src/main/java/jp/studyplus/android/sdk_example_java/MainActivity.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
import android.app.Activity;
44
import android.content.ActivityNotFoundException;
55
import android.content.Intent;
6-
import android.support.annotation.Nullable;
7-
import android.support.v7.app.AppCompatActivity;
86
import android.os.Bundle;
97
import android.view.View;
108
import android.widget.Button;
119
import android.widget.TextView;
1210
import android.widget.Toast;
13-
11+
import androidx.annotation.Nullable;
12+
import androidx.appcompat.app.AppCompatActivity;
1413
import jp.studyplus.android.sdk.Studyplus;
1514
import jp.studyplus.android.sdk.record.StudyRecord;
1615
import jp.studyplus.android.sdk.record.StudyRecordBuilder;
Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:tools="http://schemas.android.com/tools"
4-
android:layout_width="match_parent"
5-
android:layout_height="match_parent"
6-
tools:context="jp.studyplus.android.sdk_example_kt.MainActivity">
2+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
tools:context="jp.studyplus.android.sdk_example_kt.MainActivity">
77

88
<LinearLayout
9-
android:layout_width="match_parent"
10-
android:layout_height="match_parent"
11-
android:orientation="vertical"
12-
android:gravity="center_horizontal"
13-
android:padding="24dp">
9+
android:layout_width="match_parent"
10+
android:layout_height="match_parent"
11+
android:gravity="center_horizontal"
12+
android:orientation="vertical"
13+
android:padding="24dp">
1414

1515
<TextView
16-
android:id="@+id/auth_status"
17-
android:layout_width="match_parent"
18-
android:layout_height="wrap_content"
19-
android:padding="8dp"
20-
android:textStyle="bold"
21-
tools:text="認証済み" />
16+
android:id="@+id/auth_status"
17+
android:layout_width="match_parent"
18+
android:layout_height="wrap_content"
19+
android:padding="8dp"
20+
android:textStyle="bold"
21+
tools:text="認証済み"/>
2222

2323
<Space
24-
android:layout_width="match_parent"
25-
android:layout_height="24dp" />
24+
android:layout_width="match_parent"
25+
android:layout_height="24dp"/>
2626

2727
<Button
28-
android:id="@+id/start_auth"
29-
android:layout_width="match_parent"
30-
android:layout_height="wrap_content"
31-
android:padding="8dp"
32-
android:text="@string/start_auth_button" />
28+
android:id="@+id/start_auth"
29+
android:layout_width="match_parent"
30+
android:layout_height="wrap_content"
31+
android:padding="8dp"
32+
android:text="@string/start_auth_button"/>
3333

3434
<Space
35-
android:layout_width="match_parent"
36-
android:layout_height="24dp" />
35+
android:layout_width="match_parent"
36+
android:layout_height="24dp"/>
3737

3838
<Button
39-
android:id="@+id/post_study_record"
40-
android:layout_width="match_parent"
41-
android:layout_height="wrap_content"
42-
android:padding="8dp"
43-
android:text="@string/post_study_record_button" />
39+
android:id="@+id/post_study_record"
40+
android:layout_width="match_parent"
41+
android:layout_height="wrap_content"
42+
android:padding="8dp"
43+
android:text="@string/post_study_record_button"/>
4444

4545
</LinearLayout>
4646

47-
</android.support.constraint.ConstraintLayout>
47+
</androidx.constraintlayout.widget.ConstraintLayout>

sdk-example-kt/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ android {
1212
targetSdkVersion versions.targetSdk
1313
versionCode 1
1414
versionName "1.0"
15-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1616
}
1717
buildTypes {
1818
release {
@@ -29,12 +29,12 @@ repositories {
2929
dependencies {
3030
implementation fileTree(include: ['*.jar'], dir: 'libs')
3131
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
32-
implementation "com.android.support:appcompat-v7:${versions.supportLibrary}"
33-
implementation "com.android.support.constraint:constraint-layout:${versions.constraintLayout}"
32+
implementation "androidx.appcompat:appcompat:${versions.appcompat}"
33+
implementation "androidx.constraintlayout:constraintlayout:${versions.constraintLayout}"
3434

3535
implementation 'jp.studyplus.android.sdk:studyplus-android-sdk2:2.2.1'
3636

3737
testImplementation 'junit:junit:4.12'
38-
androidTestImplementation 'com.android.support.test:runner:1.0.2'
39-
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
38+
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
39+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
4040
}
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package jp.studyplus.android.sdk_example_kt
22

3-
import android.support.test.InstrumentationRegistry
4-
import android.support.test.runner.AndroidJUnit4
5-
3+
import android.content.Context
4+
import androidx.test.core.app.ApplicationProvider
5+
import androidx.test.ext.junit.runners.AndroidJUnit4
6+
import org.junit.Assert.assertEquals
67
import org.junit.Test
78
import org.junit.runner.RunWith
89

9-
import org.junit.Assert.*
10-
1110
/**
1211
* Instrumented test, which will execute on an Android device.
1312
*
@@ -18,7 +17,7 @@ class ExampleInstrumentedTest {
1817
@Test
1918
fun useAppContext() {
2019
// Context of the app under test.
21-
val appContext = InstrumentationRegistry.getTargetContext()
20+
val appContext = ApplicationProvider.getApplicationContext<Context>()
2221
assertEquals("jp.studyplus.android.sdk", appContext.packageName)
2322
}
2423
}

sdk-example-kt/src/main/java/jp/studyplus/android/sdk_example_kt/MainActivity.kt

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import android.app.Activity
44
import android.content.ActivityNotFoundException
55
import android.content.Intent
66
import android.os.Bundle
7-
import android.support.v7.app.AppCompatActivity
87
import android.view.View
98
import android.widget.TextView
109
import android.widget.Toast
10+
import androidx.appcompat.app.AppCompatActivity
1111
import jp.studyplus.android.sdk.Studyplus
1212
import jp.studyplus.android.sdk.record.StudyRecordBuilder
1313

@@ -22,8 +22,9 @@ class MainActivity : AppCompatActivity() {
2222
setContentView(R.layout.activity_main)
2323

2424
Studyplus.instance.setup(
25-
getString(R.string.consumer_key),
26-
getString(R.string.consumer_secret))
25+
getString(R.string.consumer_key),
26+
getString(R.string.consumer_secret)
27+
)
2728

2829
findViewById<View>(R.id.start_auth)?.apply {
2930
setOnClickListener {
@@ -39,23 +40,23 @@ class MainActivity : AppCompatActivity() {
3940
findViewById<View>(R.id.post_study_record)?.apply {
4041
setOnClickListener {
4142
val record = StudyRecordBuilder()
42-
.setComment("勉強した!!!")
43-
.setAmountTotal(30)
44-
.setDurationSeconds(2 * 60)
45-
.build()
43+
.setComment("勉強した!!!")
44+
.setAmountTotal(30)
45+
.setDurationSeconds(2 * 60)
46+
.build()
4647
Studyplus.instance.postRecord(this@MainActivity, record,
47-
object : Studyplus.Companion.OnPostRecordListener {
48-
override fun onResult(success: Boolean, recordId: Long?, throwable: Throwable?) {
49-
if (success) {
50-
Toast.makeText(context, "Post Study Record!! ($recordId)", Toast.LENGTH_LONG).show()
51-
} else {
52-
throwable?.apply {
53-
Toast.makeText(context, "error!!", Toast.LENGTH_LONG).show()
54-
printStackTrace()
55-
}
48+
object : Studyplus.Companion.OnPostRecordListener {
49+
override fun onResult(success: Boolean, recordId: Long?, throwable: Throwable?) {
50+
if (success) {
51+
Toast.makeText(context, "Post Study Record!! ($recordId)", Toast.LENGTH_LONG).show()
52+
} else {
53+
throwable?.apply {
54+
Toast.makeText(context, "error!!", Toast.LENGTH_LONG).show()
55+
printStackTrace()
5656
}
5757
}
58-
})
58+
}
59+
})
5960
}
6061
}
6162
}
@@ -64,7 +65,7 @@ class MainActivity : AppCompatActivity() {
6465
super.onResume()
6566

6667
val authStatusText = findViewById<TextView>(R.id.auth_status)
67-
authStatusText.text = when(Studyplus.instance.isAuthenticated(this)) {
68+
authStatusText.text = when (Studyplus.instance.isAuthenticated(this)) {
6869
true -> getString(R.string.status_authenticated)
6970
else -> getString(R.string.status_unauthenticated)
7071
}

0 commit comments

Comments
 (0)