feat: webview manager and js bridge skeleton
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package top.yeij.hearth.webview
|
||||
|
||||
import android.util.Log
|
||||
|
||||
class JsBridge(
|
||||
private val deviceWidthPx: Int,
|
||||
private val deviceHeightPx: Int,
|
||||
private val density: Float,
|
||||
private val darkMode: Boolean,
|
||||
) {
|
||||
private val gson = com.google.gson.Gson()
|
||||
|
||||
@android.webkit.JavascriptInterface
|
||||
fun getDeviceInfo(): String {
|
||||
Log.d("HearthBridge", "getDeviceInfo called")
|
||||
return gson.toJson(
|
||||
mapOf(
|
||||
"widthPx" to deviceWidthPx,
|
||||
"heightPx" to deviceHeightPx,
|
||||
"density" to density,
|
||||
"darkMode" to darkMode
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user