mirror of
https://github.com/kalarina-bit/Fogwave.git
synced 2026-11-22 08:06:09 +00:00
Release 1.0.12 with only the WebP interface icons on top of 1.0.11
This commit is contained in:
+8
-16
@@ -16,6 +16,8 @@ android {
|
|||||||
versionCode = 12
|
versionCode = 12
|
||||||
versionName = "1.0.12"
|
versionName = "1.0.12"
|
||||||
|
|
||||||
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
// Library versions shown under About -> Licenses, taken from the version catalog so they
|
// Library versions shown under About -> Licenses, taken from the version catalog so they
|
||||||
// always match what is actually bundled.
|
// always match what is actually bundled.
|
||||||
buildConfigField("String", "COMPOSE_BOM_VERSION", "\"${libs.versions.composeBom.get()}\"")
|
buildConfigField("String", "COMPOSE_BOM_VERSION", "\"${libs.versions.composeBom.get()}\"")
|
||||||
@@ -55,22 +57,6 @@ android {
|
|||||||
if (canSignRelease) signingConfig = signingConfigs.getByName("release")
|
if (canSignRelease) signingConfig = signingConfigs.getByName("release")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// The app's own languages only, so library strings never mix other languages into the UI.
|
|
||||||
androidResources { localeFilters += listOf("en", "de", "ja", "lt", "ru", "zh") }
|
|
||||||
// Version, Kotlin and license metadata files that nothing reads at runtime.
|
|
||||||
packaging {
|
|
||||||
resources {
|
|
||||||
excludes += listOf(
|
|
||||||
"/META-INF/*.version",
|
|
||||||
"/META-INF/*.kotlin_module",
|
|
||||||
"/META-INF/versions/**",
|
|
||||||
"/META-INF/{AL2.0,LGPL2.1}",
|
|
||||||
"/kotlin/**",
|
|
||||||
"/kotlin-tooling-metadata.json",
|
|
||||||
"/DebugProbesKt.bin"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility = JavaVersion.VERSION_11
|
sourceCompatibility = JavaVersion.VERSION_11
|
||||||
targetCompatibility = JavaVersion.VERSION_11
|
targetCompatibility = JavaVersion.VERSION_11
|
||||||
@@ -111,5 +97,11 @@ dependencies {
|
|||||||
testImplementation(libs.roborazzi)
|
testImplementation(libs.roborazzi)
|
||||||
testImplementation(libs.roborazzi.compose)
|
testImplementation(libs.roborazzi.compose)
|
||||||
testImplementation(libs.roborazzi.junit.rule)
|
testImplementation(libs.roborazzi.junit.rule)
|
||||||
|
androidTestImplementation(platform(libs.androidx.compose.bom))
|
||||||
|
androidTestImplementation(libs.androidx.compose.ui.test.junit4)
|
||||||
|
androidTestImplementation(libs.androidx.espresso.core)
|
||||||
|
androidTestImplementation(libs.androidx.junit)
|
||||||
|
androidTestImplementation(libs.androidx.runner)
|
||||||
debugImplementation(libs.androidx.compose.ui.test.manifest)
|
debugImplementation(libs.androidx.compose.ui.test.manifest)
|
||||||
|
debugImplementation(libs.androidx.compose.ui.tooling)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package cc.skysparkle.fogwave
|
||||||
|
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
|
import org.junit.Assert.*
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
class ExampleInstrumentedTest {
|
||||||
|
@Test
|
||||||
|
fun useAppContext() {
|
||||||
|
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||||
|
assertEquals(BuildConfig.APPLICATION_ID, appContext.packageName)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
android:localeConfig="@xml/locales_config"
|
android:localeConfig="@xml/locales_config"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
|
android:usesCleartextTraffic="false"
|
||||||
android:networkSecurityConfig="@xml/network_security_config"
|
android:networkSecurityConfig="@xml/network_security_config"
|
||||||
android:theme="@style/Theme.Fogwave">
|
android:theme="@style/Theme.Fogwave">
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,11 @@
|
|||||||
package cc.skysparkle.fogwave
|
package cc.skysparkle.fogwave
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.Context
|
|
||||||
import cc.skysparkle.fogwave.data.repository.RadioRepository
|
|
||||||
import cc.skysparkle.fogwave.player.AudioEffectsEngine
|
|
||||||
import coil.ImageLoader
|
import coil.ImageLoader
|
||||||
import coil.ImageLoaderFactory
|
import coil.ImageLoaderFactory
|
||||||
import coil.memory.MemoryCache
|
import coil.memory.MemoryCache
|
||||||
|
|
||||||
class FogwaveApp : Application(), ImageLoaderFactory {
|
class FogwaveApp : Application(), ImageLoaderFactory {
|
||||||
override fun onCreate() {
|
|
||||||
super.onCreate()
|
|
||||||
// Opening the preference files starts loading them on a background thread right away, so the
|
|
||||||
// first screen and the playback service usually find them loaded instead of waiting on the disk.
|
|
||||||
getSharedPreferences(RadioRepository.PREFS_NAME, Context.MODE_PRIVATE)
|
|
||||||
getSharedPreferences(AudioEffectsEngine.PREFS_NAME, Context.MODE_PRIVATE)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun newImageLoader(): ImageLoader {
|
override fun newImageLoader(): ImageLoader {
|
||||||
return ImageLoader.Builder(this)
|
return ImageLoader.Builder(this)
|
||||||
.memoryCache {
|
.memoryCache {
|
||||||
@@ -25,6 +14,7 @@ class FogwaveApp : Application(), ImageLoaderFactory {
|
|||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
.crossfade(true)
|
.crossfade(true)
|
||||||
|
.respectCacheHeaders(false)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package cc.skysparkle.fogwave.data.repository
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
|
import cc.skysparkle.fogwave.R
|
||||||
|
import cc.skysparkle.fogwave.data.model.Genre
|
||||||
import cc.skysparkle.fogwave.data.model.IconSizeStep
|
import cc.skysparkle.fogwave.data.model.IconSizeStep
|
||||||
import cc.skysparkle.fogwave.data.model.RadioStation
|
import cc.skysparkle.fogwave.data.model.RadioStation
|
||||||
import cc.skysparkle.fogwave.data.model.ViewMode
|
import cc.skysparkle.fogwave.data.model.ViewMode
|
||||||
@@ -11,11 +13,107 @@ import kotlinx.coroutines.flow.asStateFlow
|
|||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
|
|
||||||
class RadioRepository(context: Context) {
|
class RadioRepository(context: Context) {
|
||||||
private val prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
|
private val prefs = context.getSharedPreferences("fogwave_prefs", Context.MODE_PRIVATE)
|
||||||
|
|
||||||
val stations: List<RadioStation> = RadioStations
|
val stations: List<RadioStation> = listOf(
|
||||||
|
RadioStation(
|
||||||
|
id = "zip",
|
||||||
|
name = "ZIP FM",
|
||||||
|
descriptionRes = R.string.station_desc_zip,
|
||||||
|
streamUrl = "https://stream4.radijas.lt/zipfm",
|
||||||
|
iconResId = R.drawable.ic_station_zipfm,
|
||||||
|
genres = listOf(Genre.HITS, Genre.POP, Genre.LITHUANIAN),
|
||||||
|
bitrate = "MP3"
|
||||||
|
),
|
||||||
|
RadioStation(
|
||||||
|
id = "powerhit",
|
||||||
|
name = "Power Hit Radio",
|
||||||
|
descriptionRes = R.string.station_desc_powerhit,
|
||||||
|
// Stable revma entry point: it redirects to a fresh node URL with a short-lived token.
|
||||||
|
streamUrl = "https://stream.rcs.revma.com/f31w7e0fveuvv",
|
||||||
|
iconResId = R.drawable.ic_station_powerhit,
|
||||||
|
genres = listOf(Genre.DANCE, Genre.POP, Genre.HITS),
|
||||||
|
bitrate = "AAC"
|
||||||
|
),
|
||||||
|
RadioStation(
|
||||||
|
id = "powerhitgold",
|
||||||
|
name = "Power Hit Radio Gold",
|
||||||
|
descriptionRes = R.string.station_desc_powerhitgold,
|
||||||
|
streamUrl = "https://stream.rcs.revma.com/asdpz3qfbhuvv",
|
||||||
|
iconResId = R.drawable.ic_station_powerhitgold,
|
||||||
|
genres = listOf(Genre.DANCE, Genre.OLDIES, Genre.HITS),
|
||||||
|
bitrate = "AAC"
|
||||||
|
),
|
||||||
|
RadioStation(
|
||||||
|
id = "rock",
|
||||||
|
name = "Rock FM",
|
||||||
|
descriptionRes = R.string.station_desc_rock,
|
||||||
|
streamUrl = "https://stream4.radijas.lt/rockfm",
|
||||||
|
iconResId = R.drawable.ic_station_rockfm,
|
||||||
|
genres = listOf(Genre.ROCK, Genre.LITHUANIAN),
|
||||||
|
bitrate = "MP3",
|
||||||
|
lightBackdrop = true
|
||||||
|
),
|
||||||
|
RadioStation(
|
||||||
|
id = "relax",
|
||||||
|
name = "Relax FM",
|
||||||
|
descriptionRes = R.string.station_desc_relax,
|
||||||
|
streamUrl = "https://stream4.radijas.lt/relaxfm",
|
||||||
|
iconResId = R.drawable.ic_station_relaxfm,
|
||||||
|
genres = listOf(Genre.EASY_LISTENING),
|
||||||
|
bitrate = "MP3"
|
||||||
|
),
|
||||||
|
RadioStation(
|
||||||
|
id = "lietus",
|
||||||
|
name = "Lietus",
|
||||||
|
descriptionRes = R.string.station_desc_lietus,
|
||||||
|
streamUrl = "https://stream.m-1.fm/lietus/aacp64",
|
||||||
|
iconResId = R.drawable.ic_station_lietus,
|
||||||
|
genres = listOf(Genre.LITHUANIAN, Genre.POP),
|
||||||
|
bitrate = "AAC 64 kbps",
|
||||||
|
lightBackdrop = true
|
||||||
|
),
|
||||||
|
RadioStation(
|
||||||
|
id = "m1",
|
||||||
|
name = "M-1",
|
||||||
|
descriptionRes = R.string.station_desc_m1,
|
||||||
|
streamUrl = "https://stream.m-1.fm/m1/aacp64",
|
||||||
|
iconResId = R.drawable.ic_station_m1,
|
||||||
|
genres = listOf(Genre.POP, Genre.HITS),
|
||||||
|
bitrate = "AAC 64 kbps"
|
||||||
|
),
|
||||||
|
RadioStation(
|
||||||
|
id = "plus",
|
||||||
|
name = "M-1 Plius",
|
||||||
|
descriptionRes = R.string.station_desc_plus,
|
||||||
|
streamUrl = "https://radio.m-1.fm/m1plius/aacp64",
|
||||||
|
iconResId = R.drawable.ic_station_m1plus,
|
||||||
|
genres = listOf(Genre.POP, Genre.OLDIES),
|
||||||
|
bitrate = "AAC 64 kbps",
|
||||||
|
lightBackdrop = true
|
||||||
|
),
|
||||||
|
RadioStation(
|
||||||
|
id = "goldfm",
|
||||||
|
name = "Gold FM",
|
||||||
|
descriptionRes = R.string.station_desc_goldfm,
|
||||||
|
streamUrl = "https://stream.goldfm.lt/goldfm.aac",
|
||||||
|
iconResId = R.drawable.ic_station_goldfm,
|
||||||
|
genres = listOf(Genre.OLDIES, Genre.HITS, Genre.LITHUANIAN),
|
||||||
|
bitrate = "AAC"
|
||||||
|
),
|
||||||
|
RadioStation(
|
||||||
|
id = "rc",
|
||||||
|
name = "RC",
|
||||||
|
descriptionRes = R.string.station_desc_rc,
|
||||||
|
streamUrl = "https://stream1.rc.lt/rc128.mp3",
|
||||||
|
iconResId = R.drawable.ic_station_rc,
|
||||||
|
genres = listOf(Genre.HITS, Genre.LITHUANIAN),
|
||||||
|
bitrate = "MP3 128 kbps",
|
||||||
|
lightBackdrop = true
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
private val stationIds: Set<String> = RadioStations.mapTo(HashSet()) { it.id }
|
private val stationIds: Set<String> = stations.mapTo(HashSet()) { it.id }
|
||||||
|
|
||||||
private val _favoritesFlow = MutableStateFlow<Set<String>>(loadFavorites())
|
private val _favoritesFlow = MutableStateFlow<Set<String>>(loadFavorites())
|
||||||
val favoritesFlow: StateFlow<Set<String>> = _favoritesFlow.asStateFlow()
|
val favoritesFlow: StateFlow<Set<String>> = _favoritesFlow.asStateFlow()
|
||||||
@@ -37,10 +135,10 @@ class RadioRepository(context: Context) {
|
|||||||
return loadFavorites()
|
return loadFavorites()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun markFavoritesSeen() {
|
fun markFavoritesSeen(ids: Set<String>) {
|
||||||
val copy = _favoritesFlow.value.toSet()
|
val copy = ids.toSet()
|
||||||
_seenFavoritesFlow.value = copy
|
_seenFavoritesFlow.value = copy
|
||||||
prefs.edit { putStringSet("seen_favorites", copy) }
|
prefs.edit { putStringSet("seen_favorites", copy); remove("last_seen_favorites_count") }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getLastStationId(): String? {
|
fun getLastStationId(): String? {
|
||||||
@@ -86,11 +184,18 @@ class RadioRepository(context: Context) {
|
|||||||
return prefs.getStringSet("favorites", null)?.filterTo(HashSet()) { it in stationIds } ?: emptySet()
|
return prefs.getStringSet("favorites", null)?.filterTo(HashSet()) { it in stationIds } ?: emptySet()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toggleFavorite(stationId: String) {
|
fun toggleFavorite(stationId: String): Boolean {
|
||||||
val current = _favoritesFlow.value.toMutableSet()
|
val current = _favoritesFlow.value.toMutableSet()
|
||||||
if (!current.remove(stationId)) current.add(stationId)
|
val isNowFav = if (current.contains(stationId)) {
|
||||||
|
current.remove(stationId)
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
current.add(stationId)
|
||||||
|
true
|
||||||
|
}
|
||||||
prefs.edit { putStringSet("favorites", current) }
|
prefs.edit { putStringSet("favorites", current) }
|
||||||
_favoritesFlow.value = current
|
_favoritesFlow.value = current
|
||||||
|
return isNowFav
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadRecents(): List<String> {
|
private fun loadRecents(): List<String> {
|
||||||
@@ -155,8 +260,4 @@ class RadioRepository(context: Context) {
|
|||||||
fun markBatteryOptimizationPromptSeen() {
|
fun markBatteryOptimizationPromptSeen() {
|
||||||
prefs.edit { putBoolean("seen_battery_optimization_prompt", true) }
|
prefs.edit { putBoolean("seen_battery_optimization_prompt", true) }
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
const val PREFS_NAME = "fogwave_prefs"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,104 +0,0 @@
|
|||||||
package cc.skysparkle.fogwave.data.repository
|
|
||||||
|
|
||||||
import cc.skysparkle.fogwave.R
|
|
||||||
import cc.skysparkle.fogwave.data.model.Genre
|
|
||||||
import cc.skysparkle.fogwave.data.model.RadioStation
|
|
||||||
|
|
||||||
// Built once per process and shared by the UI and the playback service.
|
|
||||||
val RadioStations: List<RadioStation> = listOf(
|
|
||||||
RadioStation(
|
|
||||||
id = "zip",
|
|
||||||
name = "ZIP FM",
|
|
||||||
descriptionRes = R.string.station_desc_zip,
|
|
||||||
streamUrl = "https://stream4.radijas.lt/zipfm",
|
|
||||||
iconResId = R.drawable.ic_station_zipfm,
|
|
||||||
genres = listOf(Genre.HITS, Genre.POP, Genre.LITHUANIAN),
|
|
||||||
bitrate = "MP3"
|
|
||||||
),
|
|
||||||
RadioStation(
|
|
||||||
id = "powerhit",
|
|
||||||
name = "Power Hit Radio",
|
|
||||||
descriptionRes = R.string.station_desc_powerhit,
|
|
||||||
// Stable revma entry point: it redirects to a fresh node URL with a short-lived token.
|
|
||||||
streamUrl = "https://stream.rcs.revma.com/f31w7e0fveuvv",
|
|
||||||
iconResId = R.drawable.ic_station_powerhit,
|
|
||||||
genres = listOf(Genre.DANCE, Genre.POP, Genre.HITS),
|
|
||||||
bitrate = "AAC"
|
|
||||||
),
|
|
||||||
RadioStation(
|
|
||||||
id = "powerhitgold",
|
|
||||||
name = "Power Hit Radio Gold",
|
|
||||||
descriptionRes = R.string.station_desc_powerhitgold,
|
|
||||||
streamUrl = "https://stream.rcs.revma.com/asdpz3qfbhuvv",
|
|
||||||
iconResId = R.drawable.ic_station_powerhitgold,
|
|
||||||
genres = listOf(Genre.DANCE, Genre.OLDIES, Genre.HITS),
|
|
||||||
bitrate = "AAC"
|
|
||||||
),
|
|
||||||
RadioStation(
|
|
||||||
id = "rock",
|
|
||||||
name = "Rock FM",
|
|
||||||
descriptionRes = R.string.station_desc_rock,
|
|
||||||
streamUrl = "https://stream4.radijas.lt/rockfm",
|
|
||||||
iconResId = R.drawable.ic_station_rockfm,
|
|
||||||
genres = listOf(Genre.ROCK, Genre.LITHUANIAN),
|
|
||||||
bitrate = "MP3",
|
|
||||||
lightBackdrop = true
|
|
||||||
),
|
|
||||||
RadioStation(
|
|
||||||
id = "relax",
|
|
||||||
name = "Relax FM",
|
|
||||||
descriptionRes = R.string.station_desc_relax,
|
|
||||||
streamUrl = "https://stream4.radijas.lt/relaxfm",
|
|
||||||
iconResId = R.drawable.ic_station_relaxfm,
|
|
||||||
genres = listOf(Genre.EASY_LISTENING),
|
|
||||||
bitrate = "MP3"
|
|
||||||
),
|
|
||||||
RadioStation(
|
|
||||||
id = "lietus",
|
|
||||||
name = "Lietus",
|
|
||||||
descriptionRes = R.string.station_desc_lietus,
|
|
||||||
streamUrl = "https://stream.m-1.fm/lietus/aacp64",
|
|
||||||
iconResId = R.drawable.ic_station_lietus,
|
|
||||||
genres = listOf(Genre.LITHUANIAN, Genre.POP),
|
|
||||||
bitrate = "AAC 64 kbps",
|
|
||||||
lightBackdrop = true
|
|
||||||
),
|
|
||||||
RadioStation(
|
|
||||||
id = "m1",
|
|
||||||
name = "M-1",
|
|
||||||
descriptionRes = R.string.station_desc_m1,
|
|
||||||
streamUrl = "https://stream.m-1.fm/m1/aacp64",
|
|
||||||
iconResId = R.drawable.ic_station_m1,
|
|
||||||
genres = listOf(Genre.POP, Genre.HITS),
|
|
||||||
bitrate = "AAC 64 kbps"
|
|
||||||
),
|
|
||||||
RadioStation(
|
|
||||||
id = "plus",
|
|
||||||
name = "M-1 Plius",
|
|
||||||
descriptionRes = R.string.station_desc_plus,
|
|
||||||
streamUrl = "https://radio.m-1.fm/m1plius/aacp64",
|
|
||||||
iconResId = R.drawable.ic_station_m1plus,
|
|
||||||
genres = listOf(Genre.POP, Genre.OLDIES),
|
|
||||||
bitrate = "AAC 64 kbps",
|
|
||||||
lightBackdrop = true
|
|
||||||
),
|
|
||||||
RadioStation(
|
|
||||||
id = "goldfm",
|
|
||||||
name = "Gold FM",
|
|
||||||
descriptionRes = R.string.station_desc_goldfm,
|
|
||||||
streamUrl = "https://stream.goldfm.lt/goldfm.aac",
|
|
||||||
iconResId = R.drawable.ic_station_goldfm,
|
|
||||||
genres = listOf(Genre.OLDIES, Genre.HITS, Genre.LITHUANIAN),
|
|
||||||
bitrate = "AAC"
|
|
||||||
),
|
|
||||||
RadioStation(
|
|
||||||
id = "rc",
|
|
||||||
name = "RC",
|
|
||||||
descriptionRes = R.string.station_desc_rc,
|
|
||||||
streamUrl = "https://stream1.rc.lt/rc128.mp3",
|
|
||||||
iconResId = R.drawable.ic_station_rc,
|
|
||||||
genres = listOf(Genre.HITS, Genre.LITHUANIAN),
|
|
||||||
bitrate = "MP3 128 kbps",
|
|
||||||
lightBackdrop = true
|
|
||||||
)
|
|
||||||
)
|
|
||||||
@@ -42,6 +42,11 @@ object AudioEffectsController {
|
|||||||
refresh()
|
refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setLoudnessGain(gainMillibel: Float) {
|
||||||
|
engine?.setLoudnessGain(gainMillibel)
|
||||||
|
refresh()
|
||||||
|
}
|
||||||
|
|
||||||
fun setDynamicsProcessingEnabled(enabled: Boolean) {
|
fun setDynamicsProcessingEnabled(enabled: Boolean) {
|
||||||
engine?.setDynamicsProcessingEnabled(enabled)
|
engine?.setDynamicsProcessingEnabled(enabled)
|
||||||
refresh()
|
refresh()
|
||||||
|
|||||||
@@ -18,19 +18,22 @@ data class EqualizerBand(
|
|||||||
)
|
)
|
||||||
|
|
||||||
data class AudioEffectsState(
|
data class AudioEffectsState(
|
||||||
|
val equalizerAvailable: Boolean = false,
|
||||||
val equalizerEnabled: Boolean = false,
|
val equalizerEnabled: Boolean = false,
|
||||||
val bands: List<EqualizerBand> = emptyList(),
|
val bands: List<EqualizerBand> = emptyList(),
|
||||||
val presets: List<String> = emptyList(),
|
val presets: List<String> = emptyList(),
|
||||||
val currentPreset: Int = -1,
|
val currentPreset: Int = -1,
|
||||||
val loudnessAvailable: Boolean = false,
|
val loudnessAvailable: Boolean = false,
|
||||||
val loudnessEnabled: Boolean = false,
|
val loudnessEnabled: Boolean = false,
|
||||||
|
val loudnessGainMillibel: Float = 0f,
|
||||||
|
val loudnessMaxGainMillibel: Float = 2000f,
|
||||||
val dynamicsProcessingAvailable: Boolean = false,
|
val dynamicsProcessingAvailable: Boolean = false,
|
||||||
val dynamicsProcessingEnabled: Boolean = false
|
val dynamicsProcessingEnabled: Boolean = false
|
||||||
)
|
)
|
||||||
|
|
||||||
class AudioEffectsEngine(context: Context, audioSessionId: Int) {
|
class AudioEffectsEngine(context: Context, audioSessionId: Int) {
|
||||||
private val prefs: SharedPreferences =
|
private val prefs: SharedPreferences =
|
||||||
context.applicationContext.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
|
context.applicationContext.getSharedPreferences("fogwave_audio_effects", Context.MODE_PRIVATE)
|
||||||
|
|
||||||
// Tracked manually: Equalizer.currentPreset is unreliable after bands are moved by hand.
|
// Tracked manually: Equalizer.currentPreset is unreliable after bands are moved by hand.
|
||||||
private var currentPresetIndex: Int = prefs.getInt(KEY_PRESET, -1)
|
private var currentPresetIndex: Int = prefs.getInt(KEY_PRESET, -1)
|
||||||
@@ -41,21 +44,12 @@ class AudioEffectsEngine(context: Context, audioSessionId: Int) {
|
|||||||
|
|
||||||
private val presetNames = mutableListOf<String>()
|
private val presetNames = mutableListOf<String>()
|
||||||
|
|
||||||
// Fixed for the lifetime of the equalizer, so they are read once instead of on every refresh.
|
|
||||||
private var bandCenterFreqsHz = IntArray(0)
|
|
||||||
private var minBandLevel = 0
|
|
||||||
private var maxBandLevel = 0
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
try {
|
try {
|
||||||
equalizer = Equalizer(0, audioSessionId).apply {
|
equalizer = Equalizer(0, audioSessionId).apply {
|
||||||
for (p in 0 until numberOfPresets) {
|
for (p in 0 until numberOfPresets) {
|
||||||
presetNames.add(getPresetName(p.toShort()))
|
presetNames.add(getPresetName(p.toShort()))
|
||||||
}
|
}
|
||||||
bandCenterFreqsHz = IntArray(numberOfBands.toInt()) { getCenterFreq(it.toShort()) / 1000 }
|
|
||||||
val range = bandLevelRange
|
|
||||||
minBandLevel = range[0].toInt()
|
|
||||||
maxBandLevel = range[1].toInt()
|
|
||||||
|
|
||||||
val preset = currentPresetIndex
|
val preset = currentPresetIndex
|
||||||
if (preset in 0 until numberOfPresets) {
|
if (preset in 0 until numberOfPresets) {
|
||||||
@@ -74,6 +68,7 @@ class AudioEffectsEngine(context: Context, audioSessionId: Int) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
loudnessEnhancer = LoudnessEnhancer(audioSessionId).apply {
|
loudnessEnhancer = LoudnessEnhancer(audioSessionId).apply {
|
||||||
|
setTargetGain(prefs.getInt(KEY_LOUDNESS_GAIN, 0))
|
||||||
enabled = prefs.getBoolean(KEY_LOUDNESS_ENABLED, false)
|
enabled = prefs.getBoolean(KEY_LOUDNESS_ENABLED, false)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@@ -146,24 +141,32 @@ class AudioEffectsEngine(context: Context, audioSessionId: Int) {
|
|||||||
fun currentState(): AudioEffectsState {
|
fun currentState(): AudioEffectsState {
|
||||||
val eq = equalizer
|
val eq = equalizer
|
||||||
val bands = if (eq != null) {
|
val bands = if (eq != null) {
|
||||||
bandCenterFreqsHz.indices.map { i ->
|
(0 until eq.numberOfBands).map { i ->
|
||||||
|
val idx = i.toShort()
|
||||||
|
val range = eq.bandLevelRange
|
||||||
EqualizerBand(
|
EqualizerBand(
|
||||||
index = i,
|
index = i,
|
||||||
centerFreqHz = bandCenterFreqsHz[i],
|
centerFreqHz = eq.getCenterFreq(idx) / 1000,
|
||||||
levelMillibel = eq.getBandLevel(i.toShort()).toInt(),
|
levelMillibel = eq.getBandLevel(idx).toInt(),
|
||||||
minLevelMillibel = minBandLevel,
|
minLevelMillibel = range[0].toInt(),
|
||||||
maxLevelMillibel = maxBandLevel
|
maxLevelMillibel = range[1].toInt()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else emptyList()
|
} else emptyList()
|
||||||
|
|
||||||
return AudioEffectsState(
|
return AudioEffectsState(
|
||||||
|
equalizerAvailable = eq != null,
|
||||||
equalizerEnabled = eq?.enabled ?: false,
|
equalizerEnabled = eq?.enabled ?: false,
|
||||||
bands = bands,
|
bands = bands,
|
||||||
presets = presetNames,
|
presets = presetNames,
|
||||||
currentPreset = if (eq != null) currentPresetIndex else -1,
|
currentPreset = if (eq != null) currentPresetIndex else -1,
|
||||||
loudnessAvailable = loudnessEnhancer != null,
|
loudnessAvailable = loudnessEnhancer != null,
|
||||||
loudnessEnabled = loudnessEnhancer?.enabled ?: false,
|
loudnessEnabled = loudnessEnhancer?.enabled ?: false,
|
||||||
|
loudnessGainMillibel = try {
|
||||||
|
loudnessEnhancer?.targetGain ?: 0f
|
||||||
|
} catch (_: Exception) {
|
||||||
|
0f
|
||||||
|
},
|
||||||
dynamicsProcessingAvailable = dynamicsProcessing != null,
|
dynamicsProcessingAvailable = dynamicsProcessing != null,
|
||||||
dynamicsProcessingEnabled = dynamicsProcessing?.enabled ?: false
|
dynamicsProcessingEnabled = dynamicsProcessing?.enabled ?: false
|
||||||
)
|
)
|
||||||
@@ -208,6 +211,14 @@ class AudioEffectsEngine(context: Context, audioSessionId: Int) {
|
|||||||
} catch (_: Exception) {}
|
} catch (_: Exception) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setLoudnessGain(gainMillibel: Float) {
|
||||||
|
try {
|
||||||
|
val gain = gainMillibel.coerceIn(0f, 2000f).toInt()
|
||||||
|
loudnessEnhancer?.setTargetGain(gain)
|
||||||
|
prefs.edit { putInt(KEY_LOUDNESS_GAIN, gain) }
|
||||||
|
} catch (_: Exception) {}
|
||||||
|
}
|
||||||
|
|
||||||
fun setDynamicsProcessingEnabled(enabled: Boolean) {
|
fun setDynamicsProcessingEnabled(enabled: Boolean) {
|
||||||
try {
|
try {
|
||||||
dynamicsProcessing?.enabled = enabled
|
dynamicsProcessing?.enabled = enabled
|
||||||
@@ -224,13 +235,13 @@ class AudioEffectsEngine(context: Context, audioSessionId: Int) {
|
|||||||
dynamicsProcessing = null
|
dynamicsProcessing = null
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
private companion object {
|
||||||
const val PREFS_NAME = "fogwave_audio_effects"
|
const val TAG = "AudioEffectsEngine"
|
||||||
private const val TAG = "AudioEffectsEngine"
|
const val KEY_EQ_ENABLED = "eq_enabled"
|
||||||
private const val KEY_EQ_ENABLED = "eq_enabled"
|
const val KEY_PRESET = "eq_preset"
|
||||||
private const val KEY_PRESET = "eq_preset"
|
const val KEY_BAND_PREFIX = "eq_band_"
|
||||||
private const val KEY_BAND_PREFIX = "eq_band_"
|
const val KEY_LOUDNESS_ENABLED = "loudness_enabled"
|
||||||
private const val KEY_LOUDNESS_ENABLED = "loudness_enabled"
|
const val KEY_LOUDNESS_GAIN = "loudness_gain"
|
||||||
private const val KEY_DYNAMICS_ENABLED = "dynamics_enabled"
|
const val KEY_DYNAMICS_ENABLED = "dynamics_enabled"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import android.content.Intent
|
|||||||
import android.media.AudioManager
|
import android.media.AudioManager
|
||||||
import android.net.ConnectivityManager
|
import android.net.ConnectivityManager
|
||||||
import android.net.Network
|
import android.net.Network
|
||||||
import android.os.LocaleList
|
|
||||||
import android.os.SystemClock
|
import android.os.SystemClock
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.annotation.OptIn
|
import androidx.annotation.OptIn
|
||||||
@@ -20,13 +19,6 @@ import androidx.media3.common.util.UnstableApi
|
|||||||
import androidx.media3.datasource.DefaultHttpDataSource
|
import androidx.media3.datasource.DefaultHttpDataSource
|
||||||
import androidx.media3.exoplayer.DefaultLoadControl
|
import androidx.media3.exoplayer.DefaultLoadControl
|
||||||
import androidx.media3.exoplayer.ExoPlayer
|
import androidx.media3.exoplayer.ExoPlayer
|
||||||
import androidx.media3.exoplayer.Renderer
|
|
||||||
import androidx.media3.exoplayer.RenderersFactory
|
|
||||||
import androidx.media3.exoplayer.audio.DefaultAudioSink
|
|
||||||
import androidx.media3.exoplayer.audio.MediaCodecAudioRenderer
|
|
||||||
import androidx.media3.exoplayer.mediacodec.DefaultMediaCodecAdapterFactory
|
|
||||||
import androidx.media3.exoplayer.mediacodec.MediaCodecSelector
|
|
||||||
import androidx.media3.exoplayer.metadata.MetadataRenderer
|
|
||||||
import androidx.media3.exoplayer.source.DefaultMediaSourceFactory
|
import androidx.media3.exoplayer.source.DefaultMediaSourceFactory
|
||||||
import androidx.media3.session.LibraryResult
|
import androidx.media3.session.LibraryResult
|
||||||
import androidx.media3.session.MediaLibraryService
|
import androidx.media3.session.MediaLibraryService
|
||||||
@@ -36,7 +28,7 @@ import androidx.media3.session.MediaSession
|
|||||||
import cc.skysparkle.fogwave.BuildConfig
|
import cc.skysparkle.fogwave.BuildConfig
|
||||||
import cc.skysparkle.fogwave.MainActivity
|
import cc.skysparkle.fogwave.MainActivity
|
||||||
import cc.skysparkle.fogwave.R
|
import cc.skysparkle.fogwave.R
|
||||||
import cc.skysparkle.fogwave.data.repository.RadioStations
|
import cc.skysparkle.fogwave.data.repository.RadioRepository
|
||||||
import com.google.common.collect.ImmutableList
|
import com.google.common.collect.ImmutableList
|
||||||
import com.google.common.util.concurrent.Futures
|
import com.google.common.util.concurrent.Futures
|
||||||
import com.google.common.util.concurrent.ListenableFuture
|
import com.google.common.util.concurrent.ListenableFuture
|
||||||
@@ -51,6 +43,7 @@ import kotlinx.coroutines.launch
|
|||||||
@OptIn(UnstableApi::class)
|
@OptIn(UnstableApi::class)
|
||||||
class FogwavePlaybackService : MediaLibraryService() {
|
class FogwavePlaybackService : MediaLibraryService() {
|
||||||
private var mediaLibrarySession: MediaLibrarySession? = null
|
private var mediaLibrarySession: MediaLibrarySession? = null
|
||||||
|
private lateinit var repository: RadioRepository
|
||||||
private lateinit var player: ExoPlayer
|
private lateinit var player: ExoPlayer
|
||||||
private var audioEffectsEngine: AudioEffectsEngine? = null
|
private var audioEffectsEngine: AudioEffectsEngine? = null
|
||||||
|
|
||||||
@@ -82,35 +75,13 @@ class FogwavePlaybackService : MediaLibraryService() {
|
|||||||
.setPrioritizeTimeOverSizeThresholds(true)
|
.setPrioritizeTimeOverSizeThresholds(true)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
// Radio streams carry only audio and ICY/ID3 metadata. Without the default factory R8 can drop
|
private val librarySessionCallback = object : MediaLibrarySession.Callback {
|
||||||
// the video, text and image renderers. The audio renderer is configured like the default one,
|
override fun onGetLibraryRoot(
|
||||||
// and two metadata renderers keep ICY titles working next to an in-stream ID3 track.
|
session: MediaLibrarySession,
|
||||||
private fun audioOnlyRenderersFactory() = RenderersFactory { handler, _, audioListener, _, metadataOutput ->
|
browser: MediaSession.ControllerInfo,
|
||||||
arrayOf<Renderer>(
|
params: LibraryParams?
|
||||||
MediaCodecAudioRenderer(
|
): ListenableFuture<LibraryResult<MediaItem>> {
|
||||||
this@FogwavePlaybackService,
|
val rootItem = MediaItem.Builder()
|
||||||
DefaultMediaCodecAdapterFactory(this@FogwavePlaybackService),
|
|
||||||
MediaCodecSelector.DEFAULT,
|
|
||||||
false,
|
|
||||||
handler,
|
|
||||||
audioListener,
|
|
||||||
DefaultAudioSink.Builder(this@FogwavePlaybackService).build()
|
|
||||||
),
|
|
||||||
MetadataRenderer(metadataOutput, handler.looper),
|
|
||||||
MetadataRenderer(metadataOutput, handler.looper)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Browse tree for Android Auto: built once and served from memory, rebuilt only when the app
|
|
||||||
// language changes so station descriptions stay translated.
|
|
||||||
private var browseTreeLocales: LocaleList? = null
|
|
||||||
private lateinit var rootItem: MediaItem
|
|
||||||
private lateinit var stationItems: ImmutableList<MediaItem>
|
|
||||||
|
|
||||||
private fun ensureBrowseTree() {
|
|
||||||
val locales = resources.configuration.locales
|
|
||||||
if (locales == browseTreeLocales) return
|
|
||||||
rootItem = MediaItem.Builder()
|
|
||||||
.setMediaId(ROOT_ID)
|
.setMediaId(ROOT_ID)
|
||||||
.setMediaMetadata(
|
.setMediaMetadata(
|
||||||
MediaMetadata.Builder()
|
MediaMetadata.Builder()
|
||||||
@@ -121,22 +92,6 @@ class FogwavePlaybackService : MediaLibraryService() {
|
|||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
.build()
|
.build()
|
||||||
stationItems = ImmutableList.copyOf(RadioStations.map { it.toMediaItem(this) })
|
|
||||||
browseTreeLocales = locales
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun stationItem(mediaId: String): MediaItem? {
|
|
||||||
ensureBrowseTree()
|
|
||||||
return stationItems.find { it.mediaId == mediaId }
|
|
||||||
}
|
|
||||||
|
|
||||||
private val librarySessionCallback = object : MediaLibrarySession.Callback {
|
|
||||||
override fun onGetLibraryRoot(
|
|
||||||
session: MediaLibrarySession,
|
|
||||||
browser: MediaSession.ControllerInfo,
|
|
||||||
params: LibraryParams?
|
|
||||||
): ListenableFuture<LibraryResult<MediaItem>> {
|
|
||||||
ensureBrowseTree()
|
|
||||||
return Futures.immediateFuture(LibraryResult.ofItem(rootItem, params))
|
return Futures.immediateFuture(LibraryResult.ofItem(rootItem, params))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,8 +106,8 @@ class FogwavePlaybackService : MediaLibraryService() {
|
|||||||
if (parentId != ROOT_ID) {
|
if (parentId != ROOT_ID) {
|
||||||
return Futures.immediateFuture(LibraryResult.ofError(LibraryResult.RESULT_ERROR_BAD_VALUE))
|
return Futures.immediateFuture(LibraryResult.ofError(LibraryResult.RESULT_ERROR_BAD_VALUE))
|
||||||
}
|
}
|
||||||
ensureBrowseTree()
|
val items = repository.stations.map { it.toMediaItem(this@FogwavePlaybackService) }
|
||||||
return Futures.immediateFuture(LibraryResult.ofItemList(stationItems, params))
|
return Futures.immediateFuture(LibraryResult.ofItemList(ImmutableList.copyOf(items), params))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onGetItem(
|
override fun onGetItem(
|
||||||
@@ -160,9 +115,9 @@ class FogwavePlaybackService : MediaLibraryService() {
|
|||||||
browser: MediaSession.ControllerInfo,
|
browser: MediaSession.ControllerInfo,
|
||||||
mediaId: String
|
mediaId: String
|
||||||
): ListenableFuture<LibraryResult<MediaItem>> {
|
): ListenableFuture<LibraryResult<MediaItem>> {
|
||||||
val item = stationItem(mediaId)
|
val station = repository.stations.find { it.id == mediaId }
|
||||||
?: return Futures.immediateFuture(LibraryResult.ofError(LibraryResult.RESULT_ERROR_BAD_VALUE))
|
?: return Futures.immediateFuture(LibraryResult.ofError(LibraryResult.RESULT_ERROR_BAD_VALUE))
|
||||||
return Futures.immediateFuture(LibraryResult.ofItem(item, null))
|
return Futures.immediateFuture(LibraryResult.ofItem(station.toMediaItem(this@FogwavePlaybackService), null))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAddMediaItems(
|
override fun onAddMediaItems(
|
||||||
@@ -171,7 +126,13 @@ class FogwavePlaybackService : MediaLibraryService() {
|
|||||||
mediaItems: MutableList<MediaItem>
|
mediaItems: MutableList<MediaItem>
|
||||||
): ListenableFuture<MutableList<MediaItem>> {
|
): ListenableFuture<MutableList<MediaItem>> {
|
||||||
val resolved = mediaItems.map { item ->
|
val resolved = mediaItems.map { item ->
|
||||||
if (item.localConfiguration != null) item else stationItem(item.mediaId) ?: item
|
if (item.localConfiguration != null) {
|
||||||
|
item
|
||||||
|
} else {
|
||||||
|
repository.stations.find { it.id == item.mediaId }
|
||||||
|
?.toMediaItem(this@FogwavePlaybackService)
|
||||||
|
?: item
|
||||||
|
}
|
||||||
}.toMutableList()
|
}.toMutableList()
|
||||||
|
|
||||||
resolved.firstOrNull()?.let { item ->
|
resolved.firstOrNull()?.let { item ->
|
||||||
@@ -309,15 +270,14 @@ class FogwavePlaybackService : MediaLibraryService() {
|
|||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
|
repository = RadioRepository(applicationContext)
|
||||||
|
|
||||||
val audioManager = getSystemService(Context.AUDIO_SERVICE) as? AudioManager
|
val audioManager = getSystemService(Context.AUDIO_SERVICE) as? AudioManager
|
||||||
val audioSessionId = audioManager?.generateAudioSessionId()?.takeIf { it != 0 }
|
val audioSessionId = audioManager?.generateAudioSessionId()?.takeIf { it != 0 }
|
||||||
?: C.AUDIO_SESSION_ID_UNSET
|
?: C.AUDIO_SESSION_ID_UNSET
|
||||||
|
|
||||||
player = ExoPlayer.Builder(
|
player = ExoPlayer.Builder(this)
|
||||||
this,
|
.setMediaSourceFactory(DefaultMediaSourceFactory(this).setDataSourceFactory(httpDataSourceFactory))
|
||||||
audioOnlyRenderersFactory(),
|
|
||||||
DefaultMediaSourceFactory(this).setDataSourceFactory(httpDataSourceFactory)
|
|
||||||
)
|
|
||||||
.setLoadControl(loadControl)
|
.setLoadControl(loadControl)
|
||||||
.build()
|
.build()
|
||||||
.apply {
|
.apply {
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ class RadioPlayerManager(private val context: Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun play() {
|
fun play() {
|
||||||
val c = controller
|
val c = controller
|
||||||
when {
|
when {
|
||||||
c == null || c.mediaItemCount == 0 -> currentStation?.let { playStation(it) }
|
c == null || c.mediaItemCount == 0 -> currentStation?.let { playStation(it) }
|
||||||
@@ -140,7 +140,7 @@ class RadioPlayerManager(private val context: Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun pause() {
|
fun pause() {
|
||||||
controller?.pause()
|
controller?.pause()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import androidx.compose.foundation.selection.toggleable
|
|||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.OutlinedButton
|
import androidx.compose.material3.OutlinedButton
|
||||||
import androidx.compose.material3.Slider
|
import androidx.compose.material3.Slider
|
||||||
import androidx.compose.material3.SliderDefaults
|
import androidx.compose.material3.SliderDefaults
|
||||||
@@ -31,7 +32,6 @@ import androidx.compose.material3.SwitchDefaults
|
|||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.ReadOnlyComposable
|
import androidx.compose.runtime.ReadOnlyComposable
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.alpha
|
import androidx.compose.ui.draw.alpha
|
||||||
@@ -47,55 +47,10 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import cc.skysparkle.fogwave.R
|
import cc.skysparkle.fogwave.R
|
||||||
import cc.skysparkle.fogwave.player.AudioEffectsState
|
import cc.skysparkle.fogwave.player.AudioEffectsState
|
||||||
import cc.skysparkle.fogwave.player.EqualizerBand
|
|
||||||
import cc.skysparkle.fogwave.ui.theme.DarkGeoColors
|
|
||||||
import cc.skysparkle.fogwave.ui.theme.LocalGeoColors
|
import cc.skysparkle.fogwave.ui.theme.LocalGeoColors
|
||||||
import cc.skysparkle.fogwave.ui.theme.Typography
|
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
// Text styles are built once from the app's only palette, not copied on every slider move.
|
|
||||||
private val EqTitleStyle = Typography.titleLarge.copy(
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
color = DarkGeoColors.deepPurple
|
|
||||||
)
|
|
||||||
private val EqStateStyle = Typography.labelMedium.copy(
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
color = DarkGeoColors.onSurfaceVariant
|
|
||||||
)
|
|
||||||
private val EqStateOnStyle = EqStateStyle.copy(color = DarkGeoColors.liveGreen)
|
|
||||||
private val EqSectionStyle = Typography.labelMedium.copy(
|
|
||||||
color = DarkGeoColors.onSurfaceVariant,
|
|
||||||
fontWeight = FontWeight.Medium
|
|
||||||
)
|
|
||||||
private val EqUnavailableStyle = Typography.bodyMedium.copy(color = DarkGeoColors.onSurfaceVariant)
|
|
||||||
private val EqPresetNameStyle = Typography.titleMedium.copy(
|
|
||||||
fontWeight = FontWeight.SemiBold,
|
|
||||||
color = DarkGeoColors.onSurface
|
|
||||||
)
|
|
||||||
private val EqPresetChipStyle = Typography.labelLarge.copy(
|
|
||||||
fontWeight = FontWeight.Medium,
|
|
||||||
color = DarkGeoColors.onSurfaceVariant
|
|
||||||
)
|
|
||||||
private val EqPresetChipSelectedStyle = Typography.labelLarge.copy(
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
color = DarkGeoColors.deepPurple
|
|
||||||
)
|
|
||||||
private val EqLevelStyle = Typography.labelSmall.copy(
|
|
||||||
fontSize = 11.sp,
|
|
||||||
fontWeight = FontWeight.SemiBold,
|
|
||||||
color = DarkGeoColors.primary
|
|
||||||
)
|
|
||||||
private val EqLevelZeroStyle = EqLevelStyle.copy(color = DarkGeoColors.onSurfaceVariant)
|
|
||||||
private val EqFrequencyStyle = Typography.labelSmall.copy(
|
|
||||||
fontSize = 11.sp,
|
|
||||||
color = DarkGeoColors.onSurfaceVariant
|
|
||||||
)
|
|
||||||
private val EqToggleLabelStyle = Typography.bodyMedium.copy(
|
|
||||||
fontWeight = FontWeight.Medium,
|
|
||||||
color = DarkGeoColors.onSurface
|
|
||||||
)
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun EqualizerSheet(
|
fun EqualizerSheet(
|
||||||
audioEffects: AudioEffectsState,
|
audioEffects: AudioEffectsState,
|
||||||
@@ -136,12 +91,18 @@ fun EqualizerSheet(
|
|||||||
}
|
}
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.equalizer_title),
|
text = stringResource(R.string.equalizer_title),
|
||||||
style = EqTitleStyle,
|
style = MaterialTheme.typography.titleLarge.copy(
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
color = LocalGeoColors.current.deepPurple
|
||||||
|
),
|
||||||
modifier = Modifier.weight(1f)
|
modifier = Modifier.weight(1f)
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = if (audioEffects.equalizerEnabled) stringResource(R.string.equalizer_on) else stringResource(R.string.equalizer_off),
|
text = if (audioEffects.equalizerEnabled) stringResource(R.string.equalizer_on) else stringResource(R.string.equalizer_off),
|
||||||
style = if (audioEffects.equalizerEnabled) EqStateOnStyle else EqStateStyle,
|
style = MaterialTheme.typography.labelMedium.copy(
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
color = if (audioEffects.equalizerEnabled) LocalGeoColors.current.liveGreen else LocalGeoColors.current.onSurfaceVariant
|
||||||
|
),
|
||||||
modifier = Modifier.padding(end = 6.dp)
|
modifier = Modifier.padding(end = 6.dp)
|
||||||
)
|
)
|
||||||
Switch(
|
Switch(
|
||||||
@@ -175,7 +136,10 @@ fun EqualizerSheet(
|
|||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.equalizer_sound_section),
|
text = stringResource(R.string.equalizer_sound_section),
|
||||||
style = EqSectionStyle
|
style = MaterialTheme.typography.labelMedium.copy(
|
||||||
|
color = LocalGeoColors.current.onSurfaceVariant,
|
||||||
|
fontWeight = FontWeight.Medium
|
||||||
|
)
|
||||||
)
|
)
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@@ -206,11 +170,54 @@ fun EqualizerSheet(
|
|||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
audioEffects.bands.forEach { band ->
|
audioEffects.bands.forEach { band ->
|
||||||
EqualizerBandColumn(
|
Column(
|
||||||
band = band,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
enabled = audioEffects.equalizerEnabled,
|
verticalArrangement = Arrangement.spacedBy(6.dp),
|
||||||
onSetEqualizerBand = onSetEqualizerBand
|
modifier = Modifier.fillMaxHeight()
|
||||||
|
) {
|
||||||
|
val db = (band.levelMillibel / 100f).roundToInt()
|
||||||
|
Text(
|
||||||
|
text = if (db > 0) "+$db dB" else "$db dB",
|
||||||
|
style = MaterialTheme.typography.labelSmall.copy(
|
||||||
|
fontSize = 11.sp,
|
||||||
|
fontWeight = FontWeight.SemiBold,
|
||||||
|
color = if (db == 0) LocalGeoColors.current.onSurfaceVariant
|
||||||
|
else LocalGeoColors.current.primary
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.weight(1f)
|
||||||
|
.width(40.dp),
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
|
) {
|
||||||
|
Slider(
|
||||||
|
value = band.levelMillibel.toFloat(),
|
||||||
|
onValueChange = { onSetEqualizerBand(band.index, it.roundToInt()) },
|
||||||
|
valueRange = band.minLevelMillibel.toFloat()..band.maxLevelMillibel.toFloat(),
|
||||||
|
enabled = audioEffects.equalizerEnabled,
|
||||||
|
colors = SliderDefaults.colors(
|
||||||
|
thumbColor = LocalGeoColors.current.primary,
|
||||||
|
activeTrackColor = LocalGeoColors.current.primary,
|
||||||
|
inactiveTrackColor = LocalGeoColors.current.outlineVariant
|
||||||
|
),
|
||||||
|
modifier = Modifier
|
||||||
|
// requiredWidth (not width): the parent is narrower, and width() would be clamped before rotation.
|
||||||
|
.requiredWidth(160.dp)
|
||||||
|
.graphicsLayer {
|
||||||
|
rotationZ = 270f
|
||||||
|
transformOrigin = TransformOrigin(0.5f, 0.5f)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Text(
|
||||||
|
text = frequencyLabel(band.centerFreqHz),
|
||||||
|
style = MaterialTheme.typography.labelSmall.copy(
|
||||||
|
fontSize = 11.sp,
|
||||||
|
color = LocalGeoColors.current.onSurfaceVariant
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -227,7 +234,7 @@ fun EqualizerSheet(
|
|||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.equalizer_unavailable),
|
text = stringResource(R.string.equalizer_unavailable),
|
||||||
style = EqUnavailableStyle
|
style = MaterialTheme.typography.bodyMedium.copy(color = LocalGeoColors.current.onSurfaceVariant)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -249,22 +256,25 @@ fun EqualizerSheet(
|
|||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = currentPresetName,
|
text = currentPresetName,
|
||||||
style = EqPresetNameStyle
|
style = MaterialTheme.typography.titleMedium.copy(
|
||||||
|
fontWeight = FontWeight.SemiBold,
|
||||||
|
color = LocalGeoColors.current.onSurface
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Captured instead of audioEffects, so moving a band does not recompose the preset chips.
|
|
||||||
val presets = audioEffects.presets
|
|
||||||
val currentPreset = audioEffects.currentPreset
|
|
||||||
LazyRow(
|
LazyRow(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||||
) {
|
) {
|
||||||
itemsIndexed(presets) { index, name ->
|
itemsIndexed(audioEffects.presets) { index, name ->
|
||||||
val selected = currentPreset == index
|
val selected = audioEffects.currentPreset == index
|
||||||
Text(
|
Text(
|
||||||
text = presetLabel(name),
|
text = presetLabel(name),
|
||||||
style = if (selected) EqPresetChipSelectedStyle else EqPresetChipStyle,
|
style = MaterialTheme.typography.labelLarge.copy(
|
||||||
|
fontWeight = if (selected) FontWeight.Bold else FontWeight.Medium,
|
||||||
|
color = if (selected) LocalGeoColors.current.deepPurple else LocalGeoColors.current.onSurfaceVariant
|
||||||
|
),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.clip(RoundedCornerShape(20.dp))
|
.clip(RoundedCornerShape(20.dp))
|
||||||
.background(if (selected) LocalGeoColors.current.primaryContainer else LocalGeoColors.current.surfaceContainerHigh)
|
.background(if (selected) LocalGeoColors.current.primaryContainer else LocalGeoColors.current.surfaceContainerHigh)
|
||||||
@@ -314,57 +324,6 @@ fun EqualizerSheet(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stable parameters: moving one slider recomposes only that band, not its neighbors.
|
|
||||||
@Composable
|
|
||||||
private fun EqualizerBandColumn(
|
|
||||||
band: EqualizerBand,
|
|
||||||
enabled: Boolean,
|
|
||||||
onSetEqualizerBand: (Int, Int) -> Unit
|
|
||||||
) {
|
|
||||||
Column(
|
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
|
||||||
verticalArrangement = Arrangement.spacedBy(6.dp),
|
|
||||||
modifier = Modifier.fillMaxHeight()
|
|
||||||
) {
|
|
||||||
val db = (band.levelMillibel / 100f).roundToInt()
|
|
||||||
Text(
|
|
||||||
text = if (db > 0) "+$db dB" else "$db dB",
|
|
||||||
style = if (db == 0) EqLevelZeroStyle else EqLevelStyle
|
|
||||||
)
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.weight(1f)
|
|
||||||
.width(40.dp),
|
|
||||||
contentAlignment = Alignment.Center
|
|
||||||
) {
|
|
||||||
Slider(
|
|
||||||
value = band.levelMillibel.toFloat(),
|
|
||||||
onValueChange = { onSetEqualizerBand(band.index, it.roundToInt()) },
|
|
||||||
valueRange = band.minLevelMillibel.toFloat()..band.maxLevelMillibel.toFloat(),
|
|
||||||
enabled = enabled,
|
|
||||||
colors = SliderDefaults.colors(
|
|
||||||
thumbColor = LocalGeoColors.current.primary,
|
|
||||||
activeTrackColor = LocalGeoColors.current.primary,
|
|
||||||
inactiveTrackColor = LocalGeoColors.current.outlineVariant
|
|
||||||
),
|
|
||||||
modifier = Modifier
|
|
||||||
// requiredWidth (not width): the parent is narrower, and width() would be clamped before rotation.
|
|
||||||
.requiredWidth(160.dp)
|
|
||||||
.graphicsLayer {
|
|
||||||
rotationZ = 270f
|
|
||||||
transformOrigin = TransformOrigin(0.5f, 0.5f)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
// The label never changes for a band, so it is formatted once, not on every slider move.
|
|
||||||
val frequency = remember(band.centerFreqHz) { frequencyLabel(band.centerFreqHz) }
|
|
||||||
Text(
|
|
||||||
text = frequency,
|
|
||||||
style = EqFrequencyStyle
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun ToggleRow(
|
private fun ToggleRow(
|
||||||
label: String,
|
label: String,
|
||||||
@@ -383,7 +342,10 @@ private fun ToggleRow(
|
|||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = label,
|
text = label,
|
||||||
style = EqToggleLabelStyle,
|
style = MaterialTheme.typography.bodyMedium.copy(
|
||||||
|
fontWeight = FontWeight.Medium,
|
||||||
|
color = LocalGeoColors.current.onSurface
|
||||||
|
),
|
||||||
modifier = Modifier.weight(1f)
|
modifier = Modifier.weight(1f)
|
||||||
)
|
)
|
||||||
Switch(
|
Switch(
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import androidx.compose.animation.core.Spring
|
|||||||
import androidx.compose.animation.core.animate
|
import androidx.compose.animation.core.animate
|
||||||
import androidx.compose.animation.core.spring
|
import androidx.compose.animation.core.spring
|
||||||
import androidx.compose.animation.core.tween
|
import androidx.compose.animation.core.tween
|
||||||
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.border
|
import androidx.compose.foundation.border
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
@@ -26,6 +27,7 @@ import androidx.compose.foundation.shape.CircleShape
|
|||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material3.CircularProgressIndicator
|
import androidx.compose.material3.CircularProgressIndicator
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.ripple
|
import androidx.compose.material3.ripple
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
@@ -38,8 +40,10 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.draw.shadow
|
import androidx.compose.ui.draw.shadow
|
||||||
import androidx.compose.ui.graphics.graphicsLayer
|
import androidx.compose.ui.graphics.graphicsLayer
|
||||||
|
import androidx.compose.ui.layout.ContentScale
|
||||||
import androidx.compose.ui.platform.LocalDensity
|
import androidx.compose.ui.platform.LocalDensity
|
||||||
import androidx.compose.ui.platform.testTag
|
import androidx.compose.ui.platform.testTag
|
||||||
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
@@ -49,27 +53,12 @@ import androidx.compose.ui.unit.sp
|
|||||||
import cc.skysparkle.fogwave.R
|
import cc.skysparkle.fogwave.R
|
||||||
import cc.skysparkle.fogwave.data.model.RadioStation
|
import cc.skysparkle.fogwave.data.model.RadioStation
|
||||||
import cc.skysparkle.fogwave.player.PlayerState
|
import cc.skysparkle.fogwave.player.PlayerState
|
||||||
import cc.skysparkle.fogwave.ui.theme.DarkGeoColors
|
|
||||||
import cc.skysparkle.fogwave.ui.theme.LocalGeoColors
|
import cc.skysparkle.fogwave.ui.theme.LocalGeoColors
|
||||||
import cc.skysparkle.fogwave.ui.theme.Typography
|
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
private val TABLET_BREAKPOINT_DP = 600.dp
|
private val TABLET_BREAKPOINT_DP = 600.dp
|
||||||
private val TABLET_MINI_PLAYER_MAX_WIDTH_DP = 640.dp
|
private val TABLET_MINI_PLAYER_MAX_WIDTH_DP = 640.dp
|
||||||
|
|
||||||
// Text styles are built once from the app's only palette, not copied on every recomposition.
|
|
||||||
private val MiniNameStyle = Typography.bodyMedium.copy(
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
fontSize = 14.5.sp,
|
|
||||||
color = DarkGeoColors.deepPurple
|
|
||||||
)
|
|
||||||
private val MiniStatusStyle = Typography.bodySmall.copy(
|
|
||||||
fontSize = 11.5.sp,
|
|
||||||
color = DarkGeoColors.onSurfaceVariant
|
|
||||||
)
|
|
||||||
private val MiniStatusLiveStyle = MiniStatusStyle.copy(color = DarkGeoColors.liveGreen)
|
|
||||||
private val MiniStatusErrorStyle = MiniStatusStyle.copy(color = DarkGeoColors.redFavorite)
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun MiniPlayer(
|
fun MiniPlayer(
|
||||||
station: RadioStation?,
|
station: RadioStation?,
|
||||||
@@ -173,7 +162,12 @@ fun MiniPlayer(
|
|||||||
.background(stationTileColor(station))
|
.background(stationTileColor(station))
|
||||||
.border(1.dp, LocalGeoColors.current.outlineVariant, RoundedCornerShape(14.dp))
|
.border(1.dp, LocalGeoColors.current.outlineVariant, RoundedCornerShape(14.dp))
|
||||||
) {
|
) {
|
||||||
StationArtwork(station, Modifier.matchParentSize())
|
Image(
|
||||||
|
painter = painterResource(id = station.iconResId),
|
||||||
|
contentDescription = null,
|
||||||
|
contentScale = ContentScale.Crop,
|
||||||
|
modifier = Modifier.matchParentSize()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
@@ -182,14 +176,21 @@ fun MiniPlayer(
|
|||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = station.name,
|
text = station.name,
|
||||||
style = MiniNameStyle,
|
style = MaterialTheme.typography.bodyMedium.copy(
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
fontSize = 14.5.sp,
|
||||||
|
color = LocalGeoColors.current.deepPurple
|
||||||
|
),
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = subText,
|
text = subText,
|
||||||
style = if (isError) MiniStatusErrorStyle else (if (isPlaying) MiniStatusLiveStyle else MiniStatusStyle),
|
style = MaterialTheme.typography.bodySmall.copy(
|
||||||
|
fontSize = 11.5.sp,
|
||||||
|
color = if (isError) LocalGeoColors.current.redFavorite else (if (isPlaying) LocalGeoColors.current.liveGreen else LocalGeoColors.current.onSurfaceVariant)
|
||||||
|
),
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import androidx.compose.animation.core.animate
|
|||||||
import androidx.compose.animation.core.animateFloatAsState
|
import androidx.compose.animation.core.animateFloatAsState
|
||||||
import androidx.compose.animation.core.spring
|
import androidx.compose.animation.core.spring
|
||||||
import androidx.compose.animation.core.tween
|
import androidx.compose.animation.core.tween
|
||||||
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.border
|
import androidx.compose.foundation.border
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
@@ -47,16 +48,18 @@ import androidx.compose.ui.Alignment
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.draw.drawBehind
|
import androidx.compose.ui.draw.drawBehind
|
||||||
|
import androidx.compose.ui.draw.scale
|
||||||
import androidx.compose.ui.draw.shadow
|
import androidx.compose.ui.draw.shadow
|
||||||
import androidx.compose.ui.geometry.Offset
|
import androidx.compose.ui.geometry.Offset
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.graphicsLayer
|
|
||||||
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
||||||
import androidx.compose.ui.input.nestedscroll.NestedScrollSource
|
import androidx.compose.ui.input.nestedscroll.NestedScrollSource
|
||||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
import androidx.compose.ui.input.pointer.pointerInput
|
import androidx.compose.ui.input.pointer.pointerInput
|
||||||
|
import androidx.compose.ui.layout.ContentScale
|
||||||
import androidx.compose.ui.platform.LocalDensity
|
import androidx.compose.ui.platform.LocalDensity
|
||||||
import androidx.compose.ui.platform.testTag
|
import androidx.compose.ui.platform.testTag
|
||||||
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.semantics.contentDescription
|
import androidx.compose.ui.semantics.contentDescription
|
||||||
import androidx.compose.ui.semantics.semantics
|
import androidx.compose.ui.semantics.semantics
|
||||||
@@ -70,61 +73,11 @@ import androidx.compose.ui.unit.sp
|
|||||||
import cc.skysparkle.fogwave.R
|
import cc.skysparkle.fogwave.R
|
||||||
import cc.skysparkle.fogwave.data.model.ExtraPlayerTab
|
import cc.skysparkle.fogwave.data.model.ExtraPlayerTab
|
||||||
import cc.skysparkle.fogwave.data.model.RadioStation
|
import cc.skysparkle.fogwave.data.model.RadioStation
|
||||||
|
import cc.skysparkle.fogwave.player.AudioEffectsState
|
||||||
import cc.skysparkle.fogwave.player.PlayerState
|
import cc.skysparkle.fogwave.player.PlayerState
|
||||||
import cc.skysparkle.fogwave.ui.theme.DarkGeoColors
|
|
||||||
import cc.skysparkle.fogwave.ui.theme.LocalGeoColors
|
import cc.skysparkle.fogwave.ui.theme.LocalGeoColors
|
||||||
import cc.skysparkle.fogwave.ui.theme.Typography
|
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
// Text styles are built once from the app's only palette, not copied on every recomposition.
|
|
||||||
private val SheetLabelStyle = Typography.labelSmall.copy(
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
fontSize = 11.5.sp,
|
|
||||||
letterSpacing = 1.2.sp,
|
|
||||||
color = DarkGeoColors.primary
|
|
||||||
)
|
|
||||||
private val SheetTitleStyle = Typography.headlineMedium.copy(
|
|
||||||
fontWeight = FontWeight.ExtraBold,
|
|
||||||
fontSize = 25.sp,
|
|
||||||
letterSpacing = (-0.5).sp,
|
|
||||||
color = DarkGeoColors.deepPurple,
|
|
||||||
textAlign = TextAlign.Center
|
|
||||||
)
|
|
||||||
private val SheetDescriptionStyle = Typography.bodyMedium.copy(
|
|
||||||
fontSize = 14.sp,
|
|
||||||
color = DarkGeoColors.onSurfaceVariant,
|
|
||||||
textAlign = TextAlign.Center
|
|
||||||
)
|
|
||||||
private val SheetStatusStyle = Typography.labelSmall.copy(
|
|
||||||
fontWeight = FontWeight.SemiBold,
|
|
||||||
fontSize = 12.sp,
|
|
||||||
color = DarkGeoColors.onSurfaceVariant
|
|
||||||
)
|
|
||||||
private val SheetStatusLiveStyle = SheetStatusStyle.copy(color = DarkGeoColors.deepPurple)
|
|
||||||
private val SheetStatusErrorStyle = SheetStatusStyle.copy(color = DarkGeoColors.redFavorite)
|
|
||||||
private val SheetEmptyListStyle = Typography.bodySmall.copy(
|
|
||||||
color = DarkGeoColors.onSurfaceVariant,
|
|
||||||
textAlign = TextAlign.Center
|
|
||||||
)
|
|
||||||
private val SheetRowNameStyle = Typography.bodyMedium.copy(
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
color = DarkGeoColors.onSurface
|
|
||||||
)
|
|
||||||
private val SheetRowNameAccentStyle = SheetRowNameStyle.copy(color = DarkGeoColors.deepPurple)
|
|
||||||
private val SheetRowDescriptionStyle = Typography.bodySmall.copy(
|
|
||||||
fontSize = 11.5.sp,
|
|
||||||
color = DarkGeoColors.onSurfaceVariant
|
|
||||||
)
|
|
||||||
private val InfoKeyStyle = Typography.bodySmall.copy(
|
|
||||||
fontWeight = FontWeight.SemiBold,
|
|
||||||
color = DarkGeoColors.onSurfaceVariant
|
|
||||||
)
|
|
||||||
private val InfoValueStyle = Typography.bodySmall.copy(
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
color = DarkGeoColors.deepPurple,
|
|
||||||
textAlign = TextAlign.End
|
|
||||||
)
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun NowPlayingSheet(
|
fun NowPlayingSheet(
|
||||||
station: RadioStation?,
|
station: RadioStation?,
|
||||||
@@ -136,7 +89,7 @@ fun NowPlayingSheet(
|
|||||||
onNext: () -> Unit,
|
onNext: () -> Unit,
|
||||||
onClose: () -> Unit,
|
onClose: () -> Unit,
|
||||||
onOpenEqualizer: () -> Unit,
|
onOpenEqualizer: () -> Unit,
|
||||||
equalizerEnabled: Boolean,
|
audioEffects: AudioEffectsState,
|
||||||
activeExtraTab: ExtraPlayerTab,
|
activeExtraTab: ExtraPlayerTab,
|
||||||
onSelectExtraTab: (ExtraPlayerTab) -> Unit,
|
onSelectExtraTab: (ExtraPlayerTab) -> Unit,
|
||||||
recents: List<RadioStation>,
|
recents: List<RadioStation>,
|
||||||
@@ -219,7 +172,12 @@ fun NowPlayingSheet(
|
|||||||
// The sheet closes by swiping down, tapping outside it or pressing Back.
|
// The sheet closes by swiping down, tapping outside it or pressing Back.
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.now_playing_label),
|
text = stringResource(R.string.now_playing_label),
|
||||||
style = SheetLabelStyle,
|
style = MaterialTheme.typography.labelSmall.copy(
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
fontSize = 11.5.sp,
|
||||||
|
letterSpacing = 1.2.sp,
|
||||||
|
color = LocalGeoColors.current.primary
|
||||||
|
),
|
||||||
modifier = Modifier.padding(horizontal = 24.dp, vertical = 12.dp)
|
modifier = Modifier.padding(horizontal = 24.dp, vertical = 12.dp)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -228,17 +186,18 @@ fun NowPlayingSheet(
|
|||||||
.padding(horizontal = 44.dp, vertical = 10.dp)
|
.padding(horizontal = 44.dp, vertical = 10.dp)
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.aspectRatio(1f)
|
.aspectRatio(1f)
|
||||||
// Scaled in the layer, so the spring does not recompose the sheet every frame.
|
.scale(artScale)
|
||||||
.graphicsLayer {
|
|
||||||
scaleX = artScale
|
|
||||||
scaleY = artScale
|
|
||||||
}
|
|
||||||
.shadow(8.dp, RoundedCornerShape(32.dp))
|
.shadow(8.dp, RoundedCornerShape(32.dp))
|
||||||
.clip(RoundedCornerShape(32.dp))
|
.clip(RoundedCornerShape(32.dp))
|
||||||
.background(stationTileColor(station))
|
.background(stationTileColor(station))
|
||||||
.border(1.5.dp, LocalGeoColors.current.outlineVariant, RoundedCornerShape(32.dp))
|
.border(1.5.dp, LocalGeoColors.current.outlineVariant, RoundedCornerShape(32.dp))
|
||||||
) {
|
) {
|
||||||
StationArtwork(station, Modifier.matchParentSize())
|
Image(
|
||||||
|
painter = painterResource(id = station.iconResId),
|
||||||
|
contentDescription = null,
|
||||||
|
contentScale = ContentScale.Crop,
|
||||||
|
modifier = Modifier.matchParentSize()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
@@ -249,7 +208,13 @@ fun NowPlayingSheet(
|
|||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = station.name,
|
text = station.name,
|
||||||
style = SheetTitleStyle,
|
style = MaterialTheme.typography.headlineMedium.copy(
|
||||||
|
fontWeight = FontWeight.ExtraBold,
|
||||||
|
fontSize = 25.sp,
|
||||||
|
letterSpacing = (-0.5).sp,
|
||||||
|
color = LocalGeoColors.current.deepPurple,
|
||||||
|
textAlign = TextAlign.Center
|
||||||
|
),
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
@@ -258,7 +223,11 @@ fun NowPlayingSheet(
|
|||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = stationDescription(station),
|
text = stationDescription(station),
|
||||||
style = SheetDescriptionStyle,
|
style = MaterialTheme.typography.bodyMedium.copy(
|
||||||
|
fontSize = 14.sp,
|
||||||
|
color = LocalGeoColors.current.onSurfaceVariant,
|
||||||
|
textAlign = TextAlign.Center
|
||||||
|
),
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
@@ -304,7 +273,11 @@ fun NowPlayingSheet(
|
|||||||
isPlaying -> stringResource(R.string.now_playing_live)
|
isPlaying -> stringResource(R.string.now_playing_live)
|
||||||
else -> stringResource(R.string.player_stopped)
|
else -> stringResource(R.string.player_stopped)
|
||||||
},
|
},
|
||||||
style = if (isPlaying) SheetStatusLiveStyle else (if (isError) SheetStatusErrorStyle else SheetStatusStyle)
|
style = MaterialTheme.typography.labelSmall.copy(
|
||||||
|
fontWeight = FontWeight.SemiBold,
|
||||||
|
fontSize = 12.sp,
|
||||||
|
color = if (isPlaying) LocalGeoColors.current.deepPurple else (if (isError) LocalGeoColors.current.redFavorite else LocalGeoColors.current.onSurfaceVariant)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -340,7 +313,7 @@ fun NowPlayingSheet(
|
|||||||
AppIcon(
|
AppIcon(
|
||||||
resId = R.drawable.ic_equalizer,
|
resId = R.drawable.ic_equalizer,
|
||||||
contentDescription = stringResource(R.string.equalizer_content_desc),
|
contentDescription = stringResource(R.string.equalizer_content_desc),
|
||||||
tint = if (equalizerEnabled) LocalGeoColors.current.deepPurple else LocalGeoColors.current.onSurfaceVariant.copy(alpha = 0.5f),
|
tint = if (audioEffects.equalizerEnabled) LocalGeoColors.current.deepPurple else LocalGeoColors.current.onSurfaceVariant.copy(alpha = 0.5f),
|
||||||
size = 20.dp
|
size = 20.dp
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -425,10 +398,7 @@ fun NowPlayingSheet(
|
|||||||
color = if (isFavorite) LocalGeoColors.current.redFavorite else LocalGeoColors.current.outlineVariant,
|
color = if (isFavorite) LocalGeoColors.current.redFavorite else LocalGeoColors.current.outlineVariant,
|
||||||
shape = CircleShape
|
shape = CircleShape
|
||||||
)
|
)
|
||||||
.graphicsLayer {
|
.scale(favScale)
|
||||||
scaleX = favScale
|
|
||||||
scaleY = favScale
|
|
||||||
}
|
|
||||||
.clickable { onToggleFavorite() }
|
.clickable { onToggleFavorite() }
|
||||||
.testTag("np_favorite_toggle"),
|
.testTag("np_favorite_toggle"),
|
||||||
contentAlignment = Alignment.Center
|
contentAlignment = Alignment.Center
|
||||||
@@ -461,12 +431,34 @@ fun NowPlayingSheet(
|
|||||||
horizontalArrangement = Arrangement.spacedBy(4.dp)
|
horizontalArrangement = Arrangement.spacedBy(4.dp)
|
||||||
) {
|
) {
|
||||||
ExtraPlayerTab.entries.forEach { tab ->
|
ExtraPlayerTab.entries.forEach { tab ->
|
||||||
ExtraTabChip(
|
val isSelected = tab == activeExtraTab
|
||||||
title = stringResource(tab.titleRes),
|
val bg by animateColorAsState(
|
||||||
isSelected = tab == activeExtraTab,
|
targetValue = if (isSelected) LocalGeoColors.current.primaryContainer else Color.Transparent,
|
||||||
onClick = { onSelectExtraTab(tab) },
|
label = "extra_tab_bg"
|
||||||
modifier = Modifier.weight(1f)
|
|
||||||
)
|
)
|
||||||
|
val textColor by animateColorAsState(
|
||||||
|
targetValue = if (isSelected) LocalGeoColors.current.deepPurple else LocalGeoColors.current.onSurfaceVariant,
|
||||||
|
label = "extra_tab_text"
|
||||||
|
)
|
||||||
|
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.weight(1f)
|
||||||
|
.clip(RoundedCornerShape(10.dp))
|
||||||
|
.background(bg)
|
||||||
|
.clickable { onSelectExtraTab(tab) }
|
||||||
|
.padding(vertical = 8.dp),
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = stringResource(tab.titleRes),
|
||||||
|
style = MaterialTheme.typography.labelSmall.copy(
|
||||||
|
fontWeight = if (isSelected) FontWeight.Bold else FontWeight.Medium,
|
||||||
|
fontSize = 12.sp,
|
||||||
|
color = textColor
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,7 +467,10 @@ fun NowPlayingSheet(
|
|||||||
if (recents.isEmpty()) {
|
if (recents.isEmpty()) {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.recent_empty),
|
text = stringResource(R.string.recent_empty),
|
||||||
style = SheetEmptyListStyle,
|
style = MaterialTheme.typography.bodySmall.copy(
|
||||||
|
color = LocalGeoColors.current.onSurfaceVariant,
|
||||||
|
textAlign = TextAlign.Center
|
||||||
|
),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(vertical = 16.dp)
|
.padding(vertical = 16.dp)
|
||||||
@@ -501,7 +496,12 @@ fun NowPlayingSheet(
|
|||||||
.clip(RoundedCornerShape(10.dp))
|
.clip(RoundedCornerShape(10.dp))
|
||||||
.background(stationTileColor(s))
|
.background(stationTileColor(s))
|
||||||
) {
|
) {
|
||||||
StationArtwork(s, Modifier.matchParentSize())
|
Image(
|
||||||
|
painter = painterResource(id = s.iconResId),
|
||||||
|
contentDescription = null,
|
||||||
|
contentScale = ContentScale.Crop,
|
||||||
|
modifier = Modifier.matchParentSize()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(modifier = Modifier.weight(1f)) {
|
Column(modifier = Modifier.weight(1f)) {
|
||||||
@@ -514,14 +514,20 @@ fun NowPlayingSheet(
|
|||||||
}
|
}
|
||||||
Text(
|
Text(
|
||||||
text = s.name,
|
text = s.name,
|
||||||
style = if (isCur) SheetRowNameAccentStyle else SheetRowNameStyle,
|
style = MaterialTheme.typography.bodyMedium.copy(
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
color = if (isCur) LocalGeoColors.current.deepPurple else LocalGeoColors.current.onSurface
|
||||||
|
),
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Text(
|
Text(
|
||||||
text = stationDescription(s),
|
text = stationDescription(s),
|
||||||
style = SheetRowDescriptionStyle,
|
style = MaterialTheme.typography.bodySmall.copy(
|
||||||
|
fontSize = 11.5.sp,
|
||||||
|
color = LocalGeoColors.current.onSurfaceVariant
|
||||||
|
),
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
@@ -543,7 +549,10 @@ fun NowPlayingSheet(
|
|||||||
if (similarStations.isEmpty()) {
|
if (similarStations.isEmpty()) {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.similar_empty),
|
text = stringResource(R.string.similar_empty),
|
||||||
style = SheetEmptyListStyle,
|
style = MaterialTheme.typography.bodySmall.copy(
|
||||||
|
color = LocalGeoColors.current.onSurfaceVariant,
|
||||||
|
textAlign = TextAlign.Center
|
||||||
|
),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(vertical = 16.dp)
|
.padding(vertical = 16.dp)
|
||||||
@@ -568,19 +577,30 @@ fun NowPlayingSheet(
|
|||||||
.clip(RoundedCornerShape(10.dp))
|
.clip(RoundedCornerShape(10.dp))
|
||||||
.background(stationTileColor(s))
|
.background(stationTileColor(s))
|
||||||
) {
|
) {
|
||||||
StationArtwork(s, Modifier.matchParentSize())
|
Image(
|
||||||
|
painter = painterResource(id = s.iconResId),
|
||||||
|
contentDescription = null,
|
||||||
|
contentScale = ContentScale.Crop,
|
||||||
|
modifier = Modifier.matchParentSize()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(modifier = Modifier.weight(1f)) {
|
Column(modifier = Modifier.weight(1f)) {
|
||||||
Text(
|
Text(
|
||||||
text = s.name,
|
text = s.name,
|
||||||
style = SheetRowNameAccentStyle,
|
style = MaterialTheme.typography.bodyMedium.copy(
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
color = LocalGeoColors.current.deepPurple
|
||||||
|
),
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = "${stationDescription(s)} • ${stationGenres(s)}",
|
text = "${stationDescription(s)} • ${stationGenres(s)}",
|
||||||
style = SheetRowDescriptionStyle,
|
style = MaterialTheme.typography.bodySmall.copy(
|
||||||
|
fontSize = 11.5.sp,
|
||||||
|
color = LocalGeoColors.current.onSurfaceVariant
|
||||||
|
),
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
@@ -630,42 +650,6 @@ fun NowPlayingSheet(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A composable of its own, so the color animation recomposes only this chip, not the whole sheet.
|
|
||||||
@Composable
|
|
||||||
private fun ExtraTabChip(
|
|
||||||
title: String,
|
|
||||||
isSelected: Boolean,
|
|
||||||
onClick: () -> Unit,
|
|
||||||
modifier: Modifier = Modifier
|
|
||||||
) {
|
|
||||||
val bg by animateColorAsState(
|
|
||||||
targetValue = if (isSelected) LocalGeoColors.current.primaryContainer else Color.Transparent,
|
|
||||||
label = "extra_tab_bg"
|
|
||||||
)
|
|
||||||
val textColor by animateColorAsState(
|
|
||||||
targetValue = if (isSelected) LocalGeoColors.current.deepPurple else LocalGeoColors.current.onSurfaceVariant,
|
|
||||||
label = "extra_tab_text"
|
|
||||||
)
|
|
||||||
|
|
||||||
Box(
|
|
||||||
modifier = modifier
|
|
||||||
.clip(RoundedCornerShape(10.dp))
|
|
||||||
.background(bg)
|
|
||||||
.clickable(onClick = onClick)
|
|
||||||
.padding(vertical = 8.dp),
|
|
||||||
contentAlignment = Alignment.Center
|
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
text = title,
|
|
||||||
style = MaterialTheme.typography.labelSmall.copy(
|
|
||||||
fontWeight = if (isSelected) FontWeight.Bold else FontWeight.Medium,
|
|
||||||
fontSize = 12.sp,
|
|
||||||
color = textColor
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun InfoRow(key: String, value: String) {
|
private fun InfoRow(key: String, value: String) {
|
||||||
Row(
|
Row(
|
||||||
@@ -675,12 +659,19 @@ private fun InfoRow(key: String, value: String) {
|
|||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = key,
|
text = key,
|
||||||
style = InfoKeyStyle
|
style = MaterialTheme.typography.bodySmall.copy(
|
||||||
|
fontWeight = FontWeight.SemiBold,
|
||||||
|
color = LocalGeoColors.current.onSurfaceVariant
|
||||||
|
)
|
||||||
)
|
)
|
||||||
// Long values (descriptions, genre lists) wrap on the right instead of pushing the key out.
|
// Long values (descriptions, genre lists) wrap on the right instead of pushing the key out.
|
||||||
Text(
|
Text(
|
||||||
text = value,
|
text = value,
|
||||||
style = InfoValueStyle,
|
style = MaterialTheme.typography.bodySmall.copy(
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
color = LocalGeoColors.current.deepPurple,
|
||||||
|
textAlign = TextAlign.End
|
||||||
|
),
|
||||||
modifier = Modifier.weight(1f)
|
modifier = Modifier.weight(1f)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import androidx.compose.foundation.layout.size
|
|||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
@@ -39,6 +40,7 @@ import androidx.compose.ui.draw.shadow
|
|||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.Shadow
|
import androidx.compose.ui.graphics.Shadow
|
||||||
import androidx.compose.ui.graphics.graphicsLayer
|
import androidx.compose.ui.graphics.graphicsLayer
|
||||||
|
import androidx.compose.ui.layout.ContentScale
|
||||||
import androidx.compose.ui.platform.testTag
|
import androidx.compose.ui.platform.testTag
|
||||||
import androidx.compose.ui.semantics.Role
|
import androidx.compose.ui.semantics.Role
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
@@ -49,9 +51,8 @@ import androidx.compose.ui.unit.sp
|
|||||||
import cc.skysparkle.fogwave.data.model.IconSizeStep
|
import cc.skysparkle.fogwave.data.model.IconSizeStep
|
||||||
import cc.skysparkle.fogwave.data.model.RadioStation
|
import cc.skysparkle.fogwave.data.model.RadioStation
|
||||||
import cc.skysparkle.fogwave.data.model.ViewMode
|
import cc.skysparkle.fogwave.data.model.ViewMode
|
||||||
import cc.skysparkle.fogwave.ui.theme.DarkGeoColors
|
|
||||||
import cc.skysparkle.fogwave.ui.theme.LocalGeoColors
|
import cc.skysparkle.fogwave.ui.theme.LocalGeoColors
|
||||||
import cc.skysparkle.fogwave.ui.theme.Typography
|
import coil.compose.AsyncImage
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun LiveOnAirDot(modifier: Modifier = Modifier) {
|
fun LiveOnAirDot(modifier: Modifier = Modifier) {
|
||||||
@@ -80,41 +81,6 @@ fun LiveOnAirDot(modifier: Modifier = Modifier) {
|
|||||||
|
|
||||||
private val GridTextShadow = Shadow(color = Color.Black.copy(alpha = 0.55f), blurRadius = 8f)
|
private val GridTextShadow = Shadow(color = Color.Black.copy(alpha = 0.55f), blurRadius = 8f)
|
||||||
|
|
||||||
// Text styles are built once from the app's only palette, not copied on every recomposition.
|
|
||||||
private val IconsNameStyle = Typography.titleSmall.copy(
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
fontSize = 14.5.sp,
|
|
||||||
lineHeight = 17.sp,
|
|
||||||
color = DarkGeoColors.onSurface,
|
|
||||||
shadow = GridTextShadow
|
|
||||||
)
|
|
||||||
private val IconsNameCurrentStyle = IconsNameStyle.copy(color = DarkGeoColors.deepPurple)
|
|
||||||
private val IconsDescriptionStyle = Typography.bodySmall.copy(
|
|
||||||
fontSize = 11.5.sp,
|
|
||||||
color = DarkGeoColors.onSurface.copy(alpha = 0.82f),
|
|
||||||
shadow = GridTextShadow
|
|
||||||
)
|
|
||||||
private val TilesNameStyle = Typography.titleSmall.copy(
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
fontSize = 15.sp,
|
|
||||||
color = DarkGeoColors.onSurface
|
|
||||||
)
|
|
||||||
private val TilesNameCurrentStyle = TilesNameStyle.copy(color = DarkGeoColors.deepPurple)
|
|
||||||
private val TilesDescriptionStyle = Typography.bodySmall.copy(
|
|
||||||
fontSize = 12.sp,
|
|
||||||
color = DarkGeoColors.onSurfaceVariant
|
|
||||||
)
|
|
||||||
private val RowNameStyle = Typography.bodyMedium.copy(
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
color = DarkGeoColors.onSurface
|
|
||||||
)
|
|
||||||
private val RowNameCurrentStyle = RowNameStyle.copy(color = DarkGeoColors.deepPurple)
|
|
||||||
private val RowDescriptionStyle = Typography.bodySmall.copy(
|
|
||||||
fontSize = 11.5.sp,
|
|
||||||
color = DarkGeoColors.onSurfaceVariant
|
|
||||||
)
|
|
||||||
private val RowGenresStyle = RowDescriptionStyle.copy(color = DarkGeoColors.primary)
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun StationItem(
|
fun StationItem(
|
||||||
station: RadioStation,
|
station: RadioStation,
|
||||||
@@ -222,7 +188,12 @@ private fun StationIconsCard(
|
|||||||
shape = RoundedCornerShape(22.dp)
|
shape = RoundedCornerShape(22.dp)
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
StationLogoImage(station, Modifier.matchParentSize())
|
AsyncImage(
|
||||||
|
model = station.iconResId,
|
||||||
|
contentDescription = null,
|
||||||
|
contentScale = ContentScale.Crop,
|
||||||
|
modifier = Modifier.matchParentSize()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
@@ -236,7 +207,13 @@ private fun StationIconsCard(
|
|||||||
}
|
}
|
||||||
Text(
|
Text(
|
||||||
text = station.name,
|
text = station.name,
|
||||||
style = if (isCurrent) IconsNameCurrentStyle else IconsNameStyle,
|
style = MaterialTheme.typography.titleSmall.copy(
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
fontSize = 14.5.sp,
|
||||||
|
lineHeight = 17.sp,
|
||||||
|
color = if (isCurrent) LocalGeoColors.current.deepPurple else LocalGeoColors.current.onSurface,
|
||||||
|
shadow = GridTextShadow
|
||||||
|
),
|
||||||
maxLines = 2,
|
maxLines = 2,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
@@ -244,7 +221,11 @@ private fun StationIconsCard(
|
|||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = stationDescription(station),
|
text = stationDescription(station),
|
||||||
style = IconsDescriptionStyle,
|
style = MaterialTheme.typography.bodySmall.copy(
|
||||||
|
fontSize = 11.5.sp,
|
||||||
|
color = LocalGeoColors.current.onSurface.copy(alpha = 0.82f),
|
||||||
|
shadow = GridTextShadow
|
||||||
|
),
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
@@ -289,7 +270,12 @@ private fun StationTilesCard(
|
|||||||
.background(stationTileColor(station))
|
.background(stationTileColor(station))
|
||||||
.border(0.8.dp, LocalGeoColors.current.outlineVariant, RoundedCornerShape(14.dp))
|
.border(0.8.dp, LocalGeoColors.current.outlineVariant, RoundedCornerShape(14.dp))
|
||||||
) {
|
) {
|
||||||
StationLogoImage(station, Modifier.matchParentSize())
|
AsyncImage(
|
||||||
|
model = station.iconResId,
|
||||||
|
contentDescription = null,
|
||||||
|
contentScale = ContentScale.Crop,
|
||||||
|
modifier = Modifier.matchParentSize()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(modifier = Modifier.weight(1f)) {
|
Column(modifier = Modifier.weight(1f)) {
|
||||||
@@ -302,14 +288,21 @@ private fun StationTilesCard(
|
|||||||
}
|
}
|
||||||
Text(
|
Text(
|
||||||
text = station.name,
|
text = station.name,
|
||||||
style = if (isCurrent) TilesNameCurrentStyle else TilesNameStyle,
|
style = MaterialTheme.typography.titleSmall.copy(
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
fontSize = 15.sp,
|
||||||
|
color = if (isCurrent) LocalGeoColors.current.deepPurple else LocalGeoColors.current.onSurface
|
||||||
|
),
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Text(
|
Text(
|
||||||
text = stationDescription(station),
|
text = stationDescription(station),
|
||||||
style = TilesDescriptionStyle,
|
style = MaterialTheme.typography.bodySmall.copy(
|
||||||
|
fontSize = 12.sp,
|
||||||
|
color = LocalGeoColors.current.onSurfaceVariant
|
||||||
|
),
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
@@ -350,7 +343,12 @@ private fun StationListRow(
|
|||||||
.background(stationTileColor(station))
|
.background(stationTileColor(station))
|
||||||
.border(0.8.dp, LocalGeoColors.current.outlineVariant, RoundedCornerShape(10.dp))
|
.border(0.8.dp, LocalGeoColors.current.outlineVariant, RoundedCornerShape(10.dp))
|
||||||
) {
|
) {
|
||||||
StationLogoImage(station, Modifier.matchParentSize())
|
AsyncImage(
|
||||||
|
model = station.iconResId,
|
||||||
|
contentDescription = null,
|
||||||
|
contentScale = ContentScale.Crop,
|
||||||
|
modifier = Modifier.matchParentSize()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(modifier = Modifier.weight(1f)) {
|
Column(modifier = Modifier.weight(1f)) {
|
||||||
@@ -363,7 +361,10 @@ private fun StationListRow(
|
|||||||
}
|
}
|
||||||
Text(
|
Text(
|
||||||
text = station.name,
|
text = station.name,
|
||||||
style = if (isCurrent) RowNameCurrentStyle else RowNameStyle,
|
style = MaterialTheme.typography.bodyMedium.copy(
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
color = if (isCurrent) LocalGeoColors.current.deepPurple else LocalGeoColors.current.onSurface
|
||||||
|
),
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
@@ -410,7 +411,12 @@ private fun StationDetailsRow(
|
|||||||
.background(stationTileColor(station))
|
.background(stationTileColor(station))
|
||||||
.border(0.8.dp, LocalGeoColors.current.outlineVariant, RoundedCornerShape(10.dp))
|
.border(0.8.dp, LocalGeoColors.current.outlineVariant, RoundedCornerShape(10.dp))
|
||||||
) {
|
) {
|
||||||
StationLogoImage(station, Modifier.matchParentSize())
|
AsyncImage(
|
||||||
|
model = station.iconResId,
|
||||||
|
contentDescription = null,
|
||||||
|
contentScale = ContentScale.Crop,
|
||||||
|
modifier = Modifier.matchParentSize()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(modifier = Modifier.weight(1.3f)) {
|
Column(modifier = Modifier.weight(1.3f)) {
|
||||||
@@ -423,14 +429,20 @@ private fun StationDetailsRow(
|
|||||||
}
|
}
|
||||||
Text(
|
Text(
|
||||||
text = station.name,
|
text = station.name,
|
||||||
style = if (isCurrent) RowNameCurrentStyle else RowNameStyle,
|
style = MaterialTheme.typography.bodyMedium.copy(
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
color = if (isCurrent) LocalGeoColors.current.deepPurple else LocalGeoColors.current.onSurface
|
||||||
|
),
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Text(
|
Text(
|
||||||
text = stationDescription(station),
|
text = stationDescription(station),
|
||||||
style = RowDescriptionStyle,
|
style = MaterialTheme.typography.bodySmall.copy(
|
||||||
|
fontSize = 11.5.sp,
|
||||||
|
color = LocalGeoColors.current.onSurfaceVariant
|
||||||
|
),
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
@@ -438,7 +450,10 @@ private fun StationDetailsRow(
|
|||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = stationGenres(station),
|
text = stationGenres(station),
|
||||||
style = RowGenresStyle,
|
style = MaterialTheme.typography.bodySmall.copy(
|
||||||
|
fontSize = 11.5.sp,
|
||||||
|
color = LocalGeoColors.current.primary
|
||||||
|
),
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis,
|
overflow = TextOverflow.Ellipsis,
|
||||||
modifier = Modifier.weight(0.9f)
|
modifier = Modifier.weight(0.9f)
|
||||||
|
|||||||
@@ -2,14 +2,9 @@ package cc.skysparkle.fogwave.ui.components
|
|||||||
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.ReadOnlyComposable
|
import androidx.compose.runtime.ReadOnlyComposable
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
import androidx.compose.ui.Modifier
|
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.layout.ContentScale
|
|
||||||
import androidx.compose.ui.platform.LocalContext
|
|
||||||
import cc.skysparkle.fogwave.data.model.RadioStation
|
import cc.skysparkle.fogwave.data.model.RadioStation
|
||||||
import cc.skysparkle.fogwave.ui.theme.LocalGeoColors
|
import cc.skysparkle.fogwave.ui.theme.LocalGeoColors
|
||||||
import coil.compose.AsyncImage
|
|
||||||
|
|
||||||
private val LightLogoBackdrop = Color(0xFFECE8F1)
|
private val LightLogoBackdrop = Color(0xFFECE8F1)
|
||||||
|
|
||||||
@@ -18,26 +13,3 @@ private val LightLogoBackdrop = Color(0xFFECE8F1)
|
|||||||
@ReadOnlyComposable
|
@ReadOnlyComposable
|
||||||
fun stationTileColor(station: RadioStation): Color =
|
fun stationTileColor(station: RadioStation): Color =
|
||||||
if (station.lightBackdrop) LightLogoBackdrop else LocalGeoColors.current.surfaceContainer
|
if (station.lightBackdrop) LightLogoBackdrop else LocalGeoColors.current.surfaceContainer
|
||||||
|
|
||||||
// Use the same explicit Android resource URI as the Media3 session metadata. This avoids
|
|
||||||
// relying on Coil's implicit Int model handling for drawable-nodpi assets, while still letting
|
|
||||||
// Coil decode at the actual target size (important for the mini player and full-size artwork).
|
|
||||||
@Composable
|
|
||||||
fun StationLogoImage(station: RadioStation, modifier: Modifier = Modifier) {
|
|
||||||
val context = LocalContext.current
|
|
||||||
val artworkUri = remember(context.packageName, station.iconResId) {
|
|
||||||
"android.resource://${context.packageName}/${station.iconResId}"
|
|
||||||
}
|
|
||||||
|
|
||||||
AsyncImage(
|
|
||||||
model = artworkUri,
|
|
||||||
contentDescription = null,
|
|
||||||
contentScale = ContentScale.Crop,
|
|
||||||
modifier = modifier
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun StationArtwork(station: RadioStation, modifier: Modifier = Modifier) {
|
|
||||||
StationLogoImage(station, modifier)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import androidx.activity.compose.BackHandler
|
|||||||
import androidx.compose.animation.AnimatedContent
|
import androidx.compose.animation.AnimatedContent
|
||||||
import androidx.compose.animation.AnimatedVisibility
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
import androidx.compose.animation.ExitTransition
|
import androidx.compose.animation.ExitTransition
|
||||||
|
import androidx.compose.animation.ExperimentalAnimationApi
|
||||||
import androidx.compose.animation.core.FastOutLinearInEasing
|
import androidx.compose.animation.core.FastOutLinearInEasing
|
||||||
import androidx.compose.animation.core.FastOutSlowInEasing
|
import androidx.compose.animation.core.FastOutSlowInEasing
|
||||||
import androidx.compose.animation.core.Spring
|
import androidx.compose.animation.core.Spring
|
||||||
@@ -29,7 +30,6 @@ import androidx.compose.foundation.layout.padding
|
|||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.derivedStateOf
|
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
@@ -37,7 +37,7 @@ import androidx.compose.runtime.setValue
|
|||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.layout.onSizeChanged
|
import androidx.compose.ui.layout.onGloballyPositioned
|
||||||
import androidx.compose.ui.platform.LocalDensity
|
import androidx.compose.ui.platform.LocalDensity
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
@@ -59,15 +59,13 @@ import cc.skysparkle.fogwave.ui.components.StationsToolbar
|
|||||||
import cc.skysparkle.fogwave.ui.components.TopBrandBar
|
import cc.skysparkle.fogwave.ui.components.TopBrandBar
|
||||||
import cc.skysparkle.fogwave.ui.viewmodel.RadioViewModel
|
import cc.skysparkle.fogwave.ui.viewmodel.RadioViewModel
|
||||||
|
|
||||||
|
@OptIn(ExperimentalAnimationApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun HomeScreen(
|
fun HomeScreen(
|
||||||
viewModel: RadioViewModel = viewModel()
|
viewModel: RadioViewModel = viewModel()
|
||||||
) {
|
) {
|
||||||
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
|
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
|
||||||
val isPlaying = uiState.playerState is PlayerState.Playing
|
val isPlaying = uiState.playerState is PlayerState.Playing
|
||||||
// Read only inside the sheets below, so moving an equalizer slider recomposes just those.
|
|
||||||
val audioEffects = viewModel.audioEffects.collectAsStateWithLifecycle()
|
|
||||||
val equalizerEnabled by remember { derivedStateOf { audioEffects.value.equalizerEnabled } }
|
|
||||||
|
|
||||||
val favoriteStations = remember(uiState.stations, uiState.favorites) {
|
val favoriteStations = remember(uiState.stations, uiState.favorites) {
|
||||||
uiState.stations.filter { it.id in uiState.favorites }
|
uiState.stations.filter { it.id in uiState.favorites }
|
||||||
@@ -196,8 +194,8 @@ fun HomeScreen(
|
|||||||
.align(Alignment.BottomCenter)
|
.align(Alignment.BottomCenter)
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
// Measured before the inset padding so list content clears the system bar too.
|
// Measured before the inset padding so list content clears the system bar too.
|
||||||
.onSizeChanged { size ->
|
.onGloballyPositioned { coordinates ->
|
||||||
val measured = with(density) { size.height.toDp() }
|
val measured = with(density) { coordinates.size.height.toDp() }
|
||||||
if (measured > 0.dp && measured != dockHeight) {
|
if (measured > 0.dp && measured != dockHeight) {
|
||||||
dockHeight = measured
|
dockHeight = measured
|
||||||
}
|
}
|
||||||
@@ -246,7 +244,7 @@ fun HomeScreen(
|
|||||||
onNext = { viewModel.nextStation() },
|
onNext = { viewModel.nextStation() },
|
||||||
onClose = { viewModel.closeNowPlaying() },
|
onClose = { viewModel.closeNowPlaying() },
|
||||||
onOpenEqualizer = { viewModel.toggleEqualizerPop() },
|
onOpenEqualizer = { viewModel.toggleEqualizerPop() },
|
||||||
equalizerEnabled = equalizerEnabled,
|
audioEffects = uiState.audioEffects,
|
||||||
activeExtraTab = uiState.activeExtraTab,
|
activeExtraTab = uiState.activeExtraTab,
|
||||||
onSelectExtraTab = { viewModel.setActiveExtraTab(it) },
|
onSelectExtraTab = { viewModel.setActiveExtraTab(it) },
|
||||||
recents = recentStations,
|
recents = recentStations,
|
||||||
@@ -273,7 +271,7 @@ fun HomeScreen(
|
|||||||
) { it / 3 }
|
) { it / 3 }
|
||||||
) {
|
) {
|
||||||
EqualizerSheet(
|
EqualizerSheet(
|
||||||
audioEffects = audioEffects.value,
|
audioEffects = uiState.audioEffects,
|
||||||
onClose = { viewModel.closeEqualizerPop() },
|
onClose = { viewModel.closeEqualizerPop() },
|
||||||
onSetEqualizerEnabled = { viewModel.setEqualizerEnabled(it) },
|
onSetEqualizerEnabled = { viewModel.setEqualizerEnabled(it) },
|
||||||
onSetEqualizerBand = { band, level -> viewModel.setEqualizerBand(band, level) },
|
onSetEqualizerBand = { band, level -> viewModel.setEqualizerBand(band, level) },
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package cc.skysparkle.fogwave.ui.theme
|
|||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.darkColorScheme
|
import androidx.compose.material3.darkColorScheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
|
|
||||||
private val DarkColorScheme = with(DarkGeoColors) {
|
private val DarkColorScheme = with(DarkGeoColors) {
|
||||||
darkColorScheme(
|
darkColorScheme(
|
||||||
@@ -24,8 +25,9 @@ private val DarkColorScheme = with(DarkGeoColors) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// LocalGeoColors needs no provider: the dark palette is its default and the only one.
|
|
||||||
@Composable
|
@Composable
|
||||||
fun FogwaveTheme(content: @Composable () -> Unit) {
|
fun FogwaveTheme(content: @Composable () -> Unit) {
|
||||||
|
CompositionLocalProvider(LocalGeoColors provides DarkGeoColors) {
|
||||||
MaterialTheme(colorScheme = DarkColorScheme, typography = Typography, content = content)
|
MaterialTheme(colorScheme = DarkColorScheme, typography = Typography, content = content)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ data class RadioUiState(
|
|||||||
val isEqualizerPopOpen: Boolean = false,
|
val isEqualizerPopOpen: Boolean = false,
|
||||||
val isViewPopOpen: Boolean = false,
|
val isViewPopOpen: Boolean = false,
|
||||||
val activeExtraTab: ExtraPlayerTab = ExtraPlayerTab.RECENT,
|
val activeExtraTab: ExtraPlayerTab = ExtraPlayerTab.RECENT,
|
||||||
|
val audioEffects: AudioEffectsState = AudioEffectsState(),
|
||||||
val isMiniPlayerHidden: Boolean = false,
|
val isMiniPlayerHidden: Boolean = false,
|
||||||
val unseenFavoritesCount: Int = 0
|
val unseenFavoritesCount: Int = 0
|
||||||
)
|
)
|
||||||
@@ -76,9 +77,6 @@ class RadioViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
_showBatteryOptimizationPrompt.value = false
|
_showBatteryOptimizationPrompt.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kept out of uiState: equalizer changes arrive on every slider move and only the sheets need them.
|
|
||||||
val audioEffects: StateFlow<AudioEffectsState> = AudioEffectsController.state
|
|
||||||
|
|
||||||
val uiState: StateFlow<RadioUiState> = combine(
|
val uiState: StateFlow<RadioUiState> = combine(
|
||||||
_currentStation,
|
_currentStation,
|
||||||
playerManager.playerState,
|
playerManager.playerState,
|
||||||
@@ -91,6 +89,7 @@ class RadioViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
_isEqualizerPopOpen,
|
_isEqualizerPopOpen,
|
||||||
_isViewPopOpen,
|
_isViewPopOpen,
|
||||||
_activeExtraTab,
|
_activeExtraTab,
|
||||||
|
AudioEffectsController.state,
|
||||||
_isMiniPlayerHidden,
|
_isMiniPlayerHidden,
|
||||||
repository.seenFavoritesFlow,
|
repository.seenFavoritesFlow,
|
||||||
_stations
|
_stations
|
||||||
@@ -108,11 +107,12 @@ class RadioViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
val eqPop = params[8] as Boolean
|
val eqPop = params[8] as Boolean
|
||||||
val viewPop = params[9] as Boolean
|
val viewPop = params[9] as Boolean
|
||||||
val extraTab = params[10] as ExtraPlayerTab
|
val extraTab = params[10] as ExtraPlayerTab
|
||||||
val miniHidden = params[11] as Boolean
|
val effects = params[11] as AudioEffectsState
|
||||||
|
val miniHidden = params[12] as Boolean
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
val seenFavs = params[12] as Set<String>
|
val seenFavs = params[13] as Set<String>
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
val orderedStations = params[13] as List<RadioStation>
|
val orderedStations = params[14] as List<RadioStation>
|
||||||
|
|
||||||
val byId = orderedStations.associateBy { it.id }
|
val byId = orderedStations.associateBy { it.id }
|
||||||
val recentsList = recentsIds.mapNotNull { byId[it] }
|
val recentsList = recentsIds.mapNotNull { byId[it] }
|
||||||
@@ -130,6 +130,7 @@ class RadioViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
isEqualizerPopOpen = eqPop,
|
isEqualizerPopOpen = eqPop,
|
||||||
isViewPopOpen = viewPop,
|
isViewPopOpen = viewPop,
|
||||||
activeExtraTab = extraTab,
|
activeExtraTab = extraTab,
|
||||||
|
audioEffects = effects,
|
||||||
isMiniPlayerHidden = miniHidden,
|
isMiniPlayerHidden = miniHidden,
|
||||||
unseenFavoritesCount = favs.count { it !in seenFavs }
|
unseenFavoritesCount = favs.count { it !in seenFavs }
|
||||||
)
|
)
|
||||||
@@ -142,6 +143,7 @@ class RadioViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
favorites = repository.favoritesFlow.value,
|
favorites = repository.favoritesFlow.value,
|
||||||
viewMode = repository.viewModeFlow.value,
|
viewMode = repository.viewModeFlow.value,
|
||||||
sizeStep = repository.sizeStepFlow.value,
|
sizeStep = repository.sizeStepFlow.value,
|
||||||
|
audioEffects = AudioEffectsController.state.value,
|
||||||
unseenFavoritesCount = repository.favoritesFlow.value.count { it !in repository.seenFavoritesFlow.value }
|
unseenFavoritesCount = repository.favoritesFlow.value.count { it !in repository.seenFavoritesFlow.value }
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -217,11 +219,12 @@ class RadioViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
selectStation(list[prevIndex])
|
selectStation(list[prevIndex])
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toggleFavorite() {
|
fun toggleFavorite(stationId: String? = _currentStation.value?.id) {
|
||||||
val stationId = _currentStation.value?.id ?: return
|
if (stationId != null) {
|
||||||
repository.toggleFavorite(stationId)
|
repository.toggleFavorite(stationId)
|
||||||
if (_selectedTab.value == AppTab.FAVORITES) {
|
if (_selectedTab.value == AppTab.FAVORITES) {
|
||||||
repository.markFavoritesSeen()
|
repository.markFavoritesSeen(repository.favoritesFlow.value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,6 +263,10 @@ class RadioViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
AudioEffectsController.setLoudnessEnabled(enabled)
|
AudioEffectsController.setLoudnessEnabled(enabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setLoudnessGain(gainMillibel: Float) {
|
||||||
|
AudioEffectsController.setLoudnessGain(gainMillibel)
|
||||||
|
}
|
||||||
|
|
||||||
fun setDynamicsProcessingEnabled(enabled: Boolean) {
|
fun setDynamicsProcessingEnabled(enabled: Boolean) {
|
||||||
AudioEffectsController.setDynamicsProcessingEnabled(enabled)
|
AudioEffectsController.setDynamicsProcessingEnabled(enabled)
|
||||||
}
|
}
|
||||||
@@ -268,7 +275,7 @@ class RadioViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
_selectedTab.value = tab
|
_selectedTab.value = tab
|
||||||
_isViewPopOpen.value = false
|
_isViewPopOpen.value = false
|
||||||
if (tab == AppTab.FAVORITES) {
|
if (tab == AppTab.FAVORITES) {
|
||||||
repository.markFavoritesSeen()
|
repository.markFavoritesSeen(repository.favoritesFlow.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1 @@
|
|||||||
• Schnellerer Start: Einstellungen und Senderlogos werden im Hintergrund geladen
|
• Oberflächensymbole jetzt im WebP-Format: kleinere App, gleiches Aussehen
|
||||||
• Flüssigerer Player und Equalizer: Animationen und Regler zeichnen nicht mehr den ganzen Bildschirm neu
|
|
||||||
• Android Auto zeigt die Senderliste schneller an
|
|
||||||
• Kleinere App: nur die sechs App-Sprachen und nur die Audioteile des Players
|
|
||||||
|
|||||||
@@ -1,4 +1 @@
|
|||||||
• Faster start: settings and station logos load in the background
|
• Interface icons are now WebP: the app is smaller and looks the same
|
||||||
• Smoother player sheet and equalizer: animations and sliders no longer redraw the whole screen
|
|
||||||
• Android Auto shows the station list faster
|
|
||||||
• Smaller app: only the six app languages and the audio parts of the player are included
|
|
||||||
|
|||||||
@@ -1,4 +1 @@
|
|||||||
• 起動を高速化:設定と放送局のロゴをバックグラウンドで読み込み
|
• UIアイコンをWebP形式に変更:アプリが軽くなり、見た目は同じです
|
||||||
• プレーヤーとイコライザーをより滑らかに:アニメーションやスライダーで画面全体を再描画しません
|
|
||||||
• Android Auto で放送局リストがより速く表示されます
|
|
||||||
• アプリを軽量化:アプリの6言語とプレーヤーの音声部分のみを収録
|
|
||||||
|
|||||||
@@ -1,4 +1 @@
|
|||||||
• Greitesnis paleidimas: nustatymai ir stočių logotipai įkeliami fone
|
• Sąsajos piktogramos dabar WebP formatu: programa mažesnė, išvaizda ta pati
|
||||||
• Sklandesnis grotuvas ir ekvalaizeris: animacijos ir slankikliai nebeperpiešia viso ekrano
|
|
||||||
• Android Auto greičiau parodo stočių sąrašą
|
|
||||||
• Mažesnė programa: tik šešios programos kalbos ir tik garso grotuvo dalys
|
|
||||||
|
|||||||
@@ -1,4 +1 @@
|
|||||||
• Более быстрый запуск: настройки и логотипы станций загружаются в фоне
|
• Значки интерфейса теперь в формате WebP: приложение меньше, выглядит так же
|
||||||
• Плавнее плеер и эквалайзер: анимации и ползунки больше не перерисовывают весь экран
|
|
||||||
• Android Auto быстрее показывает список станций
|
|
||||||
• Приложение стало меньше: только шесть языков приложения и только аудиочасть плеера
|
|
||||||
|
|||||||
@@ -1,4 +1 @@
|
|||||||
• 启动更快:设置和电台标志在后台加载
|
• 界面图标改为 WebP 格式:应用更小,外观不变
|
||||||
• 播放器和均衡器更流畅:动画和滑块不再重绘整个屏幕
|
|
||||||
• Android Auto 更快显示电台列表
|
|
||||||
• 应用更小:只包含应用的六种语言和播放器的音频部分
|
|
||||||
|
|||||||
@@ -3,12 +3,14 @@ agp = "9.2.0"
|
|||||||
coreKtx = "1.18.0"
|
coreKtx = "1.18.0"
|
||||||
junit = "4.13.2"
|
junit = "4.13.2"
|
||||||
junitVersion = "1.3.0"
|
junitVersion = "1.3.0"
|
||||||
|
espressoCore = "3.7.0"
|
||||||
lifecycleViewmodelCompose = "2.11.0"
|
lifecycleViewmodelCompose = "2.11.0"
|
||||||
lifecycleRuntimeCompose = "2.11.0"
|
lifecycleRuntimeCompose = "2.11.0"
|
||||||
activityCompose = "1.13.0"
|
activityCompose = "1.13.0"
|
||||||
kotlin = "2.4.20"
|
kotlin = "2.4.20"
|
||||||
composeBom = "2026.09.00"
|
composeBom = "2026.09.00"
|
||||||
core = "1.6.1"
|
core = "1.6.1"
|
||||||
|
runner = "1.6.2"
|
||||||
coilCompose = "2.7.0"
|
coilCompose = "2.7.0"
|
||||||
kotlinxCoroutinesAndroid = "1.11.0"
|
kotlinxCoroutinesAndroid = "1.11.0"
|
||||||
kotlinxCoroutinesCore = "1.11.0"
|
kotlinxCoroutinesCore = "1.11.0"
|
||||||
@@ -20,15 +22,18 @@ media3 = "1.11.0"
|
|||||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||||
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
|
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
|
||||||
|
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
|
||||||
androidx-lifecycle-viewmodel-compose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version.ref = "lifecycleViewmodelCompose" }
|
androidx-lifecycle-viewmodel-compose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version.ref = "lifecycleViewmodelCompose" }
|
||||||
androidx-lifecycle-runtime-compose = { group = "androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "lifecycleRuntimeCompose" }
|
androidx-lifecycle-runtime-compose = { group = "androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "lifecycleRuntimeCompose" }
|
||||||
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
|
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
|
||||||
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
|
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
|
||||||
androidx-compose-ui = { group = "androidx.compose.ui", name = "ui" }
|
androidx-compose-ui = { group = "androidx.compose.ui", name = "ui" }
|
||||||
androidx-compose-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
|
androidx-compose-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
|
||||||
|
androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
|
||||||
androidx-compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
|
androidx-compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
|
||||||
androidx-compose-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
|
androidx-compose-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
|
||||||
androidx-core = { group = "androidx.test", name = "core", version.ref = "core" }
|
androidx-core = { group = "androidx.test", name = "core", version.ref = "core" }
|
||||||
|
androidx-runner = { group = "androidx.test", name = "runner", version.ref = "runner" }
|
||||||
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" }
|
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" }
|
||||||
coil-compose = { group = "io.coil-kt", name = "coil-compose", version.ref = "coilCompose" }
|
coil-compose = { group = "io.coil-kt", name = "coil-compose", version.ref = "coilCompose" }
|
||||||
androidx-media3-exoplayer = { group = "androidx.media3", name = "media3-exoplayer", version.ref = "media3" }
|
androidx-media3-exoplayer = { group = "androidx.media3", name = "media3-exoplayer", version.ref = "media3" }
|
||||||
|
|||||||
Reference in New Issue
Block a user