Skip to content

Commit ef311f9

Browse files
authored
Merge pull request #21 from studyplus/feature/target_sdk_29
TargetSDK 29
2 parents cad7b03 + f232c86 commit ef311f9

File tree

9 files changed

+27
-66
lines changed

9 files changed

+27
-66
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Add it in your root build.gradle at the end of repositories:
2424

2525
```groovy
2626
dependencies {
27-
implementation 'com.github.studyplus:Studyplus-Android-SDK:2.5.2'
27+
implementation 'com.github.studyplus:Studyplus-Android-SDK:2.6.0'
2828
}
2929
```
3030

build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
buildscript {
44
ext {
5-
kotlin_version = '1.3.41'
6-
kotlin_cotoutines_version = '1.2.1'
5+
kotlin_version = '1.3.50'
6+
kotlin_cotoutines_version = '1.3.1'
77
}
88
ext.versions = [
9-
'compileSdk' : 28,
9+
'compileSdk' : 29,
1010
'minSdk' : 21,
11-
'targetSdk' : 28,
11+
'targetSdk' : 29,
1212
'annotation' : '1.1.0',
1313
'core_ktx' : '1.1.0',
1414
'appcompat' : '1.1.0',
@@ -19,7 +19,7 @@ buildscript {
1919
jcenter()
2020
}
2121
dependencies {
22-
classpath 'com.android.tools.build:gradle:3.4.2'
22+
classpath 'com.android.tools.build:gradle:3.5.0'
2323
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
2424
}
2525
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Thu Apr 25 19:30:00 JST 2019
1+
#Wed Sep 25 14:10:00 JST 2019
22
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.2.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

studyplus-android-sdk/build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ android {
77
minSdkVersion versions.minSdk
88
targetSdkVersion versions.targetSdk
99

10-
consumerProguardFiles 'lib-proguard-rules.txt'
11-
1210
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1311
}
1412

@@ -47,7 +45,7 @@ dependencies {
4745
implementation "androidx.annotation:annotation:$versions.annotation"
4846
implementation "androidx.core:core-ktx:$versions.core_ktx"
4947

50-
def okhttp = "3.14.2"
48+
def okhttp = "4.2.0"
5149
implementation "com.squareup.okhttp3:okhttp:$okhttp"
5250

5351
testImplementation 'junit:junit:4.12'

studyplus-android-sdk/lib-proguard-rules.txt

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<string name="app_package_name" translatable="false">jp.studyplus.android.app.debug</string>
4+
</resources>

studyplus-android-sdk/src/main/java/jp/studyplus/android/sdk/internal/api/ApiService.kt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@ import jp.studyplus.android.sdk.BuildConfig
44
import kotlinx.coroutines.CompletableDeferred
55
import kotlinx.coroutines.Deferred
66
import okhttp3.*
7+
import okhttp3.MediaType.Companion.toMediaTypeOrNull
8+
import okhttp3.RequestBody.Companion.toRequestBody
79
import org.json.JSONObject
810
import java.io.IOException
911

1012
internal class ApiService(private val client: OkHttpClient) {
1113
fun post(auth: String, json: String): Deferred<Long?> {
1214
val body = createPostBody(json)
1315
val request = Request.Builder()
14-
.header("Accept", HEADER_JSON)
15-
.header("Content-type", HEADER_JSON)
16-
.addHeader("Authorization", auth)
17-
.url("$ENDPOINT/v1/study_records")
18-
.post(body)
19-
.build()
16+
.header("Accept", HEADER_JSON)
17+
.header("Content-type", HEADER_JSON)
18+
.addHeader("Authorization", auth)
19+
.url("$ENDPOINT/v1/study_records")
20+
.post(body)
21+
.build()
2022

2123
return execute(client.newCall(request))
2224
}
@@ -27,10 +29,9 @@ internal class ApiService(private val client: OkHttpClient) {
2729
}
2830
}
2931

30-
private val JSON_MEDIA_TYPE = MediaType.parse("application/json; charset=utf-8")
32+
private val JSON_MEDIA_TYPE = "application/json; charset=utf-8".toMediaTypeOrNull()
3133

32-
internal fun createPostBody(json: String) =
33-
RequestBody.create(JSON_MEDIA_TYPE, json)
34+
internal fun createPostBody(json: String) = json.toRequestBody(JSON_MEDIA_TYPE)
3435

3536
internal fun execute(call: Call): Deferred<Long?> {
3637
val deferred = CompletableDeferred<Long?>()
@@ -51,7 +52,7 @@ internal fun execute(call: Call): Deferred<Long?> {
5152

5253
override fun onResponse(call: Call, response: Response) {
5354
if (response.isSuccessful) {
54-
val parsedJson = JSONObject(response.body()?.string() ?: EMPTY_JSON)
55+
val parsedJson = JSONObject(response.body?.string() ?: EMPTY_JSON)
5556
val recordId = parsedJson.optLong(RECORD_ID, INVALID_RECORD_ID)
5657

5758
if (recordId != INVALID_RECORD_ID) {

studyplus-android-sdk/src/main/java/jp/studyplus/android/sdk/internal/auth/AuthTransit.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ constructor(
4545

4646
private fun isInstalledStudyplus(context: Context): Boolean {
4747
val packages = context.packageManager.getInstalledApplications(PackageManager.GET_META_DATA)
48-
return packages.any { it.packageName == "jp.studyplus.android.app" }
48+
val appName = context.getString(R.string.app_package_name)
49+
return packages.any { it.packageName == appName }
4950
}
5051
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
<resources>
22
<string name="app_custom_scheme" translatable="false">studyplus://auth/external/start</string>
3+
<string name="app_package_name" translatable="false">jp.studyplus.android.app</string>
34
</resources>

0 commit comments

Comments
 (0)