manager: Add jsapi: toast

This commit is contained in:
weishu 2024-02-22 20:40:52 +08:00
parent 66e7db2a4e
commit f20ccc1728
No known key found for this signature in database
GPG Key ID: 6D3F65FFD9559C06

View File

@ -9,6 +9,7 @@ import android.text.TextUtils
import android.view.Window
import android.webkit.JavascriptInterface
import android.webkit.WebView
import android.widget.Toast
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
@ -132,6 +133,13 @@ class WebViewInterface(val context: Context, val webView: WebView) {
}
}
@JavascriptInterface
fun toast(msg: String) {
webView.post {
Toast.makeText(context, msg, Toast.LENGTH_SHORT).show()
}
}
@JavascriptInterface
fun fullScreen(enable: Boolean) {
if (context is Activity) {