Release 1.0.12
- Load preferences and all station logos off the main thread - Keep equalizer updates and player animations from recomposing whole screens - Build the Android Auto browse tree once and serve it from memory - Create only the audio and metadata renderers, ship only the app's languages - Store interface icons as lossless WebP, drop unused code and dependencies
@@ -13,10 +13,8 @@ android {
|
|||||||
applicationId = "cc.skysparkle.fogwave"
|
applicationId = "cc.skysparkle.fogwave"
|
||||||
minSdk = 24
|
minSdk = 24
|
||||||
targetSdk = 36
|
targetSdk = 36
|
||||||
versionCode = 11
|
versionCode = 12
|
||||||
versionName = "1.0.11"
|
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.
|
||||||
@@ -57,6 +55,22 @@ 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
|
||||||
@@ -97,11 +111,5 @@ 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)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
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,7 +17,6 @@
|
|||||||
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,11 +1,22 @@
|
|||||||
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 {
|
||||||
@@ -14,7 +25,6 @@ class FogwaveApp : Application(), ImageLoaderFactory {
|
|||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
.crossfade(true)
|
.crossfade(true)
|
||||||
.respectCacheHeaders(false)
|
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ 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
|
||||||
@@ -13,107 +11,11 @@ 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("fogwave_prefs", Context.MODE_PRIVATE)
|
private val prefs = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)
|
||||||
|
|
||||||
val stations: List<RadioStation> = listOf(
|
val stations: List<RadioStation> = RadioStations
|
||||||
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> = stations.mapTo(HashSet()) { it.id }
|
private val stationIds: Set<String> = RadioStations.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()
|
||||||
@@ -135,10 +37,10 @@ class RadioRepository(context: Context) {
|
|||||||
return loadFavorites()
|
return loadFavorites()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun markFavoritesSeen(ids: Set<String>) {
|
fun markFavoritesSeen() {
|
||||||
val copy = ids.toSet()
|
val copy = _favoritesFlow.value.toSet()
|
||||||
_seenFavoritesFlow.value = copy
|
_seenFavoritesFlow.value = copy
|
||||||
prefs.edit { putStringSet("seen_favorites", copy); remove("last_seen_favorites_count") }
|
prefs.edit { putStringSet("seen_favorites", copy) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getLastStationId(): String? {
|
fun getLastStationId(): String? {
|
||||||
@@ -184,18 +86,11 @@ 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): Boolean {
|
fun toggleFavorite(stationId: String) {
|
||||||
val current = _favoritesFlow.value.toMutableSet()
|
val current = _favoritesFlow.value.toMutableSet()
|
||||||
val isNowFav = if (current.contains(stationId)) {
|
if (!current.remove(stationId)) current.add(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> {
|
||||||
@@ -260,4 +155,8 @@ 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"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,104 @@
|
|||||||
|
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,11 +42,6 @@ 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,22 +18,19 @@ 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("fogwave_audio_effects", Context.MODE_PRIVATE)
|
context.applicationContext.getSharedPreferences(PREFS_NAME, 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)
|
||||||
@@ -44,12 +41,21 @@ 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) {
|
||||||
@@ -68,7 +74,6 @@ 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) {
|
||||||
@@ -141,32 +146,24 @@ 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) {
|
||||||
(0 until eq.numberOfBands).map { i ->
|
bandCenterFreqsHz.indices.map { i ->
|
||||||
val idx = i.toShort()
|
|
||||||
val range = eq.bandLevelRange
|
|
||||||
EqualizerBand(
|
EqualizerBand(
|
||||||
index = i,
|
index = i,
|
||||||
centerFreqHz = eq.getCenterFreq(idx) / 1000,
|
centerFreqHz = bandCenterFreqsHz[i],
|
||||||
levelMillibel = eq.getBandLevel(idx).toInt(),
|
levelMillibel = eq.getBandLevel(i.toShort()).toInt(),
|
||||||
minLevelMillibel = range[0].toInt(),
|
minLevelMillibel = minBandLevel,
|
||||||
maxLevelMillibel = range[1].toInt()
|
maxLevelMillibel = maxBandLevel
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} 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
|
||||||
)
|
)
|
||||||
@@ -211,14 +208,6 @@ 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
|
||||||
@@ -235,13 +224,13 @@ class AudioEffectsEngine(context: Context, audioSessionId: Int) {
|
|||||||
dynamicsProcessing = null
|
dynamicsProcessing = null
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object {
|
companion object {
|
||||||
const val TAG = "AudioEffectsEngine"
|
const val PREFS_NAME = "fogwave_audio_effects"
|
||||||
const val KEY_EQ_ENABLED = "eq_enabled"
|
private const val TAG = "AudioEffectsEngine"
|
||||||
const val KEY_PRESET = "eq_preset"
|
private const val KEY_EQ_ENABLED = "eq_enabled"
|
||||||
const val KEY_BAND_PREFIX = "eq_band_"
|
private const val KEY_PRESET = "eq_preset"
|
||||||
const val KEY_LOUDNESS_ENABLED = "loudness_enabled"
|
private const val KEY_BAND_PREFIX = "eq_band_"
|
||||||
const val KEY_LOUDNESS_GAIN = "loudness_gain"
|
private const val KEY_LOUDNESS_ENABLED = "loudness_enabled"
|
||||||
const val KEY_DYNAMICS_ENABLED = "dynamics_enabled"
|
private const val KEY_DYNAMICS_ENABLED = "dynamics_enabled"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ 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
|
||||||
@@ -19,6 +20,13 @@ 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
|
||||||
@@ -28,7 +36,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.RadioRepository
|
import cc.skysparkle.fogwave.data.repository.RadioStations
|
||||||
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
|
||||||
@@ -43,7 +51,6 @@ 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
|
||||||
|
|
||||||
@@ -75,23 +82,61 @@ 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
|
||||||
|
// the video, text and image renderers. The audio renderer is configured like the default one,
|
||||||
|
// and two metadata renderers keep ICY titles working next to an in-stream ID3 track.
|
||||||
|
private fun audioOnlyRenderersFactory() = RenderersFactory { handler, _, audioListener, _, metadataOutput ->
|
||||||
|
arrayOf<Renderer>(
|
||||||
|
MediaCodecAudioRenderer(
|
||||||
|
this@FogwavePlaybackService,
|
||||||
|
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)
|
||||||
|
.setMediaMetadata(
|
||||||
|
MediaMetadata.Builder()
|
||||||
|
.setTitle(getString(R.string.app_name))
|
||||||
|
.setIsBrowsable(true)
|
||||||
|
.setIsPlayable(false)
|
||||||
|
.setMediaType(MediaMetadata.MEDIA_TYPE_FOLDER_MIXED)
|
||||||
|
.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 {
|
private val librarySessionCallback = object : MediaLibrarySession.Callback {
|
||||||
override fun onGetLibraryRoot(
|
override fun onGetLibraryRoot(
|
||||||
session: MediaLibrarySession,
|
session: MediaLibrarySession,
|
||||||
browser: MediaSession.ControllerInfo,
|
browser: MediaSession.ControllerInfo,
|
||||||
params: LibraryParams?
|
params: LibraryParams?
|
||||||
): ListenableFuture<LibraryResult<MediaItem>> {
|
): ListenableFuture<LibraryResult<MediaItem>> {
|
||||||
val rootItem = MediaItem.Builder()
|
ensureBrowseTree()
|
||||||
.setMediaId(ROOT_ID)
|
|
||||||
.setMediaMetadata(
|
|
||||||
MediaMetadata.Builder()
|
|
||||||
.setTitle(getString(R.string.app_name))
|
|
||||||
.setIsBrowsable(true)
|
|
||||||
.setIsPlayable(false)
|
|
||||||
.setMediaType(MediaMetadata.MEDIA_TYPE_FOLDER_MIXED)
|
|
||||||
.build()
|
|
||||||
)
|
|
||||||
.build()
|
|
||||||
return Futures.immediateFuture(LibraryResult.ofItem(rootItem, params))
|
return Futures.immediateFuture(LibraryResult.ofItem(rootItem, params))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,8 +151,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))
|
||||||
}
|
}
|
||||||
val items = repository.stations.map { it.toMediaItem(this@FogwavePlaybackService) }
|
ensureBrowseTree()
|
||||||
return Futures.immediateFuture(LibraryResult.ofItemList(ImmutableList.copyOf(items), params))
|
return Futures.immediateFuture(LibraryResult.ofItemList(stationItems, params))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onGetItem(
|
override fun onGetItem(
|
||||||
@@ -115,9 +160,9 @@ class FogwavePlaybackService : MediaLibraryService() {
|
|||||||
browser: MediaSession.ControllerInfo,
|
browser: MediaSession.ControllerInfo,
|
||||||
mediaId: String
|
mediaId: String
|
||||||
): ListenableFuture<LibraryResult<MediaItem>> {
|
): ListenableFuture<LibraryResult<MediaItem>> {
|
||||||
val station = repository.stations.find { it.id == mediaId }
|
val item = stationItem(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(station.toMediaItem(this@FogwavePlaybackService), null))
|
return Futures.immediateFuture(LibraryResult.ofItem(item, null))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAddMediaItems(
|
override fun onAddMediaItems(
|
||||||
@@ -126,13 +171,7 @@ 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) {
|
if (item.localConfiguration != null) item else stationItem(item.mediaId) ?: item
|
||||||
item
|
|
||||||
} else {
|
|
||||||
repository.stations.find { it.id == item.mediaId }
|
|
||||||
?.toMediaItem(this@FogwavePlaybackService)
|
|
||||||
?: item
|
|
||||||
}
|
|
||||||
}.toMutableList()
|
}.toMutableList()
|
||||||
|
|
||||||
resolved.firstOrNull()?.let { item ->
|
resolved.firstOrNull()?.let { item ->
|
||||||
@@ -270,14 +309,15 @@ 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(this)
|
player = ExoPlayer.Builder(
|
||||||
.setMediaSourceFactory(DefaultMediaSourceFactory(this).setDataSourceFactory(httpDataSourceFactory))
|
this,
|
||||||
|
audioOnlyRenderersFactory(),
|
||||||
|
DefaultMediaSourceFactory(this).setDataSourceFactory(httpDataSourceFactory)
|
||||||
|
)
|
||||||
.setLoadControl(loadControl)
|
.setLoadControl(loadControl)
|
||||||
.build()
|
.build()
|
||||||
.apply {
|
.apply {
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ class RadioPlayerManager(private val context: Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun play() {
|
private 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) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun pause() {
|
private fun pause() {
|
||||||
controller?.pause()
|
controller?.pause()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ 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
|
||||||
@@ -32,6 +31,7 @@ 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,10 +47,55 @@ 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,
|
||||||
@@ -91,18 +136,12 @@ fun EqualizerSheet(
|
|||||||
}
|
}
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.equalizer_title),
|
text = stringResource(R.string.equalizer_title),
|
||||||
style = MaterialTheme.typography.titleLarge.copy(
|
style = EqTitleStyle,
|
||||||
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 = MaterialTheme.typography.labelMedium.copy(
|
style = if (audioEffects.equalizerEnabled) EqStateOnStyle else EqStateStyle,
|
||||||
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(
|
||||||
@@ -136,10 +175,7 @@ fun EqualizerSheet(
|
|||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.equalizer_sound_section),
|
text = stringResource(R.string.equalizer_sound_section),
|
||||||
style = MaterialTheme.typography.labelMedium.copy(
|
style = EqSectionStyle
|
||||||
color = LocalGeoColors.current.onSurfaceVariant,
|
|
||||||
fontWeight = FontWeight.Medium
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@@ -170,54 +206,11 @@ fun EqualizerSheet(
|
|||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
audioEffects.bands.forEach { band ->
|
audioEffects.bands.forEach { band ->
|
||||||
Column(
|
EqualizerBandColumn(
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
band = band,
|
||||||
verticalArrangement = Arrangement.spacedBy(6.dp),
|
enabled = audioEffects.equalizerEnabled,
|
||||||
modifier = Modifier.fillMaxHeight()
|
onSetEqualizerBand = onSetEqualizerBand
|
||||||
) {
|
)
|
||||||
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
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -234,7 +227,7 @@ fun EqualizerSheet(
|
|||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.equalizer_unavailable),
|
text = stringResource(R.string.equalizer_unavailable),
|
||||||
style = MaterialTheme.typography.bodyMedium.copy(color = LocalGeoColors.current.onSurfaceVariant)
|
style = EqUnavailableStyle
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -256,25 +249,22 @@ fun EqualizerSheet(
|
|||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = currentPresetName,
|
text = currentPresetName,
|
||||||
style = MaterialTheme.typography.titleMedium.copy(
|
style = EqPresetNameStyle
|
||||||
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(audioEffects.presets) { index, name ->
|
itemsIndexed(presets) { index, name ->
|
||||||
val selected = audioEffects.currentPreset == index
|
val selected = currentPreset == index
|
||||||
Text(
|
Text(
|
||||||
text = presetLabel(name),
|
text = presetLabel(name),
|
||||||
style = MaterialTheme.typography.labelLarge.copy(
|
style = if (selected) EqPresetChipSelectedStyle else EqPresetChipStyle,
|
||||||
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)
|
||||||
@@ -324,6 +314,57 @@ 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,
|
||||||
@@ -342,10 +383,7 @@ private fun ToggleRow(
|
|||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = label,
|
text = label,
|
||||||
style = MaterialTheme.typography.bodyMedium.copy(
|
style = EqToggleLabelStyle,
|
||||||
fontWeight = FontWeight.Medium,
|
|
||||||
color = LocalGeoColors.current.onSurface
|
|
||||||
),
|
|
||||||
modifier = Modifier.weight(1f)
|
modifier = Modifier.weight(1f)
|
||||||
)
|
)
|
||||||
Switch(
|
Switch(
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ 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
|
||||||
@@ -27,7 +26,6 @@ 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
|
||||||
@@ -40,10 +38,8 @@ 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
|
||||||
@@ -53,12 +49,27 @@ 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?,
|
||||||
@@ -162,12 +173,7 @@ 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))
|
||||||
) {
|
) {
|
||||||
Image(
|
StationArtwork(station, Modifier.matchParentSize())
|
||||||
painter = painterResource(id = station.iconResId),
|
|
||||||
contentDescription = null,
|
|
||||||
contentScale = ContentScale.Crop,
|
|
||||||
modifier = Modifier.matchParentSize()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
@@ -176,21 +182,14 @@ fun MiniPlayer(
|
|||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = station.name,
|
text = station.name,
|
||||||
style = MaterialTheme.typography.bodyMedium.copy(
|
style = MiniNameStyle,
|
||||||
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 = MaterialTheme.typography.bodySmall.copy(
|
style = if (isError) MiniStatusErrorStyle else (if (isPlaying) MiniStatusLiveStyle else MiniStatusStyle),
|
||||||
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,7 +7,6 @@ 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
|
||||||
@@ -48,18 +47,16 @@ 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
|
||||||
@@ -73,11 +70,61 @@ 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?,
|
||||||
@@ -89,7 +136,7 @@ fun NowPlayingSheet(
|
|||||||
onNext: () -> Unit,
|
onNext: () -> Unit,
|
||||||
onClose: () -> Unit,
|
onClose: () -> Unit,
|
||||||
onOpenEqualizer: () -> Unit,
|
onOpenEqualizer: () -> Unit,
|
||||||
audioEffects: AudioEffectsState,
|
equalizerEnabled: Boolean,
|
||||||
activeExtraTab: ExtraPlayerTab,
|
activeExtraTab: ExtraPlayerTab,
|
||||||
onSelectExtraTab: (ExtraPlayerTab) -> Unit,
|
onSelectExtraTab: (ExtraPlayerTab) -> Unit,
|
||||||
recents: List<RadioStation>,
|
recents: List<RadioStation>,
|
||||||
@@ -172,12 +219,7 @@ 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 = MaterialTheme.typography.labelSmall.copy(
|
style = SheetLabelStyle,
|
||||||
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)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -186,18 +228,17 @@ fun NowPlayingSheet(
|
|||||||
.padding(horizontal = 44.dp, vertical = 10.dp)
|
.padding(horizontal = 44.dp, vertical = 10.dp)
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.aspectRatio(1f)
|
.aspectRatio(1f)
|
||||||
.scale(artScale)
|
// Scaled in the layer, so the spring does not recompose the sheet every frame.
|
||||||
|
.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))
|
||||||
) {
|
) {
|
||||||
Image(
|
StationArtwork(station, Modifier.matchParentSize())
|
||||||
painter = painterResource(id = station.iconResId),
|
|
||||||
contentDescription = null,
|
|
||||||
contentScale = ContentScale.Crop,
|
|
||||||
modifier = Modifier.matchParentSize()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
@@ -208,13 +249,7 @@ fun NowPlayingSheet(
|
|||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = station.name,
|
text = station.name,
|
||||||
style = MaterialTheme.typography.headlineMedium.copy(
|
style = SheetTitleStyle,
|
||||||
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
|
||||||
)
|
)
|
||||||
@@ -223,11 +258,7 @@ fun NowPlayingSheet(
|
|||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = stationDescription(station),
|
text = stationDescription(station),
|
||||||
style = MaterialTheme.typography.bodyMedium.copy(
|
style = SheetDescriptionStyle,
|
||||||
fontSize = 14.sp,
|
|
||||||
color = LocalGeoColors.current.onSurfaceVariant,
|
|
||||||
textAlign = TextAlign.Center
|
|
||||||
),
|
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
@@ -273,11 +304,7 @@ 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 = MaterialTheme.typography.labelSmall.copy(
|
style = if (isPlaying) SheetStatusLiveStyle else (if (isError) SheetStatusErrorStyle else SheetStatusStyle)
|
||||||
fontWeight = FontWeight.SemiBold,
|
|
||||||
fontSize = 12.sp,
|
|
||||||
color = if (isPlaying) LocalGeoColors.current.deepPurple else (if (isError) LocalGeoColors.current.redFavorite else LocalGeoColors.current.onSurfaceVariant)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -313,7 +340,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 (audioEffects.equalizerEnabled) LocalGeoColors.current.deepPurple else LocalGeoColors.current.onSurfaceVariant.copy(alpha = 0.5f),
|
tint = if (equalizerEnabled) LocalGeoColors.current.deepPurple else LocalGeoColors.current.onSurfaceVariant.copy(alpha = 0.5f),
|
||||||
size = 20.dp
|
size = 20.dp
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -398,7 +425,10 @@ 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
|
||||||
)
|
)
|
||||||
.scale(favScale)
|
.graphicsLayer {
|
||||||
|
scaleX = favScale
|
||||||
|
scaleY = favScale
|
||||||
|
}
|
||||||
.clickable { onToggleFavorite() }
|
.clickable { onToggleFavorite() }
|
||||||
.testTag("np_favorite_toggle"),
|
.testTag("np_favorite_toggle"),
|
||||||
contentAlignment = Alignment.Center
|
contentAlignment = Alignment.Center
|
||||||
@@ -431,34 +461,12 @@ fun NowPlayingSheet(
|
|||||||
horizontalArrangement = Arrangement.spacedBy(4.dp)
|
horizontalArrangement = Arrangement.spacedBy(4.dp)
|
||||||
) {
|
) {
|
||||||
ExtraPlayerTab.entries.forEach { tab ->
|
ExtraPlayerTab.entries.forEach { tab ->
|
||||||
val isSelected = tab == activeExtraTab
|
ExtraTabChip(
|
||||||
val bg by animateColorAsState(
|
title = stringResource(tab.titleRes),
|
||||||
targetValue = if (isSelected) LocalGeoColors.current.primaryContainer else Color.Transparent,
|
isSelected = tab == activeExtraTab,
|
||||||
label = "extra_tab_bg"
|
onClick = { onSelectExtraTab(tab) },
|
||||||
|
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
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -467,10 +475,7 @@ fun NowPlayingSheet(
|
|||||||
if (recents.isEmpty()) {
|
if (recents.isEmpty()) {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.recent_empty),
|
text = stringResource(R.string.recent_empty),
|
||||||
style = MaterialTheme.typography.bodySmall.copy(
|
style = SheetEmptyListStyle,
|
||||||
color = LocalGeoColors.current.onSurfaceVariant,
|
|
||||||
textAlign = TextAlign.Center
|
|
||||||
),
|
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(vertical = 16.dp)
|
.padding(vertical = 16.dp)
|
||||||
@@ -496,12 +501,7 @@ fun NowPlayingSheet(
|
|||||||
.clip(RoundedCornerShape(10.dp))
|
.clip(RoundedCornerShape(10.dp))
|
||||||
.background(stationTileColor(s))
|
.background(stationTileColor(s))
|
||||||
) {
|
) {
|
||||||
Image(
|
StationArtwork(s, Modifier.matchParentSize())
|
||||||
painter = painterResource(id = s.iconResId),
|
|
||||||
contentDescription = null,
|
|
||||||
contentScale = ContentScale.Crop,
|
|
||||||
modifier = Modifier.matchParentSize()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(modifier = Modifier.weight(1f)) {
|
Column(modifier = Modifier.weight(1f)) {
|
||||||
@@ -514,20 +514,14 @@ fun NowPlayingSheet(
|
|||||||
}
|
}
|
||||||
Text(
|
Text(
|
||||||
text = s.name,
|
text = s.name,
|
||||||
style = MaterialTheme.typography.bodyMedium.copy(
|
style = if (isCur) SheetRowNameAccentStyle else SheetRowNameStyle,
|
||||||
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 = MaterialTheme.typography.bodySmall.copy(
|
style = SheetRowDescriptionStyle,
|
||||||
fontSize = 11.5.sp,
|
|
||||||
color = LocalGeoColors.current.onSurfaceVariant
|
|
||||||
),
|
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
@@ -549,10 +543,7 @@ fun NowPlayingSheet(
|
|||||||
if (similarStations.isEmpty()) {
|
if (similarStations.isEmpty()) {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(R.string.similar_empty),
|
text = stringResource(R.string.similar_empty),
|
||||||
style = MaterialTheme.typography.bodySmall.copy(
|
style = SheetEmptyListStyle,
|
||||||
color = LocalGeoColors.current.onSurfaceVariant,
|
|
||||||
textAlign = TextAlign.Center
|
|
||||||
),
|
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(vertical = 16.dp)
|
.padding(vertical = 16.dp)
|
||||||
@@ -577,30 +568,19 @@ fun NowPlayingSheet(
|
|||||||
.clip(RoundedCornerShape(10.dp))
|
.clip(RoundedCornerShape(10.dp))
|
||||||
.background(stationTileColor(s))
|
.background(stationTileColor(s))
|
||||||
) {
|
) {
|
||||||
Image(
|
StationArtwork(s, Modifier.matchParentSize())
|
||||||
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 = MaterialTheme.typography.bodyMedium.copy(
|
style = SheetRowNameAccentStyle,
|
||||||
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 = MaterialTheme.typography.bodySmall.copy(
|
style = SheetRowDescriptionStyle,
|
||||||
fontSize = 11.5.sp,
|
|
||||||
color = LocalGeoColors.current.onSurfaceVariant
|
|
||||||
),
|
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
@@ -650,6 +630,42 @@ 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(
|
||||||
@@ -659,19 +675,12 @@ private fun InfoRow(key: String, value: String) {
|
|||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = key,
|
text = key,
|
||||||
style = MaterialTheme.typography.bodySmall.copy(
|
style = InfoKeyStyle
|
||||||
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 = MaterialTheme.typography.bodySmall.copy(
|
style = InfoValueStyle,
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
color = LocalGeoColors.current.deepPurple,
|
|
||||||
textAlign = TextAlign.End
|
|
||||||
),
|
|
||||||
modifier = Modifier.weight(1f)
|
modifier = Modifier.weight(1f)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ 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
|
||||||
@@ -40,7 +39,6 @@ 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
|
||||||
@@ -51,8 +49,9 @@ 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 coil.compose.AsyncImage
|
import cc.skysparkle.fogwave.ui.theme.Typography
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun LiveOnAirDot(modifier: Modifier = Modifier) {
|
fun LiveOnAirDot(modifier: Modifier = Modifier) {
|
||||||
@@ -81,6 +80,41 @@ 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,
|
||||||
@@ -188,12 +222,7 @@ private fun StationIconsCard(
|
|||||||
shape = RoundedCornerShape(22.dp)
|
shape = RoundedCornerShape(22.dp)
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
AsyncImage(
|
StationLogoImage(station, Modifier.matchParentSize())
|
||||||
model = station.iconResId,
|
|
||||||
contentDescription = null,
|
|
||||||
contentScale = ContentScale.Crop,
|
|
||||||
modifier = Modifier.matchParentSize()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
@@ -207,13 +236,7 @@ private fun StationIconsCard(
|
|||||||
}
|
}
|
||||||
Text(
|
Text(
|
||||||
text = station.name,
|
text = station.name,
|
||||||
style = MaterialTheme.typography.titleSmall.copy(
|
style = if (isCurrent) IconsNameCurrentStyle else IconsNameStyle,
|
||||||
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
|
||||||
)
|
)
|
||||||
@@ -221,11 +244,7 @@ private fun StationIconsCard(
|
|||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = stationDescription(station),
|
text = stationDescription(station),
|
||||||
style = MaterialTheme.typography.bodySmall.copy(
|
style = IconsDescriptionStyle,
|
||||||
fontSize = 11.5.sp,
|
|
||||||
color = LocalGeoColors.current.onSurface.copy(alpha = 0.82f),
|
|
||||||
shadow = GridTextShadow
|
|
||||||
),
|
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
@@ -270,12 +289,7 @@ 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))
|
||||||
) {
|
) {
|
||||||
AsyncImage(
|
StationLogoImage(station, Modifier.matchParentSize())
|
||||||
model = station.iconResId,
|
|
||||||
contentDescription = null,
|
|
||||||
contentScale = ContentScale.Crop,
|
|
||||||
modifier = Modifier.matchParentSize()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(modifier = Modifier.weight(1f)) {
|
Column(modifier = Modifier.weight(1f)) {
|
||||||
@@ -288,21 +302,14 @@ private fun StationTilesCard(
|
|||||||
}
|
}
|
||||||
Text(
|
Text(
|
||||||
text = station.name,
|
text = station.name,
|
||||||
style = MaterialTheme.typography.titleSmall.copy(
|
style = if (isCurrent) TilesNameCurrentStyle else TilesNameStyle,
|
||||||
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 = MaterialTheme.typography.bodySmall.copy(
|
style = TilesDescriptionStyle,
|
||||||
fontSize = 12.sp,
|
|
||||||
color = LocalGeoColors.current.onSurfaceVariant
|
|
||||||
),
|
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
@@ -343,12 +350,7 @@ 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))
|
||||||
) {
|
) {
|
||||||
AsyncImage(
|
StationLogoImage(station, Modifier.matchParentSize())
|
||||||
model = station.iconResId,
|
|
||||||
contentDescription = null,
|
|
||||||
contentScale = ContentScale.Crop,
|
|
||||||
modifier = Modifier.matchParentSize()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(modifier = Modifier.weight(1f)) {
|
Column(modifier = Modifier.weight(1f)) {
|
||||||
@@ -361,10 +363,7 @@ private fun StationListRow(
|
|||||||
}
|
}
|
||||||
Text(
|
Text(
|
||||||
text = station.name,
|
text = station.name,
|
||||||
style = MaterialTheme.typography.bodyMedium.copy(
|
style = if (isCurrent) RowNameCurrentStyle else RowNameStyle,
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
color = if (isCurrent) LocalGeoColors.current.deepPurple else LocalGeoColors.current.onSurface
|
|
||||||
),
|
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
@@ -411,12 +410,7 @@ 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))
|
||||||
) {
|
) {
|
||||||
AsyncImage(
|
StationLogoImage(station, Modifier.matchParentSize())
|
||||||
model = station.iconResId,
|
|
||||||
contentDescription = null,
|
|
||||||
contentScale = ContentScale.Crop,
|
|
||||||
modifier = Modifier.matchParentSize()
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(modifier = Modifier.weight(1.3f)) {
|
Column(modifier = Modifier.weight(1.3f)) {
|
||||||
@@ -429,20 +423,14 @@ private fun StationDetailsRow(
|
|||||||
}
|
}
|
||||||
Text(
|
Text(
|
||||||
text = station.name,
|
text = station.name,
|
||||||
style = MaterialTheme.typography.bodyMedium.copy(
|
style = if (isCurrent) RowNameCurrentStyle else RowNameStyle,
|
||||||
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 = MaterialTheme.typography.bodySmall.copy(
|
style = RowDescriptionStyle,
|
||||||
fontSize = 11.5.sp,
|
|
||||||
color = LocalGeoColors.current.onSurfaceVariant
|
|
||||||
),
|
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
@@ -450,10 +438,7 @@ private fun StationDetailsRow(
|
|||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = stationGenres(station),
|
text = stationGenres(station),
|
||||||
style = MaterialTheme.typography.bodySmall.copy(
|
style = RowGenresStyle,
|
||||||
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,9 +2,16 @@ 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
|
||||||
|
import coil.request.ImageRequest
|
||||||
|
import coil.size.Size
|
||||||
|
|
||||||
private val LightLogoBackdrop = Color(0xFFECE8F1)
|
private val LightLogoBackdrop = Color(0xFFECE8F1)
|
||||||
|
|
||||||
@@ -13,3 +20,35 @@ 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
|
||||||
|
|
||||||
|
// Decoded off the main thread and kept in Coil's memory cache, so no logo is decoded during a frame.
|
||||||
|
@Composable
|
||||||
|
fun StationLogoImage(station: RadioStation, modifier: Modifier = Modifier) {
|
||||||
|
AsyncImage(
|
||||||
|
model = station.iconResId,
|
||||||
|
contentDescription = null,
|
||||||
|
contentScale = ContentScale.Crop,
|
||||||
|
modifier = modifier
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Player artwork is decoded at full size under its own cache key: the mini player and the
|
||||||
|
// now-playing sheet share one decode, which the station list never evicts, and show it without a fade.
|
||||||
|
@Composable
|
||||||
|
fun StationArtwork(station: RadioStation, modifier: Modifier = Modifier) {
|
||||||
|
val context = LocalContext.current
|
||||||
|
val request = remember(context, station.iconResId) {
|
||||||
|
ImageRequest.Builder(context)
|
||||||
|
.data(station.iconResId)
|
||||||
|
.size(Size.ORIGINAL)
|
||||||
|
.memoryCacheKey("artwork_${station.iconResId}")
|
||||||
|
.crossfade(false)
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
AsyncImage(
|
||||||
|
model = request,
|
||||||
|
contentDescription = null,
|
||||||
|
contentScale = ContentScale.Crop,
|
||||||
|
modifier = modifier
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ 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
|
||||||
@@ -30,6 +29,7 @@ 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.onGloballyPositioned
|
import androidx.compose.ui.layout.onSizeChanged
|
||||||
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,13 +59,15 @@ 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 }
|
||||||
@@ -194,8 +196,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.
|
||||||
.onGloballyPositioned { coordinates ->
|
.onSizeChanged { size ->
|
||||||
val measured = with(density) { coordinates.size.height.toDp() }
|
val measured = with(density) { size.height.toDp() }
|
||||||
if (measured > 0.dp && measured != dockHeight) {
|
if (measured > 0.dp && measured != dockHeight) {
|
||||||
dockHeight = measured
|
dockHeight = measured
|
||||||
}
|
}
|
||||||
@@ -244,7 +246,7 @@ fun HomeScreen(
|
|||||||
onNext = { viewModel.nextStation() },
|
onNext = { viewModel.nextStation() },
|
||||||
onClose = { viewModel.closeNowPlaying() },
|
onClose = { viewModel.closeNowPlaying() },
|
||||||
onOpenEqualizer = { viewModel.toggleEqualizerPop() },
|
onOpenEqualizer = { viewModel.toggleEqualizerPop() },
|
||||||
audioEffects = uiState.audioEffects,
|
equalizerEnabled = equalizerEnabled,
|
||||||
activeExtraTab = uiState.activeExtraTab,
|
activeExtraTab = uiState.activeExtraTab,
|
||||||
onSelectExtraTab = { viewModel.setActiveExtraTab(it) },
|
onSelectExtraTab = { viewModel.setActiveExtraTab(it) },
|
||||||
recents = recentStations,
|
recents = recentStations,
|
||||||
@@ -271,7 +273,7 @@ fun HomeScreen(
|
|||||||
) { it / 3 }
|
) { it / 3 }
|
||||||
) {
|
) {
|
||||||
EqualizerSheet(
|
EqualizerSheet(
|
||||||
audioEffects = uiState.audioEffects,
|
audioEffects = audioEffects.value,
|
||||||
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,7 +3,6 @@ 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(
|
||||||
@@ -25,9 +24,8 @@ 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,7 +38,6 @@ 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
|
||||||
)
|
)
|
||||||
@@ -77,6 +76,9 @@ 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,
|
||||||
@@ -89,7 +91,6 @@ class RadioViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
_isEqualizerPopOpen,
|
_isEqualizerPopOpen,
|
||||||
_isViewPopOpen,
|
_isViewPopOpen,
|
||||||
_activeExtraTab,
|
_activeExtraTab,
|
||||||
AudioEffectsController.state,
|
|
||||||
_isMiniPlayerHidden,
|
_isMiniPlayerHidden,
|
||||||
repository.seenFavoritesFlow,
|
repository.seenFavoritesFlow,
|
||||||
_stations
|
_stations
|
||||||
@@ -107,12 +108,11 @@ 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 effects = params[11] as AudioEffectsState
|
val miniHidden = params[11] as Boolean
|
||||||
val miniHidden = params[12] as Boolean
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
val seenFavs = params[13] as Set<String>
|
val seenFavs = params[12] as Set<String>
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
val orderedStations = params[14] as List<RadioStation>
|
val orderedStations = params[13] 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,7 +130,6 @@ 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 }
|
||||||
)
|
)
|
||||||
@@ -143,7 +142,6 @@ 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 }
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -219,12 +217,11 @@ class RadioViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
selectStation(list[prevIndex])
|
selectStation(list[prevIndex])
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toggleFavorite(stationId: String? = _currentStation.value?.id) {
|
fun toggleFavorite() {
|
||||||
if (stationId != null) {
|
val stationId = _currentStation.value?.id ?: return
|
||||||
repository.toggleFavorite(stationId)
|
repository.toggleFavorite(stationId)
|
||||||
if (_selectedTab.value == AppTab.FAVORITES) {
|
if (_selectedTab.value == AppTab.FAVORITES) {
|
||||||
repository.markFavoritesSeen(repository.favoritesFlow.value)
|
repository.markFavoritesSeen()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,10 +260,6 @@ 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)
|
||||||
}
|
}
|
||||||
@@ -275,7 +268,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.favoritesFlow.value)
|
repository.markFavoritesSeen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 5.3 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 270 B |
|
Before Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 272 B |
|
Before Width: | Height: | Size: 6.8 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 890 B |
|
Before Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 952 B |
|
Before Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 7.1 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 6.0 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 678 B |
|
Before Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 680 B |
|
Before Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 922 B |
|
Before Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 918 B |
|
Before Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 430 B |
|
Before Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 756 B |
|
Before Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 5.5 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 884 B |
|
Before Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 1002 B |
|
Before Width: | Height: | Size: 4.6 KiB |
|
After Width: | Height: | Size: 930 B |
|
Before Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 868 B |
|
Before Width: | Height: | Size: 5.3 KiB |
|
After Width: | Height: | Size: 998 B |
|
Before Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 644 B |
@@ -0,0 +1,4 @@
|
|||||||
|
• Schnellerer Start: Einstellungen und Senderlogos werden im Hintergrund geladen
|
||||||
|
• 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
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
• Faster start: settings and station logos load in the background
|
||||||
|
• 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
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
• 起動を高速化:設定と放送局のロゴをバックグラウンドで読み込み
|
||||||
|
• プレーヤーとイコライザーをより滑らかに:アニメーションやスライダーで画面全体を再描画しません
|
||||||
|
• Android Auto で放送局リストがより速く表示されます
|
||||||
|
• アプリを軽量化:アプリの6言語とプレーヤーの音声部分のみを収録
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
• Greitesnis paleidimas: nustatymai ir stočių logotipai įkeliami fone
|
||||||
|
• 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
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
• Более быстрый запуск: настройки и логотипы станций загружаются в фоне
|
||||||
|
• Плавнее плеер и эквалайзер: анимации и ползунки больше не перерисовывают весь экран
|
||||||
|
• Android Auto быстрее показывает список станций
|
||||||
|
• Приложение стало меньше: только шесть языков приложения и только аудиочасть плеера
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
• 启动更快:设置和电台标志在后台加载
|
||||||
|
• 播放器和均衡器更流畅:动画和滑块不再重绘整个屏幕
|
||||||
|
• Android Auto 更快显示电台列表
|
||||||
|
• 应用更小:只包含应用的六种语言和播放器的音频部分
|
||||||
@@ -3,14 +3,12 @@ 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"
|
||||||
@@ -22,18 +20,15 @@ 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" }
|
||||||
|
|||||||