Skip to content

Fix: Settings title stuck when backing out of sub-menus#2387

Merged
d4rken merged 2 commits intomainfrom
fix/settings-toolbar-title-stuck
Apr 17, 2026
Merged

Fix: Settings title stuck when backing out of sub-menus#2387
d4rken merged 2 commits intomainfrom
fix/settings-toolbar-title-stuck

Conversation

@d4rken
Copy link
Copy Markdown
Member

@d4rken d4rken commented Apr 17, 2026

What changed

Fixed a bug on Android 16 where the Settings header stayed on a sub-page's name (e.g. "CorpseFinder") after backing out to the main Settings list with the system back button. The page content returned correctly — only the title stayed stuck. The toolbar's own back arrow was not affected.

Technical Context

  • Root cause: on Android 16's predictive-back path, the new fragment reaches RESUMED before childFragmentManager.backStackEntryCount has been decremented. Both onBackStackChanged and onFragmentResumed see a stale count.
  • The old code kept a parallel screens: ArrayList<Screen> mirroring the back stack and updated the toolbar from addOnBackStackChangedListener. On Android 16 the listener fired once with the pre-pop count and never fired again after the actual pop, so the toolbar stayed on the sub-page's title.
  • New approach: register a FragmentLifecycleCallbacks and, on each child onFragmentResumed, read the title directly from the fragment's own arguments (BKEY_SCREEN_TITLE). The root fragment has no such arg, so it falls back to the default "Settings". No back-stack-count reads in the hot path — no more stale-value race.
  • Scope is limited to SettingsFragment.kt. Shared infra (PreferenceFragment2, ToolbarHost) is untouched — SqueezerSettingsFragment uses PreferenceFragment2 as a top-level nav route without a ToolbarHost parent, and this fix shouldn't leak into that path.
  • Verified on an Android 16 emulator: forward nav, system back, toolbar up arrow, and the Settings → Support → Contact form → back path (regression guard from #60dd3e66a) all land on the correct title/subtitle.

Closes #2386

On Android 16 with predictive back, childFragmentManager's back-stack-changed listener fires while the new fragment is already RESUMED but backStackEntryCount has not yet been decremented. The old implementation read the count during the callback and ended up re-applying the previous sub-screen's title over the restored index content.

Drive the toolbar from FragmentLifecycleCallbacks.onFragmentResumed instead, and derive title from the child fragment's own arguments rather than a parallel screens list. No back-stack-count lookups means no stale-value race.

Closes #2386
@d4rken d4rken added bug Something isn't working as expected General UI/UX User Interface/Experience api: 36 A16 (Baklava) labels Apr 17, 2026
@d4rken d4rken merged commit 44e9740 into main Apr 17, 2026
12 checks passed
@d4rken d4rken deleted the fix/settings-toolbar-title-stuck branch April 17, 2026 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: 36 A16 (Baklava) bug Something isn't working as expected General UI/UX User Interface/Experience

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Back Button on Settings Menu

1 participant