From d95499b0e90f29981fb1667cd23dfe8f5ab51e56 Mon Sep 17 00:00:00 2001 From: kalarina Date: Tue, 17 Nov 2026 20:24:10 +0200 Subject: [PATCH] Show FM frequencies and station website in the Info tab MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Frequencies for Vilnius, Kaunas and Klaipėda come from the RRT broadcasting licence list, Riga for the Latvian stations. Power Hit Radio Gold is marked as online only. The website link opens the station's shows and schedule. --- .../fogwave/data/model/RadioStation.kt | 17 ++- .../data/repository/RadioRepository.kt | 103 +++++++++++++++--- .../fogwave/ui/components/NowPlayingSheet.kt | 44 ++++++++ .../fogwave/ui/components/StationLabels.kt | 16 +++ app/src/main/res/values-de/strings.xml | 9 ++ app/src/main/res/values-ja/strings.xml | 9 ++ app/src/main/res/values-lt/strings.xml | 9 ++ app/src/main/res/values-ru/strings.xml | 9 ++ app/src/main/res/values-zh/strings.xml | 9 ++ app/src/main/res/values/strings.xml | 9 ++ .../fogwave/data/RadioRepositoryTest.kt | 11 ++ 11 files changed, 230 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/cc/skysparkle/fogwave/data/model/RadioStation.kt b/app/src/main/java/cc/skysparkle/fogwave/data/model/RadioStation.kt index 8abfd0f..a347ab2 100644 --- a/app/src/main/java/cc/skysparkle/fogwave/data/model/RadioStation.kt +++ b/app/src/main/java/cc/skysparkle/fogwave/data/model/RadioStation.kt @@ -14,9 +14,24 @@ data class RadioStation( @param:DrawableRes val iconResId: Int, val genres: List, val bitrate: String, - val lightBackdrop: Boolean = false + val lightBackdrop: Boolean = false, + /** FM frequencies in the biggest cities; empty for stations that are only online. */ + val frequencies: List = emptyList(), + /** Station website with its shows and schedule. */ + val website: String? = null ) +/** One FM transmitter: the city and the frequency in MHz. */ +@Immutable +data class FmFrequency(val city: City, val mhz: Double) + +enum class City(@param:StringRes val labelRes: Int) { + VILNIUS(R.string.city_vilnius), + KAUNAS(R.string.city_kaunas), + KLAIPEDA(R.string.city_klaipeda), + RIGA(R.string.city_riga) +} + enum class Genre(@param:StringRes val labelRes: Int) { HITS(R.string.genre_hits), POP(R.string.genre_pop), diff --git a/app/src/main/java/cc/skysparkle/fogwave/data/repository/RadioRepository.kt b/app/src/main/java/cc/skysparkle/fogwave/data/repository/RadioRepository.kt index 8b7812b..81c1366 100644 --- a/app/src/main/java/cc/skysparkle/fogwave/data/repository/RadioRepository.kt +++ b/app/src/main/java/cc/skysparkle/fogwave/data/repository/RadioRepository.kt @@ -3,6 +3,8 @@ package cc.skysparkle.fogwave.data.repository import android.content.Context import androidx.core.content.edit import cc.skysparkle.fogwave.R +import cc.skysparkle.fogwave.data.model.City +import cc.skysparkle.fogwave.data.model.FmFrequency import cc.skysparkle.fogwave.data.model.Genre import cc.skysparkle.fogwave.data.model.RadioStation import kotlinx.coroutines.flow.MutableStateFlow @@ -13,6 +15,8 @@ import org.json.JSONArray class RadioRepository(context: Context) { private val prefs = context.getSharedPreferences("fogwave_prefs", Context.MODE_PRIVATE) + // FM frequencies: Lithuanian stations from the RRT broadcasting licence list (Vilnius, Kaunas, + // Klaipėda), Latvian ones for Riga. Other towns are listed on each station's website. val stations: List = listOf( RadioStation( id = "zip", @@ -21,7 +25,13 @@ class RadioRepository(context: Context) { streamUrl = "https://stream4.radijas.lt/zipfm", iconResId = R.drawable.ic_station_zipfm, genres = listOf(Genre.HITS, Genre.POP, Genre.LITHUANIAN), - bitrate = "MP3" + bitrate = "MP3", + frequencies = listOf( + FmFrequency(City.VILNIUS, 100.1), + FmFrequency(City.KAUNAS, 104.1), + FmFrequency(City.KLAIPEDA, 92.5) + ), + website = "https://www.zipfm.lt" ), RadioStation( id = "powerhit", @@ -31,7 +41,13 @@ class RadioRepository(context: Context) { streamUrl = "https://stream.rcs.revma.com/f31w7e0fveuvv", iconResId = R.drawable.ic_station_powerhit, genres = listOf(Genre.DANCE, Genre.POP, Genre.HITS), - bitrate = "AAC" + bitrate = "AAC", + frequencies = listOf( + FmFrequency(City.VILNIUS, 95.9), + FmFrequency(City.KAUNAS, 91.0), + FmFrequency(City.KLAIPEDA, 96.7) + ), + website = "https://powerhitradio.tv3.lt" ), RadioStation( id = "powerhitgold", @@ -40,7 +56,8 @@ class RadioRepository(context: Context) { streamUrl = "https://stream.rcs.revma.com/asdpz3qfbhuvv", iconResId = R.drawable.ic_station_powerhitgold, genres = listOf(Genre.DANCE, Genre.OLDIES, Genre.HITS), - bitrate = "AAC" + bitrate = "AAC", + website = "https://powerhitradio.tv3.lt" ), RadioStation( id = "rock", @@ -50,7 +67,13 @@ class RadioRepository(context: Context) { iconResId = R.drawable.ic_station_rockfm, genres = listOf(Genre.ROCK, Genre.LITHUANIAN), bitrate = "MP3", - lightBackdrop = true + lightBackdrop = true, + frequencies = listOf( + FmFrequency(City.VILNIUS, 87.8), + FmFrequency(City.KAUNAS, 90.3), + FmFrequency(City.KLAIPEDA, 100.2) + ), + website = "https://rockfm.lt" ), RadioStation( id = "relax", @@ -59,7 +82,13 @@ class RadioRepository(context: Context) { streamUrl = "https://stream4.radijas.lt/relaxfm", iconResId = R.drawable.ic_station_relaxfm, genres = listOf(Genre.EASY_LISTENING), - bitrate = "MP3" + bitrate = "MP3", + frequencies = listOf( + FmFrequency(City.VILNIUS, 96.4), + FmFrequency(City.KAUNAS, 98.5), + FmFrequency(City.KLAIPEDA, 87.5) + ), + website = "https://www.relaxfm.lt" ), RadioStation( id = "lietus", @@ -69,7 +98,13 @@ class RadioRepository(context: Context) { iconResId = R.drawable.ic_station_lietus, genres = listOf(Genre.LITHUANIAN, Genre.POP), bitrate = "AAC 64 kbps", - lightBackdrop = true + lightBackdrop = true, + frequencies = listOf( + FmFrequency(City.VILNIUS, 103.1), + FmFrequency(City.KAUNAS, 103.5), + FmFrequency(City.KLAIPEDA, 103.7) + ), + website = "https://www.lietus.fm" ), RadioStation( id = "m1", @@ -78,7 +113,13 @@ class RadioRepository(context: Context) { streamUrl = "https://stream.m-1.fm/m1/aacp64", iconResId = R.drawable.ic_station_m1, genres = listOf(Genre.POP, Genre.HITS), - bitrate = "AAC 64 kbps" + bitrate = "AAC 64 kbps", + frequencies = listOf( + FmFrequency(City.VILNIUS, 106.8), + FmFrequency(City.KAUNAS, 106.6), + FmFrequency(City.KLAIPEDA, 106.5) + ), + website = "https://www.m-1.fm" ), RadioStation( id = "plus", @@ -88,7 +129,13 @@ class RadioRepository(context: Context) { iconResId = R.drawable.ic_station_m1plus, genres = listOf(Genre.POP, Genre.OLDIES), bitrate = "AAC 64 kbps", - lightBackdrop = true + lightBackdrop = true, + frequencies = listOf( + FmFrequency(City.VILNIUS, 106.2), + FmFrequency(City.KAUNAS, 97.6), + FmFrequency(City.KLAIPEDA, 98.3) + ), + website = "https://www.pliusas.fm" ), RadioStation( id = "goldfm", @@ -97,7 +144,13 @@ class RadioRepository(context: Context) { streamUrl = "https://stream.goldfm.lt/goldfm.aac", iconResId = R.drawable.ic_station_goldfm, genres = listOf(Genre.OLDIES, Genre.HITS, Genre.LITHUANIAN), - bitrate = "AAC" + bitrate = "AAC", + frequencies = listOf( + FmFrequency(City.VILNIUS, 102.6), + FmFrequency(City.KAUNAS, 104.5), + FmFrequency(City.KLAIPEDA, 104.1) + ), + website = "https://goldfm.lt" ), RadioStation( id = "rc", @@ -107,7 +160,13 @@ class RadioRepository(context: Context) { iconResId = R.drawable.ic_station_rc, genres = listOf(Genre.HITS, Genre.LITHUANIAN), bitrate = "MP3 128 kbps", - lightBackdrop = true + lightBackdrop = true, + frequencies = listOf( + FmFrequency(City.VILNIUS, 89.6), + FmFrequency(City.KAUNAS, 107.1), + FmFrequency(City.KLAIPEDA, 101.5) + ), + website = "https://rc.lt" ), RadioStation( id = "lrt", @@ -117,7 +176,13 @@ class RadioRepository(context: Context) { iconResId = R.drawable.ic_station_lrt, genres = listOf(Genre.NEWS_TALK, Genre.LITHUANIAN), bitrate = "MP3", - lightBackdrop = true + lightBackdrop = true, + frequencies = listOf( + FmFrequency(City.VILNIUS, 89.0), + FmFrequency(City.KAUNAS, 102.1), + FmFrequency(City.KLAIPEDA, 102.8) + ), + website = "https://www.lrt.lt" ), RadioStation( id = "ziniu", @@ -126,7 +191,13 @@ class RadioRepository(context: Context) { streamUrl = "https://netradio.ziniur.lt/ziniur.mp3?n=975355", iconResId = R.drawable.ic_station_ziniu, genres = listOf(Genre.NEWS_TALK), - bitrate = "MP3" + bitrate = "MP3", + frequencies = listOf( + FmFrequency(City.VILNIUS, 97.3), + FmFrequency(City.KAUNAS, 104.9), + FmFrequency(City.KLAIPEDA, 102.2) + ), + website = "https://www.ziniuradijas.lt" ), RadioStation( id = "lr1", @@ -135,7 +206,9 @@ class RadioRepository(context: Context) { streamUrl = "https://muste.latvijasradio.lv/shoutcast/mp4:lr1a.stream/playlist.m3u8", iconResId = R.drawable.ic_station_lr1, genres = listOf(Genre.NEWS_TALK), - bitrate = "HLS" + bitrate = "HLS", + frequencies = listOf(FmFrequency(City.RIGA, 90.7)), + website = "https://lr1.lsm.lv" ), RadioStation( id = "lr2", @@ -144,7 +217,9 @@ class RadioRepository(context: Context) { streamUrl = "https://muste.latvijasradio.lv/shoutcast/mp4:lr2a.stream/playlist.m3u8", iconResId = R.drawable.ic_station_lr2, genres = listOf(Genre.LATVIAN, Genre.POP), - bitrate = "HLS" + bitrate = "HLS", + frequencies = listOf(FmFrequency(City.RIGA, 91.5)), + website = "https://lr2.lsm.lv" ) ) diff --git a/app/src/main/java/cc/skysparkle/fogwave/ui/components/NowPlayingSheet.kt b/app/src/main/java/cc/skysparkle/fogwave/ui/components/NowPlayingSheet.kt index 78e591b..97ba274 100644 --- a/app/src/main/java/cc/skysparkle/fogwave/ui/components/NowPlayingSheet.kt +++ b/app/src/main/java/cc/skysparkle/fogwave/ui/components/NowPlayingSheet.kt @@ -68,6 +68,7 @@ import androidx.compose.ui.semantics.contentDescription import androidx.compose.ui.semantics.semantics import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.Velocity @@ -529,6 +530,16 @@ private fun ExtraPanel( InfoRow(key = stringResource(R.string.info_description), value = stationDescription(station)) InfoRow(key = stringResource(R.string.info_genre), value = stationGenres(station)) InfoRow(key = stringResource(R.string.info_quality), value = station.bitrate) + InfoRow(key = stringResource(R.string.info_fm), value = stationFrequencies(station)) + station.website?.let { url -> + val context = LocalContext.current + InfoLinkRow( + key = stringResource(R.string.info_schedule), + label = displayHost(url), + description = stringResource(R.string.info_open_website), + onClick = { context.openUrl(url) } + ) + } InfoRow( key = stringResource(R.string.info_status), value = when (playerState) { @@ -586,6 +597,39 @@ private fun InfoRow(key: String, value: String) { } } +/** Like [InfoRow], but the value is a link that opens in the browser. */ +@Composable +private fun InfoLinkRow(key: String, label: String, description: String, onClick: () -> Unit) { + val colors = LocalGeoColors.current + Row( + modifier = Modifier + .fillMaxWidth() + .clip(RoundedCornerShape(8.dp)) + .clickable(role = Role.Button, onClickLabel = description, onClick = onClick) + .testTag("info_website"), + horizontalArrangement = Arrangement.spacedBy(16.dp), + verticalAlignment = Alignment.CenterVertically + ) { + Text( + text = key, + style = MaterialTheme.typography.bodySmall.copy( + fontWeight = FontWeight.SemiBold, + color = colors.onSurfaceVariant + ) + ) + Text( + text = "$label \u2197", + style = MaterialTheme.typography.bodySmall.copy( + fontWeight = FontWeight.Bold, + color = colors.accentLavender, + textAlign = TextAlign.End, + textDecoration = TextDecoration.Underline + ), + modifier = Modifier.weight(1f) + ) + } +} + private fun Context.shareStation(station: RadioStation, trackTitle: String?) { val text = if (trackTitle != null) { getString(R.string.share_text_track, trackTitle, station.name) diff --git a/app/src/main/java/cc/skysparkle/fogwave/ui/components/StationLabels.kt b/app/src/main/java/cc/skysparkle/fogwave/ui/components/StationLabels.kt index 3f4bde7..613f107 100644 --- a/app/src/main/java/cc/skysparkle/fogwave/ui/components/StationLabels.kt +++ b/app/src/main/java/cc/skysparkle/fogwave/ui/components/StationLabels.kt @@ -7,7 +7,9 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.ReadOnlyComposable import androidx.compose.ui.res.stringResource import androidx.core.net.toUri +import cc.skysparkle.fogwave.R import cc.skysparkle.fogwave.data.model.RadioStation +import java.util.Locale @Composable @ReadOnlyComposable @@ -18,6 +20,20 @@ fun stationDescription(station: RadioStation): String = stringResource(station.d fun stationGenres(station: RadioStation): String = station.genres.map { stringResource(it.labelRes) }.joinToString(", ") +/** FM frequencies one per line («Vilnius · 100.1 MHz»), or «Online only» for internet stations. */ +@Composable +@ReadOnlyComposable +fun stationFrequencies(station: RadioStation): String { + if (station.frequencies.isEmpty()) return stringResource(R.string.info_fm_online_only) + return station.frequencies.map { f -> + // Decimal separator of the current language: 100.1 in English, 100,1 in Lithuanian + stringResource(R.string.info_fm_line, stringResource(f.city.labelRes), String.format(Locale.getDefault(), "%.1f", f.mhz)) + }.joinToString("\n") +} + +/** Website address without the scheme and «www.», for display: «zipfm.lt». */ +fun displayHost(url: String): String = url.substringAfter("://").removePrefix("www.").trimEnd('/') + /** Opens [url] in the user's browser; silently does nothing when no browser is installed. */ fun Context.openUrl(url: String) { try { diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 487fcdf..4357b71 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -34,6 +34,15 @@ Beschreibung Genre Qualität + UKW + %1$s · %2$s MHz + Nur online + Sendungen & Programm + Website des Senders öffnen + Vilnius + Kaunas + Klaipėda + Riga Status Auf Sendung • Livestream diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 165ca4a..4198b95 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -34,6 +34,15 @@ 説明 ジャンル 音質 + FM + %1$s · %2$s MHz + オンラインのみ + 番組と放送スケジュール + 局のウェブサイトを開く + ヴィリニュス + カウナス + クライペダ + リガ 状態 オンエア中 • ライブストリーム diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml index ac9ffc2..c178691 100644 --- a/app/src/main/res/values-lt/strings.xml +++ b/app/src/main/res/values-lt/strings.xml @@ -34,6 +34,15 @@ Aprašymas Žanras Kokybė + FM + %1$s · %2$s MHz + Tik internetu + Laidos ir programa + Atidaryti stoties svetainę + Vilnius + Kaunas + Klaipėda + Ryga Būsena Eteryje • tiesioginė transliacija diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 676681f..92e8049 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -34,6 +34,15 @@ Описание Жанр Качество + FM + %1$s · %2$s МГц + Только онлайн + Передачи и расписание + Открыть сайт станции + Вильнюс + Каунас + Клайпеда + Рига Статус В эфире • прямая трансляция diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 9952177..0aeff6e 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -34,6 +34,15 @@ 简介 类型 音质 + FM + %1$s · %2$s MHz + 仅限在线 + 节目与时间表 + 打开电台网站 + 维尔纽斯 + 考纳斯 + 克莱佩达 + 里加 状态 正在直播 • 实时音频流 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2ce2500..2c3ed47 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -38,6 +38,15 @@ Description Genre Quality + FM + %1$s · %2$s MHz + Online only + Shows & schedule + Open the station\'s website + Vilnius + Kaunas + Klaipėda + Riga Status On air • Live Stream diff --git a/app/src/test/java/cc/skysparkle/fogwave/data/RadioRepositoryTest.kt b/app/src/test/java/cc/skysparkle/fogwave/data/RadioRepositoryTest.kt index ca742a7..07c22fb 100644 --- a/app/src/test/java/cc/skysparkle/fogwave/data/RadioRepositoryTest.kt +++ b/app/src/test/java/cc/skysparkle/fogwave/data/RadioRepositoryTest.kt @@ -65,4 +65,15 @@ class RadioRepositoryTest { assertEquals(listOf("lr2", "rc"), sorted.take(2).map { it.id }) assertEquals(repository.stations.size, sorted.size) } + + @Test + fun everyStationHasAWebsiteAndValidFmFrequencies() { + RadioRepository(context).stations.forEach { station -> + assertTrue("${station.id} website", station.website?.startsWith("https://") == true) + station.frequencies.forEach { f -> + assertTrue("${station.id} ${f.mhz}", f.mhz in 87.5..108.0) + } + assertEquals("${station.id} cities", station.frequencies.size, station.frequencies.map { it.city }.toSet().size) + } + } }