Skip to content

TagSpaces is an offline, open source, document manager with tagging support

fix: ui under the notch on Android issue

Ilian Sapundshiev9e0b3e835e71
diff --git a/capacitor/android/app/src/main/java/org/tagspaces/mobileapp/MainActivity.java b/capacitor/android/app/src/main/java/org/tagspaces/mobileapp/MainActivity.java
index cad6d8b73..d887548bb 100644
--- a/capacitor/android/app/src/main/java/org/tagspaces/mobileapp/MainActivity.java
+++ b/capacitor/android/app/src/main/java/org/tagspaces/mobileapp/MainActivity.java
@@ -1,6 +1,10 @@
package org.tagspaces.mobileapp;
import android.os.Bundle;
+import android.view.View;
+import androidx.core.graphics.Insets;
+import androidx.core.view.ViewCompat;
+import androidx.core.view.WindowInsetsCompat;
import com.getcapacitor.BridgeActivity;
import org.tagspaces.plugins.IntentHandlerPlugin;
import org.tagspaces.plugins.StoragePermissionPlugin;
@@ -11,5 +15,25 @@ public class MainActivity extends BridgeActivity {
registerPlugin(StoragePermissionPlugin.class);
registerPlugin(IntentHandlerPlugin.class);
super.onCreate(savedInstanceState);
+ insetWebViewFromSystemBars();
+ }
+
+ // Android 15+ (targetSdk 35+) force-enables edge-to-edge: the WebView always
+ // extends behind the status bar, notch, and gesture nav. StatusBar plugin's
+ // setOverlaysWebView({overlay:false}) became a no-op, and the SDK-35 opt-out
+ // flag was removed in SDK 36. We restore pre-edge-to-edge behavior by padding
+ // the WebView's parent so the WebView itself no longer overlaps system bars —
+ // this fixes both flow and position:fixed/absolute UI inside the WebView.
+ private void insetWebViewFromSystemBars() {
+ final View parent = (View) getBridge().getWebView().getParent();
+ if (parent == null) return;
+ ViewCompat.setOnApplyWindowInsetsListener(parent, (v, insets) -> {
+ Insets bars = insets.getInsets(
+ WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout()
+ );
+ v.setPadding(bars.left, bars.top, bars.right, bars.bottom);
+ return WindowInsetsCompat.CONSUMED;
+ });
+ ViewCompat.requestApplyInsets(parent);
}
}
diff --git a/capacitor/www/index.html b/capacitor/www/index.html
index a449088cf..ac2241d47 100644
--- a/capacitor/www/index.html
+++ b/capacitor/www/index.html
@@ -39,28 +39,6 @@
<meta name="apple-mobile-web-app-title" content="TagSpaces">
<link rel="stylesheet" type="text/css" href="dist/style.css">
<script type="text/javascript" src="extconfig.js"></script>
- <script>
- // Android: detect status bar height and apply as padding if safe-area-inset is 0
- document.addEventListener('DOMContentLoaded', function() {
- if (window.Capacitor && window.Capacitor.isNativePlatform && window.Capacitor.isNativePlatform()) {
- // Wait for Capacitor plugins to be ready
- setTimeout(function() {
- try {
- if (window.Capacitor.Plugins && window.Capacitor.Plugins.StatusBar) {
- window.Capacitor.Plugins.StatusBar.getInfo().then(function(info) {
- if (info && info.height && info.height > 0) {
- var currentPadding = parseInt(window.getComputedStyle(document.body).paddingTop) || 0;
- if (currentPadding < info.height) {
- document.body.style.paddingTop = info.height + 'px';
- }
- }
- }).catch(function() {});
- }
- } catch(e) {}
- }, 500);
- }
- });
- </script>
</head>
<body style="overflow: hidden; margin: 0;">