Skip to content

Commit

Permalink
Merge branch 'feat/bridge' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
dogdduddy committed Mar 7, 2023
2 parents 30e5486 + b51abec commit aa04d94
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 8 deletions.
15 changes: 8 additions & 7 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@
android:usesCleartextTraffic="true">
<activity
android:name=".view.LoginActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
android:exported="false">
</activity>
<activity
android:name=".view.WebViewActivity"
android:exported="false" />
<activity
android:name=".view.MainActivity"
android:exported="false">
android:exported="true">

<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

Expand Down
20 changes: 20 additions & 0 deletions app/src/main/assets/webviewexam.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
</head>
<body>
<p>
로딩이 완료된 웹뷰 입니다.
</p>

<input type="button" value="Say hello" onClick="showAndroidToast('Hello Black Jin World!')"/>
<script type="text/javascript">
function showAndroidToast(toast) {
Android.showToast(toast);
}

</script>
</body>
</html>
15 changes: 15 additions & 0 deletions app/src/main/java/com/dogdduddy/jmt/view/WebAppInterface.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.dogdduddy.jmt.view

import android.content.Context
import android.webkit.JavascriptInterface
import android.widget.Toast

/** Instantiate the interface and set the context */
class WebAppInterface(private val mContext: Context) {

/** Show a toast from the web page */
@JavascriptInterface
fun showToast(toast: String) {
Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show()
}
}
7 changes: 6 additions & 1 deletion app/src/main/java/com/dogdduddy/jmt/view/WebViewActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ class WebViewActivity : AppCompatActivity() {

webView = binding.webView
webViewInit()

/*
intent.extras?.let {
binding.webView.loadUrl(it.getString("url")!!)
}
// https://jmt-matzip.dev/
*/
//binding.webView.loadUrl("file:///android_asset/webviewexam.html")
binding.webView.loadUrl("https://jmt-matzip.dev/")

val actionBar: ActionBar? = supportActionBar
actionBar!!.hide()
Expand All @@ -35,5 +39,6 @@ class WebViewActivity : AppCompatActivity() {
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) //화면이 계속 켜짐
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_FULL_USER
webView.setWebViewClient(WebViewClient())
webView.addJavascriptInterface(WebAppInterface(this), "Android")
}
}

0 comments on commit aa04d94

Please sign in to comment.