Skip to content

Fix navigation drawer not switching screens on first launch#374

Merged
cbalster merged 1 commit into
criticalmaps:masterfrom
richterrene:fix/first-launch-drawer-navigation
Jun 15, 2026
Merged

Fix navigation drawer not switching screens on first launch#374
cbalster merged 1 commit into
criticalmaps:masterfrom
richterrene:fix/first-launch-drawer-navigation

Conversation

@richterrene

Copy link
Copy Markdown
Contributor

What

Fixes the first-launch bug where the navigation drawer opens but tapping a menu entry (Chat / Rules / Settings / About) does not switch screens — the app stays on Map until it is force-stopped and relaunched.

Fixes #373.

Root cause

activity_main.xml gave DrawerLayout two content children plus the drawer:

DrawerLayout
 ├─ CoordinatorLayout   (content_frame + toolbar)   ← content child #1
 ├─ NavigationView      (layout_gravity="start")      ← drawer
 └─ LinearLayout @+id/introduction_view               ← content child #2 (no layout_gravity)

introduction_view is a full-screen, clickable/focusable view with no layout_gravity, so DrawerLayout treats it as a second content view. It is only shown on first launch (until the privacy policy is accepted) and then hidden. Showing then hiding that extra content child leaves DrawerLayout's touch handling broken for the session: taps on NavigationView rows are swallowed as a "close drawer" gesture, so onNavigationItemSelected never fires. A restart recreates the hierarchy cleanly and the overlay is never shown again, which is why a restart "fixes" it.

Fix

Wrap the content and the intro overlay in a single FrameLayout so DrawerLayout has exactly one content child plus the NavigationView drawer. Layout-only change — no Java changes.

Testing

Verified on a Pixel emulator (API 36) against master:

Tap Chat on first launch
Before drawer closes, stays on Map; onNavigationItemSelected never fires
After navigates to ChatFragment; Rules/Settings also verified

Confirmed via dumpsys activity top (fragment swap) and instrumented onNavigationItemSelected / onDrawerClosed / navigateTo logging on both first-launch and post-restart paths.

Note

A Kotlin/Compose rewrite exists on migrate_to_kotlin_and_compose, but master still ships this Java/XML screen, so this targets master. If the Compose UI replaces this screen, the same "single content child under the drawer" rule should carry over.

introduction_view was a second content child of DrawerLayout (no
layout_gravity). Showing then hiding it on first launch broke
DrawerLayout touch handling, so taps on menu rows closed the drawer
instead of selecting the item, and onNavigationItemSelected never fired.

Wrap the content and the intro overlay in a single FrameLayout so
DrawerLayout has exactly one content child plus the NavigationView
drawer. Layout-only change.

Fixes criticalmaps#373
@richterrene richterrene requested a review from a team as a code owner June 14, 2026 10:19
@cbalster

Copy link
Copy Markdown
Member

Hi @richterrene,
lgtm - thank you very much :)

@cbalster cbalster merged commit 1649517 into criticalmaps:master Jun 15, 2026
1 check passed
@stephanlindauer

Copy link
Copy Markdown
Member

Merci @richterrene!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Navigation drawer doesn't switch screens on first launch (works after restart)

3 participants