feat: hide foreground webapp when switching sidebar pages
This commit is contained in:
@@ -293,6 +293,12 @@ class MainActivity : Activity() {
|
||||
Log.d(TAG, "switchWebView: id=$id")
|
||||
}
|
||||
|
||||
override fun hideAll() {
|
||||
contentWebViews.values.forEach { it.visibility = View.GONE }
|
||||
currentVisibleId = null
|
||||
Log.d(TAG, "hideAll: hidden ${contentWebViews.size} webviews")
|
||||
}
|
||||
|
||||
override fun goBack(): Boolean {
|
||||
val webView = currentVisibleId?.let { contentWebViews[it] }
|
||||
return if (webView != null && webView.canGoBack()) {
|
||||
|
||||
@@ -202,6 +202,16 @@ class JsBridge(
|
||||
Log.d("HearthBridge", "webReload called")
|
||||
}
|
||||
|
||||
// 隐藏所有内容 WebView(把前台 webapp 丢到后台,标签状态保留)
|
||||
// Hide all content WebViews (send the foreground webapp to background,
|
||||
// keeping the tab state) — called when the user switches pages via the sidebar
|
||||
@android.webkit.JavascriptInterface
|
||||
fun hideWebApps() {
|
||||
val host = webAppHost ?: return
|
||||
onMain { host.hideAll() }
|
||||
Log.d("HearthBridge", "hideWebApps called")
|
||||
}
|
||||
|
||||
// 清单内存缓存:首次拉取成功后缓存,后续复用(避免 openWebApp 重复 I/O)
|
||||
// 空结果(离线失败)不缓存,下次调用重试拉取,避免空清单被永久缓存
|
||||
// In-memory manifest cache: cache only on a successful non-empty fetch (avoid
|
||||
|
||||
@@ -35,4 +35,9 @@ interface WebAppHost {
|
||||
// 将标签状态推送到桌面 H5 顶栏
|
||||
// Push the tab state to the desktop H5 topbar
|
||||
fun syncTabs(tabs: List<Tab>)
|
||||
|
||||
// 隐藏所有内容 WebView(把前台 webapp 丢到后台,标签状态保留)
|
||||
// Hide all content WebViews (send the foreground webapp to background,
|
||||
// keeping the tab state)
|
||||
fun hideAll()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user