How jayant-gade/online-radio-for-tv works
Purpose and runtime
This is a Kotlin Android application for Android TV, also usable on phones. It provides D-pad-friendly discovery, saving, and playback of public online radio stations. The single Android app module is built through app/build.gradle.kts; application/component declarations begin at app/src/main/AndroidManifest.xml.
Application entry and screen orchestration
MainActivity is the primary UI entry point and coordinates the station list, playback interaction, navigation, and dialogs. Its view hierarchy is XML-based rather than a web or server application.
• app/src/main/java/com/jay/onlinetvradio/MainActivity.kt
• app/src/main/res/layout/activity_main.xml
• app/src/main/java/com/jay/onlinetvradio/ui/SafeAreaLayout.kt
Station presentation and remote interaction
Stations are rendered through a list adapter with dedicated row layouts and visual playback/focus states. This is the core TV interaction boundary: D-pad focus selects a station; selecting the current station toggles pause/play; long-press exposes actions such as information or deletion.
• app/src/main/java/com/jay/onlinetvradio/StationAdapter.kt
• app/src/main/res/layout/item_station.xml
• app/src/main/res/drawable/now_playing_background.xml
Search and external station discovery
Search is a modal workflow that obtains public station metadata and lets users add stations to favorites/recent lists. RadioBrowser is the stated external metadata/source-discovery service; streams themselves remain third-party URLs.
• app/src/main/java/com/jay/onlinetvradio/SearchDialogFragment.kt
• app/src/main/res/layout/dialog_search.xml
• app/src/main/java/com/jay/onlinetvradio/SafeHttpDataSourceFactory.kt
Playback subsystem
Playback is separated from the activity in a service, allowing audio lifecycle control beyond a single screen. Player state/events are exposed through a dedicated event component, while the safe HTTP data-source factory forms the boundary between the player and remote streaming endpoints.
• app/src/main/java/com/jay/onlinetvradio/PlaybackService.kt
• app/src/main/java/com/jay/onlinetvradio/PlayerEvents.kt
• app/src/main/java/com/jay/onlinetvradio/SafeHttpDataSourceFactory.kt
Local persistence and initial state
A database helper owns durable station-related state, supporting the README’s favorites and recent-station behavior. Initial-run logic likely establishes first-launch state or seed content before normal activity use.
• app/src/main/java/com/jay/onlinetvradio/DBHelper.kt
• app/src/main/java/com/jay/onlinetvradio/InitialRun.kt
• app/src/main/res/values/arrays.xml
Dialog-driven management and settings
Secondary user flows are isolated in fragments: station metadata, server/source changes, search, and preferences. Settings have both dialog and fragment representations, with Android preference resources defining the settings surface.
• app/src/main/java/com/jay/onlinetvradio/InfoDialogFragment.kt
• app/src/main/java/com/jay/onlinetvradio/ServerChangeFragment.kt
• app/src/main/java/com/jay/onlinetvradio/SettingsFragment.kt
• app/src/main/res/xml/preferences.xml
Network, packaging, and boundaries
The app directly consumes public metadata APIs and third-party audio streams; it does not host a backend. Android network policy is explicitly configured, relevant to radio stream compatibility. Release artifacts and baseline profiles indicate packaged Android distribution/performance optimization.
• app/src/main/res/xml/network_security_config.xml
• app/release/output-metadata.json
• app/release/baselineProfiles/0/app-release.dm
Main entry points: MainActivity.kt MainActivity · SearchDialogFragment.kt SearchDialogFragment · PlaybackService.kt PlaybackService · SafeHttpDataSourceFactory.kt SafeHttpDataSourceFactory
Components 18
Android UI
TV-focused XML screens and dialog workflows.
- MainActivity · Coordinates station browsing, playback interaction, navigation, and dialogs.
app/src/main/java/com/jay/onlinetvradio/MainActivity.kt - Main screen layout
app/src/main/res/layout/activity_main.xml - SafeAreaLayout
app/src/main/java/com/jay/onlinetvradio/ui/SafeAreaLayout.kt - StationAdapter · Handles D-pad focus, selection, and long-press actions.
app/src/main/java/com/jay/onlinetvradio/StationAdapter.kt - Station row visuals · Station rows include focus and now-playing states.
app/src/main/res/layout/item_station.xml - SearchDialogFragment · Searches public metadata and adds stations.
app/src/main/java/com/jay/onlinetvradio/SearchDialogFragment.kt - Management dialogs · Station info, source changes, and preferences flows.
app/src/main/java/com/jay/onlinetvradio/InfoDialogFragment.kt - Preference definitions
app/src/main/res/xml/preferences.xml
App Core
Playback, state, and persistence services.
- Android manifest
app/src/main/AndroidManifest.xml - PlaybackService · Owns audio lifecycle outside the activity.
app/src/main/java/com/jay/onlinetvradio/PlaybackService.kt - PlayerEvents
app/src/main/java/com/jay/onlinetvradio/PlayerEvents.kt - SafeHttpDataSourceFactory · Boundary between player and remote stream endpoints.
app/src/main/java/com/jay/onlinetvradio/SafeHttpDataSourceFactory.kt - DBHelper · Stores favorites and recent stations.
app/src/main/java/com/jay/onlinetvradio/DBHelper.kt - InitialRun
app/src/main/java/com/jay/onlinetvradio/InitialRun.kt - Station seed data
app/src/main/res/values/arrays.xml - Network security policy · Configures compatibility with radio stream networking.
app/src/main/res/xml/network_security_config.xml
External Sources
Public metadata APIs and third-party streams.
- RadioBrowser · Public station discovery service.
- Third-party audio streams
Connections 19
- Android manifest → MainActivity: launches
- MainActivity → Main screen layout: renders
- Main screen layout → SafeAreaLayout: uses
- MainActivity → StationAdapter: populates
- StationAdapter → Station row visuals: renders
- MainActivity → SearchDialogFragment: opens
- MainActivity → Management dialogs: opens
- Management dialogs → Preference definitions: defines settings
- MainActivity → PlaybackService: controls
- PlaybackService → PlayerEvents: publishes
- PlayerEvents → MainActivity: updates UI
- PlaybackService → SafeHttpDataSourceFactory: uses
- SafeHttpDataSourceFactory → Third-party audio streams: streams audio
- SearchDialogFragment → RadioBrowser: discovers stations
- SearchDialogFragment → DBHelper: saves stations
- MainActivity → DBHelper: loads station state
- InitialRun → Station seed data: reads seed data
- InitialRun → DBHelper: initializes
- Network security policy → SafeHttpDataSourceFactory: governs network access