@@ -5,13 +5,14 @@ import android.content.ClipboardManager
55import android.content.Context
66import android.util.Log
77import android.webkit.JavascriptInterface
8+ import android.widget.Toast
9+ import to.dev.dev_android.BuildConfig
810
911/* *
1012 * This class currently is empty because more methods would be added to it
1113 * when new bridge functionalities are added.
1214 */
13- class AndroidWebViewBridge (private val mContext : Context ) {
14-
15+ class AndroidWebViewBridge (private val context : Context ) {
1516 /* *
1617 * Every method that has to be accessed from web-view needs to be marked with
1718 * `@JavascriptInterface`.
@@ -23,9 +24,14 @@ class AndroidWebViewBridge(private val mContext: Context) {
2324 }
2425
2526 @JavascriptInterface
26- fun copyToClipboard (text : String ) {
27- val clipboard = mContext.getSystemService(Context .CLIPBOARD_SERVICE ) as ? ClipboardManager
28- val clip = ClipData .newPlainText(" clipboard" , text)
29- clipboard?.primaryClip = clip
27+ fun copyToClipboard (copyText : String ) {
28+ val clipboard = context.getSystemService(Context .CLIPBOARD_SERVICE ) as ? ClipboardManager
29+ val clipData = ClipData .newPlainText(" DEV Community" , copyText)
30+ clipboard?.primaryClip = clipData
31+ }
32+
33+ @JavascriptInterface
34+ fun showToast (message : String ) {
35+ Toast .makeText(context, message, Toast .LENGTH_LONG ).show()
3036 }
3137}
0 commit comments