From c929d6083f385fad9355a94f1e2310f541f3549c Mon Sep 17 00:00:00 2001 From: bingbong Date: Thu, 8 Apr 2021 17:38:24 +0900 Subject: [PATCH 01/16] hotfix : OkHttpOverride error --- .../com/iamport/sdk/domain/di/apiModule.kt | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/sdk/src/main/java/com/iamport/sdk/domain/di/apiModule.kt b/sdk/src/main/java/com/iamport/sdk/domain/di/apiModule.kt index 9154c13b..14a956e2 100644 --- a/sdk/src/main/java/com/iamport/sdk/domain/di/apiModule.kt +++ b/sdk/src/main/java/com/iamport/sdk/domain/di/apiModule.kt @@ -16,21 +16,21 @@ import retrofit2.converter.gson.GsonConverterFactory import java.util.concurrent.TimeUnit -fun provideOkHttpClient(context: Context?): OkHttpClient? { - return context?.let { - OkHttpClient.Builder() - .connectTimeout(20, TimeUnit.MINUTES) - .readTimeout(20, TimeUnit.SECONDS) - .writeTimeout(20, TimeUnit.SECONDS).apply { - if (BuildConfig.DEBUG) { - addInterceptor(HttpLoggingInterceptor().apply { - level = HttpLoggingInterceptor.Level.BODY - }) - } - } - .build() - } ?: run { null } -} +//fun provideOkHttpClient(context: Context?): OkHttpClient? { +// return context?.let { +// OkHttpClient.Builder() +// .connectTimeout(20, TimeUnit.MINUTES) +// .readTimeout(20, TimeUnit.SECONDS) +// .writeTimeout(20, TimeUnit.SECONDS).apply { +// if (BuildConfig.DEBUG) { +// addInterceptor(HttpLoggingInterceptor().apply { +// level = HttpLoggingInterceptor.Level.BODY +// }) +// } +// } +// .build() +// } ?: run { null } +//} fun provideIamportApi(gson: Gson, client: OkHttpClient?): IamportApi { @@ -63,14 +63,16 @@ fun provideChaiApi(isStaging: Boolean, gson: Gson, client: OkHttpClient?): ChaiA .create(ChaiApi::class.java) } -@OptIn(KoinApiExtension::class) -val httpClientModule = module { - single { provideOkHttpClient(get()) } -} +//@OptIn(KoinApiExtension::class) +//val httpClientModule = module { +// single { provideOkHttpClient(get()) } +//} @OptIn(KoinApiExtension::class) val apiModule = module { - single { provideIamportApi(get(), get()) } +// single { provideIamportApi(get(), get()) } +// single { provideNiceApi(get(), get()) } + single { provideIamportApi(get(), null) } // single { provideChaiApi(false, get(), get()) } - single { provideNiceApi(get(), get()) } + single { provideNiceApi(get(), null) } } \ No newline at end of file From 31f7a97f4bcc024977b8ece5764faccaaff5a513 Mon Sep 17 00:00:00 2001 From: bingbong Date: Thu, 8 Apr 2021 17:38:49 +0900 Subject: [PATCH 02/16] update gradle --- sdk/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/build.gradle b/sdk/build.gradle index c547a9dd..1cad5644 100644 --- a/sdk/build.gradle +++ b/sdk/build.gradle @@ -10,8 +10,8 @@ android { defaultConfig { minSdkVersion 16 targetSdkVersion 30 - versionCode 210408001 // yymmdd000 - versionName "0.0.6-dev24" // prod(x.y.z), dev(x.y.z-dev00), poc(x.y.z-poc00) + versionCode 210408002 // yymmdd000 + versionName "0.0.6-dev25" // prod(x.y.z), dev(x.y.z-dev00), poc(x.y.z-poc00) multiDexEnabled true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" From 5446a7aef83c050ca3be1d6489c27adf3b4a8784 Mon Sep 17 00:00:00 2001 From: bingbong Date: Thu, 8 Apr 2021 17:54:26 +0900 Subject: [PATCH 03/16] hotfix : not use module --- sdk/src/main/java/com/iamport/sdk/domain/core/Iamport.kt | 4 ++-- sdk/src/main/java/com/iamport/sdk/domain/di/apiModule.kt | 4 +--- .../java/com/iamport/sdk/domain/strategy/chai/ChaiStrategy.kt | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/sdk/src/main/java/com/iamport/sdk/domain/core/Iamport.kt b/sdk/src/main/java/com/iamport/sdk/domain/core/Iamport.kt index 2630c1e6..a50b8034 100644 --- a/sdk/src/main/java/com/iamport/sdk/domain/core/Iamport.kt +++ b/sdk/src/main/java/com/iamport/sdk/domain/core/Iamport.kt @@ -15,7 +15,7 @@ import com.iamport.sdk.domain.di.IamportKoinContext import com.iamport.sdk.domain.di.IamportKoinContext.koinApp import com.iamport.sdk.domain.di.apiModule import com.iamport.sdk.domain.di.appModule -import com.iamport.sdk.domain.di.httpClientModule +//import com.iamport.sdk.domain.di.httpClientModule import com.iamport.sdk.domain.service.ChaiService import com.iamport.sdk.domain.utils.CONST import com.iamport.sdk.domain.utils.Event @@ -87,7 +87,7 @@ object Iamport { // TODO Application 사용하지 않는 방안 모색 fun createWithKoin(app: Application, koinApp: KoinApplication? = null) { - val modules = listOf(httpClientModule, apiModule, appModule) + val modules = listOf(apiModule, appModule) IamportKoinContext.koinApp = if (koinApp == null) { stopKoin() startKoin { diff --git a/sdk/src/main/java/com/iamport/sdk/domain/di/apiModule.kt b/sdk/src/main/java/com/iamport/sdk/domain/di/apiModule.kt index 14a956e2..ac4ab361 100644 --- a/sdk/src/main/java/com/iamport/sdk/domain/di/apiModule.kt +++ b/sdk/src/main/java/com/iamport/sdk/domain/di/apiModule.kt @@ -64,14 +64,12 @@ fun provideChaiApi(isStaging: Boolean, gson: Gson, client: OkHttpClient?): ChaiA } //@OptIn(KoinApiExtension::class) -//val httpClientModule = module { +//val httpClientModule = module(override = true) { // single { provideOkHttpClient(get()) } //} @OptIn(KoinApiExtension::class) val apiModule = module { -// single { provideIamportApi(get(), get()) } -// single { provideNiceApi(get(), get()) } single { provideIamportApi(get(), null) } // single { provideChaiApi(false, get(), get()) } single { provideNiceApi(get(), null) } diff --git a/sdk/src/main/java/com/iamport/sdk/domain/strategy/chai/ChaiStrategy.kt b/sdk/src/main/java/com/iamport/sdk/domain/strategy/chai/ChaiStrategy.kt index 95b472cc..9f8a3182 100644 --- a/sdk/src/main/java/com/iamport/sdk/domain/strategy/chai/ChaiStrategy.kt +++ b/sdk/src/main/java/com/iamport/sdk/domain/strategy/chai/ChaiStrategy.kt @@ -385,7 +385,7 @@ open class ChaiStrategy : BaseStrategy() { if (code == 0) { data.run { prepareData = this - chaiApi = provideChaiApi(mode == CHAI.MODE, get(), get()) // mode 에 따라 chaiApi 생성 + chaiApi = provideChaiApi(mode == CHAI.MODE, get(), null) // mode 에 따라 chaiApi 생성 returnUrl?.let { bus.chaiUri.value = Event(it) } } } else { From f308940c7d03ac3e2b00ec8016b37f840e5d42f9 Mon Sep 17 00:00:00 2001 From: bingbong Date: Thu, 8 Apr 2021 17:55:26 +0900 Subject: [PATCH 04/16] update gradle --- sdk/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/build.gradle b/sdk/build.gradle index 1cad5644..0af5133e 100644 --- a/sdk/build.gradle +++ b/sdk/build.gradle @@ -10,8 +10,8 @@ android { defaultConfig { minSdkVersion 16 targetSdkVersion 30 - versionCode 210408002 // yymmdd000 - versionName "0.0.6-dev25" // prod(x.y.z), dev(x.y.z-dev00), poc(x.y.z-poc00) + versionCode 210408003 // yymmdd000 + versionName "0.0.6-dev26" // prod(x.y.z), dev(x.y.z-dev00), poc(x.y.z-poc00) multiDexEnabled true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" From 065fc4bff5465865f5ac37b2960efb62a86669dc Mon Sep 17 00:00:00 2001 From: bingbong Date: Thu, 8 Apr 2021 18:15:37 +0900 Subject: [PATCH 05/16] hotfix : not use koin gson --- .../java/com/iamport/sdk/domain/di/apiModule.kt | 16 ++++++++-------- .../java/com/iamport/sdk/domain/di/appModule.kt | 2 +- .../sdk/domain/strategy/base/BaseStrategy.kt | 3 ++- .../domain/strategy/base/BaseWebViewStrategy.kt | 3 ++- .../sdk/domain/strategy/chai/ChaiStrategy.kt | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/sdk/src/main/java/com/iamport/sdk/domain/di/apiModule.kt b/sdk/src/main/java/com/iamport/sdk/domain/di/apiModule.kt index ac4ab361..e4888ea4 100644 --- a/sdk/src/main/java/com/iamport/sdk/domain/di/apiModule.kt +++ b/sdk/src/main/java/com/iamport/sdk/domain/di/apiModule.kt @@ -32,31 +32,31 @@ import java.util.concurrent.TimeUnit // } ?: run { null } //} -fun provideIamportApi(gson: Gson, client: OkHttpClient?): IamportApi { +fun provideIamportApi(client: OkHttpClient?): IamportApi { return Retrofit.Builder() .baseUrl(CONST.IAMPORT_PROD_URL) - .addConverterFactory(GsonConverterFactory.create(gson)).apply { + .addConverterFactory(GsonConverterFactory.create(Gson())).apply { client?.let { client(it) } } .build() .create(IamportApi::class.java) } -fun provideNiceApi(gson: Gson, client: OkHttpClient?): NiceApi { +fun provideNiceApi(client: OkHttpClient?): NiceApi { return Retrofit.Builder() .baseUrl("${CONST.IAMPORT_DETECT_URL}/") - .addConverterFactory(GsonConverterFactory.create(gson)).apply { + .addConverterFactory(GsonConverterFactory.create(Gson())).apply { client?.let { client(it) } } .build() .create(NiceApi::class.java) } -fun provideChaiApi(isStaging: Boolean, gson: Gson, client: OkHttpClient?): ChaiApi { +fun provideChaiApi(isStaging: Boolean, client: OkHttpClient?): ChaiApi { return Retrofit.Builder() .baseUrl(if (isStaging) CONST.CHAI_SERVICE_STAGING_URL else CONST.CHAI_SERVICE_URL) - .addConverterFactory(GsonConverterFactory.create(gson)).apply { + .addConverterFactory(GsonConverterFactory.create(Gson())).apply { client?.let { client(it) } } .build() @@ -70,7 +70,7 @@ fun provideChaiApi(isStaging: Boolean, gson: Gson, client: OkHttpClient?): ChaiA @OptIn(KoinApiExtension::class) val apiModule = module { - single { provideIamportApi(get(), null) } + single { provideIamportApi(null) } // single { provideChaiApi(false, get(), get()) } - single { provideNiceApi(get(), null) } + single { provideNiceApi(null) } } \ No newline at end of file diff --git a/sdk/src/main/java/com/iamport/sdk/domain/di/appModule.kt b/sdk/src/main/java/com/iamport/sdk/domain/di/appModule.kt index d4ff87a5..50a4e019 100644 --- a/sdk/src/main/java/com/iamport/sdk/domain/di/appModule.kt +++ b/sdk/src/main/java/com/iamport/sdk/domain/di/appModule.kt @@ -22,7 +22,7 @@ val appModule = module { viewModel { MainViewModel(get(), get()) } viewModel { WebViewModel(get(), get()) } single { IamportReceiver() } - single { Gson() } +// single { Gson() } single { StrategyRepository() } single { WebViewLiveDataEventBus() } diff --git a/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/BaseStrategy.kt b/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/BaseStrategy.kt index 0cd12f84..fa95d448 100644 --- a/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/BaseStrategy.kt +++ b/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/BaseStrategy.kt @@ -13,7 +13,8 @@ import org.koin.core.component.inject @KoinApiExtension abstract class BaseStrategy : IStrategy, IamportKoinComponent { - protected val gson: Gson by inject() +// protected val gson: Gson by inject() + protected val gson = Gson() protected val bus: NativeLiveDataEventBus by inject() lateinit var payment: Payment diff --git a/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/BaseWebViewStrategy.kt b/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/BaseWebViewStrategy.kt index 40e69a02..b751766c 100644 --- a/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/BaseWebViewStrategy.kt +++ b/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/BaseWebViewStrategy.kt @@ -20,7 +20,8 @@ import org.koin.core.component.inject @KoinApiExtension open class BaseWebViewStrategy : WebViewClient(), IStrategy, IamportKoinComponent { - protected val gson: Gson by inject() +// protected val gson: Gson by inject() + protected val gson = Gson() protected val bus: WebViewLiveDataEventBus by inject() lateinit var payment: Payment diff --git a/sdk/src/main/java/com/iamport/sdk/domain/strategy/chai/ChaiStrategy.kt b/sdk/src/main/java/com/iamport/sdk/domain/strategy/chai/ChaiStrategy.kt index 9f8a3182..7d45ef8c 100644 --- a/sdk/src/main/java/com/iamport/sdk/domain/strategy/chai/ChaiStrategy.kt +++ b/sdk/src/main/java/com/iamport/sdk/domain/strategy/chai/ChaiStrategy.kt @@ -385,7 +385,7 @@ open class ChaiStrategy : BaseStrategy() { if (code == 0) { data.run { prepareData = this - chaiApi = provideChaiApi(mode == CHAI.MODE, get(), null) // mode 에 따라 chaiApi 생성 + chaiApi = provideChaiApi(mode == CHAI.MODE, null) // mode 에 따라 chaiApi 생성 returnUrl?.let { bus.chaiUri.value = Event(it) } } } else { From be3d8e34ecebe07394686df5ccc492206fbb7dbb Mon Sep 17 00:00:00 2001 From: bingbong Date: Thu, 8 Apr 2021 18:18:40 +0900 Subject: [PATCH 06/16] update gradle --- sdk/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/build.gradle b/sdk/build.gradle index 0af5133e..dedcaabe 100644 --- a/sdk/build.gradle +++ b/sdk/build.gradle @@ -10,8 +10,8 @@ android { defaultConfig { minSdkVersion 16 targetSdkVersion 30 - versionCode 210408003 // yymmdd000 - versionName "0.0.6-dev26" // prod(x.y.z), dev(x.y.z-dev00), poc(x.y.z-poc00) + versionCode 210408004 // yymmdd000 + versionName "0.0.6-dev27" // prod(x.y.z), dev(x.y.z-dev00), poc(x.y.z-poc00) multiDexEnabled true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" From 6bf8bcd52554ee175ffb38397d2edf126c8ff34f Mon Sep 17 00:00:00 2001 From: bingbong Date: Thu, 8 Apr 2021 18:39:10 +0900 Subject: [PATCH 07/16] fix : gson --- .../com/iamport/sdk/presentation/activity/WebViewActivity.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/src/main/java/com/iamport/sdk/presentation/activity/WebViewActivity.kt b/sdk/src/main/java/com/iamport/sdk/presentation/activity/WebViewActivity.kt index efc9fb68..37f5de08 100644 --- a/sdk/src/main/java/com/iamport/sdk/presentation/activity/WebViewActivity.kt +++ b/sdk/src/main/java/com/iamport/sdk/presentation/activity/WebViewActivity.kt @@ -6,6 +6,7 @@ import android.net.Uri import android.view.View import android.widget.ProgressBar import androidx.lifecycle.viewModelScope +import com.google.gson.Gson import com.google.gson.GsonBuilder import com.iamport.sdk.R import com.iamport.sdk.data.sdk.IamPortResponse @@ -225,7 +226,7 @@ class WebViewActivity : BaseActivity(), Ia setLayerType(View.LAYER_TYPE_HARDWARE, null) clearCache(true) addJavascriptInterface( - JsNativeInterface(payment, get(), get(), evaluateJS), + JsNativeInterface(payment, Gson(), get(), evaluateJS), CONST.PAYMENT_WEBVIEW_JS_INTERFACE_NAME ) webViewClient = viewModel.getWebViewClient(payment) From ff70c487efe259df1165cdbe9b3cfafda8777f2c Mon Sep 17 00:00:00 2001 From: bingbong Date: Thu, 8 Apr 2021 18:39:30 +0900 Subject: [PATCH 08/16] update gradle --- sdk/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/build.gradle b/sdk/build.gradle index dedcaabe..5eead832 100644 --- a/sdk/build.gradle +++ b/sdk/build.gradle @@ -10,8 +10,8 @@ android { defaultConfig { minSdkVersion 16 targetSdkVersion 30 - versionCode 210408004 // yymmdd000 - versionName "0.0.6-dev27" // prod(x.y.z), dev(x.y.z-dev00), poc(x.y.z-poc00) + versionCode 210408005 // yymmdd000 + versionName "0.0.6-dev28" // prod(x.y.z), dev(x.y.z-dev00), poc(x.y.z-poc00) multiDexEnabled true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" From 5cfa5476aaf8d76b5379f11d98bd95bb2015d8d5 Mon Sep 17 00:00:00 2001 From: bingbong Date: Thu, 8 Apr 2021 18:54:57 +0900 Subject: [PATCH 09/16] update gradle --- sdk/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/build.gradle b/sdk/build.gradle index 5eead832..bc87920b 100644 --- a/sdk/build.gradle +++ b/sdk/build.gradle @@ -10,8 +10,8 @@ android { defaultConfig { minSdkVersion 16 targetSdkVersion 30 - versionCode 210408005 // yymmdd000 - versionName "0.0.6-dev28" // prod(x.y.z), dev(x.y.z-dev00), poc(x.y.z-poc00) + versionCode 210408006 // yymmdd000 + versionName "0.0.6-dev29" // prod(x.y.z), dev(x.y.z-dev00), poc(x.y.z-poc00) multiDexEnabled true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" From eb66d1317300b6906541232edf6bc3a6b08a297c Mon Sep 17 00:00:00 2001 From: bingbong Date: Thu, 8 Apr 2021 19:34:01 +0900 Subject: [PATCH 10/16] =?UTF-8?q?refactor=20:=20koin=20key=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20for=20=EB=AF=B8=EC=83=81=EC=86=8D=20=EA=B0=9D?= =?UTF-8?q?=EC=B2=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/iamport/sdk/domain/core/Iamport.kt | 3 +- .../com/iamport/sdk/domain/di/apiModule.kt | 55 ++++++++++--------- .../com/iamport/sdk/domain/di/appModule.kt | 4 +- .../sdk/domain/strategy/base/BaseStrategy.kt | 5 +- .../strategy/base/BaseWebViewStrategy.kt | 4 +- .../sdk/domain/strategy/chai/ChaiStrategy.kt | 3 +- .../com/iamport/sdk/domain/utils/CONST.kt | 1 + .../presentation/activity/WebViewActivity.kt | 3 +- 8 files changed, 43 insertions(+), 35 deletions(-) diff --git a/sdk/src/main/java/com/iamport/sdk/domain/core/Iamport.kt b/sdk/src/main/java/com/iamport/sdk/domain/core/Iamport.kt index a50b8034..3a1aabb2 100644 --- a/sdk/src/main/java/com/iamport/sdk/domain/core/Iamport.kt +++ b/sdk/src/main/java/com/iamport/sdk/domain/core/Iamport.kt @@ -15,6 +15,7 @@ import com.iamport.sdk.domain.di.IamportKoinContext import com.iamport.sdk.domain.di.IamportKoinContext.koinApp import com.iamport.sdk.domain.di.apiModule import com.iamport.sdk.domain.di.appModule +import com.iamport.sdk.domain.di.httpClientModule //import com.iamport.sdk.domain.di.httpClientModule import com.iamport.sdk.domain.service.ChaiService import com.iamport.sdk.domain.utils.CONST @@ -87,7 +88,7 @@ object Iamport { // TODO Application 사용하지 않는 방안 모색 fun createWithKoin(app: Application, koinApp: KoinApplication? = null) { - val modules = listOf(apiModule, appModule) + val modules = listOf(httpClientModule, apiModule, appModule) IamportKoinContext.koinApp = if (koinApp == null) { stopKoin() startKoin { diff --git a/sdk/src/main/java/com/iamport/sdk/domain/di/apiModule.kt b/sdk/src/main/java/com/iamport/sdk/domain/di/apiModule.kt index e4888ea4..7d01f7ea 100644 --- a/sdk/src/main/java/com/iamport/sdk/domain/di/apiModule.kt +++ b/sdk/src/main/java/com/iamport/sdk/domain/di/apiModule.kt @@ -10,67 +10,68 @@ import com.iamport.sdk.domain.utils.CONST import okhttp3.OkHttpClient import okhttp3.logging.HttpLoggingInterceptor import org.koin.core.component.KoinApiExtension +import org.koin.core.qualifier.named import org.koin.dsl.module import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory import java.util.concurrent.TimeUnit -//fun provideOkHttpClient(context: Context?): OkHttpClient? { -// return context?.let { -// OkHttpClient.Builder() -// .connectTimeout(20, TimeUnit.MINUTES) -// .readTimeout(20, TimeUnit.SECONDS) -// .writeTimeout(20, TimeUnit.SECONDS).apply { -// if (BuildConfig.DEBUG) { -// addInterceptor(HttpLoggingInterceptor().apply { -// level = HttpLoggingInterceptor.Level.BODY -// }) -// } -// } -// .build() -// } ?: run { null } -//} +fun provideOkHttpClient(context: Context?): OkHttpClient? { + return context?.let { + OkHttpClient.Builder() + .connectTimeout(20, TimeUnit.MINUTES) + .readTimeout(20, TimeUnit.SECONDS) + .writeTimeout(20, TimeUnit.SECONDS).apply { + if (BuildConfig.DEBUG) { + addInterceptor(HttpLoggingInterceptor().apply { + level = HttpLoggingInterceptor.Level.BODY + }) + } + } + .build() + } ?: run { null } +} -fun provideIamportApi(client: OkHttpClient?): IamportApi { +fun provideIamportApi(gson : Gson, client: OkHttpClient?): IamportApi { return Retrofit.Builder() .baseUrl(CONST.IAMPORT_PROD_URL) - .addConverterFactory(GsonConverterFactory.create(Gson())).apply { + .addConverterFactory(GsonConverterFactory.create(gson)).apply { client?.let { client(it) } } .build() .create(IamportApi::class.java) } -fun provideNiceApi(client: OkHttpClient?): NiceApi { +fun provideNiceApi(gson : Gson, client: OkHttpClient?): NiceApi { return Retrofit.Builder() .baseUrl("${CONST.IAMPORT_DETECT_URL}/") - .addConverterFactory(GsonConverterFactory.create(Gson())).apply { + .addConverterFactory(GsonConverterFactory.create(gson)).apply { client?.let { client(it) } } .build() .create(NiceApi::class.java) } -fun provideChaiApi(isStaging: Boolean, client: OkHttpClient?): ChaiApi { +fun provideChaiApi(isStaging: Boolean, gson : Gson, client: OkHttpClient?): ChaiApi { return Retrofit.Builder() .baseUrl(if (isStaging) CONST.CHAI_SERVICE_STAGING_URL else CONST.CHAI_SERVICE_URL) - .addConverterFactory(GsonConverterFactory.create(Gson())).apply { + .addConverterFactory(GsonConverterFactory.create(gson)).apply { client?.let { client(it) } } .build() .create(ChaiApi::class.java) } -//@OptIn(KoinApiExtension::class) -//val httpClientModule = module(override = true) { -// single { provideOkHttpClient(get()) } -//} +@OptIn(KoinApiExtension::class) +val httpClientModule = module(override = true) { + single(named("${CONST.KOIN_KEY}provideOkHttpClient")) { provideOkHttpClient(get()) } +} @OptIn(KoinApiExtension::class) val apiModule = module { - single { provideIamportApi(null) } + single { provideIamportApi(get(named("${CONST.KOIN_KEY}Gson")), get(named("${CONST.KOIN_KEY}provideOkHttpClient")),) } // single { provideChaiApi(false, get(), get()) } - single { provideNiceApi(null) } + single { provideNiceApi(get(named("${CONST.KOIN_KEY}Gson")), get(named("${CONST.KOIN_KEY}provideOkHttpClient")),) } } \ No newline at end of file diff --git a/sdk/src/main/java/com/iamport/sdk/domain/di/appModule.kt b/sdk/src/main/java/com/iamport/sdk/domain/di/appModule.kt index 50a4e019..d60f7b29 100644 --- a/sdk/src/main/java/com/iamport/sdk/domain/di/appModule.kt +++ b/sdk/src/main/java/com/iamport/sdk/domain/di/appModule.kt @@ -8,12 +8,14 @@ import com.iamport.sdk.domain.strategy.chai.ChaiStrategy import com.iamport.sdk.domain.strategy.webview.CertificationWebViewStrategy import com.iamport.sdk.domain.strategy.webview.NiceTransWebViewStrategy import com.iamport.sdk.domain.strategy.webview.WebViewStrategy +import com.iamport.sdk.domain.utils.CONST import com.iamport.sdk.domain.utils.NativeLiveDataEventBus import com.iamport.sdk.domain.utils.WebViewLiveDataEventBus import com.iamport.sdk.presentation.viewmodel.MainViewModel import com.iamport.sdk.presentation.viewmodel.WebViewModel import org.koin.androidx.viewmodel.dsl.viewModel import org.koin.core.component.KoinApiExtension +import org.koin.core.qualifier.named import org.koin.dsl.module @@ -22,7 +24,7 @@ val appModule = module { viewModel { MainViewModel(get(), get()) } viewModel { WebViewModel(get(), get()) } single { IamportReceiver() } -// single { Gson() } + single(named("${CONST.KOIN_KEY}Gson")) { Gson() } single { StrategyRepository() } single { WebViewLiveDataEventBus() } diff --git a/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/BaseStrategy.kt b/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/BaseStrategy.kt index fa95d448..58685803 100644 --- a/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/BaseStrategy.kt +++ b/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/BaseStrategy.kt @@ -4,17 +4,18 @@ import com.google.gson.Gson import com.iamport.sdk.data.sdk.IamPortResponse import com.iamport.sdk.data.sdk.Payment import com.iamport.sdk.domain.di.IamportKoinComponent +import com.iamport.sdk.domain.utils.CONST import com.iamport.sdk.domain.utils.Event import com.iamport.sdk.domain.utils.NativeLiveDataEventBus import kotlinx.coroutines.CancellationException import org.koin.core.component.KoinApiExtension import org.koin.core.component.inject +import org.koin.core.qualifier.named @KoinApiExtension abstract class BaseStrategy : IStrategy, IamportKoinComponent { -// protected val gson: Gson by inject() - protected val gson = Gson() + protected val gson: Gson by inject(named("${CONST.KOIN_KEY}Gson")) protected val bus: NativeLiveDataEventBus by inject() lateinit var payment: Payment diff --git a/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/BaseWebViewStrategy.kt b/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/BaseWebViewStrategy.kt index b751766c..2e860fe4 100644 --- a/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/BaseWebViewStrategy.kt +++ b/sdk/src/main/java/com/iamport/sdk/domain/strategy/base/BaseWebViewStrategy.kt @@ -16,12 +16,12 @@ import com.orhanobut.logger.Logger import com.orhanobut.logger.Logger.d import org.koin.core.component.KoinApiExtension import org.koin.core.component.inject +import org.koin.core.qualifier.named @KoinApiExtension open class BaseWebViewStrategy : WebViewClient(), IStrategy, IamportKoinComponent { -// protected val gson: Gson by inject() - protected val gson = Gson() + protected val gson: Gson by inject(named("${CONST.KOIN_KEY}Gson")) protected val bus: WebViewLiveDataEventBus by inject() lateinit var payment: Payment diff --git a/sdk/src/main/java/com/iamport/sdk/domain/strategy/chai/ChaiStrategy.kt b/sdk/src/main/java/com/iamport/sdk/domain/strategy/chai/ChaiStrategy.kt index 7d45ef8c..4c521458 100644 --- a/sdk/src/main/java/com/iamport/sdk/domain/strategy/chai/ChaiStrategy.kt +++ b/sdk/src/main/java/com/iamport/sdk/domain/strategy/chai/ChaiStrategy.kt @@ -25,6 +25,7 @@ import kotlinx.coroutines.withContext import org.koin.core.component.KoinApiExtension import org.koin.core.component.get import org.koin.core.component.inject +import org.koin.core.qualifier.named import java.util.concurrent.atomic.AtomicInteger // TODO: 12/1/20 구조 좀 정리하기 ㅠㅠ 너무 복잡 ㅠㅠ @@ -385,7 +386,7 @@ open class ChaiStrategy : BaseStrategy() { if (code == 0) { data.run { prepareData = this - chaiApi = provideChaiApi(mode == CHAI.MODE, null) // mode 에 따라 chaiApi 생성 + chaiApi = provideChaiApi(mode == CHAI.MODE, get(named("${CONST.KOIN_KEY}Gson")), get(named("${CONST.KOIN_KEY}provideOkHttpClient"))) // mode 에 따라 chaiApi 생성 returnUrl?.let { bus.chaiUri.value = Event(it) } } } else { diff --git a/sdk/src/main/java/com/iamport/sdk/domain/utils/CONST.kt b/sdk/src/main/java/com/iamport/sdk/domain/utils/CONST.kt index ea871674..cd3234e7 100644 --- a/sdk/src/main/java/com/iamport/sdk/domain/utils/CONST.kt +++ b/sdk/src/main/java/com/iamport/sdk/domain/utils/CONST.kt @@ -1,6 +1,7 @@ package com.iamport.sdk.domain.utils object CONST { + const val KOIN_KEY = "iamport-koin-key" const val APP_SCHME = "iamport_android" const val HTTP_SCHEME = "http" const val HTTPS_SCHEME = "https" diff --git a/sdk/src/main/java/com/iamport/sdk/presentation/activity/WebViewActivity.kt b/sdk/src/main/java/com/iamport/sdk/presentation/activity/WebViewActivity.kt index 37f5de08..2f953f45 100644 --- a/sdk/src/main/java/com/iamport/sdk/presentation/activity/WebViewActivity.kt +++ b/sdk/src/main/java/com/iamport/sdk/presentation/activity/WebViewActivity.kt @@ -24,6 +24,7 @@ import kotlinx.coroutines.* import org.koin.android.ext.android.get import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.component.KoinApiExtension +import org.koin.core.qualifier.named @KoinApiExtension @@ -226,7 +227,7 @@ class WebViewActivity : BaseActivity(), Ia setLayerType(View.LAYER_TYPE_HARDWARE, null) clearCache(true) addJavascriptInterface( - JsNativeInterface(payment, Gson(), get(), evaluateJS), + JsNativeInterface(payment, get(named("${CONST.KOIN_KEY}Gson")), get(), evaluateJS), CONST.PAYMENT_WEBVIEW_JS_INTERFACE_NAME ) webViewClient = viewModel.getWebViewClient(payment) From a4c153b986ae2592954d7ce953bdce64ca4cfa98 Mon Sep 17 00:00:00 2001 From: bingbong Date: Thu, 8 Apr 2021 19:34:37 +0900 Subject: [PATCH 11/16] update gradle --- sdk/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/build.gradle b/sdk/build.gradle index bc87920b..af9f7b12 100644 --- a/sdk/build.gradle +++ b/sdk/build.gradle @@ -10,8 +10,8 @@ android { defaultConfig { minSdkVersion 16 targetSdkVersion 30 - versionCode 210408006 // yymmdd000 - versionName "0.0.6-dev29" // prod(x.y.z), dev(x.y.z-dev00), poc(x.y.z-poc00) + versionCode 210408007 // yymmdd000 + versionName "0.0.6-dev30" // prod(x.y.z), dev(x.y.z-dev00), poc(x.y.z-poc00) multiDexEnabled true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" From 04c3ac08298cdff632f0e91680b75d9dfcef4290 Mon Sep 17 00:00:00 2001 From: bingbong Date: Tue, 13 Apr 2021 11:00:33 +0900 Subject: [PATCH 12/16] =?UTF-8?q?fix=20:=20gson=20koin=20get=20key=20?= =?UTF-8?q?=EB=B0=98=EC=98=81=20=EB=B0=8F=20class=20=EC=9D=B4=EB=A6=84?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...amPortWebView.kt => IamPortWebViewMode.kt} | 23 ++++++++++--------- .../sdk/presentation/activity/IamportSdk.kt | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) rename sdk/src/main/java/com/iamport/sdk/presentation/activity/{IamPortWebView.kt => IamPortWebViewMode.kt} (93%) diff --git a/sdk/src/main/java/com/iamport/sdk/presentation/activity/IamPortWebView.kt b/sdk/src/main/java/com/iamport/sdk/presentation/activity/IamPortWebViewMode.kt similarity index 93% rename from sdk/src/main/java/com/iamport/sdk/presentation/activity/IamPortWebView.kt rename to sdk/src/main/java/com/iamport/sdk/presentation/activity/IamPortWebViewMode.kt index 3601bb26..3ad2c160 100644 --- a/sdk/src/main/java/com/iamport/sdk/presentation/activity/IamPortWebView.kt +++ b/sdk/src/main/java/com/iamport/sdk/presentation/activity/IamPortWebViewMode.kt @@ -25,10 +25,11 @@ import com.orhanobut.logger.Logger.* import kotlinx.coroutines.* import org.koin.core.component.KoinApiExtension import org.koin.core.component.get +import org.koin.core.qualifier.named @KoinApiExtension -class IamPortWebView @JvmOverloads constructor(scope: BaseCoroutineScope = UICoroutineScope()) : +class IamPortWebViewMode @JvmOverloads constructor(scope: BaseCoroutineScope = UICoroutineScope()) : IamportKoinComponent, BaseCoroutineScope by scope { // override val viewModel: WebViewModel by viewModel() @@ -100,16 +101,16 @@ class IamPortWebView @JvmOverloads constructor(scope: BaseCoroutineScope = UICor payment?.let { pay: Payment -> activity?.run { - i("등록하니?") + d("등록하니?") - viewModel.payment().observe(this, EventObserver(this@IamPortWebView::requestPayment)) - viewModel.loading().observe(this, EventObserver(this@IamPortWebView::loadingVisible)) + viewModel.payment().observe(this, EventObserver(this@IamPortWebViewMode::requestPayment)) + viewModel.loading().observe(this, EventObserver(this@IamPortWebViewMode::loadingVisible)) - viewModel.openWebView().observe(this, EventObserver(this@IamPortWebView::openWebView)) - viewModel.niceTransRequestParam().observe(this, EventObserver(this@IamPortWebView::openNiceTransApp)) - viewModel.thirdPartyUri().observe(this, EventObserver(this@IamPortWebView::openThirdPartyApp)) + viewModel.openWebView().observe(this, EventObserver(this@IamPortWebViewMode::openWebView)) + viewModel.niceTransRequestParam().observe(this, EventObserver(this@IamPortWebViewMode::openNiceTransApp)) + viewModel.thirdPartyUri().observe(this, EventObserver(this@IamPortWebViewMode::openThirdPartyApp)) - viewModel.impResponse().observe(this, EventObserver(this@IamPortWebView::sdkFinish)) + viewModel.impResponse().observe(this, EventObserver(this@IamPortWebViewMode::sdkFinish)) viewModel.startPayment(pay) } @@ -127,7 +128,7 @@ class IamPortWebView @JvmOverloads constructor(scope: BaseCoroutineScope = UICor * 결제 요청 실행 */ private fun requestPayment(it: Payment) { - i("나왔니??") + d("나왔니??") loadingVisible(true) activity?.run { if (!Util.isInternetAvailable(this)) { @@ -167,7 +168,7 @@ class IamPortWebView @JvmOverloads constructor(scope: BaseCoroutineScope = UICor // activity?.setResult(Activity.RESULT_OK, // Intent().apply { putExtra(CONST.CONTRACT_OUTPUT, iamPortResponse) }) // activity?.finish() - Iamport.callback(iamPortResponse) + Iamport.callback.invoke(iamPortResponse) } /** @@ -249,7 +250,7 @@ class IamPortWebView @JvmOverloads constructor(scope: BaseCoroutineScope = UICor setLayerType(View.LAYER_TYPE_HARDWARE, null) clearCache(true) addJavascriptInterface( - JsNativeInterface(payment, get(), get(), evaluateJS), + JsNativeInterface(payment, get(named("${CONST.KOIN_KEY}Gson")), get(), evaluateJS), CONST.PAYMENT_WEBVIEW_JS_INTERFACE_NAME ) webViewClient = viewModel.getWebViewClient(payment) diff --git a/sdk/src/main/java/com/iamport/sdk/presentation/activity/IamportSdk.kt b/sdk/src/main/java/com/iamport/sdk/presentation/activity/IamportSdk.kt index 33f6563d..0c400e9f 100644 --- a/sdk/src/main/java/com/iamport/sdk/presentation/activity/IamportSdk.kt +++ b/sdk/src/main/java/com/iamport/sdk/presentation/activity/IamportSdk.kt @@ -313,7 +313,7 @@ internal class IamportSdk( clearData() webview?.let { webView -> hostHelper.activity?.let { activity -> - IamPortWebView().initStart(activity, webView, it) // webview only 모드 + IamPortWebViewMode().initStart(activity, webView, it) // webview only 모드 } ?: run { w("Cannot found activity, So running activity mode") webViewLauncher?.launch(it) // new activity 모드 From 264371b1f69ba36a2a37a382a2d716506da0d296 Mon Sep 17 00:00:00 2001 From: bingbong Date: Tue, 13 Apr 2021 11:01:01 +0900 Subject: [PATCH 13/16] update gradle --- sdk/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/build.gradle b/sdk/build.gradle index af9f7b12..b8074b78 100644 --- a/sdk/build.gradle +++ b/sdk/build.gradle @@ -10,8 +10,8 @@ android { defaultConfig { minSdkVersion 16 targetSdkVersion 30 - versionCode 210408007 // yymmdd000 - versionName "0.0.6-dev30" // prod(x.y.z), dev(x.y.z-dev00), poc(x.y.z-poc00) + versionCode 210413001 // yymmdd000 + versionName "0.0.6-dev31" // prod(x.y.z), dev(x.y.z-dev00), poc(x.y.z-poc00) multiDexEnabled true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" From f4ca051ddafa1232b0d14585c7f08d038fbde4a9 Mon Sep 17 00:00:00 2001 From: bingbong Date: Wed, 14 Apr 2021 16:21:31 +0900 Subject: [PATCH 14/16] =?UTF-8?q?fix=20:=20SDK=2026=20=EC=A7=80=EC=9B=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ERR : Only fullscreen opaque activities can request orientation 에러 수정 --- sdk/src/main/res/values-v26/styles.xml | 16 ++++++++++++++++ sdk/src/main/res/values-v27/styles.xml | 16 ++++++++++++++++ sdk/src/main/res/values/styles.xml | 2 +- 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 sdk/src/main/res/values-v26/styles.xml create mode 100644 sdk/src/main/res/values-v27/styles.xml diff --git a/sdk/src/main/res/values-v26/styles.xml b/sdk/src/main/res/values-v26/styles.xml new file mode 100644 index 00000000..918a11f1 --- /dev/null +++ b/sdk/src/main/res/values-v26/styles.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/sdk/src/main/res/values-v27/styles.xml b/sdk/src/main/res/values-v27/styles.xml new file mode 100644 index 00000000..fb6c1aef --- /dev/null +++ b/sdk/src/main/res/values-v27/styles.xml @@ -0,0 +1,16 @@ + + + + \ No newline at end of file diff --git a/sdk/src/main/res/values/styles.xml b/sdk/src/main/res/values/styles.xml index 31947c6e..eb70b6dd 100644 --- a/sdk/src/main/res/values/styles.xml +++ b/sdk/src/main/res/values/styles.xml @@ -7,7 +7,7 @@ @color/colorAccent - +