Add navigation drawer back to new study screen#21143
Open
timrae wants to merge 2 commits into
Open
Conversation
Contributor
|
Snapshot diff report vs
All 8 changed screenshotsStudyScreenScreenshotTest
|
Adds an app-level navigation drawer to the new study screen, mirroring the destinations in the legacy nav drawer. This allows users to navigate to the Browser/Stats/Settings/Help pages directly from the reviewer without unnecessary button presses, or leaving the reviewer context. Extracts AppDestination as a single source of truth for the app-level navigation surface; both the new ReviewerFragment drawer and the legacy NavigationDrawerActivity build their NavigationView menus from it via a shared Menu.populateFromAppDestinations() helper. res/menu/navigation_drawer.xml is deleted; the orphaned menu-item ids move into ids.xml so existing references (CardBrowser, DeckPicker, BottomNavActivity, espresso tests) keep resolving. ReviewerFragment hosts the drawer locally — its layout root becomes a ClosableDrawerLayout wrapping the existing CoordinatorLayout, with an <include> of the existing include_navigation_drawer.xml as the drawer panel. The hamburger button replaces the back button in the tools row; exiting the reviewer is the system back gesture (which closes the drawer first when it's open via an OnBackPressedCallback). No Compose; no toolchain changes. The legacy and new drawers use the same Views widgets so they stay in lockstep.
Swap the ClosableDrawerLayout-based drawer for a Compose ModalNavigationDrawer hosted in a ComposeView overlay. This is the first Compose surface in the app. Brings in: - Compose BOM 2026.05.01 + Material3 + kotlin.plugin.compose, plus activity-compose / lifecycle-viewmodel-compose / lifecycle-runtime-compose. - AnkiTheme — a minimal MaterialTheme bridge that reads the AppCompat / Material Components theme attributes so Compose surfaces honour the user's selected colour theme. Translucent values are composited over colorBackground so Compose colours are fully opaque. - AppNavigationDrawer — the M3 ModalNavigationDrawer rendering the AppDestination entries. Owns its own open/closed state; the host emits on a one-shot Flow<Unit> of "open" requests and the drawer closes itself on scrim tap / predictive back / item click. Returns an empty composition while fully closed so touches fall through to the WebView. In the reviewer: - fragment_reviewer.xml: drop the ClosableDrawerLayout wrap and the <include> of include_navigation_drawer.xml. Add a ComposeView overlay for the drawer. Move android:fitsSystemWindows="true" off the root CoordinatorLayout onto the inner LinearLayout so the ComposeView spans the full window and the drawer paints up to the top edge — parity with the legacy DrawerLayout behaviour. - ReviewerFragment: drop the Views-based setupNavigationDrawer in favour of one that wires the ComposeView to AppNavigationDrawer. - ReviewerViewModel: add openNavigationDrawerFlow / onHamburgerClicked so view-model state survives configuration changes; the drawer's own internal state is what handles the open/close UX.
6d2e8ed to
626a601
Compare
Contributor
|
Heya! We are moving away from Nav rail and bottom app bar will be introduced (part of GSoC 2026 project), I don't think it will be worth the efforts |
Member
|
Unless you are super productive, and based on how the code is written, I believe that AI was used here. If so, you need to follow the AI policy and disclose it. |
Member
Author
|
My bad, looks like I read an older version of the policy that said disclosure is optional for established contributors.
Yes I used Opus 4.7 during the creation of this PR |
This was referenced May 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose / Description
The new study screen (
ReviewerFragment) currently has no navigation drawer, so reaching Browser / Statistics / Settings / Help from a review session requires the user to back out to the deck picker first, introducing extra clicks.This PR adds an app-level navigation drawer to the new reviewer, mirroring the destinations of the legacy
NavigationDrawerActivitydrawer, and uses it as the first Compose surface in the app.Fixes
#21139 (partial fix)
Approach
Done in two commits:
1.
feat(reviewer): add navigation drawer to the new study screen— Views-only, no toolchain changes.AppDestinationas a single source of truth for the app-level navigation surface (Decks / Browser / Statistics / Settings / Help / Send feedback / etc.).ReviewerFragmentdrawer and the legacyNavigationDrawerActivitynow build theirNavigationViewmenus from it via a sharedMenu.populateFromAppDestinations()helper.res/menu/navigation_drawer.xml; orphaned menu-item ids move intoids.xmlso existing references (CardBrowser,DeckPicker,BottomNavActivity, espresso tests) keep resolving.ReviewerFragmenthosts the drawer locally — root becomes aClosableDrawerLayoutwrapping the existingCoordinatorLayout, withinclude_navigation_drawer.xmlas the drawer panel. The hamburger button replaces the back button in the tools row; exiting the reviewer remains the system back gesture (anOnBackPressedCallbackcloses the drawer first when it's open).2.
feat(compose): render the reviewer's nav drawer with Compose— swap the implementation behind the same UX.kotlin.plugin.compose, plusactivity-compose/lifecycle-viewmodel-compose/lifecycle-runtime-compose. First Compose surface in the app.AnkiTheme— a minimalMaterialThemebridge that reads the AppCompat / Material Components theme attributes so Compose surfaces honour the user's selected colour theme. Translucent values are composited overcolorBackgroundso Compose colours are fully opaque.AppNavigationDrawer— an M3ModalNavigationDrawerrendering theAppDestinationentries. Owns its open/closed state; the host emits on a one-shotFlow<Unit>of "open" requests and the drawer closes itself on scrim tap / predictive back / item click. Returns an empty composition while fully closed sotouches fall through to the WebView underneath.
fragment_reviewer.xml: drops theClosableDrawerLayoutwrap and the<include>ofinclude_navigation_drawer.xml; adds aComposeViewoverlay.android:fitsSystemWindows="true"moves off the rootCoordinatorLayoutonto the innerLinearLayoutso theComposeViewspans the full window and the drawerpaints up to the top edge — parity with the legacy
DrawerLayoutbehaviour.ReviewerViewModelgainsopenNavigationDrawerFlow/onHamburgerClickedso the "should open" signal survives configuration changes; the drawer's own internalDrawerStatehandles open/close UX.This second commit could be reverted if the majority opinion of the current maintainers is not to introduce the new dependencies yet.
How Has This Been Tested?
Manual testing on a physical Pixel 8a (Android 14) and the API 34 emulator,
playDebugbuild:ReviewerViewModel.openNavigationDrawerFlow+ Compose'srememberSaveable.AnkiThemepicks up the AppCompat colours and the drawer matches the surrounding chrome.NavigationDrawerActivitydrawer still renders correctly after theAppDestinationrefactor (Decks/Browser/Stats/Settings/Help all present)../gradlew lintPlayDebug ktLintCheck :AnkiDroid:testPlayDebugUnitTestpasses.Screenshots
Learning (optional, can help others)
ModalNavigationDrawerChecklist
Licenses
Maintainers: