feat: webview manager and js bridge skeleton
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
package top.yeij.hearth
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.res.Configuration
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.WindowInsets
|
||||
import android.view.WindowInsetsController
|
||||
import top.yeij.hearth.webview.JsBridge
|
||||
import top.yeij.hearth.webview.WebViewManager
|
||||
|
||||
// HOME 桌面 activity,后续 Task 挂载 WebView 与 JsBridge
|
||||
// HOME launcher activity; later tasks mount WebView and JsBridge
|
||||
@@ -18,6 +21,28 @@ class MainActivity : Activity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
Log.d(TAG, "onCreate: enter immersive mode")
|
||||
enterImmersive()
|
||||
setupWebView()
|
||||
}
|
||||
|
||||
// 创建 JsBridge 并挂载 WebView 桌面层
|
||||
// Create JsBridge and mount the WebView launcher layer
|
||||
private fun setupWebView() {
|
||||
val dm = resources.displayMetrics
|
||||
val darkMode =
|
||||
(resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) ==
|
||||
Configuration.UI_MODE_NIGHT_YES
|
||||
val bridge = JsBridge(
|
||||
deviceWidthPx = dm.widthPixels,
|
||||
deviceHeightPx = dm.heightPixels,
|
||||
density = dm.density,
|
||||
darkMode = darkMode,
|
||||
)
|
||||
WebViewManager(this).attach(bridge)
|
||||
Log.d(
|
||||
TAG,
|
||||
"setupWebView: attached WebView ${dm.widthPixels}x${dm.heightPixels}" +
|
||||
" density=${dm.density} darkMode=$darkMode"
|
||||
)
|
||||
}
|
||||
|
||||
// 进入沉浸式全屏:隐藏状态栏与导航栏,滑动可临时唤出
|
||||
|
||||
Reference in New Issue
Block a user