mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-10 23:21:59 +01:00
First block of #65: the state machine, the platform download engine, a single-song download from the song context menu, the downloaded indicator in song lists, and local-first playback. - `song_downloads`, keyed `(sourceId, songId)` with CASCADE on the source, and the 16 -> 17 migration. - `DownloadEngine` over `android.app.DownloadManager`, with a fake for tests. Files land in app-specific external storage at `.../Music/downloads/<sourceId>/<songId>`, plus a `.nomedia` so media scanners on pre-Android-10 devices leave them alone. - `DownloadRepository` enqueues, mirrors progress by polling, cancels, deletes and reconciles on start and on source change: a queued row whose engine entry is gone is started again, a completed row whose file is gone becomes failed rather than being resurrected, and files with no row are swept. - Playback prefers the downloaded file: the media item build takes the local URI when the download is complete and leaves it unclipped. - Deleting a download reloads the player window at its position, so the item falls back to streaming instead of failing mid-read. - Deleting a source cancels its downloads and removes their files. Downloads are the system's own notifications and stay off metered networks for now. Artwork, bulk downloads and the management screen are later blocks.