Skip to content

Conversation

@sande11
Copy link

@sande11 sande11 commented Nov 11, 2025

Summary

This PR fixes two related issues on the Saved (My Bookmarks) screen:
The bottom navigation items (Home/Search/Settings) were not receiving taps because the fragment content overlapped the BottomNavigationView.
The Home button behaviour was inconsistent: after visiting Saved and then switching to Search or Settings, tapping Home could return the user back to Saved instead of always taking them to Home.

What was causing the bug

Touch interception: fragment_saved's RecyclerView was constrained to the parent bottom edge and could overlap the BottomNavigationView; even when the nav was visible on top, the RecyclerView continued to intercept touch events so taps on the bottom nav did nothing in some states.

Navigation/back-stack semantics: SavedFragment is not a bottom-nav destination. After navigating from mainFragment → savedFragment, the BottomNavigationView still showed the Home item as selected. The Navigation component (via setupWithNavController) will ignore reselection by default. Because of the back stack state, tapping Home did not always navigate to the true mainFragment—it sometimes left savedFragment on top, producing the incorrect behaviour.

Solution

Prevent touch interception by leaving space at the bottom of the content: add bottom padding to the RecyclerView in fragment_saved.xml and use a dimen resource for the nav height. clipToPadding="false" allows the RecyclerView to scroll under that padding while keeping the bottom touch area free.
Make bottom-nav selection explicit: intercept bottom nav item selections and either pop back to the matching destination if it exists in the back stack or navigate to it otherwise. Also keep a reselection handler for consistent behavior on tapping an already-selected tab. This ensures Home always navigates to mainFragment.

Files changed

fragment_saved.xml
Added: android:paddingBottom="@dimen/bottom_nav_height" on bookmarks_recycler_view (keeps bottom nav clickable)
dimens.xml
Added: 72dp (adjustable)

MainActivity.kt
Added a custom setOnItemSelectedListener to the BottomNavigationView that:
tries navController.popBackStack(, false) and navigates if pop failed
guarantees selecting Home always ends up on mainFragment
Added a setOnItemReselectedListener to handle reselection (pop back to root of that tab)

 // Intercept bottom navigation selections so that selecting any bottom-nav
        // item always navigates to that destination (popping back to it if it's
        // already in the back stack). This guarantees the Home button always
        // leads to the mainFragment regardless of intermediate navigation.
        binding.bottomNavigationView.setOnItemSelectedListener { item ->
            when (item.itemId) {
                R.id.mainFragment -> {
                    // If mainFragment is already in the back stack, pop back to it.
                    // Otherwise navigate to it.
                    val popped = navController.popBackStack(R.id.mainFragment, false)
                    if (!popped) navController.navigate(R.id.mainFragment)
                    true
                }
                R.id.globalSearchFragment -> {
                    val popped = navController.popBackStack(R.id.globalSearchFragment, false)
                    if (!popped) navController.navigate(R.id.globalSearchFragment)
                    true
                }
                R.id.settingsFragment -> {
                    val popped = navController.popBackStack(R.id.settingsFragment, false)
                    if (!popped) navController.navigate(R.id.settingsFragment)
                    true
                }
                else -> false
            }
        }

Bottom padding in fragment_saved.xml:
bookmarks RecyclerView:
android:paddingBottom="@dimen/bottom_nav_height"
android:clipToPadding="false" (already present)
MainActivity navigation changes:
binding.bottomNavigationView.setOnItemSelectedListener { ... } — ensures deterministic navigation behavior
binding.bottomNavigationView.setOnItemReselectedListener { ... } — preserves reselection semantics (pop to root)

Testing / Verification

  • From the Home (main) screen:

  • Tap MY Bookmarks — confirm the My Bookmarks screen opens.

  • Tap Home — should return to Home (mainFragment).

  • From Home, open Saved again, then:

  • Tap Search — confirm it goes to Search.

  • Tap Settings — confirm it goes to Settings.

  • Tap Home — must always go to Home (mainFragment) (this was the incorrect behavior before).

  • On Saved screen, verify bottom nav buttons are responsive (touches register immediately).

  • Verify RecyclerView scroll still works and content isn't covered visually (padding is only space — RecyclerView can scroll under the padding).

Added custom selection and reselection handlers for bottom navigation to ensure consistent navigation to root fragments. Updated fragment_saved.xml to include bottom padding for navigation bar, and defined bottom_nav_height in dimens.xml.
@sande11 sande11 requested a review from MaxwellKJr November 11, 2025 18:29
@sande11 sande11 self-assigned this Nov 11, 2025
Corrected image paths, improved table formatting, fixed HTML entities, and updated external links in multiple TB-related asset pages. These changes enhance clarity, consistency, and ensure accurate representation of diagnostic and treatment criteria.
@sande11 sande11 merged commit 4ac26ff into 131-update-tb-guide-android-app-ui-with-new-figma-design Nov 12, 2025
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.

2 participants