Skip to content

Commit 91b9ff7

Browse files
authored
Merge pull request #8 from riyhs/submission-2
add api key
2 parents 7859241 + 00347da commit 91b9ff7

File tree

6 files changed

+35
-13
lines changed

6 files changed

+35
-13
lines changed

.circleci/config.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ version: 2.1
22

33
orbs:
44
android: circleci/[email protected]
5-
5+
6+
before_script:
7+
- touch apikey.properties
8+
69
jobs:
710
build:
811
executor: android/android

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
.externalNativeBuild
1414
.cxx
1515
local.properties
16+
apikey.properties

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ android {
1515
applicationId "com.riyaldi.gamekuy"
1616
minSdkVersion 23
1717
targetSdkVersion 30
18-
versionCode 2
19-
versionName "1.1"
18+
versionCode 3
19+
versionName "1.2"
2020

2121
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2222
}
15.8 MB
Binary file not shown.

core/build.gradle

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@ plugins {
66
}
77
apply from: '../shared_dependencies.gradle'
88

9+
def apikeyPropertiesFile = rootProject.file("apikey.properties")
10+
def apikeyProperties = new Properties()
11+
apikeyProperties.load(new FileInputStream(apikeyPropertiesFile))
12+
913
android {
1014
compileSdkVersion 30
1115
buildToolsVersion "30.0.3"
1216

1317
defaultConfig {
1418
minSdkVersion 23
1519
targetSdkVersion 30
16-
versionCode 2
17-
versionName "1.1"
20+
versionCode 3
21+
versionName "1.2"
1822

1923
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2024
consumerProguardFiles "consumer-rules.pro"
@@ -27,6 +31,7 @@ android {
2731
buildConfigField("String", "PIN_B", "\"sha256/hS5jJ4P+iQUErBkvoWBQOd1T7VOAYlOVegvv1iMzpxA=\"")
2832
buildConfigField("String", "PIN_C", "\"sha256/R+V29DqDnO269dFhAAB5jMlZHepWpDGuoejXJjprh7A=\"")
2933
buildConfigField("String", "PIN_D", "\"sha256/FEzVOUp4dF3gI0ZVPRJhFbSJVXR+uQmMH65xhs1glH4=\"")
34+
buildConfigField("String", "APIKEY", apikeyProperties['APIKEY'])
3035
}
3136

3237
buildTypes {

core/src/main/java/com/riyaldi/core/di/NetworkModule.kt

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import dagger.Module
66
import dagger.Provides
77
import dagger.hilt.InstallIn
88
import dagger.hilt.android.components.ApplicationComponent
9-
import okhttp3.CertificatePinner
10-
import okhttp3.OkHttpClient
9+
import okhttp3.*
1110
import okhttp3.logging.HttpLoggingInterceptor
1211
import retrofit2.Retrofit
1312
import retrofit2.converter.gson.GsonConverterFactory
@@ -29,12 +28,26 @@ class NetworkModule {
2928
)
3029
.build()
3130

32-
return OkHttpClient.Builder()
33-
.addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
34-
.connectTimeout(120, TimeUnit.SECONDS)
35-
.readTimeout(120, TimeUnit.SECONDS)
36-
.certificatePinner(certificatePinner)
37-
.build()
31+
val httpClient = OkHttpClient.Builder()
32+
httpClient.addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
33+
httpClient.connectTimeout(120, TimeUnit.SECONDS)
34+
httpClient.readTimeout(120, TimeUnit.SECONDS)
35+
httpClient.certificatePinner(certificatePinner)
36+
httpClient.addInterceptor(object : Interceptor {
37+
override fun intercept(chain: Interceptor.Chain): Response {
38+
val original: Request = chain.request()
39+
val originalHttpUrl: HttpUrl = original.url
40+
val url = originalHttpUrl.newBuilder()
41+
.addQueryParameter("key", BuildConfig.APIKEY)
42+
.build()
43+
val requestBuilder: Request.Builder = original.newBuilder()
44+
.url(url)
45+
val request: Request = requestBuilder.build()
46+
return chain.proceed(request)
47+
}
48+
})
49+
50+
return httpClient.build()
3851
}
3952

4053
@Provides

0 commit comments

Comments
 (0)