feat: per-app initial scale config

This commit is contained in:
2026-08-17 20:01:01 +08:00
parent b65a0400a6
commit bb714d8de3
5 changed files with 23 additions and 12 deletions
@@ -31,7 +31,7 @@ class WebViewManager(private val activity: Activity) {
// (lifecycle is managed by the host); transparent background so a webapp without
// a declared background shows the wallpaper instead of a default white
@SuppressLint("SetJavaScriptEnabled")
fun createContentWebView(ua: String?): WebView {
fun createContentWebView(ua: String?, scale: Int?): WebView {
val webView = WebView(activity)
webView.setBackgroundColor(Color.TRANSPARENT)
configure(webView)
@@ -43,6 +43,11 @@ class WebViewManager(private val activity: Activity) {
ua == "desktop" || ua == "pc" -> UA_DESKTOP
else -> ua
}
// 初始缩放(1-100):用于 PC 版页面缩放适配横屏
// Initial zoom (1-100): scale desktop pages to fit landscape
if (scale != null && scale in 1..100) {
webView.setInitialScale(scale)
}
return webView
}