From 3ed40a4879a924026d258b13ade9246f5337d6b0 Mon Sep 17 00:00:00 2001 From: MiMoHo <37556964+MiMoHo@users.noreply.github.com> Date: Thu, 9 Jul 2026 00:09:40 +0200 Subject: [PATCH] fix(edit): keep editor toolbar below the status bar after activity recreation EditNoteActivity registered its window insets listener on the DecorView. A listener set there replaces DecorView#onApplyWindowInsets during insets dispatch, so the platform's own system bar fitting silently depends on decor-internal state: after the activity is recreated (for example when the system switches between light and dark theme while a note is open), the new DecorView never applies the status bar offset and the toolbar - including the in-note search bar - is drawn behind the status bar. Register the listener on the activity's content view instead and apply the insets that actually arrive there. This leaves the platform's decor handling intact: when the platform already fits the system bars, the arriving insets are consumed and no extra padding is added; on a truly edge-to-edge window the content view now pads itself, including the display cutout. The bottom padding keeps the max(IME, system bar) logic from the fix for #2700. Reproduced on an Android 15 emulator by toggling dark mode while a note was open (adb shell cmd uimode night yes). Assisted-by: Claude Code:claude-fable-5 AI-assistant: Claude Code 2.1.195 (Claude Fable 5) Signed-off-by: MiMoHo <37556964+MiMoHo@users.noreply.github.com> --- .../owncloud/notes/edit/EditNoteActivity.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/it/niedermann/owncloud/notes/edit/EditNoteActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/edit/EditNoteActivity.java index 1a669e615..2f96f2cfe 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/edit/EditNoteActivity.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/edit/EditNoteActivity.java @@ -108,7 +108,7 @@ protected void onCreate(final Bundle savedInstanceState) { setSupportActionBar(binding.toolbar); binding.toolbar.setOnClickListener((v) -> fragment.showEditTitleDialog()); - setImeInsets(); + setWindowInsets(); getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) { @Override @@ -120,7 +120,7 @@ public void handleOnBackPressed() { }); } - private void setImeInsets() { + private void setWindowInsets() { final var window = getWindow(); if (window == null) { return; @@ -128,22 +128,22 @@ private void setImeInsets() { WindowCompat.setDecorFitsSystemWindows(window, false); - final var decorView = window.getDecorView(); - ViewCompat.setOnApplyWindowInsetsListener(decorView, (v, insets) -> { + ViewCompat.setOnApplyWindowInsetsListener(binding.getRoot(), (v, insets) -> { + Insets barInsets = insets.getInsets( + WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout()); Insets imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime()); - Insets navBarInsets = insets.getInsets(WindowInsetsCompat.Type.navigationBars()); // Apply bottom padding when keyboard is shown - int bottomPadding = Math.max(imeInsets.bottom, navBarInsets.bottom); + int bottomPadding = Math.max(imeInsets.bottom, barInsets.bottom); v.setPadding( - v.getPaddingLeft(), - v.getPaddingTop(), - v.getPaddingRight(), + barInsets.left, + barInsets.top, + barInsets.right, bottomPadding ); - return insets; + return WindowInsetsCompat.CONSUMED; }); }