Skip to content

[Multi-Profile] feat: add profile dialog in Compose#21328

Open
criticalAY wants to merge 8 commits into
ankidroid:mainfrom
criticalAY:compose-add-profile-dialog
Open

[Multi-Profile] feat: add profile dialog in Compose#21328
criticalAY wants to merge 8 commits into
ankidroid:mainfrom
criticalAY:compose-add-profile-dialog

Conversation

@criticalAY

@criticalAY criticalAY commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Note

Assisted-by: Claude Opus 4.8 to figure out why the views were broken

Purpose / Description

We agreed to use Compose for new screens and refactors instead of migrating existing components. The switch profiles screen was a good first candidate: it had very little View UI (a toolbar, an unused RecyclerView adapter and a FAB) and a stub add profile dialog. This PR moves the whole screen to Compose and sets up reusable pieces (input dialog, themed FAB, theme bridge additions) that future Compose screens can build on.

Fixes

Approach

See commits, I have kept them self-explanatory imo

How Has This Been Tested?

Unit test and each commit compiles and then test the dialog and fab being displayed on my Device (Pixel 10)

Learning (optional, can help others)

  • Blank dialog previews turned out to be a layoutlib regression with Compose 1.9+, see paparazzi#2071. Rendering the dialog card inline under LocalInspectionMode makes previews independent of the Studio version.

Checklist

Please, go through these checks before submitting the PR.

  • 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

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Important

Maintainers: This PR contains Strings changes

  1. Sync Translations before merging this PR and wait for the action to complete
  2. Review and merge the auto-generated PR in order to sync all user-submitted translations
  3. Sync Translations again and merge the PR so the huge automated string changes caused by merging this PR are by themselves and easy to review

@david-allison

Copy link
Copy Markdown
Member

Could we add screenshot tests?

@criticalAY criticalAY force-pushed the compose-add-profile-dialog branch from ba4c12c to ad9261b Compare July 1, 2026 22:01
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Snapshot diff report vs main. Open screenshot-diff for diffs.

  • PreferencesScreenshotTest: 1 change
All 1 changed screenshots

PreferencesScreenshotTest

  • SwitchProfilesFragment_compare.png

@criticalAY criticalAY changed the title Compose add profile dialog [Multi-Profile] feat: add profile dialog in Compose Jul 1, 2026
Comment thread AnkiDroid/src/main/res/values/01-core.xml Outdated
Compose counterpart of the View based AlertDialog.input helper: autofocus,
confirm on keyboard Done, validation with inline errors and an optional
character counter. Renders the card inline in previews because dialog
windows don't show up in the static preview pane.
Compose FABs default to colorScheme.primaryContainer, which the theme
bridge leaves at the Material3 baseline purple on purpose. Read the
fab_normal attr into an AnkiDroidColors CompositionLocal, paired with
onPrimary, the same pair every View FAB uses.
Extended FAB with the fab_normal tint baked in, so screens can't fall
back to the baseline purple by forgetting the colors.
Strings in 01-core.xml must be translated before a language can be
enabled, and the multi profile feature is still in development, so it
shouldn't gate that. Resource lookup is by name, so references and any
existing translations keep working.
Thin wrapper around TextInputDialog that validates input through
ProfileName.validate, so the UI and the domain layer enforce the same
rules. Not shown anywhere yet.
Holds the profile list and the add profile dialog visibility so both
survive configuration changes. Profile creation, rename and deletion
still need ProfileManager to be wired into the app.
Replaces the XML layout with a stateless Scaffold screen: top bar,
profile list, AnkiDroidExtendedFab and the add profile dialog. The
fragment becomes a thin ComposeView host, it has to stay a Fragment
because preference_headers.xml launches it by class name. The hardcoded
toolbar title moves to a string resource.
The RecyclerView adapter was never wired to the fragment and its row
layout and circle drawable are replaced by the Compose ProfileRow.
@criticalAY criticalAY force-pushed the compose-add-profile-dialog branch from ad9261b to ec38372 Compare July 4, 2026 03:13
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.

2 participants