Skip to content

Build your personal knowledge base with Trilium Notes

fix(mobile): keep the layout clear of the notch in landscape

Elian Doran7f3f2acf9d2d
diff --git a/apps/client/src/stylesheets/style.css b/apps/client/src/stylesheets/style.css
index 7f3598fd1a..b4152316ae 100644
--- a/apps/client/src/stylesheets/style.css
+++ b/apps/client/src/stylesheets/style.css
@@ -128,6 +128,8 @@ body.mobile.context-menu-shown * {
body.mobile #root-widget {
padding-top: var(--safe-area-inset-top, env(safe-area-inset-top));
+ padding-left: var(--safe-area-inset-left, env(safe-area-inset-left));
+ padding-right: var(--safe-area-inset-right, env(safe-area-inset-right));
}
body.mobile #root-widget.virtual-keyboard-opened #mobile-bottom-bar {
diff --git a/apps/client/src/widgets/mobile_widgets/hide_keyboard_button.css b/apps/client/src/widgets/mobile_widgets/hide_keyboard_button.css
index 2906362563..c98d7f9c35 100644
--- a/apps/client/src/widgets/mobile_widgets/hide_keyboard_button.css
+++ b/apps/client/src/widgets/mobile_widgets/hide_keyboard_button.css
@@ -40,7 +40,7 @@ body.mobile .hide-keyboard-button {
contain: none;
position: fixed;
bottom: 0;
- inset-inline-end: 0;
+ right: var(--safe-area-inset-right, env(safe-area-inset-right));
margin-inline-end: var(--mobile-toolbar-gap);
margin-bottom: var(--mobile-toolbar-gap);
/* Above every dialog (2000, plus 10 per stacked one in `dialog.ts`) and menu,
@@ -55,6 +55,11 @@ body.mobile .hide-keyboard-button {
}
}
+body.mobile[dir="rtl"] .hide-keyboard-button {
+ right: auto;
+ left: var(--safe-area-inset-left, env(safe-area-inset-left));
+}
+
body.mobile:has(.classic-toolbar-outer-container.active) .hide-keyboard-button,
body.mobile:not(:has(:focus)) .hide-keyboard-button {
display: none;
diff --git a/apps/mobile/android/app/src/main/java/org/triliumnotes/trilium/MainActivity.java b/apps/mobile/android/app/src/main/java/org/triliumnotes/trilium/MainActivity.java
index dfc55eb38b..b972e0439d 100644
--- a/apps/mobile/android/app/src/main/java/org/triliumnotes/trilium/MainActivity.java
+++ b/apps/mobile/android/app/src/main/java/org/triliumnotes/trilium/MainActivity.java
@@ -54,22 +54,23 @@ public class MainActivity extends BridgeActivity {
}
/**
- * Injects system bar insets into the WebView as CSS custom properties,
+ * Injects system bar and display cutout insets into the WebView as CSS custom properties,
* since Android's WebView doesn't populate env(safe-area-inset-*).
* Also handles IME (keyboard) insets to shrink the viewport instead of scrolling.
*/
private void forwardInsetsToWebView() {
View decorView = getWindow().getDecorView();
ViewCompat.setOnApplyWindowInsetsListener(decorView, (v, insets) -> {
- Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
+ Insets safeArea = insets.getInsets(
+ WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout());
Insets ime = insets.getInsets(WindowInsetsCompat.Type.ime());
boolean isKeyboardVisible = insets.isVisible(WindowInsetsCompat.Type.ime());
float density = getResources().getDisplayMetrics().density;
- int top = Math.round(systemBars.top / density);
- int bottom = Math.round(systemBars.bottom / density);
- int left = Math.round(systemBars.left / density);
- int right = Math.round(systemBars.right / density);
+ int top = Math.round(safeArea.top / density);
+ int bottom = Math.round(safeArea.bottom / density);
+ int left = Math.round(safeArea.left / density);
+ int right = Math.round(safeArea.right / density);
int keyboardHeight = Math.round(ime.bottom / density);
String js = "document.documentElement.style.setProperty('--safe-area-inset-top', '" + top + "px');"