feat(gift): 배송지 검색 화면을 추가한다

This commit is contained in:
2026-10-01 15:58:04 +09:00
parent 5090150ab1
commit 6ae865a7b6
3 changed files with 116 additions and 0 deletions
+7
View File
@@ -115,6 +115,13 @@
</activity>
<activity android:name=".main.MainActivity" />
<activity android:name=".v2.main.MainV2Activity" />
<activity
android:name=".v2.gift.GiftSendRequestActivity"
android:exported="false"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize" />
<activity
android:name=".v2.gift.KakaoPostcodeSearchActivity"
android:exported="false" />
<activity android:name=".v2.main.content.overview.ContentOverviewActivity" />
<activity android:name=".v2.creator.channel.CreatorChannelActivity" />
<activity
@@ -0,0 +1,98 @@
package kr.co.vividnext.sodalive.v2.gift
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.webkit.JavascriptInterface
import android.webkit.WebSettings
import kr.co.vividnext.sodalive.base.BaseActivity
import kr.co.vividnext.sodalive.databinding.ActivityKakaoPostcodeSearchBinding
class KakaoPostcodeSearchActivity : BaseActivity<ActivityKakaoPostcodeSearchBinding>(
ActivityKakaoPostcodeSearchBinding::inflate
) {
@SuppressLint("SetJavaScriptEnabled")
override fun setupView() = with(binding.webviewPostcode) {
settings.javaScriptEnabled = true
settings.domStorageEnabled = true
settings.cacheMode = WebSettings.LOAD_NO_CACHE
addJavascriptInterface(PostcodeBridge(), BRIDGE_NAME)
loadDataWithBaseURL(KAKAO_POSTCODE_BASE_URL, postcodeHtml(), "text/html", "UTF-8", null)
}
private inner class PostcodeBridge {
@JavascriptInterface
fun onComplete(
zonecode: String,
userSelectedType: String,
roadAddress: String,
jibunAddress: String,
address: String
) {
val result = GiftSendRequestPresenter.toPostcodeResult(
KakaoPostcodeData(
zonecode = zonecode,
userSelectedType = userSelectedType,
roadAddress = roadAddress,
jibunAddress = jibunAddress,
address = address
)
)
runOnUiThread {
setResult(
Activity.RESULT_OK,
Intent()
.putExtra(EXTRA_ZONE_CODE, result.zoneCode)
.putExtra(EXTRA_ADDRESS, result.address)
)
finish()
}
}
}
companion object {
const val EXTRA_ZONE_CODE = "extra_zone_code"
const val EXTRA_ADDRESS = "extra_address"
private const val BRIDGE_NAME = "AndroidPostcode"
private const val KAKAO_POSTCODE_BASE_URL = "https://postcode.map.kakao.com"
fun newIntent(context: Context): Intent = Intent(context, KakaoPostcodeSearchActivity::class.java)
private fun postcodeHtml(): String = """
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<script src="https://t1.kakaocdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js"></script>
<style>
html, body, #wrap { width: 100%; height: 100%; margin: 0; padding: 0; }
</style>
</head>
<body>
<div id="wrap"></div>
<script>
window.onload = function() {
var Postcode = (window.kakao && window.kakao.Postcode) || (window.daum && window.daum.Postcode);
new Postcode({
oncomplete: function(data) {
AndroidPostcode.onComplete(
data.zonecode || '',
data.userSelectedType || '',
data.roadAddress || '',
data.jibunAddress || '',
data.address || ''
);
},
width: '100%',
height: '100%'
}).embed(document.getElementById('wrap'));
};
</script>
</body>
</html>
""".trimIndent()
}
}
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<WebView
android:id="@+id/webview_postcode"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>