:library:feature:changelog
Purpose
Owns changelog retrieval and presentation: the package-aware Markdown fetch, its legacy fallback, and the bottom sheet that renders it.
Owns
ChangelogPreferencesDataSourceand its default indata/local, using the shared settings file.ChangelogRepositoryandDefaultChangelogRepository, including selection of the Android App Metadata API call and the legacy GitHub fallback.GetChangelogUseCase, which picks the current-version section or the full history, andextractChangesForVersion, which finds that section's heading.ChangelogViewModel,ChangelogUiState(whosemarkdownis aLoadable), andChangelogEvent.Load, sent on start and on retry.ChangelogDialog, infeature.changelog.ui, the modal bottom sheet the host shows from its drawer, and the statelessChangelogDialogContentit draws inside the sheet. The content draws each part of the Markdown on its own and the Toolkit'sHorizontalWavyDividerwhere the Markdown has a rule (splitAtThematicBreaks), in place of the renderer's flat line.ChangelogDialog(releasesUrl)adds an info button beside the title that opens that page, such asGithubConstants.APP_TOOLKIT_RELEASES; without one the sheet shows no button.
Does not own
The drawer entry that opens the dialog, owned by
:library:navigationand the host shell.In-app update triggering, owned by
:library:integration:update.The About screen and its metadata, owned by
:library:feature:about.
Depends on
:library:core:common,:library:core:datastore,:library:core:network, and:library:core:uifor shared state, persistence, HTTP, and Compose.compose-markdownto render the fetched Markdown.
Used by
:library:apptoolkitand:sample.
Flow chart
flowchart TD
Dialog[ChangelogDialog] --> VM[ChangelogViewModel]
Dialog --> Content[ChangelogDialogContent]
VM --> UseCase[GetChangelogUseCase]
UseCase --> Repo[ChangelogRepository]
Repo --> Api[App metadata API]
Repo --> Legacy[Legacy GitHub changelog]
Content -->|retry| Load[ChangelogEvent.Load]
Load --> VMArchitectural decisions
The dialog is on
core.ui.screen.ChangelogRepository.getChangelogreturns the Markdown or throws aNetworkException, the use case passes a failure through, andChangelogViewModelmaps it withtoFailed: an offline device sees the offline text, anything else the changelog's own, and the sheet's action retries only a failure that a retry can fix. A changelog with nothing in it isLoadable.Empty, shown as no new updates. Neither the ViewModel nor the repository needs a dispatcher: Ktor suspends.The package endpoint is authoritative and the legacy URL is a compatibility fallback, used only when the package name is blank or the endpoint answers 404, so a host that has not been published to the metadata API still shows release notes.
Heading selection and thematic-break splitting share a fence scanner. Backtick and tilde fences close only with the same marker, a sufficient run length and a blank suffix. Code examples do not create version boundaries or dividers.
The use case prefers the current version's section but falls back to the full history, so a version-format mismatch never hides content that was fetched successfully.
The sheet keeps its header and action fixed while the body scrolls, so long release notes cannot push the dismissal action off-screen.
Shared button labels come from
:library:core:uirather than being duplicated here.
Public contracts
ChangelogPreferencesDataSourceand its default indata/local, using the shared settings file.ChangelogRepository,GetChangelogUseCase,ChangelogViewModel,ChangelogUiState,ChangelogEvent,ChangelogDialog, andchangelogModule.ChangelogDialogContentis internal.
Internal implementations
HTTP fetch in
data/remote/ChangelogRemoteDataSource, itsdata/remote/models/MarkdownResponse, status-to-NetworkExceptionmapping, fallback selection, and Markdown rendering.
Current risks
The legacy fallback keeps a second source of truth alive. Until every host is published to the metadata API, a 404 silently changes which document the user reads.
Markdown ownership
Version-section parsing lives beside GetChangelogUseCase; thematic-break parsing lives in ui/extensions/ChangelogMarkdownExtensions.kt. The former utils/extensions/ChangelogExtensions.kt is removed. DefaultChangelogRepository takes ChangelogRemoteDataSource directly instead of an HttpClient. Callers constructing the repository directly must update that argument; the feature's Koin module supplies it automatically.