Skip to content

refactor(card-browser): convert to MenuProvider#20208

Open
david-allison wants to merge 7 commits intoankidroid:mainfrom
david-allison:browse-menu-refactor
Open

refactor(card-browser): convert to MenuProvider#20208
david-allison wants to merge 7 commits intoankidroid:mainfrom
david-allison:browse-menu-refactor

Conversation

@david-allison
Copy link
Member

@david-allison david-allison commented Jan 24, 2026

Purpose / Description

The card browser still had a long way to go for refactors: the menu logic was extremely complex.

Although I want most of the menu logic to CardBrowserFragment, the coordination logic of the fragments should remain in the activity.

This performs the split out of 'fragment-based' logic, then simplifies the logic further, by splitting out the non-selected and multiselect case of the menu.

The eventual aim is that the SearchBar is used as a MenuHost, this SearchBar will need to be lifted out of the CardBrowserFragment in the final implementation in order to support "split Card Browser" functionality

Fixes

Approach

See the commits, gradual refactorings

How Has This Been Tested?

API 33 Medium Tablet

  • Found & fixed one bug in the 'Flags' menu, where items were added multiple times.

Learning (optional, can help others)

https://developer.android.com/reference/androidx/core/view/MenuProvider

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

@david-allison

This comment was marked as resolved.

@david-allison david-allison mentioned this pull request Jan 24, 2026
5 tasks
@david-allison david-allison marked this pull request as draft January 29, 2026 22:15
@david-allison david-allison removed Needs Author Reply Waiting for a reply from the original author Has Conflicts labels Jan 29, 2026
@david-allison david-allison added Blocked by dependency Currently blocked by some other dependent / related change and removed Blocked by dependency Currently blocked by some other dependent / related change labels Jan 29, 2026
@david-allison david-allison marked this pull request as ready for review January 30, 2026 09:21
@david-allison david-allison added the Needs Author Reply Waiting for a reply from the original author label Mar 5, 2026
@david-allison david-allison force-pushed the browse-menu-refactor branch from efd8d44 to f78d5ac Compare March 5, 2026 21:20
@david-allison david-allison removed Needs Author Reply Waiting for a reply from the original author Has Conflicts labels Mar 5, 2026
to `R.id.action_preview_many`

This is technically a functional change as it fixes a bug:
Sanjay intended that `preview_item` was disabled if the view
was fragmented, in 48db476
but the code wasn't working as expected

This ID was shared between two menus: `card_browser`
 and `note_editor` which will appear on the same screen

This causes issues with menu APIs, as they expect distinct
 IDs:

`menu.findItem(id)`; `menu.removeItem(id)` etc...
Handling fragments belongs in the Activity

The rest of the logic should be pushed down
We previously had one provider for both single select
 and multiselect.

This made logic difficult to reason about
@david-allison david-allison force-pushed the browse-menu-refactor branch from f78d5ac to 7e63226 Compare March 5, 2026 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant