Skip to content

Commit

Permalink
Merge pull request #43 from iamport/feat/koin
Browse files Browse the repository at this point in the history
feat : koin update 2.2.3 -> 3.1.2
  • Loading branch information
kjh5833 authored Nov 8, 2021
2 parents ddc58c6 + a7c6ce8 commit 38784f7
Show file tree
Hide file tree
Showing 24 changed files with 45 additions and 81 deletions.
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
android:name=".BaseApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<!-- android:name=".BaseApplication"-->
<!--android:resizeableActivity="false"-->

<activity
android:name=".ui.MainActivity"
android:screenOrientation="portrait">
android:screenOrientation="portrait"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
8 changes: 6 additions & 2 deletions app/src/main/java/com/iamport/sampleapp/BaseApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import com.iamport.sdk.domain.core.Iamport
class BaseApplication : Application() {
override fun onCreate() {
super.onCreate()
Iamport.create(this)
/**
* activity 를 통해 application 을 가져올 수 있기에 제거
*/
// Iamport.create(this)

/**
* DI 로 KOIN 사용시 아래와 같이 사용
Expand All @@ -18,4 +21,5 @@ class BaseApplication : Application() {
Iamport.createWithKoin(this, koinApp)
*/
}
}
}

4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ buildscript {

classpath 'com.android.tools.build:gradle:7.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$Versions.kotlin_stdlib_jdk"
classpath "io.insert-koin:koin-gradle-plugin:$Versions.koin_version"
// classpath "io.insert-koin:koin-gradle-plugin:$Versions.koin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$Versions.kotlin_stdlib_jdk"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

apply plugin: 'koin'
//apply plugin: 'koin'
apply plugin: "com.github.ben-manes.versions"

allprojects {
Expand Down
25 changes: 14 additions & 11 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// 디펜던시 업데이트 확인 ./gradlew dependencyUpdates -Drevision=release
object Versions {
const val versionCode = 210928001 // yymmdd000
const val versionName = "1.1.0-hotfix08" // https://www.notion.so/chaifinance/QA-Process-d1a4be396337493b81c6e85fff2d5cd6
const val versionCode = 211108001 // yymmdd000
const val versionName = "1.1.0-hotfix11" // https://www.notion.so/chaifinance/QA-Process-d1a4be396337493b81c6e85fff2d5cd6

const val gradle_versions_plugin = "0.39.0"
const val gradle_version = "4.1.1"
Expand All @@ -12,7 +12,7 @@ object Versions {
const val appcompat = "1.3.1"

const val mokito = "3.11.2"
const val mokito_kotlin= "2.2.0"
const val mokito_kotlin = "2.2.0"

const val junit = "4.13.1"
const val testJunit = "1.1.3"
Expand All @@ -30,7 +30,7 @@ object Versions {
const val activity_ktx = "1.3.0"
const val fragment_ktx = "1.3.6"

const val koin_version = "2.2.3"
const val koin_version = "3.1.2"
const val retrofit_version = "2.9.0"
const val logging_interceptor = "4.9.0"

Expand All @@ -48,7 +48,7 @@ object Versions {
// loading animation
const val spinKit = "1.4.0"

// const val chuck = "1.1.0"
// const val chuck = "1.1.0"
const val robolectric = "4.6"

const val serialization = "1.2.2"
Expand Down Expand Up @@ -90,15 +90,18 @@ object Libs {
const val activity_ktx = "androidx.activity:activity-ktx:${Versions.activity_ktx}"
const val fragment_ktx = "androidx.fragment:fragment-ktx:${Versions.fragment_ktx}"

// Koin main features for Android (Scope,ViewModel ...)
const val koin_android = "io.insert-koin:koin-android:${Versions.koin_version}"

const val koin_core = "io.insert-koin:koin-core:${Versions.koin_version}"
const val koin_core_ext = "io.insert-koin:koin-core-ext:${Versions.koin_version}"
const val koin_test = "io.insert-koin:koin-test:${Versions.koin_version}"

// AndroidX Scope 생성 - 삭제 자동화
const val koin_androidx_scope = "io.insert-koin:koin-androidx-scope:${Versions.koin_version}"
const val koin_androidx_viewmodel = "io.insert-koin:koin-androidx-viewmodel:${Versions.koin_version}"
const val koin_androidx_fragment = "io.insert-koin:koin-androidx-fragment:${Versions.koin_version}"
const val koin_androidx_ext = "io.insert-koin:koin-androidx-ext:${Versions.koin_version}"
// Koin Java Compatibility
const val koin_android_compat = "io.insert-koin:koin-android-compat:${Versions.koin_version}"
// Koin for Jetpack WorkManager
const val koin_android_workmanager = "io.insert-koin:koin-androidx-workmanager:${Versions.koin_version}"
// Koin for Jetpack Compose
const val koin_android_compose = "io.insert-koin:koin-androidx-compose:${Versions.koin_version}"


// Retorofit
Expand Down
12 changes: 4 additions & 8 deletions sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,10 @@ dependencies {

implementation Libs.koin_core
testImplementation Libs.koin_test
implementation Libs.koin_core_ext
// androidTestImplementation Libs.koin_test

// AndroidX Scope 생성 - 삭제 자동화
implementation Libs.koin_androidx_scope
implementation Libs.koin_androidx_viewmodel
implementation Libs.koin_androidx_fragment
implementation Libs.koin_androidx_ext
implementation Libs.koin_android
implementation Libs.koin_android_compat
implementation Libs.koin_android_workmanager
implementation Libs.koin_android_compose

// Retorofit
implementation Libs.retrofit
Expand Down
9 changes: 0 additions & 9 deletions sdk/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize"
android:theme="@style/Theme.AppCompat.Transparent.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<!-- // FIXME scheme 변수로 불러오기 및 CONST.APP_SCHME 도 수정 -->
<data android:scheme="iamport_android_webview" />
</intent-filter>
</activity>

</application>
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/main/java/com/iamport/sdk/data/sdk/PG.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ enum class PG(val korName: String) {
/*kakao("카카오"), */ danal("다날휴대폰소액결제"), danal_tpay("다날일반결제"),
kicc("한국정보통신"), paypal("페이팔"), mobilians("모빌리언스 휴대폰소액결제"),
payco("페이코"), eximbay("엑심베이"), settle("세틀뱅크"), settle_firm("세틀뱅크_펌"),
naverco("네이버페이-주문형"), naverpay("네이버페이-결제형"), smilepay("스마일페이"),
/*naverco("네이버페이-주문형"),*/ naverpay("네이버페이-결제형"), smilepay("스마일페이"),
payple("페이플"), alipay("알리페이"),
bluewalnut("bluewalnut"), tosspay("간편결제 - 토스"), smartro("스마트로"); /*, inicis("이니시스ActiveX결제창"), syrup("시럽페이");*/

Expand Down
2 changes: 0 additions & 2 deletions sdk/src/main/java/com/iamport/sdk/domain/JsNativeInterface.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import com.iamport.sdk.domain.di.IamportKoinComponent
import com.iamport.sdk.domain.utils.Event
import com.iamport.sdk.domain.utils.WebViewLiveDataEventBus
import com.orhanobut.logger.Logger
import org.koin.core.component.KoinApiExtension

@KoinApiExtension
class JsNativeInterface(val payment: Payment, val gson: Gson, val evaluateJS: ((String) -> Unit)) : IamportKoinComponent {
private val bus: WebViewLiveDataEventBus by lazy { WebViewLiveDataEventBus }

Expand Down
18 changes: 11 additions & 7 deletions sdk/src/main/java/com/iamport/sdk/domain/core/Iamport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import com.orhanobut.logger.PrettyFormatStrategy
import org.koin.android.ext.koin.androidContext
import org.koin.android.logger.AndroidLogger
import org.koin.core.KoinApplication
import org.koin.core.component.KoinApiExtension
import org.koin.core.context.startKoin
import org.koin.core.context.stopKoin
import org.koin.core.module.Module
Expand Down Expand Up @@ -64,7 +63,7 @@ object Iamport {
// Application class 에서 생성 했는지 확인
private fun isSDKCreate(): Boolean {
if (!isCreated) {
Log.e(CONST.IAMPORT_LOG, "IAMPORT SDK was not created. Please initialize it in Application class")
Log.i(CONST.IAMPORT_LOG, "IAMPORT SDK was not created yet.")
}
return isCreated
}
Expand Down Expand Up @@ -114,6 +113,7 @@ object Iamport {
koinApp.modules(modules) // or getKoinModules 를 직접 받아서 사용
}


val formatStrategy = PrettyFormatStrategy.newBuilder().apply {
tag(CONST.IAMPORT_LOG)
if (DEBUG) {
Expand Down Expand Up @@ -167,7 +167,7 @@ object Iamport {
*/
val callback = fun(iamPortResponse: IamPortResponse?) {

if(iamPortResponse == null) {
if (iamPortResponse == null) {
i("iamPortResponse 없이 결제 종료")
impCallbackFunction?.invoke(iamPortResponse)
return
Expand Down Expand Up @@ -202,7 +202,9 @@ object Iamport {
*/
fun init(componentActivity: ComponentActivity) {
if (!isSDKCreate()) {
return
create(componentActivity.application)
// init(componentActivity)
// return
}

d("INITIALIZE IAMPORT SDK from activity")
Expand All @@ -226,7 +228,11 @@ object Iamport {
*/
fun init(fragment: Fragment) {
if (!isSDKCreate()) {
return
fragment.activity?.let {
create(it.application)
}
// init(fragment)
// return
}

d("INITIALIZE IAMPORT SDK from fragment")
Expand Down Expand Up @@ -299,7 +305,6 @@ object Iamport {
}
}

@KoinApiExtension
internal fun coreCertification(
payment: Payment,
paymentResultCallback: ((IamPortResponse?) -> Unit)?
Expand All @@ -308,7 +313,6 @@ object Iamport {
iamportSdk?.initStart(payment, paymentResultCallback)
}

@KoinApiExtension
internal fun corePayment(
payment: Payment,
approveCallback: ((IamPortApprove) -> Unit)?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
import com.iamport.sdk.presentation.contract.BankPayContract
import com.orhanobut.logger.Logger
import org.koin.core.component.KoinApiExtension

@KoinApiExtension
class IamportLifecycleObserver(private val registry: ActivityResultRegistry) : DefaultLifecycleObserver {
private lateinit var bankPayLauncher: ActivityResultLauncher<String>
lateinit var resultCallback: (Pair<String, String>) -> Unit
Expand Down
5 changes: 1 addition & 4 deletions sdk/src/main/java/com/iamport/sdk/domain/di/apiModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.iamport.sdk.data.remote.NiceApi
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
Expand Down Expand Up @@ -65,12 +64,10 @@ fun provideChaiApi(url: String, gson : Gson, client: OkHttpClient?): ChaiApi {
.create(ChaiApi::class.java)
}

@OptIn(KoinApiExtension::class)
val httpClientModule = module(override = true) {
val httpClientModule = module {
single(named("${CONST.KOIN_KEY}provideOkHttpClient")) { provideOkHttpClient(get()) }
}

@OptIn(KoinApiExtension::class)
val apiModule = module {
single { provideIamportApi(get(named("${CONST.KOIN_KEY}Gson")), get(named("${CONST.KOIN_KEY}provideOkHttpClient")),) }
// single { provideChaiApi(false, get(), get()) }
Expand Down
3 changes: 0 additions & 3 deletions sdk/src/main/java/com/iamport/sdk/domain/di/appModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@ import com.iamport.sdk.domain.repository.StrategyRepository
import com.iamport.sdk.domain.strategy.base.JudgeStrategy
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.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


@OptIn(KoinApiExtension::class)
val appModule = module {
viewModel { MainViewModel(get(), get(), get()) }
viewModel { WebViewModel(get()) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ import com.iamport.sdk.domain.strategy.chai.ChaiStrategy
import com.iamport.sdk.domain.strategy.webview.IamPortMobileModeWebViewClient
import com.iamport.sdk.domain.strategy.webview.WebViewStrategy
import com.orhanobut.logger.Logger
import org.koin.core.component.KoinApiExtension
import org.koin.core.component.inject

@KoinApiExtension
class StrategyRepository : IamportKoinComponent {

val judgeStrategy: JudgeStrategy by inject()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ 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(named("${CONST.KOIN_KEY}Gson"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ import com.iamport.sdk.domain.di.IamportKoinComponent
import com.iamport.sdk.domain.utils.CONST
import com.orhanobut.logger.Logger
import kotlinx.coroutines.Dispatchers
import org.koin.core.component.KoinApiExtension
import org.koin.core.component.inject

@KoinApiExtension
class JudgeStrategy : BaseStrategy(), IamportKoinComponent {

// 유저 정보 판단 결과 타입
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ import com.iamport.sdk.domain.utils.CONST
import com.iamport.sdk.domain.utils.Event
import com.orhanobut.logger.Logger.*
import kotlinx.coroutines.*
import org.koin.core.component.KoinApiExtension
import org.koin.core.component.get
import org.koin.core.component.inject
import org.koin.core.qualifier.named

@KoinApiExtension
open class ChaiStrategy : BaseStrategy() {

private val job = SupervisorJob()
Expand Down
6 changes: 3 additions & 3 deletions sdk/src/main/java/com/iamport/sdk/domain/utils/Util.kt
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ object Util {
PayMethod.molpay,
PayMethod.paysbuy
)
jtnet, nice, danal_tpay, kicc,
naverco, naverpay -> defaultPayMethod
jtnet, nice, danal_tpay, kicc, -> defaultPayMethod
/*naverco,*/ naverpay -> setOf(PayMethod.card)
smartro -> setOf(PayMethod.card, PayMethod.vbank, PayMethod.trans)
else -> defaultPayMethod
}
Expand Down Expand Up @@ -165,7 +165,7 @@ object Util {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
cm?.run {
getNetworkCapabilities(activeNetwork)?.run {
Logger.w(this.toString())
Logger.d(this.toString())
result = when {
hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> true
hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import com.iamport.sdk.domain.strategy.webview.IamPortMobileModeWebViewClient
import com.iamport.sdk.domain.utils.Event
import com.iamport.sdk.domain.utils.EventObserver
import com.orhanobut.logger.Logger
import org.koin.core.component.KoinApiExtension

@KoinApiExtension
open class IamPortMobileWebMode() : IamPortWebViewMode() {

fun initStart(activity: ComponentActivity, webview: WebView) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ import com.iamport.sdk.domain.utils.*
import com.iamport.sdk.presentation.viewmodel.WebViewModel
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
open class IamPortWebViewMode @JvmOverloads constructor(
scope: BaseCoroutineScope = UICoroutineScope()
) : IamportKoinComponent, BaseMain, BaseCoroutineScope by scope {
Expand Down
Loading

0 comments on commit 38784f7

Please sign in to comment.