diff --git a/README.md b/README.md index e51e2893..44535ae3 100644 --- a/README.md +++ b/README.md @@ -220,7 +220,7 @@ Iamport.pluginMobileWebSupporter(webview) - Custom WebViewClient 의 사용 -[샘플앱의 예시 MyWebViewClient.kt](./app/src/main/java/com/iamport/sampleapp/ui/MyWebViewClient.kt) +[샘플앱의 예시 MyWebViewClient class](./app/src/main/java/com/iamport/sampleapp/MyWebViewClient.kt) ```kotlin /** @@ -249,6 +249,35 @@ class MobileWebViewModeFragment : Fragment() { } } +``` + + +- Custom WebChromeClient 의 사용 + +[샘플앱의 예시 MyWebViewChromeClient class](./app/src/main/java/com/iamport/sampleapp/MyWebViewClient.kt) + + + +```kotlin +/** + [IamportWebChromeClient] 상속하여 사용 + */ +// CASE 1 : IamportWebChromeClient 상속 +open class MyWebViewChromeClient : IamportWebChromeClient() { + override fun onJsConfirm(view: WebView, url: String, message: String, result: JsResult): Boolean { + Log.i("MyWebViewChromeClient", "called this function") + return super.onJsConfirm(view, url, message, result) + } +} + +class MobileWebViewModeFragment : Fragment() { + override fun setupWebView() { + // IamportWebChromeClient 사용 + it.webChromeClient = MyWebViewChromeClient() + // .. + } +} + ``` diff --git a/app/src/main/java/com/iamport/sampleapp/MyWebViewClient.kt b/app/src/main/java/com/iamport/sampleapp/MyWebViewClient.kt index c5642f2b..110ab4b7 100644 --- a/app/src/main/java/com/iamport/sampleapp/MyWebViewClient.kt +++ b/app/src/main/java/com/iamport/sampleapp/MyWebViewClient.kt @@ -1,8 +1,10 @@ package com.iamport.sampleapp import android.util.Log +import android.webkit.JsResult import android.webkit.WebResourceRequest import android.webkit.WebView +import com.iamport.sdk.domain.IamportWebChromeClient import com.iamport.sdk.domain.strategy.webview.IamPortMobileModeWebViewClient open class MyWebViewClient : IamPortMobileModeWebViewClient() { @@ -14,4 +16,13 @@ open class MyWebViewClient : IamPortMobileModeWebViewClient() { return super.shouldOverrideUrlLoading(view, request) } -} \ No newline at end of file +} + +open class MyWebViewChromeClient : IamportWebChromeClient() { + + override fun onJsConfirm(view: WebView, url: String, message: String, result: JsResult): Boolean { + Log.i("MyWebViewChromeClient", "called this function") + return super.onJsConfirm(view, url, message, result) + } +} + diff --git a/app/src/main/java/com/iamport/sampleapp/ui/MobileWebViewModeFragment.kt b/app/src/main/java/com/iamport/sampleapp/ui/MobileWebViewModeFragment.kt index 93a85bf6..bd482ffe 100644 --- a/app/src/main/java/com/iamport/sampleapp/ui/MobileWebViewModeFragment.kt +++ b/app/src/main/java/com/iamport/sampleapp/ui/MobileWebViewModeFragment.kt @@ -6,6 +6,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment +import com.iamport.sampleapp.MyWebViewChromeClient import com.iamport.sampleapp.MyWebViewClient import com.iamport.sampleapp.databinding.WebViewModeFragmentBinding import com.iamport.sdk.domain.core.Iamport @@ -43,6 +44,7 @@ class MobileWebViewModeFragment : Fragment() { // 통상적인 경우의 custom webviewClient it.webViewClient = MyWebViewClient() + it.webChromeClient = MyWebViewChromeClient() // oreo 미만에서 url 변경만 보고 싶은경우 Iamport.mobileWebModeShouldOverrideUrlLoading()?.observe(this, EventObserver { uri -> diff --git a/sdk/src/main/java/com/iamport/sdk/data/chai/request/PrepareRequest.kt b/sdk/src/main/java/com/iamport/sdk/data/chai/request/PrepareRequest.kt index ec11973e..5d95aaa2 100644 --- a/sdk/src/main/java/com/iamport/sdk/data/chai/request/PrepareRequest.kt +++ b/sdk/src/main/java/com/iamport/sdk/data/chai/request/PrepareRequest.kt @@ -18,7 +18,7 @@ data class PrepareRequest( val pay_method: PayMethod = PayMethod.trans,//fixed val escrow: Boolean?, // true or false val amount: String, // 결제금액 - val tax_free: String?, // 결제금액 중 면세공급가액, + val tax_free: Float?, // 결제금액 중 면세공급가액, val name: String, //주문명, val merchant_uid: String, // 가맹점 주문번호, val customer_uid: String?, // 정기결제용 @@ -47,7 +47,7 @@ data class PrepareRequest( PrepareRequest( escrow = false, amount = amount, - tax_free = Util.getOrZeroString(tax_free), + tax_free = tax_free, name = Util.getOrEmpty(name), merchant_uid = merchant_uid, customer_uid = customer_uid, diff --git a/sdk/src/main/java/com/iamport/sdk/data/sdk/IamPortRequest.kt b/sdk/src/main/java/com/iamport/sdk/data/sdk/IamPortRequest.kt index b548198e..e5aebfeb 100644 --- a/sdk/src/main/java/com/iamport/sdk/data/sdk/IamPortRequest.kt +++ b/sdk/src/main/java/com/iamport/sdk/data/sdk/IamPortRequest.kt @@ -16,14 +16,14 @@ import kotlinx.serialization.Serializable @Serializable data class IamPortRequest( val pg: String, - val pay_method: PayMethod = PayMethod.card, // 명세상 필수인지 불명확함, default card + val pay_method: PayMethod = PayMethod.card, // default card val escrow: Boolean? = null, // default false val merchant_uid: String, // default "random" val customer_uid: String? = null, // 정기결제용 val name: String? = null, val amount: String, - val custom_data: String? = null, // 명세상 불명확 - val tax_free: String? = null, + val custom_data: String? = null, + val tax_free: Float? = null, val currency: Currency? = null, // default KRW, 페이팔은 USD 이어야 함 val language: String? = null, // default "ko", en, zh, jp => TODO validator 에 추가 val buyer_name: String? = null, @@ -36,7 +36,7 @@ data class IamPortRequest( val digital: Boolean? = null, // default false val vbank_due: String? = null, // YYYYMMDDhhmm private var m_redirect_url: String? = Platform.native.redirectUrl, // 콜백 - val app_scheme: String? = null, // 명세상 nullable 이나, RN 에서 필수 + val app_scheme: String? = null, val biz_num: String? = null, val popup: Boolean? = null, private val niceMobileV2 : Boolean = true, @@ -96,7 +96,7 @@ data class IamPortRequest( var name: String? = null var custom_data: String? = null // 명세상 불명확 - var tax_free: String? = null + var tax_free: Float? = null var currency: Currency? = null // default KRW, 페이팔은 USD 이어야 함 var language: String? = null // default "ko" var buyer_name: String? = null @@ -158,7 +158,7 @@ data class IamPortRequest( this.custom_data = custom_data } - fun tax_free(tax_free: String) = apply { + fun tax_free(tax_free: Float) = apply { this.tax_free = tax_free } diff --git a/sdk/src/main/java/com/iamport/sdk/domain/IamportWebChromeClient.kt b/sdk/src/main/java/com/iamport/sdk/domain/IamportWebChromeClient.kt index e160ff2b..cec790ad 100644 --- a/sdk/src/main/java/com/iamport/sdk/domain/IamportWebChromeClient.kt +++ b/sdk/src/main/java/com/iamport/sdk/domain/IamportWebChromeClient.kt @@ -7,7 +7,7 @@ import android.webkit.WebChromeClient import android.webkit.WebView -class IamportWebChromeClient : WebChromeClient() { +open class IamportWebChromeClient : WebChromeClient() { override fun onJsConfirm( view: WebView, url: String, diff --git a/sdk/src/main/java/com/iamport/sdk/presentation/activity/IamPortMobileWebMode.kt b/sdk/src/main/java/com/iamport/sdk/presentation/activity/IamPortMobileWebMode.kt index 44a71907..ac4eac26 100644 --- a/sdk/src/main/java/com/iamport/sdk/presentation/activity/IamPortMobileWebMode.kt +++ b/sdk/src/main/java/com/iamport/sdk/presentation/activity/IamPortMobileWebMode.kt @@ -64,7 +64,18 @@ open class IamPortMobileWebMode() : IamPortWebViewMode() { setLayerType(View.LAYER_TYPE_HARDWARE, null) clearCache(true) // FIXME: 안지워도 될까? 고민.. visibility = View.VISIBLE - webChromeClient = IamportWebChromeClient() +// webChromeClient = IamportWebChromeClient() + + webChromeClient = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + webChromeClient.let { + if (it is IamportWebChromeClient) { + return@let it + } + IamportWebChromeClient() + } + } else { + IamportWebChromeClient() + } webViewClient = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { webViewClient.let {