From 840891ab2f5f8528f7a7bd20af44484bfde828a1 Mon Sep 17 00:00:00 2001 From: DOGDDUDDY Date: Wed, 30 Aug 2023 23:09:23 +0900 Subject: [PATCH 01/11] =?UTF-8?q?[feat/webview=5Fbridge]:=20WebView=20Brid?= =?UTF-8?q?ge=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=A0=95=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdsc/presentation/view/WebAppInterface.kt | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt b/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt index 626c6a09..7ef9ccb0 100644 --- a/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt +++ b/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt @@ -19,7 +19,7 @@ class WebAppInterface( } @JavascriptInterface - fun navigationEnable(isVisible: Boolean) { + fun navigation(isVisible: Boolean) { if (isVisible) slideUpBottomNavigationView() else slideDownBottomNavigationView() } @@ -29,4 +29,21 @@ class WebAppInterface( navigateToRestaurantEdit(restaurantId) } + // webView.canGoBack으로 뒤로가기 처리 완료해서 비워뒀습니다. + @JavascriptInterface + fun back(isEnableBack: Boolean) { + } + + @JavascriptInterface + fun token() { + } + + @JavascriptInterface + fun share() { + } + + @JavascriptInterface + fun navigate(route: String) { + } + } \ No newline at end of file From e68d2cd7d602346f443a813497bd1b58ac325e08 Mon Sep 17 00:00:00 2001 From: DOGDDUDDY Date: Wed, 30 Aug 2023 23:10:16 +0900 Subject: [PATCH 02/11] =?UTF-8?q?[feat/webview=5Fbridge]:=20WebView=20?= =?UTF-8?q?=EC=95=88=EB=B3=B4=EC=9D=B4=EB=8A=94=20=EC=9D=B4=EC=8A=88=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/gdsc/presentation/view/home/HomeFragment.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/presentation/src/main/java/org/gdsc/presentation/view/home/HomeFragment.kt b/presentation/src/main/java/org/gdsc/presentation/view/home/HomeFragment.kt index 84c45f9d..79411ba8 100644 --- a/presentation/src/main/java/org/gdsc/presentation/view/home/HomeFragment.kt +++ b/presentation/src/main/java/org/gdsc/presentation/view/home/HomeFragment.kt @@ -35,6 +35,7 @@ class HomeFragment : Fragment() { binding.webView.apply { loadUrl("https://jmt-matzip.dev") settings.javaScriptEnabled = true + settings.domStorageEnabled = true webViewClient = WebViewClient() addJavascriptInterface(WebAppInterface( From 9ab4ce16ac6fdfae04fb9c811d0fc6347e838f0b Mon Sep 17 00:00:00 2001 From: DOGDDUDDY Date: Wed, 30 Aug 2023 23:11:55 +0900 Subject: [PATCH 03/11] =?UTF-8?q?[feat/webview=5Fbridge]:=20Web=EC=97=90?= =?UTF-8?q?=20AccessToken=20=EB=84=98=EA=B8=B0=EA=B8=B0=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/gdsc/presentation/view/WebAppInterface.kt | 6 +++--- .../gdsc/presentation/view/home/HomeFragment.kt | 14 ++++++++++++-- .../gdsc/presentation/view/home/HomeViewModel.kt | 6 +++++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt b/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt index 7ef9ccb0..21458564 100644 --- a/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt +++ b/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt @@ -9,7 +9,8 @@ class WebAppInterface( private val mContext: Context, private val slideUpBottomNavigationView: () -> Unit = {}, private val slideDownBottomNavigationView: () -> Unit = {}, - private val navigateToRestaurantEdit: (Int) -> Unit = {} + private val navigateToRestaurantEdit: (Int) -> Unit = {}, + private val setAccessToken: () -> Unit = {}, ) { /** Show a toast from the web page */ @@ -35,8 +36,7 @@ class WebAppInterface( } @JavascriptInterface - fun token() { - } + fun token() = setAccessToken() @JavascriptInterface fun share() { diff --git a/presentation/src/main/java/org/gdsc/presentation/view/home/HomeFragment.kt b/presentation/src/main/java/org/gdsc/presentation/view/home/HomeFragment.kt index 79411ba8..1dc70e37 100644 --- a/presentation/src/main/java/org/gdsc/presentation/view/home/HomeFragment.kt +++ b/presentation/src/main/java/org/gdsc/presentation/view/home/HomeFragment.kt @@ -7,8 +7,10 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.webkit.WebViewClient +import androidx.fragment.app.viewModels import dagger.hilt.android.AndroidEntryPoint import org.gdsc.presentation.databinding.FragmentHomeBinding +import org.gdsc.presentation.utils.repeatWhenUiStarted import org.gdsc.presentation.view.MainActivity import org.gdsc.presentation.view.WebAppInterface @@ -18,6 +20,8 @@ class HomeFragment : Fragment() { private var _binding: FragmentHomeBinding? = null private val binding get() = _binding!! + val viewModel: HomeViewModel by viewModels() + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? @@ -48,10 +52,16 @@ class HomeFragment : Fragment() { }, { parentActivity.navigateToEditRestaurantInfo(it) + }, + { + repeatWhenUiStarted { + binding.webView.loadUrl( + "javascript:setAccessToken(\"${viewModel.getAccessToken()}\")" + ) + } } - ), "Android") + ), "webviewBridge") } - } override fun onDestroyView() { diff --git a/presentation/src/main/java/org/gdsc/presentation/view/home/HomeViewModel.kt b/presentation/src/main/java/org/gdsc/presentation/view/home/HomeViewModel.kt index 94dd112e..57fbf065 100644 --- a/presentation/src/main/java/org/gdsc/presentation/view/home/HomeViewModel.kt +++ b/presentation/src/main/java/org/gdsc/presentation/view/home/HomeViewModel.kt @@ -2,13 +2,17 @@ package org.gdsc.presentation.view.home import androidx.lifecycle.ViewModel import dagger.hilt.android.lifecycle.HiltViewModel +import org.gdsc.domain.usecase.token.GetAccessTokenUseCase import org.gdsc.presentation.JmtLocationManager import javax.inject.Inject @HiltViewModel class HomeViewModel @Inject constructor( - private val locationManager: JmtLocationManager + private val locationManager: JmtLocationManager, + private val getAccessTokenUseCase: GetAccessTokenUseCase, ) : ViewModel() { suspend fun getCurrentLocation() = locationManager.getCurrentLocation() + + suspend fun getAccessToken() = getAccessTokenUseCase.invoke() } \ No newline at end of file From 3db7457b773033e06e23393d1b820de47c4e4378 Mon Sep 17 00:00:00 2001 From: DOGDDUDDY Date: Sun, 3 Sep 2023 19:04:14 +0900 Subject: [PATCH 04/11] =?UTF-8?q?[feat/webview=5Fbridge]:=20Web=20BackPres?= =?UTF-8?q?s=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/gdsc/presentation/view/home/HomeFragment.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/presentation/src/main/java/org/gdsc/presentation/view/home/HomeFragment.kt b/presentation/src/main/java/org/gdsc/presentation/view/home/HomeFragment.kt index 1dc70e37..274f3da0 100644 --- a/presentation/src/main/java/org/gdsc/presentation/view/home/HomeFragment.kt +++ b/presentation/src/main/java/org/gdsc/presentation/view/home/HomeFragment.kt @@ -7,6 +7,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.webkit.WebViewClient +import androidx.activity.addCallback import androidx.fragment.app.viewModels import dagger.hilt.android.AndroidEntryPoint import org.gdsc.presentation.databinding.FragmentHomeBinding @@ -35,6 +36,7 @@ class HomeFragment : Fragment() { super.onViewCreated(view, savedInstanceState) val parentActivity = requireActivity() as MainActivity + setWebViewBackPress() binding.webView.apply { loadUrl("https://jmt-matzip.dev") @@ -68,4 +70,14 @@ class HomeFragment : Fragment() { _binding = null super.onDestroyView() } + + private fun setWebViewBackPress() { + requireActivity().onBackPressedDispatcher.addCallback(this) { + if (binding.webView.canGoBack()) { + binding.webView.goBack() + } else { + requireActivity().finish() + } + } + } } \ No newline at end of file From 5efa64fead9630617fad8c64b785526bc86960fe Mon Sep 17 00:00:00 2001 From: DOGDDUDDY Date: Sun, 3 Sep 2023 19:05:50 +0900 Subject: [PATCH 05/11] =?UTF-8?q?[feat/webview=5Fbridge]:=20Route=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Route 데이터에 맞춰 해당 페이지로 이동 - FE 미배포로 디테일한 내용은 추후 구현 --- .../java/org/gdsc/presentation/model/Route.kt | 7 ++++ .../gdsc/presentation/view/WebAppInterface.kt | 34 +++++++++---------- 2 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 presentation/src/main/java/org/gdsc/presentation/model/Route.kt diff --git a/presentation/src/main/java/org/gdsc/presentation/model/Route.kt b/presentation/src/main/java/org/gdsc/presentation/model/Route.kt new file mode 100644 index 00000000..8105fdd9 --- /dev/null +++ b/presentation/src/main/java/org/gdsc/presentation/model/Route.kt @@ -0,0 +1,7 @@ +package org.gdsc.presentation.model + +enum class Route( + val route: String +) { + EDIT_RESTAURANT("editRestaurantInfo"), +} \ No newline at end of file diff --git a/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt b/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt index 21458564..f137527e 100644 --- a/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt +++ b/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt @@ -3,6 +3,8 @@ package org.gdsc.presentation.view import android.content.Context import android.webkit.JavascriptInterface import android.widget.Toast +import org.gdsc.presentation.model.Route +import org.json.JSONObject /** Instantiate the interface and set the context */ class WebAppInterface( @@ -14,27 +16,15 @@ class WebAppInterface( ) { /** Show a toast from the web page */ - @JavascriptInterface - fun showToast(toast: String) { - Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show() - } @JavascriptInterface - fun navigation(isVisible: Boolean) { + fun navigation(data: String) { + val isVisible:Boolean = JSONObject(data).get("isVisible") as Boolean + if (isVisible) slideUpBottomNavigationView() else slideDownBottomNavigationView() } - @JavascriptInterface - fun editRestaurantInfo(restaurantId: Int) { - navigateToRestaurantEdit(restaurantId) - } - - // webView.canGoBack으로 뒤로가기 처리 완료해서 비워뒀습니다. - @JavascriptInterface - fun back(isEnableBack: Boolean) { - } - @JavascriptInterface fun token() = setAccessToken() @@ -43,7 +33,17 @@ class WebAppInterface( } @JavascriptInterface - fun navigate(route: String) { + fun navigate(data: String) { + when(JSONObject(data).get("route") as String) { + Route.EDIT_RESTAURANT.route-> { + val restaurantId = JSONObject(data).get("restaurantId") as Int + navigateToRestaurantEdit(restaurantId) + } + } } -} \ No newline at end of file + // webView.canGoBack으로 뒤로가기 처리 완료해서 비워뒀습니다. + @JavascriptInterface + fun back(isEnableBack: Boolean) { + } +} From 8d84f4b55bca7962709a61cb4dbb2d1ada440f71 Mon Sep 17 00:00:00 2001 From: DOGDDUDDY Date: Sun, 3 Sep 2023 20:00:48 +0900 Subject: [PATCH 06/11] =?UTF-8?q?[feat/webview=5Fbridge]:=20build=20keySto?= =?UTF-8?q?re=20=EA=B4=80=EB=A0=A8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- presentation/build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/presentation/build.gradle b/presentation/build.gradle index 113c2881..5d6b0bd5 100644 --- a/presentation/build.gradle +++ b/presentation/build.gradle @@ -25,9 +25,9 @@ android { signingConfigs { release { storeFile file("../jmtKey") - storePassword "$System.env.KEYSTORE_PASSWORD" - keyAlias "$System.env.KEY_ALIAS" - keyPassword "$System.env.KEY_PASSWORD" + storePassword "$System.env.SIGNING_STORE_PASSWORD" + keyAlias "$System.env.SIGNING_KEY_ALIAS" + keyPassword "$System.env.SIGNING_KEY_PASSWORD" } } buildTypes { From 0a0c93ac7cf62c68f7e1f9fdac84de48bbb0c4a9 Mon Sep 17 00:00:00 2001 From: DOGDDUDDY Date: Wed, 6 Sep 2023 22:18:18 +0900 Subject: [PATCH 07/11] =?UTF-8?q?[feat/webview=5Fbridge]:=20Route=20?= =?UTF-8?q?=ED=82=A4=20=EA=B0=92=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jmtKey_base64.txt | 56 +++++++++++++++++++ .../java/org/gdsc/presentation/model/Route.kt | 2 +- .../gdsc/presentation/view/WebAppInterface.kt | 9 ++- 3 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 jmtKey_base64.txt diff --git a/jmtKey_base64.txt b/jmtKey_base64.txt new file mode 100644 index 00000000..3b72197a --- /dev/null +++ b/jmtKey_base64.txt @@ -0,0 +1,56 @@ +MIIKVAIBAzCCCf4GCSqGSIb3DQEHAaCCCe8EggnrMIIJ5zCCBa4GCSqGSIb3DQEH +AaCCBZ8EggWbMIIFlzCCBZMGCyqGSIb3DQEMCgECoIIFQDCCBTwwZgYJKoZIhvcN +AQUNMFkwOAYJKoZIhvcNAQUMMCsEFH/pDFBEVd7IBTKlYt1IaKVmgoAnAgInEAIB +IDAMBggqhkiG9w0CCQUAMB0GCWCGSAFlAwQBKgQQX3yntG7xkt+K+NZ6QV0gSgSC +BNCQP0Qy3gF7SYNnzlXlvUHsg2Di7mad0g4Roilt0YuCMzNh97NsqGcbJ+gOBQA1 +JHt5oBzXLvGZCOziPyJl327UtMjJk0bSxCyN8DuoVlBNBbLrIE3oXJsKmWalvxqK +/JaGhMm8g2vNbH3KRjTP4+bW/duGEY9XcpQvkTNxibNo0XWnW7yzUik05l+HnOEK +5Wc6iqVd9+UoXBbROZEEcAmkl65rBB5LoYg29JH8L0Cl1LgTtPD3Nzsw3TyFRVrR +pa1tNUtOG4grcqVvV4Flp7GZ/wgx7I2JkElC41oDP4FDNNu/ik+7cTtS79SoORdX +imZeL2atT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P6qJHGSsTpiY4JqeeITjb6LNDKPwLBCWu5Z3acsVNrDyGoy6vVCe +N2EhQclk2cD2gMMaVpiXa1lM0/keLkJPLBzt1XPOZmTry8v9mcEvSH90hSnqiNy0 +15x2eEGg0h/0d5o4DtVySvpRo82lfXUlx6PPzQ6I3Y5IEaZO8ztJ30hrF537XjjT +/adGkKFqV7H4DSAYefukB4uKL4BEQIji7yyryPvUMAfDWXO+a2fMx/CovItSmqtZ +5zrqqU5Ga7XqKH9zp3y9hGBbG8B6rTOSG0TKo00QfR+Rtjb3Nac7X69vfXyWpWFu +l3bfiY23L0i0envmTDwNuU6QUjDVZ1MDbvsGED0SLPGZRfCoNYkceF560Plxmxxi +eaTzOJJa4RTsiy5e4epGasBwAF0Ycbx8HweG79gET0b6XHL5d0ulGNpQzuQF9Piw +UKN8Foq6pDdKGo9acJhGbwan9UUVoEh5Fd6/M4GaWxVnFJC19HwJg4vdDYwSbvX4 +ZD++rctVkzDGCBTZKP0DtQrDnKSnJ1MmUC2QA7MLceh8ZO7Xeq+Y+RKgsHjRjtl4 +2t3F2RJJNT6fqRFbSBMMVG72vx0TuXbKAlYwtzu9RZ0xaJFom7ys9y3gsnK49fB3 +NH21Doh2cOH8Yy56Aw7pR+MDIxq2cu21gPjTuVeqQfFka+jyGYpoBPvCjKnwfUgU +6G5If8zzS5VesV7QZMn55WRzka0KGK5p8zBNMDEwDQYJYIZIAWUDBAIBBQAEIJST +q/CUt9FxXKOOq8DSykYBHe5GKbAV8g3ULRgnBh3/BBSP8QjdaMnGzSozCBbtggTQ +7zWsuAICJxA= diff --git a/presentation/src/main/java/org/gdsc/presentation/model/Route.kt b/presentation/src/main/java/org/gdsc/presentation/model/Route.kt index 8105fdd9..47be5047 100644 --- a/presentation/src/main/java/org/gdsc/presentation/model/Route.kt +++ b/presentation/src/main/java/org/gdsc/presentation/model/Route.kt @@ -3,5 +3,5 @@ package org.gdsc.presentation.model enum class Route( val route: String ) { - EDIT_RESTAURANT("editRestaurantInfo"), + EDIT_RESTAURANT("editRestaurant"), } \ No newline at end of file diff --git a/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt b/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt index f137527e..9fa1b74a 100644 --- a/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt +++ b/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt @@ -6,7 +6,6 @@ import android.widget.Toast import org.gdsc.presentation.model.Route import org.json.JSONObject -/** Instantiate the interface and set the context */ class WebAppInterface( private val mContext: Context, private val slideUpBottomNavigationView: () -> Unit = {}, @@ -15,8 +14,6 @@ class WebAppInterface( private val setAccessToken: () -> Unit = {}, ) { - /** Show a toast from the web page */ - @JavascriptInterface fun navigation(data: String) { val isVisible:Boolean = JSONObject(data).get("isVisible") as Boolean @@ -28,15 +25,17 @@ class WebAppInterface( @JavascriptInterface fun token() = setAccessToken() + // 딥링크 생성 필요 @JavascriptInterface fun share() { } + // 데이터 구조는 다시 상의 후에 결정해서, 객체화 시키면 좋을 것으로 보임 @JavascriptInterface fun navigate(data: String) { - when(JSONObject(data).get("route") as String) { + when(JSONObject(data).getString("route")) { Route.EDIT_RESTAURANT.route-> { - val restaurantId = JSONObject(data).get("restaurantId") as Int + val restaurantId = JSONObject(data).getString("restaurantId").toInt() navigateToRestaurantEdit(restaurantId) } } From 774d1a8a4d130dfd229728a582ba249658ba8e71 Mon Sep 17 00:00:00 2001 From: DOGDDUDDY Date: Wed, 6 Sep 2023 22:37:54 +0900 Subject: [PATCH 08/11] =?UTF-8?q?[feat/webview=5Fbridge]:=20Web=20Url=20Co?= =?UTF-8?q?nst=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/gdsc/presentation/view/WebAppInterface.kt | 2 ++ .../main/java/org/gdsc/presentation/view/home/HomeFragment.kt | 3 ++- .../view/restaurantregistration/RegisterRestaurantFragment.kt | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt b/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt index 9fa1b74a..06c2ffa7 100644 --- a/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt +++ b/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt @@ -6,6 +6,8 @@ import android.widget.Toast import org.gdsc.presentation.model.Route import org.json.JSONObject +const val WEB_BASE_URL = "https://jmt-matzip.dev/detail/" + class WebAppInterface( private val mContext: Context, private val slideUpBottomNavigationView: () -> Unit = {}, diff --git a/presentation/src/main/java/org/gdsc/presentation/view/home/HomeFragment.kt b/presentation/src/main/java/org/gdsc/presentation/view/home/HomeFragment.kt index 274f3da0..243657f5 100644 --- a/presentation/src/main/java/org/gdsc/presentation/view/home/HomeFragment.kt +++ b/presentation/src/main/java/org/gdsc/presentation/view/home/HomeFragment.kt @@ -13,6 +13,7 @@ import dagger.hilt.android.AndroidEntryPoint import org.gdsc.presentation.databinding.FragmentHomeBinding import org.gdsc.presentation.utils.repeatWhenUiStarted import org.gdsc.presentation.view.MainActivity +import org.gdsc.presentation.view.WEB_BASE_URL import org.gdsc.presentation.view.WebAppInterface @AndroidEntryPoint @@ -39,7 +40,7 @@ class HomeFragment : Fragment() { setWebViewBackPress() binding.webView.apply { - loadUrl("https://jmt-matzip.dev") + loadUrl(WEB_BASE_URL) settings.javaScriptEnabled = true settings.domStorageEnabled = true webViewClient = WebViewClient() diff --git a/presentation/src/main/java/org/gdsc/presentation/view/restaurantregistration/RegisterRestaurantFragment.kt b/presentation/src/main/java/org/gdsc/presentation/view/restaurantregistration/RegisterRestaurantFragment.kt index f5397fc9..1a29de42 100644 --- a/presentation/src/main/java/org/gdsc/presentation/view/restaurantregistration/RegisterRestaurantFragment.kt +++ b/presentation/src/main/java/org/gdsc/presentation/view/restaurantregistration/RegisterRestaurantFragment.kt @@ -31,6 +31,7 @@ import org.gdsc.presentation.utils.animateShrinkWidth import org.gdsc.presentation.utils.checkMediaPermissions import org.gdsc.presentation.utils.findPath import org.gdsc.presentation.view.MainActivity +import org.gdsc.presentation.view.WEB_BASE_URL import org.gdsc.presentation.view.WebViewActivity import org.gdsc.presentation.view.custom.FoodCategoryBottomSheetDialog import org.gdsc.presentation.view.restaurantregistration.adapter.RegisterRestaurantAdapter @@ -243,10 +244,11 @@ class RegisterRestaurantFragment : BaseFragment() { val intent = Intent(requireContext(), WebViewActivity::class.java) + // 주소는 변경 되어야 함, 현재는 Lucy LocalHost 테스트 intent.putExtra( "url", - "http://172.20.10.13:3000/detail/$restaurantId" + "$WEB_BASE_URL$restaurantId" ) startActivity(intent) } From 093ceea9989f53cedba1287bc951f6195615def5 Mon Sep 17 00:00:00 2001 From: dogdduddy <32217176+dogdduddy@users.noreply.github.com> Date: Fri, 8 Sep 2023 12:46:00 +0900 Subject: [PATCH 09/11] Delete jmtKey_base64.txt --- jmtKey_base64.txt | 56 ----------------------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 jmtKey_base64.txt diff --git a/jmtKey_base64.txt b/jmtKey_base64.txt deleted file mode 100644 index 3b72197a..00000000 --- a/jmtKey_base64.txt +++ /dev/null @@ -1,56 +0,0 @@ -MIIKVAIBAzCCCf4GCSqGSIb3DQEHAaCCCe8EggnrMIIJ5zCCBa4GCSqGSIb3DQEH -AaCCBZ8EggWbMIIFlzCCBZMGCyqGSIb3DQEMCgECoIIFQDCCBTwwZgYJKoZIhvcN -AQUNMFkwOAYJKoZIhvcNAQUMMCsEFH/pDFBEVd7IBTKlYt1IaKVmgoAnAgInEAIB -IDAMBggqhkiG9w0CCQUAMB0GCWCGSAFlAwQBKgQQX3yntG7xkt+K+NZ6QV0gSgSC -BNCQP0Qy3gF7SYNnzlXlvUHsg2Di7mad0g4Roilt0YuCMzNh97NsqGcbJ+gOBQA1 -JHt5oBzXLvGZCOziPyJl327UtMjJk0bSxCyN8DuoVlBNBbLrIE3o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b324f358471b9831997f98fd0f4c484bb47 Mon Sep 17 00:00:00 2001 From: DOGDDUDDY Date: Sun, 10 Sep 2023 15:10:17 +0900 Subject: [PATCH 10/11] =?UTF-8?q?[feat/webview=5Fbridge]:=20=EC=9B=B9=20?= =?UTF-8?q?=EB=B2=A0=EC=9D=B4=EC=8A=A4=20URL=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/org/gdsc/presentation/view/WebAppInterface.kt | 2 +- .../view/restaurantregistration/RegisterRestaurantFragment.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt b/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt index 06c2ffa7..4112f304 100644 --- a/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt +++ b/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt @@ -6,7 +6,7 @@ import android.widget.Toast import org.gdsc.presentation.model.Route import org.json.JSONObject -const val WEB_BASE_URL = "https://jmt-matzip.dev/detail/" +const val WEB_BASE_URL = "https://jmt-matzip.dev/" class WebAppInterface( private val mContext: Context, diff --git a/presentation/src/main/java/org/gdsc/presentation/view/restaurantregistration/RegisterRestaurantFragment.kt b/presentation/src/main/java/org/gdsc/presentation/view/restaurantregistration/RegisterRestaurantFragment.kt index 1a29de42..8cce260a 100644 --- a/presentation/src/main/java/org/gdsc/presentation/view/restaurantregistration/RegisterRestaurantFragment.kt +++ b/presentation/src/main/java/org/gdsc/presentation/view/restaurantregistration/RegisterRestaurantFragment.kt @@ -248,7 +248,7 @@ class RegisterRestaurantFragment : BaseFragment() { // 주소는 변경 되어야 함, 현재는 Lucy LocalHost 테스트 intent.putExtra( "url", - "$WEB_BASE_URL$restaurantId" + "${WEB_BASE_URL}detail/$restaurantId" ) startActivity(intent) } From 80086b405620421b2cf9b02bf219677bc3ff64f5 Mon Sep 17 00:00:00 2001 From: DOGDDUDDY Date: Sun, 10 Sep 2023 15:13:20 +0900 Subject: [PATCH 11/11] =?UTF-8?q?[feat/webview=5Fbridge]:=20=EC=A4=91?= =?UTF-8?q?=EB=B3=B5=20=EC=BD=94=EB=93=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/gdsc/presentation/view/WebAppInterface.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt b/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt index 4112f304..102b732c 100644 --- a/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt +++ b/presentation/src/main/java/org/gdsc/presentation/view/WebAppInterface.kt @@ -35,9 +35,11 @@ class WebAppInterface( // 데이터 구조는 다시 상의 후에 결정해서, 객체화 시키면 좋을 것으로 보임 @JavascriptInterface fun navigate(data: String) { - when(JSONObject(data).getString("route")) { + val result = JSONObject(data) + + when(result.getString("route")) { Route.EDIT_RESTAURANT.route-> { - val restaurantId = JSONObject(data).getString("restaurantId").toInt() + val restaurantId = result.getString("restaurantId").toInt() navigateToRestaurantEdit(restaurantId) } }