forge
Explore
Log in

Don't you dare go Hollow

Hand the gesture bar's height to the page

Browse files at this commit

206f72a97bdfd3baa0eb6a1a6f00d97b55dbe9c9Burak BoduroğluParent: 57ff759
Android reports only the display cutout through CSS env(safe-area-inset-*),
so the web app can see the camera notch but not the navigation bar, and its
bottom tab bar rendered underneath the gesture pill. MainActivity measures
the inset and sets it on the document as --android-nav-inset, which the tab
bar and the drawers pad by.

The height is read from the view rather than through an
OnApplyWindowInsetsListener: installing that listener takes over the
webview's own inset handling, and the page then loses
env(safe-area-inset-top) — the top bar slides back under the clock. Verified
on the emulator both ways round.
frontendmodified+1 -1
@@ -1 +1 @@
1-Subproject commit 3392c985678fa6f0b6a0abf5676ad7f0c718988d
1+Subproject commit d92d9c6add1380d291341821e27fde0c80880294
src-tauri/gen/android/app/src/main/java/co/hezarfen/app/MainActivity.ktmodified+44 -0
@@ -1,11 +1,55 @@
11 package co.hezarfen.app
22
33 import android.os.Bundle
4+import android.webkit.WebView
45 import androidx.activity.enableEdgeToEdge
6+import androidx.core.view.ViewCompat
7+import androidx.core.view.WindowInsetsCompat
58
69 class MainActivity : TauriActivity() {
10+ private var webView: WebView? = null
11+
712 override fun onCreate(savedInstanceState: Bundle?) {
813 enableEdgeToEdge()
914 super.onCreate(savedInstanceState)
1015 }
16+
17+ // On Android, CSS env(safe-area-inset-*) only reports the display cutout, so
18+ // the page can see the camera notch but not the gesture bar — the bottom tab
19+ // bar would render underneath it. Only the system knows that height, so read
20+ // it here and hand it to the page as a custom property its layout can pad by.
21+ // Keeping the padding inside the page (rather than insetting the webview)
22+ // means the tab bar's own background covers the strip, so it stays the colour
23+ // of whichever theme the user picked in the app.
24+ //
25+ // The insets are read from the view rather than through an
26+ // OnApplyWindowInsetsListener on purpose: installing that listener takes over
27+ // the webview's inset handling, and the page then loses
28+ // env(safe-area-inset-top) — the cutout is only reported to CSS while the
29+ // webview applies the insets itself.
30+ override fun onWebViewCreate(webView: WebView) {
31+ this.webView = webView
32+ webView.addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ -> publishBottomInset() }
33+ // The first layout can land before the page has a document to set the
34+ // property on; this catches that case.
35+ webView.postDelayed({ publishBottomInset() }, 500)
36+ }
37+
38+ override fun onResume() {
39+ super.onResume()
40+ // Re-applied after a reload or a return from the background, when the
41+ // property set above no longer exists on the new document.
42+ publishBottomInset()
43+ }
44+
45+ private fun publishBottomInset() {
46+ val view = webView ?: return
47+ val insets = ViewCompat.getRootWindowInsets(view) ?: return
48+ val bottom = insets.getInsets(WindowInsetsCompat.Type.systemBars()).bottom
49+ val dp = bottom / view.resources.displayMetrics.density
50+ view.evaluateJavascript(
51+ "document.documentElement.style.setProperty('--android-nav-inset', '${dp}px')",
52+ null,
53+ )
54+ }
1155 }