From 003c399ecf9102899727c07b4974ddd79369849f 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 23:21:05 +0300 Subject: [PATCH] Expose the gesture-bar height to the page as a bridge Pushing the value in with evaluateJavascript only reached the document that happened to be loaded: after a reload the property was gone and the tab bar went back under the gesture pill. A JavascriptInterface is bound to the webview instead, so any document can read it before its first paint. --- frontend | 2 +- .../main/java/co/hezarfen/app/MainActivity.kt | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/frontend b/frontend index 4448c06..a6408c3 160000 --- a/frontend +++ b/frontend @@ -1 +1 @@ -Subproject commit 4448c0633bc8af87f783f58976e79eae15f6fe2c +Subproject commit a6408c3f840031b794525bef3a525ad5fe8daab5 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 ca8a189..7308f82 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,6 +1,7 @@ package co.hezarfen.app import android.os.Bundle +import android.webkit.JavascriptInterface import android.webkit.WebView import androidx.activity.enableEdgeToEdge import androidx.core.view.ViewCompat @@ -9,6 +10,22 @@ import androidx.core.view.WindowInsetsCompat class MainActivity : TauriActivity() { private var webView: WebView? = null + /** + * What the page can ask the shell about the device it is running on. Bound to + * the webview, so it survives navigations and reloads — unlike a value pushed + * into a document, which dies with that document. + */ + inner class ShellBridge { + /** Height of the gesture bar in CSS pixels; 0 when there is none. */ + @JavascriptInterface + fun bottomInsetPx(): Float { + val view = webView ?: return 0f + val insets = ViewCompat.getRootWindowInsets(view) ?: return 0f + return insets.getInsets(WindowInsetsCompat.Type.systemBars()).bottom / + view.resources.displayMetrics.density + } + } + override fun onCreate(savedInstanceState: Bundle?) { enableEdgeToEdge() super.onCreate(savedInstanceState) @@ -29,6 +46,7 @@ class MainActivity : TauriActivity() { // webview applies the insets itself. override fun onWebViewCreate(webView: WebView) { this.webView = webView + webView.addJavascriptInterface(ShellBridge(), "HezarfenShell") // The page hides scrollbars in CSS, but those rules cannot reach the ones // Android draws over the webview itself, which is what still flashes down