Skip to content

Commit 3ed40a4

Browse files
committed
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>
1 parent 6315891 commit 3ed40a4

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

‎app/src/main/java/it/niedermann/owncloud/notes/edit/EditNoteActivity.java‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ protected void onCreate(final Bundle savedInstanceState) {
108108

109109
setSupportActionBar(binding.toolbar);
110110
binding.toolbar.setOnClickListener((v) -> fragment.showEditTitleDialog());
111-
setImeInsets();
111+
setWindowInsets();
112112

113113
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
114114
@Override
@@ -120,30 +120,30 @@ public void handleOnBackPressed() {
120120
});
121121
}
122122

123-
private void setImeInsets() {
123+
private void setWindowInsets() {
124124
final var window = getWindow();
125125
if (window == null) {
126126
return;
127127
}
128128

129129
WindowCompat.setDecorFitsSystemWindows(window, false);
130130

131-
final var decorView = window.getDecorView();
132-
ViewCompat.setOnApplyWindowInsetsListener(decorView, (v, insets) -> {
131+
ViewCompat.setOnApplyWindowInsetsListener(binding.getRoot(), (v, insets) -> {
132+
Insets barInsets = insets.getInsets(
133+
WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout());
133134
Insets imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime());
134-
Insets navBarInsets = insets.getInsets(WindowInsetsCompat.Type.navigationBars());
135135

136136
// Apply bottom padding when keyboard is shown
137-
int bottomPadding = Math.max(imeInsets.bottom, navBarInsets.bottom);
137+
int bottomPadding = Math.max(imeInsets.bottom, barInsets.bottom);
138138

139139
v.setPadding(
140-
v.getPaddingLeft(),
141-
v.getPaddingTop(),
142-
v.getPaddingRight(),
140+
barInsets.left,
141+
barInsets.top,
142+
barInsets.right,
143143
bottomPadding
144144
);
145145

146-
return insets;
146+
return WindowInsetsCompat.CONSUMED;
147147
});
148148
}
149149

0 commit comments

Comments
 (0)