From 206f72a97bdfd3baa0eb6a1a6f00d97b55dbe9c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Boduro=C4=9Flu?= <80620802+burakboduroglu@users.noreply.github.com> Date: Sun, 23 Aug 2026 22:27:32 +0300 Subject: [PATCH] Hand the gesture bar's height to the page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- frontend | 2 +- .../main/java/co/hezarfen/app/MainActivity.kt | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/frontend b/frontend index 3392c98..d92d9c6 160000 --- a/frontend +++ b/frontend @@ -1 +1 @@ -Subproject commit 3392c985678fa6f0b6a0abf5676ad7f0c718988d +Subproject commit d92d9c6add1380d291341821e27fde0c80880294 diff --git a/src-tauri/gen/android/app/src/main/java/co/hezarfen/app/MainActivity.kt b/src-tauri/gen/android/app/src/main/java/co/hezarfen/app/MainActivity.kt index 3d22f85..b4810d9 100644 --- a/src-tauri/gen/android/app/src/main/java/co/hezarfen/app/MainActivity.kt +++ b/src-tauri/gen/android/app/src/main/java/co/hezarfen/app/MainActivity.kt @@ -1,11 +1,55 @@ package co.hezarfen.app import android.os.Bundle +import android.webkit.WebView import androidx.activity.enableEdgeToEdge +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat class MainActivity : TauriActivity() { + private var webView: WebView? = null + override fun onCreate(savedInstanceState: Bundle?) { enableEdgeToEdge() super.onCreate(savedInstanceState) } + + // On Android, CSS env(safe-area-inset-*) only reports the display cutout, so + // the page can see the camera notch but not the gesture bar — the bottom tab + // bar would render underneath it. Only the system knows that height, so read + // it here and hand it to the page as a custom property its layout can pad by. + // Keeping the padding inside the page (rather than insetting the webview) + // means the tab bar's own background covers the strip, so it stays the colour + // of whichever theme the user picked in the app. + // + // The insets are read from the view rather than through an + // OnApplyWindowInsetsListener on purpose: installing that listener takes over + // the webview's inset handling, and the page then loses + // env(safe-area-inset-top) — the cutout is only reported to CSS while the + // webview applies the insets itself. + override fun onWebViewCreate(webView: WebView) { + this.webView = webView + webView.addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ -> publishBottomInset() } + // The first layout can land before the page has a document to set the + // property on; this catches that case. + webView.postDelayed({ publishBottomInset() }, 500) + } + + override fun onResume() { + super.onResume() + // Re-applied after a reload or a return from the background, when the + // property set above no longer exists on the new document. + publishBottomInset() + } + + private fun publishBottomInset() { + val view = webView ?: return + val insets = ViewCompat.getRootWindowInsets(view) ?: return + val bottom = insets.getInsets(WindowInsetsCompat.Type.systemBars()).bottom + val dp = bottom / view.resources.displayMetrics.density + view.evaluateJavascript( + "document.documentElement.style.setProperty('--android-nav-inset', '${dp}px')", + null, + ) + } }