:library:feature:onboarding
Purpose
Owns the multi-page onboarding flow of a first launch, including theme choice and completion persistence. It is a start screen of the shell, drawn before its tabs, and follows the startup screen of :library:feature:startup.
Owns
onboardingPages(), which registersOnboardingRouteas a page without a title and offers it as a start screen (startScreens).OnboardingScreen, withOnboardingScreenContentin the same file,OnboardingViewModel, its state (OnboardingUiState,OnboardingCompletion) andOnboardingEvent. The screen asks for consent on each resume and callsenterShell()once completion is saved.onboardingModule, which bindsOnboardingThemeViewModel.ThemeOnboardingPageTab,OnboardingThemeViewModel,OnboardingThemeUiStateandOnboardingThemeEvent: the theme page reads the stored theme preferences and the seasonal unlock, and saves each choice throughThemePreferencesRepository. Its theme mode and palette choices areThemeModePickerandThemePalettePickerfrom:library:core:ui, the same ones the theme settings page shows; only the title, subtitle and AMOLED card are this page's own.The
OnboardingProviderhost extension contract.DefaultOnboardingRepositoryand the onboarding preference sources indata/local.Page models, controls, and the default and finish pages.
Does not own
The startup screen before it,
StartupProviderand the permission request, owned by:library:feature:startup, which hands over toOnboardingRouteby key.Deciding whether the first launch runs. The app starts on
StartupRoutefromShellHost(resolveStart = ...)while its startup flag is set; see Using it.Host-specific onboarding provider implementations, owned by
:sample:feature:onboarding.Consent SDK orchestration, owned by
:library:integration:consent.The diagnostics page and the privacy choices dialog it opens, owned by
:library:feature:diagnostics(TelemetryOnboardingPage) along with the state they read and write. A host lists it among its pages throughOnboardingProvider.Theme implementation and settings repositories, owned by core design system and DataStore.
Depends on
:library:core:common,:library:core:datastore,:library:core:network, and:library:core:uifor shared contracts, completion persistence, errors, and UI.:library:navigationfor the keys, the graph builder and the shell navigator.:library:integration:consentforConsentRepository, which the ViewModel asks with aConsentHostbuilt from the activity.No other feature module.
Used by
:library:apptoolkit, which callsonboardingPages()fromtoolkitPages(), and:sample:feature:onboarding, which provides the pages and binds the ViewModel.
Using it
ShellHost(
graph = graph,
resolveStart = { if (dataStore.startup.first()) StartupRoute else startKeyFor(storedTab) },
onReady = { keepSplashVisible = false },
)The startup screen hands over to onboarding. Neither has the shell under it, so back from either leaves the app. Finishing onboarding writes completion and enters the shell on its start tab; the next launch then resolves past StartupRoute.
The host binds the provider, the repository and the onboarding ViewModel, as :sample:feature:onboarding does:
single<OnboardingProvider> { AppOnboardingProvider() }
// onboardingModule supplies the source and repository bindings.
viewModel {
OnboardingViewModel(
onboardingRepository = get(),
consentRepository = get(),
telemetryRepository = get(),
)
}Flow chart
flowchart TD
Host[ShellHost resolveStart] -->|startup flag set| Startup[StartupRoute page, feature:startup]
Host -->|otherwise| Tabs[Shell tabs]
Startup -->|continueStart| Screen[OnboardingScreen]
Screen -->|each resume: RequestConsent host| VM[OnboardingViewModel]
VM --> Consent[ConsentRepository]
Screen --> Pages[Provider-defined ordered pages]
Pages --> Theme[ThemeOnboardingPageTab: OnboardingThemeViewModel]
Theme --> ThemeRepo[ThemePreferencesRepository]
Pages --> Diagnostics[TelemetryOnboardingPage from feature:diagnostics]
Screen -->|Skip or Finish: CompleteOnboarding| VM
VM --> Completion[OnboardingRepository]
Completion --> Store[Preferences DataStore]
VM -->|completion Saved| Screen
VM -->|save failed| Message[Error message, completion Failed]
Screen -->|enterShell| TabsArchitectural decisions
Start screens, not activities. The first launch runs inside the one activity, so consent and permission requests go through
LocalActivity.current, and the shell's start is decided once inresolveStartinstead of by a launcher activity that forwarded to the main one.Startup and onboarding are separate modules: startup asks for permissions and consent, while onboarding owns page progress and completion. They meet only at
OnboardingRoute, a key in:library:navigation.OnboardingScreenowns the ViewModel, tracking, the consent host, navigation and the snackbar host.OnboardingScreenContentrenders the pager and reports throughOnboardingEvent.The ViewModel runs the consent request with the
ConsentHostthe screen sends, for that request only, so it keeps no activity once the request ends. A resume restarts a request still waiting.Completion is written only after Skip or Finish. The ViewModel marks it
OnboardingCompletion.Savedin state and the screen enters the shell when it sees that, so a save that ends during a rotation still leaves. The stored flag,isOnboardingCompleted, is not used to navigate: it is already true when onboarding is opened again from the developer options.The onboarding flow logs
tutorial_beginon entry andtutorial_completeon completion, distinguishingmethod = "done"frommethod = "skip". Moving between pages logsonboarding_step_viewwith the page index, stable page key and direction, while skipping and theme edits record action events under theOnboardingscreen.A failed completion write shows an error message and leaves the pages on screen, since finishing is the only way out.
screen_statereportssuccesswhile the pages show,loadingwhile saving anderrorafter a failed save.The screen provides its snackbar host as
LocalPageSnackbarHostState, so a page's own ViewModel (the theme page, the diagnostics page) shows its messages above the footer.The host supplies page/routing extension points, but toolkit state holders persist confirmed choices. Presentation callbacks do not write DataStore directly.
Theme and consent pages use their owning repositories/ViewModels so onboarding does not become a second implementation of settings behavior. The theme page shows the Toolkit's default theme until the stored preferences arrive, and a failed write shows an error message.
On large screens the pages keep to a column at most 640dp wide, centred, so a tablet shows them at a readable width instead of stretched across the window.
Public contracts
onboardingPages()andonboardingModule.OnboardingScreen()andThemeOnboardingPageTab(),DefaultOnboardingPage,FinishOnboardingPage.OnboardingViewModel(onboardingRepository, consentRepository, telemetryRepository), which the host binds, withOnboardingUiState,OnboardingCompletionandOnboardingEvent.OnboardingThemeViewModel,OnboardingThemeUiStateandOnboardingThemeEvent.OnboardingProvider,OnboardingPage,OnboardingRepositoryandDefaultOnboardingRepository, whosesetOnboardingCompleted()throwsStorageExceptionwhen the write fails.
Internal implementations
OnboardingScreenContentandThemeOnboardingPageTabContent, page ordering and rendering, and celebration state.
Current risks
The app decides when the first launch runs. An app that forgets the
resolveStartcheck never shows onboarding, and one that never clears its startup flag shows it on every launch.The module coordinates consent, persisted theme state and the host's pages; changes require checking several module contracts together.
ConsentRepository.requestConsent()is a suspend call that completes or throws. The ViewModel reports a failure without blocking onboarding, and cancelling its wait does not cancel the shared UMP round trip owned by the repository.
Preference ownership
The onboarding module registers its own data/local source over the shared settings file and DefaultOnboardingRepository. The OnboardingRepository interface lives in core.common.data.repositories, allowing host core code to observe completion without importing the feature. Hosts no longer duplicate these bindings in their own onboarding module.
Migration notes
From 3.0.0-pre30, host providers call TelemetryOnboardingPage(isSelected) from :library:feature:diagnostics instead of FirebaseOnboardingPage. This is a breaking rename without an alias; the onboarding module still owns only the pager, not the consent page. Update imports and calls as shown in the 3.0.0 migration guide.
PageIndicatorDots in ui.views.controls is also removed in 3.0.0-pre30; OnboardingFooter now uses the shared AospPageIndicator from :library:core:ui.