@@ -5,13 +5,14 @@ import android.content.ClipboardManager
5
5
import android.content.Context
6
6
import android.util.Log
7
7
import android.webkit.JavascriptInterface
8
+ import android.widget.Toast
9
+ import to.dev.dev_android.BuildConfig
8
10
9
11
/* *
10
12
* This class currently is empty because more methods would be added to it
11
13
* when new bridge functionalities are added.
12
14
*/
13
- class AndroidWebViewBridge (private val mContext : Context ) {
14
-
15
+ class AndroidWebViewBridge (private val context : Context ) {
15
16
/* *
16
17
* Every method that has to be accessed from web-view needs to be marked with
17
18
* `@JavascriptInterface`.
@@ -23,9 +24,14 @@ class AndroidWebViewBridge(private val mContext: Context) {
23
24
}
24
25
25
26
@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()
30
36
}
31
37
}
0 commit comments