Files
Android-247-Radio/chat-summaries/2026-03-10_13-00-settings-panel.md

34 lines
2.4 KiB
Markdown
Raw Normal View History

# Settings Panel Implementation
## Task
Added four new feature sections to the Settings screen: SomaFM quality preference, now-playing history file logging, reset customizations, and restart app. Also fixed a crash-on-launch bug on physical devices caused by missing `isHidden` column in seed data INSERT.
## Changes Made
### Bug Fix
- `SomaFmSeedData.kt`: Added `isHidden` column to the station INSERT for fresh installs (v4+ schema) to fix `SQLiteConstraintException` crash on real devices.
### New Files
- `data/model/StationStream.kt` — Room entity for multi-stream quality options per station
- `data/db/StationStreamDao.kt` — DAO for station stream queries
- `service/StreamResolver.kt` — Resolves ordered list of stream URLs based on quality preference (per-station override or global)
- `data/logging/NowPlayingHistoryWriter.kt` — Appends track changes to a file in CSV, JSON lines, or plain text format
### Modified Files
- `data/model/Station.kt` — Added `qualityOverride: String?` column
- `data/db/RadioDatabase.kt` — Added `StationStream` entity, `StationStreamDao`, bumped to v4, added `MIGRATION_3_4`
- `data/db/SomaFmSeedData.kt` — Seeds `station_streams` table (2-4 rows per station: SSL/non-SSL x 128/256kbps), added `includeStreams` parameter, `seedStreamsForExistingStations()` for migration
- `data/prefs/RadioPreferences.kt` — Added `qualityPreference`, `historyEnabled`, `historyFormat`, `historyDirUri` keys + setters
- `RadioApplication.kt` — Exposed `streamResolver` and `historyWriter`, registered `MIGRATION_3_4`
- `service/RadioPlaybackService.kt` — Uses `StreamResolver` for URL resolution, calls `historyWriter.append()` after metadata persist
- `ui/screens/settings/SettingsScreen.kt` — Added SomaFM Quality (reorderable list), Now Playing History (toggle/format/dir picker), Reset (with optional station deletion), Restart App sections
- `ui/screens/settings/SettingsViewModel.kt` — Added quality/history preference management, `resetCustomizations()` (DB transaction), `restartApp()` (graceful then forced)
### Design Doc
- `docs/plans/2026-03-10-settings-panel-design.md`
## Follow-up Items
- Per-station quality override UI (accessible from station edit dialog or long-press menu)
- Stream fallback chain retry (currently uses first resolved URL; could try subsequent URLs on connection failure)
- History file rotation/cleanup for large files