:library:feature:display
Purpose
Draws the display settings page: the person's own preferences. The dark theme and dynamic colors, bouncy buttons, the startup page, the navigation labels and the language, each only where it means something in the app. The shell's own variations are developer options, in :library:feature:developer.
Owns
Feature event builders and their bounded keys in
ui/analytics; screens only report events.DisplaySettingsScreen,DisplaySettingsViewModel,DisplaySettingsUiState(whosesettingsis aLoadableofDisplaySettings) andDisplaySettingsEvent.DisplaySettingsScreenContent, the stateless list with its loading and failure states.DisplayRow,DisplayCategoryanddisplayRows(capabilities, startup, sdkInt): which rows the page shows in this app, and under which heading.DisplaySettingsProvider, the contract a host implements to offer a startup page dialog, and say how many places it offers (startupPageChoices).The language and startup selection dialogs,
SelectLanguageAlertDialogandSelectStartupScreenAlertDialog.Its rows in the settings search,
displaySettingsSearch(startup, sdkInt), asettingsSearchProviderbound asdisplaythat lists exactlydisplayRows. AnddisplaySettingsModule.displaySettingsPage(), the registration ofDisplaySettingsRouteas a detail of the settings list.Localized display settings resources.
Does not own
The stored preferences, owned by
:library:core:datastore(DisplayPreferencesRepository,ThemePreferencesRepository).What the app's shell can show,
ShellCapabilities, owned by:library:navigationand provided byShellHost.The shell's overrides and their store, owned by
:library:shelland offered by:library:feature:developer.The theme page the dark theme row opens, owned by
:library:feature:themeand reached throughThemeSettingsRoute.Which startup pages exist, owned by the host's
DisplaySettingsProvider.
Depends on
:library:core:common,:library:core:datastore,:library:core:uiand:library:navigationfor the keys, the graph and the capabilities.No other feature module, and not
:library:shell.
Used by
:library:apptoolkit, which callsdisplaySettingsPage()and includesdisplaySettingsModule.:sample:feature:display, which provides the sample'sDisplaySettingsProvider.
Rows
| Heading | Row | Shown when |
|---|---|---|
| Appearance | Dark theme, opening the theme page | always |
| Dynamic colors | Android 12 or later | |
| App behavior | Bounce buttons | always |
| Navigation | Startup page | the host supports one and offers more than one choice; without startupPageChoices, when the app has more than one tab |
| Show labels on bottom bar | the app shows more than one tab in a bottom bar on some window (hasMultipleTabs && usesBottomNavigation) | |
| Language | Language | always |
A heading without a row is left out, so an app without tabs shows Appearance, App behavior and Language only.
Flow chart
flowchart TD
Host[ShellHost: graph + ShellLayoutPolicy] --> Caps[LocalShellCapabilities]
Caps --> Rows[displayRows]
Provider[DisplaySettingsProvider] --> Rows
Rows --> Content[DisplaySettingsScreenContent]
Rows --> Search[displaySettingsSearch]
Page[displaySettingsPage: DisplaySettingsRoute] --> Screen[DisplaySettingsScreen]
Screen --> VM[DisplaySettingsViewModel]
Screen --> Content
VM --> Display[DisplayPreferencesRepository]
VM --> Theme[ThemePreferencesRepository]
Content -->|preference changed| VM
Screen -->|dark theme row| ThemeRoute[navigate ThemeSettingsRoute]
Screen -->|startup page row| Dialog[DisplaySettingsProvider.StartupPageDialog]
Screen -->|language row| Language[system language settings or SelectLanguageAlertDialog]
VM -->|failed write| Messages[MessageHost snackbar]Architectural decisions
The person's preferences only. A row belongs here when it changes the person's experience in a way they would choose: theme, colors, feedback, startup page, labels, language. Overrides that force or compare the shell's own variations (app bar style, navigation bar style, tint, content width, hiding the bars on scroll, transitions, back swipe) are developer options.
One list for the page and its search.
displayRowsdecides the rows fromShellCapabilities, the host'sDisplaySettingsProviderand the Android version. The page draws them anddisplaySettingsSearchlists them, so a row can never show without being searchable, or be found without showing. EachDisplayRowcarries its heading, title and searched summary.Rows follow the app as declared. Capabilities come from the graph and the layout policy, not the window drawn now or a forced layout: an app that uses a bottom bar on phones keeps its labels row on a tablet. The labels row needs more than one tab, since the bar always labels the selected tab.
On
core.ui.screen.DisplaySettingsViewModelfollows the theme mode, dynamic colors, bouncy buttons, bottom bar labels, language and startup page with onecollectReport. A failed read isLoadable.Failedwith Retry; a failed write keeps the preferences on screen and shows an error message. Every write is its ownlaunchReport, so one never cancels another.The screen owns platform calls and tap events. Opening the theme page, the system language settings, the host's startup page dialog and the language dialog, and the GA4 events for each, stay in
DisplaySettingsScreen.DisplaySettingsScreenContenttakes the rows as a value, so it renders in a preview.The host chooses the startup page.
DisplaySettingsProvider.StartupPageDialogreturns a confirmed route, and the ViewModel stores it.
Public contracts
DisplaySettingsScreen(),displaySettingsPage(),DisplaySettingsViewModel,DisplaySettingsUiState,DisplaySettings,DisplaySettingsEvent,DisplaySettingsProvider(supportsStartupPage,startupPageChoices,StartupPageDialog),SelectLanguageAlertDialog,SelectStartupScreenAlertDialoganddisplaySettingsModule.DisplaySettingsScreenContent,DisplayRow,DisplayCategory,displayRowsanddisplaySettingsSearchare internal.
Current risks
Hosts must keep the startup page dialog's contract and account for a stored route that is no longer available.
A host that does not set
startupPageChoicesgets the tab count as an estimate of its choices.