Download tasks/efflora__notallyx-overview-compose/solution/DESIGN.md from efflora/android-bench-sample: direct link, hf CLI and curl.
- Browser
- Download file 4.24 kB
-
https://huggingface.co/datasets/efflora/android-bench-sample/resolve/main/tasks/efflora__notallyx-overview-compose/solution/DESIGN.md
- Command line
-
hf download hf://datasets/efflora/android-bench-sample/tasks/efflora__notallyx-overview-compose/solution/DESIGN.md
-
curl -L -o DESIGN.md https://huggingface.co/datasets/efflora/android-bench-sample/resolve/main/tasks/efflora__notallyx-overview-compose/solution/DESIGN.md
Reference solution: design notes
The reference moves the overview's rendering to Compose and its screen state into the existing
BaseNoteModel, and leaves the navigation, the drawer, the main top bar, the create buttons, the
editors and the dialogs as they are.
Architecture
- Screens stay fragments, their content is Compose.
NotallyFragment(Notes, label, Unlabeled, Archived, Deleted),RemindersFragmentandSearchFragmentkeep their places in the navigation graph, so destinations, the drawer and the back stack behave as before; each returns aComposeViewdrawing oneOverview(). Subclasses only add what differs: filter chips, the loading indicator, how notes are arranged. - One list composable.
NotesListdraws headers and cards in aLazyColumn(list view) or a two-columnLazyVerticalStaggeredGrid(grid view) with headers spanning both columns. It also draws the empty state.NoteCardrenders text notes and lists, items, labels, images, reminders and the creation date under the same overview settings the view holder read (text size, title, line and item limits, date format, hidden labels and images, note colour). - Ordering is plain functions. The adapter's sort callbacks became comparators in
NoteOrdering.kt: the user's sort preference with pinned notes first, the three reminder filters each with their own order and no headers, andsectioned()inserting the Pinned/Others/Archived headers. - Selection bar.
SelectionBarreplaces the toolbar shown in action mode, in the same place inactivity_main.xml.SelectionActionslists, per folder, the same actions as the old menus, each as an icon or in the "More options" overflow, and runs them with the same confirmations and Undo snackbars; it replacesModelFolderObserver. - Picker.
PickNoteActivityandConfigureWidgetActivityreuseNotesListandNoteCard, so the picker cards match the overview.
State and process death
BaseNoteModel (the screen's existing AndroidViewModel) now takes a SavedStateHandle and keeps
the search text and the selected note ids in it. ActionMode publishes the selection as LiveData,
remembers the anchor of a range selection and reports every change, so the saved ids stay current.
After process death the ids are restored once the notes they refer to are listed again, which brings
the selection bar back. The reminder filter and the search folder are saved in the fragments'
instance state; scroll positions use Compose's saveable list and grid states per destination; the
destination itself comes back through the navigation graph.
Behaviour that needed care
- Range selection: long-pressing another note while notes are selected selects every note in between in the order shown, not in database order.
- Search: matches are highlighted in titles, bodies and list items with the same snippet logic
(
HighlightableTextViewnow exposes it to Compose), and opening a result passes the search text to the editor. - A note created from a label view still gets the label; the picker still leaves out the note being edited; Delete all in Deleted still asks first.
- Accessibility stays as it was: icon actions are labelled with their titles (
Select All,Pin,Delete), the overflow button withMore options(the old toolbar's label), the close icon with "Close" as on the old toolbar (now from a new@string/close), selected cards report their selected state, and the search field is an editable text field.
Trade-offs
- The fragments and the navigation graph are kept rather than moving to a single Compose screen: the drawer, the top bar, the editors and the dialogs stay out of scope, and the change stays reviewable.
- State lives in the existing
BaseNoteModelinstead of a new per-screen ViewModel, because the activity, the selection bar and all destinations already share it. - The old layouts for cards and headers, the adapter, the view holders and the sort callbacks are deleted; the Labels screen keeps its own layout, as the instruction allows.