mirror of
https://github.com/kalarina-bit/Fogwave.git
synced 2026-11-22 08:06:09 +00:00
Compare commits
6
Commits
v1.0.17
...
f6793cf5c0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6793cf5c0 | ||
|
|
5fd7be69e1 | ||
|
|
847aa8daae | ||
|
|
8cd9133803 | ||
|
|
ac19416c00 | ||
|
|
73dd720533 |
@@ -44,7 +44,6 @@
|
|||||||
- 🎚️ **Equalizer** with presets, loudness boost and dynamics processing
|
- 🎚️ **Equalizer** with presets, loudness boost and dynamics processing
|
||||||
- ❤️ **Favorites, recently played and similar stations** matched by genre
|
- ❤️ **Favorites, recently played and similar stations** matched by genre
|
||||||
- 🔍 **Search** to find a station in a tap
|
- 🔍 **Search** to find a station in a tap
|
||||||
- 🎵 **Song titles** for stations that broadcast them
|
|
||||||
- 🌙 **Dark theme**
|
- 🌙 **Dark theme**
|
||||||
- 🌍 **Six languages** — English, Russian, German, Japanese, Lithuanian and Chinese
|
- 🌍 **Six languages** — English, Russian, German, Japanese, Lithuanian and Chinese
|
||||||
- 🔓 **No ads, no tracking, no accounts**
|
- 🔓 **No ads, no tracking, no accounts**
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ android {
|
|||||||
applicationId = "cc.skysparkle.fogwave"
|
applicationId = "cc.skysparkle.fogwave"
|
||||||
minSdk = 24
|
minSdk = 24
|
||||||
targetSdk = 36
|
targetSdk = 36
|
||||||
versionCode = 17
|
versionCode = 18
|
||||||
versionName = "1.0.17"
|
versionName = "1.0.18"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
@@ -27,7 +27,6 @@ android {
|
|||||||
buildConfigField("String", "MEDIA3_VERSION", "\"${libs.versions.media3.get()}\"")
|
buildConfigField("String", "MEDIA3_VERSION", "\"${libs.versions.media3.get()}\"")
|
||||||
buildConfigField("String", "COROUTINES_VERSION", "\"${libs.versions.kotlinxCoroutinesAndroid.get()}\"")
|
buildConfigField("String", "COROUTINES_VERSION", "\"${libs.versions.kotlinxCoroutinesAndroid.get()}\"")
|
||||||
buildConfigField("String", "KOTLIN_VERSION", "\"${libs.versions.kotlin.get()}\"")
|
buildConfigField("String", "KOTLIN_VERSION", "\"${libs.versions.kotlin.get()}\"")
|
||||||
buildConfigField("String", "COIL_VERSION", "\"${libs.versions.coilCompose.get()}\"")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release signing is applied only when a keystore is available, so anyone (including F-Droid,
|
// Release signing is applied only when a keystore is available, so anyone (including F-Droid,
|
||||||
@@ -83,7 +82,6 @@ dependencies {
|
|||||||
implementation(libs.androidx.lifecycle.runtime.compose)
|
implementation(libs.androidx.lifecycle.runtime.compose)
|
||||||
implementation(libs.androidx.lifecycle.viewmodel.compose)
|
implementation(libs.androidx.lifecycle.viewmodel.compose)
|
||||||
|
|
||||||
implementation(libs.coil.compose)
|
|
||||||
implementation(libs.androidx.media3.exoplayer)
|
implementation(libs.androidx.media3.exoplayer)
|
||||||
implementation(libs.androidx.media3.exoplayer.hls)
|
implementation(libs.androidx.media3.exoplayer.hls)
|
||||||
implementation(libs.androidx.media3.common)
|
implementation(libs.androidx.media3.common)
|
||||||
|
|||||||
Vendored
+6
@@ -1,2 +1,8 @@
|
|||||||
-keepattributes SourceFile,LineNumberTable
|
-keepattributes SourceFile,LineNumberTable
|
||||||
-renamesourcefileattribute SourceFile
|
-renamesourcefileattribute SourceFile
|
||||||
|
|
||||||
|
# Debug and verbose logging is stripped from release builds.
|
||||||
|
-assumenosideeffects class android.util.Log {
|
||||||
|
public static int d(...);
|
||||||
|
public static int v(...);
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,10 +8,7 @@
|
|||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".FogwaveApp"
|
android:allowBackup="false"
|
||||||
android:allowBackup="true"
|
|
||||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
|
||||||
android:fullBackupContent="@xml/backup_rules"
|
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:localeConfig="@xml/locales_config"
|
android:localeConfig="@xml/locales_config"
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
package cc.skysparkle.fogwave
|
|
||||||
|
|
||||||
import android.app.Application
|
|
||||||
import coil.ImageLoader
|
|
||||||
import coil.ImageLoaderFactory
|
|
||||||
import coil.memory.MemoryCache
|
|
||||||
|
|
||||||
class FogwaveApp : Application(), ImageLoaderFactory {
|
|
||||||
override fun newImageLoader(): ImageLoader {
|
|
||||||
return ImageLoader.Builder(this)
|
|
||||||
.memoryCache {
|
|
||||||
MemoryCache.Builder(this)
|
|
||||||
.maxSizePercent(0.20)
|
|
||||||
.build()
|
|
||||||
}
|
|
||||||
.crossfade(true)
|
|
||||||
.respectCacheHeaders(false)
|
|
||||||
.build()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -11,11 +11,13 @@ import androidx.compose.material3.MaterialTheme
|
|||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import cc.skysparkle.fogwave.ui.screens.HomeScreen
|
import cc.skysparkle.fogwave.ui.screens.HomeScreen
|
||||||
|
import cc.skysparkle.fogwave.ui.theme.AppThemeState
|
||||||
import cc.skysparkle.fogwave.ui.theme.FogwaveTheme
|
import cc.skysparkle.fogwave.ui.theme.FogwaveTheme
|
||||||
|
|
||||||
class MainActivity : ComponentActivity() {
|
class MainActivity : ComponentActivity() {
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
AppThemeState.load(this)
|
||||||
enableEdgeToEdge(
|
enableEdgeToEdge(
|
||||||
statusBarStyle = SystemBarStyle.dark(Color.TRANSPARENT),
|
statusBarStyle = SystemBarStyle.dark(Color.TRANSPARENT),
|
||||||
navigationBarStyle = SystemBarStyle.dark(Color.TRANSPARENT)
|
navigationBarStyle = SystemBarStyle.dark(Color.TRANSPARENT)
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ class RadioRepository(context: Context) {
|
|||||||
fun markFavoritesSeen(ids: Set<String>) {
|
fun markFavoritesSeen(ids: Set<String>) {
|
||||||
val copy = ids.toSet()
|
val copy = ids.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? {
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ data class AudioEffectsState(
|
|||||||
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
|
||||||
)
|
)
|
||||||
@@ -52,7 +50,10 @@ class AudioEffectsEngine(context: Context, audioSessionId: Int) {
|
|||||||
|
|
||||||
private var equalizerEnabled = prefs.getBoolean(KEY_EQ_ENABLED, false)
|
private var equalizerEnabled = prefs.getBoolean(KEY_EQ_ENABLED, false)
|
||||||
private var loudnessEnabled = prefs.getBoolean(KEY_LOUDNESS_ENABLED, false)
|
private var loudnessEnabled = prefs.getBoolean(KEY_LOUDNESS_ENABLED, false)
|
||||||
private var loudnessGain = prefs.getInt(KEY_LOUDNESS_GAIN, 0).coerceIn(0, MAX_LOUDNESS_GAIN)
|
// There is no gain slider, so the switch applies a fixed, moderate boost. A gain of 0 (the old
|
||||||
|
// default) made the switch do nothing.
|
||||||
|
private val loudnessGain = prefs.getInt(KEY_LOUDNESS_GAIN, DEFAULT_LOUDNESS_GAIN)
|
||||||
|
.takeIf { it > 0 }?.coerceAtMost(MAX_LOUDNESS_GAIN) ?: DEFAULT_LOUDNESS_GAIN
|
||||||
private var dynamicsEnabled = prefs.getBoolean(KEY_DYNAMICS_ENABLED, false)
|
private var dynamicsEnabled = prefs.getBoolean(KEY_DYNAMICS_ENABLED, false)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@@ -178,7 +179,6 @@ class AudioEffectsEngine(context: Context, audioSessionId: Int) {
|
|||||||
currentPreset = if (eqAvailable) currentPresetIndex else -1,
|
currentPreset = if (eqAvailable) currentPresetIndex else -1,
|
||||||
loudnessAvailable = loudnessEnhancer != null,
|
loudnessAvailable = loudnessEnhancer != null,
|
||||||
loudnessEnabled = loudnessEnhancer != null && loudnessEnabled,
|
loudnessEnabled = loudnessEnhancer != null && loudnessEnabled,
|
||||||
loudnessGainMillibel = if (loudnessEnhancer != null) loudnessGain.toFloat() else 0f,
|
|
||||||
dynamicsProcessingAvailable = dynamicsProcessing != null,
|
dynamicsProcessingAvailable = dynamicsProcessing != null,
|
||||||
dynamicsProcessingEnabled = dynamicsProcessing != null && dynamicsEnabled
|
dynamicsProcessingEnabled = dynamicsProcessing != null && dynamicsEnabled
|
||||||
)
|
)
|
||||||
@@ -233,17 +233,6 @@ class AudioEffectsEngine(context: Context, audioSessionId: Int) {
|
|||||||
} catch (_: Exception) {}
|
} catch (_: Exception) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setLoudnessGain(gainMillibel: Float) {
|
|
||||||
val le = loudnessEnhancer ?: return
|
|
||||||
val gain = gainMillibel.coerceIn(0f, MAX_LOUDNESS_GAIN.toFloat()).toInt()
|
|
||||||
if (gain == loudnessGain) return
|
|
||||||
try {
|
|
||||||
le.setTargetGain(gain)
|
|
||||||
loudnessGain = gain
|
|
||||||
prefs.edit { putInt(KEY_LOUDNESS_GAIN, gain) }
|
|
||||||
} catch (_: Exception) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setDynamicsProcessingEnabled(enabled: Boolean) {
|
fun setDynamicsProcessingEnabled(enabled: Boolean) {
|
||||||
val dp = dynamicsProcessing ?: return
|
val dp = dynamicsProcessing ?: return
|
||||||
try {
|
try {
|
||||||
@@ -265,6 +254,7 @@ class AudioEffectsEngine(context: Context, audioSessionId: Int) {
|
|||||||
private companion object {
|
private companion object {
|
||||||
const val TAG = "AudioEffectsEngine"
|
const val TAG = "AudioEffectsEngine"
|
||||||
const val MAX_LOUDNESS_GAIN = 2000
|
const val MAX_LOUDNESS_GAIN = 2000
|
||||||
|
const val DEFAULT_LOUDNESS_GAIN = 600
|
||||||
const val KEY_EQ_ENABLED = "eq_enabled"
|
const val KEY_EQ_ENABLED = "eq_enabled"
|
||||||
const val KEY_PRESET = "eq_preset"
|
const val KEY_PRESET = "eq_preset"
|
||||||
const val KEY_BAND_PREFIX = "eq_band_"
|
const val KEY_BAND_PREFIX = "eq_band_"
|
||||||
|
|||||||
@@ -15,13 +15,13 @@ import android.util.Log
|
|||||||
import androidx.annotation.OptIn
|
import androidx.annotation.OptIn
|
||||||
import androidx.media3.common.AudioAttributes
|
import androidx.media3.common.AudioAttributes
|
||||||
import androidx.media3.common.C
|
import androidx.media3.common.C
|
||||||
|
import androidx.media3.common.ForwardingSimpleBasePlayer
|
||||||
import androidx.media3.common.MediaItem
|
import androidx.media3.common.MediaItem
|
||||||
import androidx.media3.common.MediaMetadata
|
import androidx.media3.common.MediaMetadata
|
||||||
import androidx.media3.common.PlaybackException
|
import androidx.media3.common.PlaybackException
|
||||||
import androidx.media3.common.Player
|
import androidx.media3.common.Player
|
||||||
import androidx.media3.common.util.UnstableApi
|
import androidx.media3.common.util.UnstableApi
|
||||||
import androidx.media3.datasource.DefaultHttpDataSource
|
import androidx.media3.datasource.DefaultHttpDataSource
|
||||||
import androidx.media3.datasource.HttpDataSource
|
|
||||||
import androidx.media3.exoplayer.DefaultLoadControl
|
import androidx.media3.exoplayer.DefaultLoadControl
|
||||||
import androidx.media3.exoplayer.ExoPlayer
|
import androidx.media3.exoplayer.ExoPlayer
|
||||||
import androidx.media3.exoplayer.source.DefaultMediaSourceFactory
|
import androidx.media3.exoplayer.source.DefaultMediaSourceFactory
|
||||||
@@ -33,6 +33,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.model.RadioStation
|
||||||
import cc.skysparkle.fogwave.data.repository.RadioRepository
|
import cc.skysparkle.fogwave.data.repository.RadioRepository
|
||||||
import com.google.common.collect.ImmutableList
|
import com.google.common.collect.ImmutableList
|
||||||
import com.google.common.util.concurrent.Futures
|
import com.google.common.util.concurrent.Futures
|
||||||
@@ -50,6 +51,10 @@ class FogwavePlaybackService : MediaLibraryService() {
|
|||||||
private var mediaLibrarySession: MediaLibrarySession? = null
|
private var mediaLibrarySession: MediaLibrarySession? = null
|
||||||
private lateinit var repository: RadioRepository
|
private lateinit var repository: RadioRepository
|
||||||
private lateinit var player: ExoPlayer
|
private lateinit var player: ExoPlayer
|
||||||
|
|
||||||
|
// Station order for next/previous from the notification, a headset or the car; sorted once,
|
||||||
|
// like the grid in the app.
|
||||||
|
private var stationOrder: List<RadioStation> = emptyList()
|
||||||
private var audioEffectsEngine: AudioEffectsEngine? = null
|
private var audioEffectsEngine: AudioEffectsEngine? = null
|
||||||
|
|
||||||
private val serviceScope = CoroutineScope(Dispatchers.Main.immediate + SupervisorJob())
|
private val serviceScope = CoroutineScope(Dispatchers.Main.immediate + SupervisorJob())
|
||||||
@@ -66,6 +71,11 @@ class FogwavePlaybackService : MediaLibraryService() {
|
|||||||
private var connectivityManager: ConnectivityManager? = null
|
private var connectivityManager: ConnectivityManager? = null
|
||||||
private var networkCallback: ConnectivityManager.NetworkCallback? = null
|
private var networkCallback: ConnectivityManager.NetworkCallback? = null
|
||||||
private var defaultNetwork: Network? = null
|
private var defaultNetwork: Network? = null
|
||||||
|
private var hasNetwork = true
|
||||||
|
|
||||||
|
// Set when a reconnect is due but there is no network: no attempts are spent while offline,
|
||||||
|
// the stream is reopened from onAvailable instead.
|
||||||
|
private var waitingForNetwork = false
|
||||||
|
|
||||||
// ExoPlayer drops its own wake and Wi-Fi locks once the player is idle after an error, so the
|
// ExoPlayer drops its own wake and Wi-Fi locks once the player is idle after an error, so the
|
||||||
// backoff delay would stall while the CPU sleeps. These are held only while a reconnect is pending.
|
// backoff delay would stall while the CPU sleeps. These are held only while a reconnect is pending.
|
||||||
@@ -136,32 +146,96 @@ class FogwavePlaybackService : MediaLibraryService() {
|
|||||||
return Futures.immediateFuture(LibraryResult.ofItem(station.toMediaItem(this@FogwavePlaybackService), null))
|
return Futures.immediateFuture(LibraryResult.ofItem(station.toMediaItem(this@FogwavePlaybackService), null))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Items coming from a controller are never trusted: only the mediaId (or a voice search
|
||||||
|
// query) is read, and the stream URI always comes from our own station list. Without this
|
||||||
|
// an item without a URI (a voice request from Assistant or Android Auto) crashed the
|
||||||
|
// player, and any app on the device could make Fogwave play an arbitrary stream.
|
||||||
override fun onAddMediaItems(
|
override fun onAddMediaItems(
|
||||||
mediaSession: MediaSession,
|
mediaSession: MediaSession,
|
||||||
controller: MediaSession.ControllerInfo,
|
controller: MediaSession.ControllerInfo,
|
||||||
mediaItems: MutableList<MediaItem>
|
mediaItems: MutableList<MediaItem>
|
||||||
): ListenableFuture<MutableList<MediaItem>> {
|
): ListenableFuture<MutableList<MediaItem>> {
|
||||||
val resolved = mediaItems.map { item ->
|
val resolved = mediaItems.map { resolveStation(it).toMediaItem(this@FogwavePlaybackService) }
|
||||||
if (item.localConfiguration != null) {
|
.toMutableList()
|
||||||
item
|
resolved.firstOrNull()?.let { onNewRequest(it) }
|
||||||
} else {
|
|
||||||
repository.stations.find { it.id == item.mediaId }
|
|
||||||
?.toMediaItem(this@FogwavePlaybackService)
|
|
||||||
?: item
|
|
||||||
}
|
|
||||||
}.toMutableList()
|
|
||||||
|
|
||||||
resolved.firstOrNull()?.let { item ->
|
|
||||||
Log.d(TAG, "MediaItem resolved: mediaId=${item.mediaId} uri=${item.localConfiguration?.uri}")
|
|
||||||
lastRequestedItem = item
|
|
||||||
retryJob?.cancel()
|
|
||||||
retryAttempt = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
return Futures.immediateFuture(resolved)
|
return Futures.immediateFuture(resolved)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun resolveStation(item: MediaItem): RadioStation {
|
||||||
|
val stations = repository.stations
|
||||||
|
val query = item.requestMetadata.searchQuery?.trim().orEmpty()
|
||||||
|
return stations.find { it.id == item.mediaId }
|
||||||
|
?: query.takeIf { it.isNotEmpty() }?.let { q ->
|
||||||
|
stations.find { it.name.contains(q, ignoreCase = true) }
|
||||||
|
?: stations.find { q.contains(it.name, ignoreCase = true) }
|
||||||
|
}
|
||||||
|
?: stations.find { it.id == repository.getLastStationId() }
|
||||||
|
?: stations.first()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun onNewRequest(item: MediaItem) {
|
||||||
|
Log.d(TAG, "MediaItem resolved: mediaId=${item.mediaId}")
|
||||||
|
lastRequestedItem = item
|
||||||
|
retryJob?.cancel()
|
||||||
|
retryAttempt = 0
|
||||||
|
waitingForNetwork = false
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun switchStation(step: Int) {
|
||||||
|
val order = stationOrder.ifEmpty { repository.stations }
|
||||||
|
val currentId = player.currentMediaItem?.mediaId ?: lastRequestedItem?.mediaId
|
||||||
|
val index = order.indexOfFirst { it.id == currentId }
|
||||||
|
val target = if (index < 0) order.first() else order[(index + step).mod(order.size)]
|
||||||
|
Log.d(TAG, "Switching station: ${target.id}")
|
||||||
|
val item = target.toMediaItem(this)
|
||||||
|
onNewRequest(item)
|
||||||
|
repository.setLastStationId(target.id)
|
||||||
|
// playWhenReady is kept: a paused player switches the station and stays paused.
|
||||||
|
player.setMediaItem(item)
|
||||||
|
player.prepare()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The player only ever holds the station that is on air: with the whole list in ExoPlayer every
|
||||||
|
* stream would be prepared at once, and the HLS ones would keep refreshing their playlists in
|
||||||
|
* the background. Instead next/previous are always offered to the session (notification,
|
||||||
|
* headset buttons, Android Auto) and switch the station here, wrapping around like the app.
|
||||||
|
*/
|
||||||
|
private inner class StationSwitchingPlayer(player: Player) : ForwardingSimpleBasePlayer(player) {
|
||||||
|
override fun getState(): State {
|
||||||
|
val state = super.getState()
|
||||||
|
if (state.timeline.isEmpty()) return state
|
||||||
|
val commands = state.availableCommands.buildUpon()
|
||||||
|
.addAll(
|
||||||
|
Player.COMMAND_SEEK_TO_NEXT,
|
||||||
|
Player.COMMAND_SEEK_TO_NEXT_MEDIA_ITEM,
|
||||||
|
Player.COMMAND_SEEK_TO_PREVIOUS,
|
||||||
|
Player.COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM
|
||||||
|
)
|
||||||
|
.remove(Player.COMMAND_SET_REPEAT_MODE)
|
||||||
|
.build()
|
||||||
|
// REPEAT_MODE_ALL makes next/previous resolve to the single item, which lands in
|
||||||
|
// handleSeek below with the original seek command.
|
||||||
|
return state.buildUpon()
|
||||||
|
.setAvailableCommands(commands)
|
||||||
|
.setRepeatMode(Player.REPEAT_MODE_ALL)
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handleSeek(mediaItemIndex: Int, positionMs: Long, seekCommand: Int): ListenableFuture<*> {
|
||||||
|
when (seekCommand) {
|
||||||
|
Player.COMMAND_SEEK_TO_NEXT, Player.COMMAND_SEEK_TO_NEXT_MEDIA_ITEM -> switchStation(+1)
|
||||||
|
Player.COMMAND_SEEK_TO_PREVIOUS, Player.COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM -> switchStation(-1)
|
||||||
|
else -> return super.handleSeek(mediaItemIndex, positionMs, seekCommand)
|
||||||
|
}
|
||||||
|
return Futures.immediateVoidFuture()
|
||||||
|
}
|
||||||
|
|
||||||
|
// The stream's own repeat mode stays off; a dropped stream is handled by scheduleReconnect.
|
||||||
|
override fun handleSetRepeatMode(repeatMode: Int): ListenableFuture<*> = Futures.immediateVoidFuture()
|
||||||
|
}
|
||||||
|
|
||||||
private val resiliencePlayerListener = object : Player.Listener {
|
private val resiliencePlayerListener = object : Player.Listener {
|
||||||
override fun onPlaybackStateChanged(playbackState: Int) {
|
override fun onPlaybackStateChanged(playbackState: Int) {
|
||||||
val stateName = when (playbackState) {
|
val stateName = when (playbackState) {
|
||||||
@@ -196,6 +270,7 @@ class FogwavePlaybackService : MediaLibraryService() {
|
|||||||
Log.d(TAG, "Reconnect cancelled - playWhenReady=false (reason=$reason)")
|
Log.d(TAG, "Reconnect cancelled - playWhenReady=false (reason=$reason)")
|
||||||
}
|
}
|
||||||
retryJob?.cancel()
|
retryJob?.cancel()
|
||||||
|
waitingForNetwork = false
|
||||||
releaseReconnectLocks()
|
releaseReconnectLocks()
|
||||||
pausedAtMs = SystemClock.elapsedRealtime()
|
pausedAtMs = SystemClock.elapsedRealtime()
|
||||||
return
|
return
|
||||||
@@ -225,25 +300,16 @@ class FogwavePlaybackService : MediaLibraryService() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// A missing stream or an unsupported format will not fix itself, so it gets only a couple of
|
|
||||||
// attempts (a stale token or a short server outage can still recover); network errors get the full backoff.
|
|
||||||
private fun maxRetryAttemptsFor(error: PlaybackException): Int {
|
|
||||||
val httpCode = (error.cause as? HttpDataSource.InvalidResponseCodeException)?.responseCode
|
|
||||||
val permanent = when (error.errorCode) {
|
|
||||||
PlaybackException.ERROR_CODE_IO_BAD_HTTP_STATUS ->
|
|
||||||
httpCode != null && httpCode in 400..499 && httpCode != 408 && httpCode != 429
|
|
||||||
PlaybackException.ERROR_CODE_IO_FILE_NOT_FOUND,
|
|
||||||
PlaybackException.ERROR_CODE_IO_CLEARTEXT_NOT_PERMITTED,
|
|
||||||
PlaybackException.ERROR_CODE_PARSING_CONTAINER_UNSUPPORTED,
|
|
||||||
PlaybackException.ERROR_CODE_PARSING_MANIFEST_UNSUPPORTED,
|
|
||||||
PlaybackException.ERROR_CODE_DECODING_FORMAT_UNSUPPORTED -> true
|
|
||||||
else -> false
|
|
||||||
}
|
|
||||||
return if (permanent) MAX_PERMANENT_ERROR_RETRY_ATTEMPTS else MAX_RETRY_ATTEMPTS
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun scheduleReconnect(immediate: Boolean = false, maxAttempts: Int = MAX_RETRY_ATTEMPTS) {
|
private fun scheduleReconnect(immediate: Boolean = false, maxAttempts: Int = MAX_RETRY_ATTEMPTS) {
|
||||||
retryJob?.cancel()
|
retryJob?.cancel()
|
||||||
|
if (!immediate && !hasNetwork) {
|
||||||
|
// Attempts would only fail and run out while offline; wait for onAvailable instead.
|
||||||
|
Log.d(TAG, "No network - waiting for it before reconnecting")
|
||||||
|
waitingForNetwork = true
|
||||||
|
releaseReconnectLocks()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
waitingForNetwork = false
|
||||||
if (!immediate && retryAttempt >= maxAttempts) {
|
if (!immediate && retryAttempt >= maxAttempts) {
|
||||||
// Give up instead of keeping the device busy forever; the error stays visible and a tap
|
// Give up instead of keeping the device busy forever; the error stays visible and a tap
|
||||||
// on play starts over.
|
// on play starts over.
|
||||||
@@ -316,13 +382,23 @@ class FogwavePlaybackService : MediaLibraryService() {
|
|||||||
private fun registerNetworkCallback() {
|
private fun registerNetworkCallback() {
|
||||||
val cm = getSystemService(Context.CONNECTIVITY_SERVICE) as? ConnectivityManager ?: return
|
val cm = getSystemService(Context.CONNECTIVITY_SERVICE) as? ConnectivityManager ?: return
|
||||||
connectivityManager = cm
|
connectivityManager = cm
|
||||||
|
hasNetwork = cm.activeNetwork != null
|
||||||
val callback = object : ConnectivityManager.NetworkCallback() {
|
val callback = object : ConnectivityManager.NetworkCallback() {
|
||||||
// Called on a ConnectivityManager thread; ExoPlayer must only be accessed on the main thread.
|
// Called on a ConnectivityManager thread; ExoPlayer must only be accessed on the main thread.
|
||||||
override fun onAvailable(network: Network) {
|
override fun onAvailable(network: Network) {
|
||||||
serviceScope.launch {
|
serviceScope.launch {
|
||||||
val previous = defaultNetwork
|
val previous = defaultNetwork
|
||||||
defaultNetwork = network
|
defaultNetwork = network
|
||||||
|
hasNetwork = true
|
||||||
|
val wasWaiting = waitingForNetwork
|
||||||
|
waitingForNetwork = false
|
||||||
if (!player.playWhenReady || player.playbackState == Player.STATE_READY) return@launch
|
if (!player.playWhenReady || player.playbackState == Player.STATE_READY) return@launch
|
||||||
|
if (wasWaiting) {
|
||||||
|
Log.d(TAG, "Network is back - reconnecting")
|
||||||
|
retryAttempt = 0
|
||||||
|
scheduleReconnect(immediate = true)
|
||||||
|
return@launch
|
||||||
|
}
|
||||||
// After a switch (e.g. Wi-Fi to mobile) a stalled load can sit on a dead socket until
|
// After a switch (e.g. Wi-Fi to mobile) a stalled load can sit on a dead socket until
|
||||||
// the read timeout, so reopen right away instead of waiting for the error.
|
// the read timeout, so reopen right away instead of waiting for the error.
|
||||||
val switchedWhileStalled = previous != null && previous != network &&
|
val switchedWhileStalled = previous != null && previous != network &&
|
||||||
@@ -333,6 +409,13 @@ class FogwavePlaybackService : MediaLibraryService() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onLost(network: Network) {
|
||||||
|
serviceScope.launch {
|
||||||
|
// A switch reports the new network first; only the loss of the current one counts.
|
||||||
|
if (network == defaultNetwork) hasNetwork = false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
networkCallback = callback
|
networkCallback = callback
|
||||||
try {
|
try {
|
||||||
@@ -344,6 +427,7 @@ class FogwavePlaybackService : MediaLibraryService() {
|
|||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
repository = RadioRepository(applicationContext)
|
repository = RadioRepository(applicationContext)
|
||||||
|
stationOrder = repository.stationsSortedByPopularity()
|
||||||
|
|
||||||
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 }
|
||||||
@@ -385,7 +469,7 @@ class FogwavePlaybackService : MediaLibraryService() {
|
|||||||
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
)
|
)
|
||||||
|
|
||||||
mediaLibrarySession = MediaLibrarySession.Builder(this, player, librarySessionCallback)
|
mediaLibrarySession = MediaLibrarySession.Builder(this, StationSwitchingPlayer(player), librarySessionCallback)
|
||||||
.setSessionActivity(sessionActivity)
|
.setSessionActivity(sessionActivity)
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
@@ -412,10 +496,13 @@ class FogwavePlaybackService : MediaLibraryService() {
|
|||||||
|
|
||||||
override fun onGetSession(controllerInfo: MediaSession.ControllerInfo): MediaLibrarySession? = mediaLibrarySession
|
override fun onGetSession(controllerInfo: MediaSession.ControllerInfo): MediaLibrarySession? = mediaLibrarySession
|
||||||
|
|
||||||
|
// Swiping the app away keeps only real playback alive (a short rebuffer counts): a failed
|
||||||
|
// stream, a pending reconnect or a pause stop the service. The Media3 default would also stop
|
||||||
|
// during a rebuffer, because isPlaying is false while buffering.
|
||||||
override fun onTaskRemoved(rootIntent: Intent?) {
|
override fun onTaskRemoved(rootIntent: Intent?) {
|
||||||
if (!player.playWhenReady || player.mediaItemCount == 0) {
|
val reconnecting = retryJob?.isActive == true || waitingForNetwork || player.playerError != null
|
||||||
player.pause()
|
if (!isPlaybackOngoing() || !player.playWhenReady || player.mediaItemCount == 0 || reconnecting) {
|
||||||
stopSelf()
|
pauseAllPlayersAndStopSelf()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -441,8 +528,6 @@ class FogwavePlaybackService : MediaLibraryService() {
|
|||||||
companion object {
|
companion object {
|
||||||
private const val ROOT_ID = "fogwave_root"
|
private const val ROOT_ID = "fogwave_root"
|
||||||
private const val TAG = "FogwavePlaybackService"
|
private const val TAG = "FogwavePlaybackService"
|
||||||
private const val MAX_RETRY_ATTEMPTS = 12
|
|
||||||
private const val MAX_PERMANENT_ERROR_RETRY_ATTEMPTS = 2
|
|
||||||
private const val RECONNECT_LOCK_TIMEOUT_MS = 2 * 60_000L
|
private const val RECONNECT_LOCK_TIMEOUT_MS = 2 * 60_000L
|
||||||
private const val LIVE_RESYNC_AFTER_MS = 30_000L
|
private const val LIVE_RESYNC_AFTER_MS = 30_000L
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package cc.skysparkle.fogwave.player
|
||||||
|
|
||||||
|
import androidx.annotation.OptIn
|
||||||
|
import androidx.media3.common.PlaybackException
|
||||||
|
import androidx.media3.common.Player
|
||||||
|
import androidx.media3.common.util.UnstableApi
|
||||||
|
import androidx.media3.datasource.HttpDataSource
|
||||||
|
|
||||||
|
// Kept apart from the service and the UI controller so the decisions can be unit tested.
|
||||||
|
|
||||||
|
internal const val MAX_RETRY_ATTEMPTS = 12
|
||||||
|
internal const val MAX_PERMANENT_ERROR_RETRY_ATTEMPTS = 2
|
||||||
|
|
||||||
|
// A missing stream or an unsupported format will not fix itself, so it gets only a couple of
|
||||||
|
// attempts (a stale token or a short server outage can still recover); network errors get the full backoff.
|
||||||
|
@OptIn(UnstableApi::class)
|
||||||
|
internal fun maxRetryAttemptsFor(error: PlaybackException): Int {
|
||||||
|
val httpCode = (error.cause as? HttpDataSource.InvalidResponseCodeException)?.responseCode
|
||||||
|
val permanent = when (error.errorCode) {
|
||||||
|
PlaybackException.ERROR_CODE_IO_BAD_HTTP_STATUS ->
|
||||||
|
httpCode != null && httpCode in 400..499 && httpCode != 408 && httpCode != 429
|
||||||
|
PlaybackException.ERROR_CODE_IO_FILE_NOT_FOUND,
|
||||||
|
PlaybackException.ERROR_CODE_IO_CLEARTEXT_NOT_PERMITTED,
|
||||||
|
PlaybackException.ERROR_CODE_PARSING_CONTAINER_UNSUPPORTED,
|
||||||
|
PlaybackException.ERROR_CODE_PARSING_MANIFEST_UNSUPPORTED,
|
||||||
|
PlaybackException.ERROR_CODE_DECODING_FORMAT_UNSUPPORTED -> true
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
return if (permanent) MAX_PERMANENT_ERROR_RETRY_ATTEMPTS else MAX_RETRY_ATTEMPTS
|
||||||
|
}
|
||||||
|
|
||||||
|
/** What the UI shows for the session's player; [errorMessage] turns a playback error into text. */
|
||||||
|
internal fun deriveState(p: Player, errorMessage: (PlaybackException) -> String): PlayerState {
|
||||||
|
p.playerError?.let { return PlayerState.Error(errorMessage(it)) }
|
||||||
|
return when (p.playbackState) {
|
||||||
|
Player.STATE_READY -> if (p.playWhenReady) PlayerState.Playing else PlayerState.Paused
|
||||||
|
Player.STATE_BUFFERING, Player.STATE_ENDED ->
|
||||||
|
if (p.playWhenReady) PlayerState.Connecting else PlayerState.Paused
|
||||||
|
else -> when {
|
||||||
|
p.mediaItemCount == 0 -> PlayerState.Idle
|
||||||
|
p.playWhenReady -> PlayerState.Connecting
|
||||||
|
else -> PlayerState.Paused
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -43,7 +43,7 @@ class RadioPlayerManager(private val context: Context) {
|
|||||||
|
|
||||||
private val playerListener = object : Player.Listener {
|
private val playerListener = object : Player.Listener {
|
||||||
override fun onEvents(player: Player, events: Player.Events) {
|
override fun onEvents(player: Player, events: Player.Events) {
|
||||||
_playerState.value = deriveState(player)
|
_playerState.value = deriveState(player, ::errorMessage)
|
||||||
_currentMediaId.value = player.currentMediaItem?.mediaId
|
_currentMediaId.value = player.currentMediaItem?.mediaId
|
||||||
_nowPlayingTitle.value = streamTitle(player)
|
_nowPlayingTitle.value = streamTitle(player)
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ class RadioPlayerManager(private val context: Context) {
|
|||||||
if (station != null) {
|
if (station != null) {
|
||||||
playStation(station)
|
playStation(station)
|
||||||
} else {
|
} else {
|
||||||
_playerState.value = deriveState(c)
|
_playerState.value = deriveState(c, ::errorMessage)
|
||||||
_currentMediaId.value = c.currentMediaItem?.mediaId
|
_currentMediaId.value = c.currentMediaItem?.mediaId
|
||||||
_nowPlayingTitle.value = streamTitle(c)
|
_nowPlayingTitle.value = streamTitle(c)
|
||||||
}
|
}
|
||||||
@@ -117,20 +117,6 @@ class RadioPlayerManager(private val context: Context) {
|
|||||||
controllerFuture = null
|
controllerFuture = null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun deriveState(p: Player): PlayerState {
|
|
||||||
p.playerError?.let { return PlayerState.Error(errorMessage(it)) }
|
|
||||||
return when (p.playbackState) {
|
|
||||||
Player.STATE_READY -> if (p.playWhenReady) PlayerState.Playing else PlayerState.Paused
|
|
||||||
Player.STATE_BUFFERING, Player.STATE_ENDED ->
|
|
||||||
if (p.playWhenReady) PlayerState.Connecting else PlayerState.Paused
|
|
||||||
else -> when {
|
|
||||||
p.mediaItemCount == 0 -> PlayerState.Idle
|
|
||||||
p.playWhenReady -> PlayerState.Connecting
|
|
||||||
else -> PlayerState.Paused
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stream metadata replaces the item's own title; the station name itself is not a song.
|
// Stream metadata replaces the item's own title; the station name itself is not a song.
|
||||||
private fun streamTitle(p: Player): String? {
|
private fun streamTitle(p: Player): String? {
|
||||||
val title = p.mediaMetadata.title?.toString()?.trim()
|
val title = p.mediaMetadata.title?.toString()?.trim()
|
||||||
|
|||||||
@@ -1,40 +1,52 @@
|
|||||||
package cc.skysparkle.fogwave.ui.components
|
package cc.skysparkle.fogwave.ui.components
|
||||||
|
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
|
import androidx.compose.animation.animateColorAsState
|
||||||
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
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.ColumnScope
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.selection.selectable
|
||||||
|
import androidx.compose.foundation.selection.toggleable
|
||||||
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.MaterialTheme
|
||||||
|
import androidx.compose.material3.Switch
|
||||||
|
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.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.saveable.rememberSaveable
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
import androidx.compose.runtime.setValue
|
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.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.draw.shadow
|
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.platform.testTag
|
import androidx.compose.ui.platform.testTag
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
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
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import cc.skysparkle.fogwave.BuildConfig
|
import cc.skysparkle.fogwave.BuildConfig
|
||||||
import cc.skysparkle.fogwave.R
|
import cc.skysparkle.fogwave.R
|
||||||
|
import cc.skysparkle.fogwave.ui.theme.AppStyle
|
||||||
|
import cc.skysparkle.fogwave.ui.theme.AppThemeState
|
||||||
|
import cc.skysparkle.fogwave.ui.theme.GeoColors
|
||||||
import cc.skysparkle.fogwave.ui.theme.LocalGeoColors
|
import cc.skysparkle.fogwave.ui.theme.LocalGeoColors
|
||||||
|
|
||||||
private const val REPOSITORY_URL = "https://git.skysparkle.cc/kalarina/Fogwave"
|
private const val REPOSITORY_URL = "https://git.skysparkle.cc/kalarina/Fogwave"
|
||||||
@@ -48,92 +60,47 @@ fun AboutPanel(modifier: Modifier = Modifier) {
|
|||||||
Column(
|
Column(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(horizontal = 20.dp, vertical = 12.dp),
|
.padding(horizontal = 20.dp, vertical = 8.dp),
|
||||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
verticalArrangement = Arrangement.spacedBy(10.dp)
|
||||||
) {
|
) {
|
||||||
Column(
|
AppHeader()
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.shadow(4.dp, RoundedCornerShape(24.dp))
|
|
||||||
.clip(RoundedCornerShape(24.dp))
|
|
||||||
.background(LocalGeoColors.current.surfaceContainer)
|
|
||||||
.border(1.dp, LocalGeoColors.current.outlineVariant, RoundedCornerShape(24.dp))
|
|
||||||
.padding(20.dp),
|
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
|
||||||
verticalArrangement = Arrangement.spacedBy(10.dp)
|
|
||||||
) {
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.size(64.dp)
|
|
||||||
.clip(RoundedCornerShape(20.dp)),
|
|
||||||
contentAlignment = Alignment.Center
|
|
||||||
) {
|
|
||||||
AppIcon(
|
|
||||||
resId = R.drawable.ic_fogwave_logo,
|
|
||||||
contentDescription = stringResource(R.string.fogwave_logo_content_desc),
|
|
||||||
size = 52.dp
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
Text(
|
SectionLabel(stringResource(R.string.about_appearance))
|
||||||
text = stringResource(R.string.app_name),
|
GroupCard {
|
||||||
style = MaterialTheme.typography.titleLarge.copy(
|
StylePicker()
|
||||||
fontWeight = FontWeight.ExtraBold,
|
CardDivider()
|
||||||
fontSize = 22.sp,
|
StationFogRow()
|
||||||
letterSpacing = (-0.5).sp,
|
|
||||||
color = LocalGeoColors.current.deepPurple
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
// Comes straight from versionName in app/build.gradle.kts, so it can never drift.
|
|
||||||
Text(
|
|
||||||
text = stringResource(R.string.about_version, BuildConfig.VERSION_NAME),
|
|
||||||
style = MaterialTheme.typography.labelMedium.copy(
|
|
||||||
fontWeight = FontWeight.SemiBold,
|
|
||||||
color = LocalGeoColors.current.primary
|
|
||||||
),
|
|
||||||
modifier = Modifier.testTag("about_version")
|
|
||||||
)
|
|
||||||
|
|
||||||
Text(
|
|
||||||
text = stringResource(R.string.about_description),
|
|
||||||
style = MaterialTheme.typography.bodyMedium.copy(
|
|
||||||
fontSize = 13.5.sp,
|
|
||||||
lineHeight = 20.sp,
|
|
||||||
color = LocalGeoColors.current.onSurfaceVariant,
|
|
||||||
textAlign = TextAlign.Center
|
|
||||||
),
|
|
||||||
modifier = Modifier.padding(top = 4.dp)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AboutLinkCard(
|
SectionLabel(stringResource(R.string.about_more))
|
||||||
iconRes = R.drawable.ic_repo,
|
GroupCard {
|
||||||
iconTint = null,
|
LinkRow(
|
||||||
title = stringResource(R.string.about_my_repository),
|
iconRes = R.drawable.ic_mc_code,
|
||||||
subtitle = REPOSITORY_URL.removePrefix("https://git.skysparkle.cc/"),
|
title = stringResource(R.string.about_my_repository),
|
||||||
trailingIconRes = R.drawable.ic_open_in_new,
|
subtitle = REPOSITORY_URL.removePrefix("https://"),
|
||||||
onClick = { context.openUrl(REPOSITORY_URL) },
|
external = true,
|
||||||
modifier = Modifier.testTag("github_repo_card")
|
onClick = { context.openUrl(REPOSITORY_URL) },
|
||||||
)
|
modifier = Modifier.testTag("github_repo_card")
|
||||||
|
)
|
||||||
AboutLinkCard(
|
CardDivider()
|
||||||
iconRes = R.drawable.ic_privacy,
|
LinkRow(
|
||||||
title = stringResource(R.string.privacy_title),
|
iconRes = R.drawable.ic_mc_shield,
|
||||||
subtitle = stringResource(R.string.privacy_subtitle),
|
title = stringResource(R.string.privacy_title),
|
||||||
trailingIconRes = R.drawable.ic_open_in_new,
|
subtitle = stringResource(R.string.privacy_subtitle),
|
||||||
onClick = { context.openUrl(PRIVACY_POLICY_URL) },
|
external = true,
|
||||||
modifier = Modifier.testTag("privacy_card")
|
onClick = { context.openUrl(PRIVACY_POLICY_URL) },
|
||||||
)
|
modifier = Modifier.testTag("privacy_card")
|
||||||
|
)
|
||||||
AboutLinkCard(
|
CardDivider()
|
||||||
iconRes = R.drawable.ic_copyright,
|
LinkRow(
|
||||||
title = stringResource(R.string.licenses_title),
|
iconRes = R.drawable.ic_mc_copyright,
|
||||||
subtitle = stringResource(R.string.licenses_subtitle),
|
title = stringResource(R.string.licenses_title),
|
||||||
trailingIconRes = R.drawable.ic_chevron_right,
|
subtitle = stringResource(R.string.licenses_subtitle),
|
||||||
onClick = { showLicenses = true },
|
external = false,
|
||||||
modifier = Modifier.testTag("licenses_card")
|
onClick = { showLicenses = true },
|
||||||
)
|
modifier = Modifier.testTag("licenses_card")
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showLicenses) {
|
if (showLicenses) {
|
||||||
@@ -141,86 +108,324 @@ fun AboutPanel(modifier: Modifier = Modifier) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Logo, name and version in one row, the description underneath. */
|
||||||
@Composable
|
@Composable
|
||||||
private fun AboutLinkCard(
|
private fun AppHeader() {
|
||||||
@DrawableRes iconRes: Int,
|
val colors = LocalGeoColors.current
|
||||||
title: String,
|
GroupCard(contentPadding = 16.dp) {
|
||||||
subtitle: String,
|
Row(
|
||||||
@DrawableRes trailingIconRes: Int,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
onClick: () -> Unit,
|
horizontalArrangement = Arrangement.spacedBy(14.dp)
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
iconTint: Color? = LocalGeoColors.current.deepPurple
|
|
||||||
) {
|
|
||||||
val opensBrowser = trailingIconRes == R.drawable.ic_open_in_new
|
|
||||||
Row(
|
|
||||||
modifier = modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.shadow(4.dp, RoundedCornerShape(20.dp))
|
|
||||||
.clip(RoundedCornerShape(20.dp))
|
|
||||||
.background(LocalGeoColors.current.surfaceContainer)
|
|
||||||
.border(1.2.dp, LocalGeoColors.current.outlineVariant, RoundedCornerShape(20.dp))
|
|
||||||
.clickable(
|
|
||||||
onClickLabel = if (opensBrowser) stringResource(R.string.about_open_in_browser) else null,
|
|
||||||
role = Role.Button,
|
|
||||||
onClick = onClick
|
|
||||||
)
|
|
||||||
.padding(16.dp),
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(14.dp)
|
|
||||||
) {
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.size(48.dp)
|
|
||||||
.clip(RoundedCornerShape(14.dp))
|
|
||||||
.background(LocalGeoColors.current.primaryContainer)
|
|
||||||
.border(1.dp, LocalGeoColors.current.outlineVariant, RoundedCornerShape(14.dp)),
|
|
||||||
contentAlignment = Alignment.Center
|
|
||||||
) {
|
) {
|
||||||
AppIcon(
|
|
||||||
resId = iconRes,
|
|
||||||
tint = iconTint ?: Color.Unspecified,
|
|
||||||
size = if (iconTint == null) 32.dp else 26.dp
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
Column(modifier = Modifier.weight(1f)) {
|
|
||||||
Text(
|
|
||||||
text = title,
|
|
||||||
style = MaterialTheme.typography.titleSmall.copy(
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
fontSize = 15.sp,
|
|
||||||
color = LocalGeoColors.current.deepPurple
|
|
||||||
)
|
|
||||||
)
|
|
||||||
Text(
|
|
||||||
text = subtitle,
|
|
||||||
style = MaterialTheme.typography.bodySmall.copy(
|
|
||||||
fontSize = 12.sp,
|
|
||||||
color = LocalGeoColors.current.primary
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opensBrowser) {
|
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(36.dp)
|
.size(52.dp)
|
||||||
.clip(CircleShape)
|
.clip(RoundedCornerShape(16.dp))
|
||||||
.background(LocalGeoColors.current.primaryContainer),
|
.background(colors.primaryContainer),
|
||||||
contentAlignment = Alignment.Center
|
contentAlignment = Alignment.Center
|
||||||
) {
|
) {
|
||||||
AppIcon(
|
AppIcon(
|
||||||
resId = trailingIconRes,
|
resId = R.drawable.ic_fogwave_logo,
|
||||||
tint = LocalGeoColors.current.deepPurple,
|
contentDescription = stringResource(R.string.fogwave_logo_content_desc),
|
||||||
size = 18.dp
|
size = 40.dp
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
Column(verticalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||||
AppIcon(
|
Text(
|
||||||
resId = trailingIconRes,
|
text = stringResource(R.string.app_name),
|
||||||
tint = LocalGeoColors.current.onSurfaceVariant,
|
style = MaterialTheme.typography.titleLarge.copy(
|
||||||
size = 18.dp
|
fontWeight = FontWeight.ExtraBold,
|
||||||
|
fontSize = 21.sp,
|
||||||
|
letterSpacing = (-0.4).sp,
|
||||||
|
color = colors.deepPurple
|
||||||
|
)
|
||||||
|
)
|
||||||
|
// Comes straight from versionName in app/build.gradle.kts, so it can never drift.
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.about_version, BuildConfig.VERSION_NAME),
|
||||||
|
style = MaterialTheme.typography.labelSmall.copy(
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
fontSize = 11.sp,
|
||||||
|
color = colors.primary
|
||||||
|
),
|
||||||
|
modifier = Modifier
|
||||||
|
.clip(CircleShape)
|
||||||
|
.background(colors.primaryContainer)
|
||||||
|
.padding(horizontal = 9.dp, vertical = 3.dp)
|
||||||
|
.testTag("about_version")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.about_description),
|
||||||
|
style = MaterialTheme.typography.bodySmall.copy(
|
||||||
|
fontSize = 13.sp,
|
||||||
|
lineHeight = 19.sp,
|
||||||
|
color = colors.onSurfaceVariant
|
||||||
|
),
|
||||||
|
modifier = Modifier.padding(top = 12.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun StylePicker() {
|
||||||
|
val context = LocalContext.current
|
||||||
|
val colors = LocalGeoColors.current
|
||||||
|
val selected = AppThemeState.style
|
||||||
|
val styles = remember { AppStyle.available }
|
||||||
|
|
||||||
|
Column(modifier = Modifier.padding(16.dp)) {
|
||||||
|
RowHeader(iconRes = R.drawable.ic_mc_palette, title = stringResource(R.string.app_style_title))
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(top = 14.dp),
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(4.dp)
|
||||||
|
) {
|
||||||
|
styles.forEach { style ->
|
||||||
|
StyleSwatch(
|
||||||
|
style = style,
|
||||||
|
preview = remember(style) { AppThemeState.colorsFor(context, style) },
|
||||||
|
selected = style == selected,
|
||||||
|
onClick = { AppThemeState.select(context, style) },
|
||||||
|
modifier = Modifier.weight(1f)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AnimatedVisibility(visible = selected == AppStyle.DEVICE) {
|
||||||
|
Text(
|
||||||
|
text = stringResource(R.string.app_style_device_hint),
|
||||||
|
style = MaterialTheme.typography.bodySmall.copy(
|
||||||
|
fontSize = 12.sp,
|
||||||
|
lineHeight = 17.sp,
|
||||||
|
color = colors.onSurfaceVariant
|
||||||
|
),
|
||||||
|
modifier = Modifier.padding(top = 12.dp)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun StyleSwatch(
|
||||||
|
style: AppStyle,
|
||||||
|
preview: GeoColors,
|
||||||
|
selected: Boolean,
|
||||||
|
onClick: () -> Unit,
|
||||||
|
modifier: Modifier = Modifier
|
||||||
|
) {
|
||||||
|
val colors = LocalGeoColors.current
|
||||||
|
val ring by animateColorAsState(if (selected) colors.deepPurple else Color.Transparent, label = "swatch_ring")
|
||||||
|
|
||||||
|
Column(
|
||||||
|
modifier = modifier
|
||||||
|
.clip(RoundedCornerShape(14.dp))
|
||||||
|
.selectable(selected = selected, role = Role.RadioButton, onClick = onClick)
|
||||||
|
.padding(vertical = 6.dp)
|
||||||
|
.testTag("style_${style.name.lowercase()}"),
|
||||||
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
|
verticalArrangement = Arrangement.spacedBy(6.dp)
|
||||||
|
) {
|
||||||
|
// The outer ring shows the selection; inside, the style's accent over its background
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.size(42.dp)
|
||||||
|
.border(2.dp, ring, CircleShape)
|
||||||
|
.padding(4.dp)
|
||||||
|
.clip(CircleShape)
|
||||||
|
.background(preview.surfaceContainerHigh),
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
|
) {
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.size(24.dp)
|
||||||
|
.clip(CircleShape)
|
||||||
|
.background(preview.accentLavender),
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
|
) {
|
||||||
|
if (selected) {
|
||||||
|
AppIcon(resId = R.drawable.ic_mc_check, tint = preview.onAccentLavender, size = 15.dp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Text(
|
||||||
|
text = stringResource(style.titleRes),
|
||||||
|
style = MaterialTheme.typography.labelSmall.copy(
|
||||||
|
fontSize = 11.sp,
|
||||||
|
fontWeight = if (selected) FontWeight.Bold else FontWeight.Medium,
|
||||||
|
color = if (selected) colors.deepPurple else colors.onSurfaceVariant
|
||||||
|
),
|
||||||
|
maxLines = 1,
|
||||||
|
overflow = TextOverflow.Ellipsis
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun StationFogRow() {
|
||||||
|
val context = LocalContext.current
|
||||||
|
val colors = LocalGeoColors.current
|
||||||
|
val checked = AppThemeState.stationFog
|
||||||
|
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.toggleable(
|
||||||
|
value = checked,
|
||||||
|
role = Role.Switch,
|
||||||
|
onValueChange = { AppThemeState.setStationFog(context, it) }
|
||||||
|
)
|
||||||
|
.padding(16.dp)
|
||||||
|
.testTag("station_fog_toggle"),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(12.dp)
|
||||||
|
) {
|
||||||
|
RowIcon(R.drawable.ic_mc_fog)
|
||||||
|
Column(modifier = Modifier.weight(1f)) {
|
||||||
|
RowTitle(stringResource(R.string.station_fog_title))
|
||||||
|
RowSubtitle(stringResource(R.string.station_fog_subtitle), maxLines = 3)
|
||||||
|
}
|
||||||
|
// The row handles the tap, so the switch itself only shows the state
|
||||||
|
Switch(
|
||||||
|
checked = checked,
|
||||||
|
onCheckedChange = null,
|
||||||
|
colors = SwitchDefaults.colors(
|
||||||
|
checkedThumbColor = colors.onAccentLavender,
|
||||||
|
checkedTrackColor = colors.accentLavender,
|
||||||
|
checkedBorderColor = colors.accentLavender,
|
||||||
|
uncheckedThumbColor = colors.onSurfaceVariant,
|
||||||
|
uncheckedTrackColor = colors.surfaceContainerHigh,
|
||||||
|
uncheckedBorderColor = colors.outline
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun LinkRow(
|
||||||
|
@DrawableRes iconRes: Int,
|
||||||
|
title: String,
|
||||||
|
subtitle: String,
|
||||||
|
external: Boolean,
|
||||||
|
onClick: () -> Unit,
|
||||||
|
modifier: Modifier = Modifier
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
modifier = modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.clickable(
|
||||||
|
onClickLabel = if (external) stringResource(R.string.about_open_in_browser) else null,
|
||||||
|
role = Role.Button,
|
||||||
|
onClick = onClick
|
||||||
|
)
|
||||||
|
.padding(horizontal = 16.dp, vertical = 13.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(12.dp)
|
||||||
|
) {
|
||||||
|
RowIcon(iconRes)
|
||||||
|
Column(modifier = Modifier.weight(1f)) {
|
||||||
|
RowTitle(title)
|
||||||
|
RowSubtitle(subtitle)
|
||||||
|
}
|
||||||
|
AppIcon(
|
||||||
|
resId = if (external) R.drawable.ic_mc_external else R.drawable.ic_mc_right,
|
||||||
|
tint = LocalGeoColors.current.onSurfaceVariant,
|
||||||
|
size = 18.dp
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun RowHeader(@DrawableRes iconRes: Int, title: String) {
|
||||||
|
Row(
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(12.dp)
|
||||||
|
) {
|
||||||
|
RowIcon(iconRes)
|
||||||
|
RowTitle(title)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun RowIcon(@DrawableRes iconRes: Int) {
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.size(36.dp)
|
||||||
|
.clip(RoundedCornerShape(11.dp))
|
||||||
|
.background(LocalGeoColors.current.primaryContainer),
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
|
) {
|
||||||
|
AppIcon(resId = iconRes, tint = LocalGeoColors.current.primary, size = 20.dp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun RowTitle(text: String) {
|
||||||
|
Text(
|
||||||
|
text = text,
|
||||||
|
style = MaterialTheme.typography.titleSmall.copy(
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
fontSize = 14.5.sp,
|
||||||
|
color = LocalGeoColors.current.deepPurple
|
||||||
|
),
|
||||||
|
maxLines = 1,
|
||||||
|
overflow = TextOverflow.Ellipsis
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun RowSubtitle(text: String, maxLines: Int = 1) {
|
||||||
|
Text(
|
||||||
|
text = text,
|
||||||
|
style = MaterialTheme.typography.bodySmall.copy(
|
||||||
|
fontSize = 12.sp,
|
||||||
|
lineHeight = 16.sp,
|
||||||
|
color = LocalGeoColors.current.onSurfaceVariant
|
||||||
|
),
|
||||||
|
maxLines = maxLines,
|
||||||
|
overflow = TextOverflow.Ellipsis
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun SectionLabel(text: String) {
|
||||||
|
Text(
|
||||||
|
text = text.uppercase(),
|
||||||
|
style = MaterialTheme.typography.labelSmall.copy(
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
fontSize = 11.sp,
|
||||||
|
letterSpacing = 1.2.sp,
|
||||||
|
color = LocalGeoColors.current.onSurfaceVariant
|
||||||
|
),
|
||||||
|
modifier = Modifier.padding(start = 6.dp, top = 8.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Rows grouped on one rounded card, like a settings list. */
|
||||||
|
@Composable
|
||||||
|
private fun GroupCard(
|
||||||
|
contentPadding: Dp = 0.dp,
|
||||||
|
content: @Composable ColumnScope.() -> Unit
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.clip(RoundedCornerShape(22.dp))
|
||||||
|
.background(LocalGeoColors.current.surfaceContainer)
|
||||||
|
.border(1.dp, LocalGeoColors.current.outlineVariant, RoundedCornerShape(22.dp))
|
||||||
|
.padding(contentPadding),
|
||||||
|
content = content
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun CardDivider() {
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(start = 64.dp)
|
||||||
|
.height(1.dp)
|
||||||
|
.background(LocalGeoColors.current.outlineVariant)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ fun EqualizerSheet(
|
|||||||
) {
|
) {
|
||||||
val db = (band.levelMillibel / 100f).roundToInt()
|
val db = (band.levelMillibel / 100f).roundToInt()
|
||||||
Text(
|
Text(
|
||||||
text = if (db > 0) "+$db dB" else "$db dB",
|
text = stringResource(R.string.eq_gain_db, if (db > 0) "+$db" else "$db"),
|
||||||
style = MaterialTheme.typography.labelSmall.copy(
|
style = MaterialTheme.typography.labelSmall.copy(
|
||||||
fontSize = 11.sp,
|
fontSize = 11.sp,
|
||||||
fontWeight = FontWeight.SemiBold,
|
fontWeight = FontWeight.SemiBold,
|
||||||
@@ -356,10 +356,11 @@ private fun ToggleRow(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
private fun frequencyLabel(hz: Int): String = when {
|
private fun frequencyLabel(hz: Int): String = when {
|
||||||
hz < 1000 -> "$hz Hz"
|
hz < 1000 -> stringResource(R.string.eq_freq_hz, hz.toString())
|
||||||
hz % 1000 == 0 -> "${hz / 1000} kHz"
|
hz % 1000 == 0 -> stringResource(R.string.eq_freq_khz, (hz / 1000).toString())
|
||||||
else -> String.format(Locale.getDefault(), "%.1f kHz", hz / 1000f)
|
else -> stringResource(R.string.eq_freq_khz, String.format(Locale.getDefault(), "%.1f", hz / 1000f))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preset names come from the device's audio framework in English; translate the standard ones.
|
// Preset names come from the device's audio framework in English; translate the standard ones.
|
||||||
|
|||||||
@@ -6,11 +6,12 @@ import androidx.compose.animation.core.animateFloat
|
|||||||
import androidx.compose.animation.core.infiniteRepeatable
|
import androidx.compose.animation.core.infiniteRepeatable
|
||||||
import androidx.compose.animation.core.rememberInfiniteTransition
|
import androidx.compose.animation.core.rememberInfiniteTransition
|
||||||
import androidx.compose.animation.core.tween
|
import androidx.compose.animation.core.tween
|
||||||
import androidx.compose.foundation.Canvas
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clipToBounds
|
import androidx.compose.ui.draw.clipToBounds
|
||||||
|
import androidx.compose.ui.draw.drawWithCache
|
||||||
import androidx.compose.ui.draw.drawWithContent
|
import androidx.compose.ui.draw.drawWithContent
|
||||||
import androidx.compose.ui.geometry.Offset
|
import androidx.compose.ui.geometry.Offset
|
||||||
import androidx.compose.ui.graphics.BlendMode
|
import androidx.compose.ui.graphics.BlendMode
|
||||||
@@ -18,6 +19,7 @@ import androidx.compose.ui.graphics.Brush
|
|||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.CompositingStrategy
|
import androidx.compose.ui.graphics.CompositingStrategy
|
||||||
import androidx.compose.ui.graphics.drawscope.DrawScope
|
import androidx.compose.ui.graphics.drawscope.DrawScope
|
||||||
|
import androidx.compose.ui.graphics.drawscope.translate
|
||||||
import androidx.compose.ui.graphics.graphicsLayer
|
import androidx.compose.ui.graphics.graphicsLayer
|
||||||
import androidx.compose.ui.graphics.lerp
|
import androidx.compose.ui.graphics.lerp
|
||||||
import kotlin.math.PI
|
import kotlin.math.PI
|
||||||
@@ -47,56 +49,91 @@ private val Wisps = listOf(
|
|||||||
/**
|
/**
|
||||||
* Slowly drifting colored fog — Fogwave's signature backdrop. [tint] is usually the playing
|
* Slowly drifting colored fog — Fogwave's signature backdrop. [tint] is usually the playing
|
||||||
* station's color. Only the draw phase reads the animation, so the fog never recomposes anything.
|
* station's color. Only the draw phase reads the animation, so the fog never recomposes anything.
|
||||||
|
* With [animate] off (the layer is covered, e.g. by the open player) the fog holds still and the
|
||||||
|
* animation stops; it resumes from the same spot.
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun FogLayer(
|
fun FogLayer(
|
||||||
tint: Color,
|
tint: Color,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
intensity: Float = 1f
|
intensity: Float = 1f,
|
||||||
|
animate: Boolean = true
|
||||||
) {
|
) {
|
||||||
val transition = rememberInfiniteTransition(label = "fog")
|
// Last drawn time and breathing, so a paused fog stays put and resumes without a jump.
|
||||||
val t by transition.animateFloat(
|
val last = remember { floatArrayOf(0f, 1f) }
|
||||||
initialValue = 0f,
|
|
||||||
targetValue = (2 * PI).toFloat(),
|
|
||||||
animationSpec = infiniteRepeatable(tween(28_000, easing = LinearEasing), RepeatMode.Restart),
|
|
||||||
label = "fog_t"
|
|
||||||
)
|
|
||||||
val breathe by transition.animateFloat(
|
|
||||||
initialValue = 0.85f,
|
|
||||||
targetValue = 1f,
|
|
||||||
animationSpec = infiniteRepeatable(tween(6_000), RepeatMode.Reverse),
|
|
||||||
label = "fog_breathe"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Wisps are larger than the layer; clipping keeps them from leaking past its edges.
|
if (animate) {
|
||||||
Canvas(modifier = modifier.clipToBounds()) {
|
val transition = rememberInfiniteTransition(label = "fog")
|
||||||
Wisps.forEach { wisp -> drawWisp(wisp, t, breathe * intensity, tint) }
|
val t = transition.animateFloat(
|
||||||
|
initialValue = 0f,
|
||||||
|
targetValue = TWO_PI,
|
||||||
|
animationSpec = infiniteRepeatable(tween(28_000, easing = LinearEasing), RepeatMode.Restart),
|
||||||
|
label = "fog_t"
|
||||||
|
)
|
||||||
|
val breathe = transition.animateFloat(
|
||||||
|
initialValue = 0.85f,
|
||||||
|
targetValue = 1f,
|
||||||
|
animationSpec = infiniteRepeatable(tween(6_000), RepeatMode.Reverse),
|
||||||
|
label = "fog_breathe"
|
||||||
|
)
|
||||||
|
// The transition restarts from 0 each time; continue from where the fog was paused.
|
||||||
|
val start = remember { last[0] }
|
||||||
|
FogCanvas(tint, intensity, last, modifier) {
|
||||||
|
last[0] = (start + t.value) % TWO_PI
|
||||||
|
last[1] = breathe.value
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
FogCanvas(tint, intensity, last, modifier) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun DrawScope.drawWisp(wisp: Wisp, time: Float, intensity: Float, tint: Color) {
|
@Composable
|
||||||
val unit = max(size.width, size.height)
|
private fun FogCanvas(
|
||||||
val center = Offset(
|
tint: Color,
|
||||||
x = size.width * (wisp.x + wisp.dx * sin(time + wisp.phase)),
|
intensity: Float,
|
||||||
y = size.height * (wisp.y + wisp.dy * cos(time * 2f + wisp.phase))
|
last: FloatArray,
|
||||||
|
modifier: Modifier,
|
||||||
|
advance: () -> Unit
|
||||||
|
) {
|
||||||
|
// Wisps are larger than the layer; clipping keeps them from leaking past its edges.
|
||||||
|
Spacer(
|
||||||
|
modifier = modifier.clipToBounds().drawWithCache {
|
||||||
|
// The gradients only depend on the size, tint and intensity; a frame just moves them.
|
||||||
|
val unit = max(size.width, size.height)
|
||||||
|
val brushes = Wisps.map { wisp -> wispBrush(wisp, unit, tint, intensity) }
|
||||||
|
onDrawBehind {
|
||||||
|
// Reads the animation here, in the draw phase, so only drawing repeats per frame.
|
||||||
|
advance()
|
||||||
|
Wisps.forEachIndexed { i, wisp -> drawWisp(wisp, brushes[i], unit, last[0], last[1]) }
|
||||||
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
val radius = unit * wisp.radius
|
}
|
||||||
|
|
||||||
|
private const val TWO_PI = (2 * PI).toFloat()
|
||||||
|
|
||||||
|
private fun wispBrush(wisp: Wisp, unit: Float, tint: Color, intensity: Float): Brush {
|
||||||
// Part of the mist is paler, so the fog is not a flat single-color glow.
|
// Part of the mist is paler, so the fog is not a flat single-color glow.
|
||||||
val color = lerp(tint, Color(0xFFDDE6FF), wisp.mix)
|
val color = lerp(tint, Color(0xFFDDE6FF), wisp.mix)
|
||||||
val a = (wisp.alpha * intensity).coerceIn(0f, 1f)
|
val a = (wisp.alpha * intensity).coerceIn(0f, 1f)
|
||||||
drawCircle(
|
// Centered at the origin; drawWisp moves it into place.
|
||||||
brush = Brush.radialGradient(
|
return Brush.radialGradient(
|
||||||
0f to color.copy(alpha = a),
|
0f to color.copy(alpha = a),
|
||||||
0.45f to color.copy(alpha = a * 0.35f),
|
0.45f to color.copy(alpha = a * 0.35f),
|
||||||
1f to Color.Transparent,
|
1f to Color.Transparent,
|
||||||
center = center,
|
center = Offset.Zero,
|
||||||
radius = radius
|
radius = unit * wisp.radius
|
||||||
),
|
|
||||||
radius = radius,
|
|
||||||
center = center
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun DrawScope.drawWisp(wisp: Wisp, brush: Brush, unit: Float, time: Float, breathe: Float) {
|
||||||
|
val cx = size.width * (wisp.x + wisp.dx * sin(time + wisp.phase))
|
||||||
|
val cy = size.height * (wisp.y + wisp.dy * cos(time * 2f + wisp.phase))
|
||||||
|
translate(cx, cy) {
|
||||||
|
drawCircle(brush = brush, radius = unit * wisp.radius, center = Offset.Zero, alpha = breathe)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Fades the content to transparent towards the bottom, starting at [from] of its height. */
|
/** Fades the content to transparent towards the bottom, starting at [from] of its height. */
|
||||||
fun Modifier.fadeOutBottom(from: Float = 0.55f): Modifier = this
|
fun Modifier.fadeOutBottom(from: Float = 0.55f): Modifier = this
|
||||||
.clipToBounds()
|
.clipToBounds()
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package cc.skysparkle.fogwave.ui.components
|
package cc.skysparkle.fogwave.ui.components
|
||||||
|
|
||||||
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
@@ -15,33 +16,24 @@ import androidx.compose.ui.graphics.ColorFilter
|
|||||||
import androidx.compose.ui.graphics.ColorMatrix
|
import androidx.compose.ui.graphics.ColorMatrix
|
||||||
import androidx.compose.ui.graphics.graphicsLayer
|
import androidx.compose.ui.graphics.graphicsLayer
|
||||||
import androidx.compose.ui.layout.ContentScale
|
import androidx.compose.ui.layout.ContentScale
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import cc.skysparkle.fogwave.R
|
import cc.skysparkle.fogwave.R
|
||||||
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.Scale
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Misty peak at the top of the home screen with drifting fog in the playing station's color.
|
* Misty peak at the top of the home screen with drifting fog in the playing station's color.
|
||||||
|
* [animate] is turned off while the home screen is covered, so the hidden fog does not keep drawing.
|
||||||
* [visibility] is read in the draw phase (0 = gone, 1 = fully shown) so scrolling never recomposes it.
|
* [visibility] is read in the draw phase (0 = gone, 1 = fully shown) so scrolling never recomposes it.
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun HomeBackdrop(
|
fun HomeBackdrop(
|
||||||
tint: Color,
|
tint: Color,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
|
animate: Boolean = true,
|
||||||
visibility: () -> Float = { 1f }
|
visibility: () -> Float = { 1f }
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
|
||||||
val background = LocalGeoColors.current.background
|
val background = LocalGeoColors.current.background
|
||||||
val request = remember(context) {
|
|
||||||
ImageRequest.Builder(context)
|
|
||||||
.data(R.drawable.bg_misty_mountain)
|
|
||||||
.scale(Scale.FILL)
|
|
||||||
.crossfade(300)
|
|
||||||
.build()
|
|
||||||
}
|
|
||||||
// Cool, slightly desaturated photo so the colored fog and the UI stay in front.
|
// Cool, slightly desaturated photo so the colored fog and the UI stay in front.
|
||||||
val muted = remember {
|
val muted = remember {
|
||||||
ColorFilter.colorMatrix(ColorMatrix().apply { setToSaturation(0.35f) })
|
ColorFilter.colorMatrix(ColorMatrix().apply { setToSaturation(0.35f) })
|
||||||
@@ -55,8 +47,8 @@ fun HomeBackdrop(
|
|||||||
// Everything (photo and fog) melts into the page instead of ending at a hard edge.
|
// Everything (photo and fog) melts into the page instead of ending at a hard edge.
|
||||||
.fadeOutBottom(from = 0.45f)
|
.fadeOutBottom(from = 0.45f)
|
||||||
) {
|
) {
|
||||||
AsyncImage(
|
Image(
|
||||||
model = request,
|
painter = painterResource(R.drawable.bg_misty_mountain),
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
contentScale = ContentScale.Crop,
|
contentScale = ContentScale.Crop,
|
||||||
alignment = Alignment.TopCenter,
|
alignment = Alignment.TopCenter,
|
||||||
@@ -64,7 +56,7 @@ fun HomeBackdrop(
|
|||||||
alpha = 0.5f,
|
alpha = 0.5f,
|
||||||
modifier = Modifier.fillMaxSize()
|
modifier = Modifier.fillMaxSize()
|
||||||
)
|
)
|
||||||
FogLayer(tint = tint, intensity = 0.6f, modifier = Modifier.fillMaxSize())
|
FogLayer(tint = tint, intensity = 0.6f, animate = animate, modifier = Modifier.fillMaxSize())
|
||||||
// Darker top keeps the header readable over the photo.
|
// Darker top keeps the header readable over the photo.
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|||||||
@@ -50,9 +50,7 @@ private val LIBRARIES = listOf(
|
|||||||
LicenseRow("AndroidX \u2014 other libraries pulled in by the ones above", AOSP, APACHE, "https://developer.android.com/jetpack/androidx"),
|
LicenseRow("AndroidX \u2014 other libraries pulled in by the ones above", AOSP, APACHE, "https://developer.android.com/jetpack/androidx"),
|
||||||
LicenseRow("Guava (used by Media3)", "Google", APACHE, "https://github.com/google/guava"),
|
LicenseRow("Guava (used by Media3)", "Google", APACHE, "https://github.com/google/guava"),
|
||||||
LicenseRow("kotlinx.coroutines", "JetBrains", APACHE, "https://github.com/Kotlin/kotlinx.coroutines", BuildConfig.COROUTINES_VERSION),
|
LicenseRow("kotlinx.coroutines", "JetBrains", APACHE, "https://github.com/Kotlin/kotlinx.coroutines", BuildConfig.COROUTINES_VERSION),
|
||||||
LicenseRow("Kotlin Standard Library", "JetBrains", APACHE, "https://github.com/JetBrains/kotlin", BuildConfig.KOTLIN_VERSION),
|
LicenseRow("Kotlin Standard Library", "JetBrains", APACHE, "https://github.com/JetBrains/kotlin", BuildConfig.KOTLIN_VERSION)
|
||||||
LicenseRow("Coil", "Coil Contributors", APACHE, "https://github.com/coil-kt/coil", BuildConfig.COIL_VERSION),
|
|
||||||
LicenseRow("OkHttp & Okio (used by Coil)", "Square, Inc.", APACHE, "https://square.github.io/okhttp/")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
private val ASSETS = listOf(
|
private val ASSETS = listOf(
|
||||||
@@ -69,7 +67,11 @@ private val STATIONS = listOf(
|
|||||||
LicenseRow("M-1", "M-1 group", BROADCASTER, "https://www.m-1.fm/"),
|
LicenseRow("M-1", "M-1 group", BROADCASTER, "https://www.m-1.fm/"),
|
||||||
LicenseRow("M-1 Plius", "M-1 group", BROADCASTER, "https://www.m-1.fm/"),
|
LicenseRow("M-1 Plius", "M-1 group", BROADCASTER, "https://www.m-1.fm/"),
|
||||||
LicenseRow("Gold FM", "Gold FM", BROADCASTER, "https://www.goldfm.lt/"),
|
LicenseRow("Gold FM", "Gold FM", BROADCASTER, "https://www.goldfm.lt/"),
|
||||||
LicenseRow("RC", "Radiocentras group", BROADCASTER, "https://www.rc.lt/")
|
LicenseRow("RC", "Radiocentras group", BROADCASTER, "https://www.rc.lt/"),
|
||||||
|
LicenseRow("LRT Radijas", "Lietuvos nacionalinis radijas ir televizija (LRT)", BROADCASTER, "https://www.lrt.lt/"),
|
||||||
|
LicenseRow("\u017Dini\u0173 radijas", "\u017Dini\u0173 radijas, UAB", BROADCASTER, "https://www.ziniuradijas.lt/"),
|
||||||
|
LicenseRow("Latvijas Radio 1", "Latvijas Sabiedriskais medijs (LSM)", BROADCASTER, "https://latvijasradio.lsm.lv/"),
|
||||||
|
LicenseRow("Latvijas Radio 2", "Latvijas Sabiedriskais medijs (LSM)", BROADCASTER, "https://latvijasradio.lsm.lv/")
|
||||||
)
|
)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import androidx.compose.ui.graphics.graphicsLayer
|
|||||||
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.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.semantics.Role
|
||||||
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
|
||||||
import androidx.compose.ui.unit.IntOffset
|
import androidx.compose.ui.unit.IntOffset
|
||||||
@@ -194,7 +195,7 @@ fun MiniPlayer(
|
|||||||
.shadow(6.dp, CircleShape)
|
.shadow(6.dp, CircleShape)
|
||||||
.clip(CircleShape)
|
.clip(CircleShape)
|
||||||
.background(colors.accentLavender)
|
.background(colors.accentLavender)
|
||||||
.clickable { onTogglePlay() }
|
.clickable(role = Role.Button) { onTogglePlay() }
|
||||||
.testTag("mini_play_btn"),
|
.testTag("mini_play_btn"),
|
||||||
contentAlignment = Alignment.Center
|
contentAlignment = Alignment.Center
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ import androidx.compose.ui.platform.LocalContext
|
|||||||
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.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.semantics.Role
|
||||||
import androidx.compose.ui.semantics.contentDescription
|
import androidx.compose.ui.semantics.contentDescription
|
||||||
import androidx.compose.ui.semantics.semantics
|
import androidx.compose.ui.semantics.semantics
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
@@ -77,6 +78,7 @@ 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.AudioEffectsState
|
||||||
import cc.skysparkle.fogwave.player.PlayerState
|
import cc.skysparkle.fogwave.player.PlayerState
|
||||||
|
import cc.skysparkle.fogwave.ui.theme.AppThemeState
|
||||||
import cc.skysparkle.fogwave.ui.theme.LocalGeoColors
|
import cc.skysparkle.fogwave.ui.theme.LocalGeoColors
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
@@ -120,7 +122,7 @@ fun NowPlayingSheet(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
val accent by animateColorAsState(
|
val accent by animateColorAsState(
|
||||||
targetValue = rememberStationArt(station).accentOr(colors.accentLavender),
|
targetValue = rememberStationArt(station).takeIf { AppThemeState.stationFog }.accentOr(colors.accentLavender),
|
||||||
animationSpec = tween(700),
|
animationSpec = tween(700),
|
||||||
label = "page_accent"
|
label = "page_accent"
|
||||||
)
|
)
|
||||||
@@ -352,7 +354,7 @@ fun NowPlayingSheet(
|
|||||||
.shadow(14.dp, CircleShape, ambientColor = colors.accentLavender, spotColor = colors.accentLavender)
|
.shadow(14.dp, CircleShape, ambientColor = colors.accentLavender, spotColor = colors.accentLavender)
|
||||||
.clip(CircleShape)
|
.clip(CircleShape)
|
||||||
.background(colors.accentLavender)
|
.background(colors.accentLavender)
|
||||||
.clickable { onTogglePlay() }
|
.clickable(role = Role.Button) { onTogglePlay() }
|
||||||
.testTag("np_play_btn"),
|
.testTag("np_play_btn"),
|
||||||
contentAlignment = Alignment.Center
|
contentAlignment = Alignment.Center
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import androidx.compose.ui.res.painterResource
|
|||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import cc.skysparkle.fogwave.data.model.RadioStation
|
import cc.skysparkle.fogwave.data.model.RadioStation
|
||||||
|
import cc.skysparkle.fogwave.ui.theme.AppThemeState
|
||||||
import cc.skysparkle.fogwave.ui.theme.LocalGeoColors
|
import cc.skysparkle.fogwave.ui.theme.LocalGeoColors
|
||||||
import kotlin.math.cos
|
import kotlin.math.cos
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
@@ -56,7 +57,7 @@ fun StationDisc(
|
|||||||
val colors = LocalGeoColors.current
|
val colors = LocalGeoColors.current
|
||||||
val art = rememberStationArt(station)
|
val art = rememberStationArt(station)
|
||||||
val accent by animateColorAsState(
|
val accent by animateColorAsState(
|
||||||
targetValue = art.accentOr(colors.primary),
|
targetValue = art.takeIf { AppThemeState.stationFog }.accentOr(colors.primary),
|
||||||
animationSpec = tween(600),
|
animationSpec = tween(600),
|
||||||
label = "disc_accent"
|
label = "disc_accent"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ import cc.skysparkle.fogwave.ui.components.TopBrandBar
|
|||||||
import cc.skysparkle.fogwave.ui.components.accentOr
|
import cc.skysparkle.fogwave.ui.components.accentOr
|
||||||
import cc.skysparkle.fogwave.ui.components.rememberStationArt
|
import cc.skysparkle.fogwave.ui.components.rememberStationArt
|
||||||
import cc.skysparkle.fogwave.ui.components.stationDescription
|
import cc.skysparkle.fogwave.ui.components.stationDescription
|
||||||
|
import cc.skysparkle.fogwave.ui.theme.AppThemeState
|
||||||
import cc.skysparkle.fogwave.ui.theme.LocalGeoColors
|
import cc.skysparkle.fogwave.ui.theme.LocalGeoColors
|
||||||
import cc.skysparkle.fogwave.ui.viewmodel.RadioViewModel
|
import cc.skysparkle.fogwave.ui.viewmodel.RadioViewModel
|
||||||
|
|
||||||
@@ -116,7 +117,10 @@ fun HomeScreen(
|
|||||||
|
|
||||||
val radioListState = rememberLazyListState()
|
val radioListState = rememberLazyListState()
|
||||||
val accent by animateColorAsState(
|
val accent by animateColorAsState(
|
||||||
targetValue = uiState.currentStation?.let { rememberStationArt(it) }.accentOr(LocalGeoColors.current.accentLavender),
|
// The style's colour unless the user asked for each station's own
|
||||||
|
targetValue = uiState.currentStation?.let { rememberStationArt(it) }
|
||||||
|
.takeIf { AppThemeState.stationFog }
|
||||||
|
.accentOr(LocalGeoColors.current.accentLavender),
|
||||||
animationSpec = tween(700),
|
animationSpec = tween(700),
|
||||||
label = "home_accent"
|
label = "home_accent"
|
||||||
)
|
)
|
||||||
@@ -132,6 +136,8 @@ fun HomeScreen(
|
|||||||
) {
|
) {
|
||||||
HomeBackdrop(
|
HomeBackdrop(
|
||||||
tint = accent,
|
tint = accent,
|
||||||
|
// Covered by the open player; no need to keep animating fog nobody sees.
|
||||||
|
animate = !uiState.isNowPlayingOpen,
|
||||||
visibility = {
|
visibility = {
|
||||||
if (uiState.selectedTab != AppTab.RADIO) {
|
if (uiState.selectedTab != AppTab.RADIO) {
|
||||||
0.55f
|
0.55f
|
||||||
|
|||||||
@@ -0,0 +1,126 @@
|
|||||||
|
package cc.skysparkle.fogwave.ui.theme
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.os.Build
|
||||||
|
import androidx.annotation.StringRes
|
||||||
|
import androidx.compose.material3.dynamicDarkColorScheme
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.graphics.lerp
|
||||||
|
import cc.skysparkle.fogwave.R
|
||||||
|
|
||||||
|
/** Colour styles, the same set as in Matewave. Every style is dark. */
|
||||||
|
enum class AppStyle(@param:StringRes val titleRes: Int) {
|
||||||
|
FOGWAVE(R.string.app_style_fogwave),
|
||||||
|
LAVENDER(R.string.app_style_lavender),
|
||||||
|
PEACH(R.string.app_style_peach),
|
||||||
|
MINT(R.string.app_style_mint),
|
||||||
|
SKY(R.string.app_style_sky),
|
||||||
|
DEVICE(R.string.app_style_device);
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
/** Wallpaper colours exist from Android 12. */
|
||||||
|
val deviceSupported: Boolean get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
|
||||||
|
|
||||||
|
val available: List<AppStyle> get() = entries.filter { it != DEVICE || deviceSupported }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The selected style, kept in compose state so every screen recolours at once. */
|
||||||
|
object AppThemeState {
|
||||||
|
private const val PREFS = "app_theme"
|
||||||
|
private const val KEY_STYLE = "style"
|
||||||
|
private const val KEY_STATION_FOG = "station_fog"
|
||||||
|
|
||||||
|
var style by mutableStateOf(AppStyle.FOGWAVE)
|
||||||
|
private set
|
||||||
|
|
||||||
|
var colors by mutableStateOf(DarkGeoColors)
|
||||||
|
private set
|
||||||
|
|
||||||
|
/** Fog and the disc ring take the playing station's colour instead of the style's. */
|
||||||
|
var stationFog by mutableStateOf(false)
|
||||||
|
private set
|
||||||
|
|
||||||
|
/** Reads the saved settings; call before the first frame. */
|
||||||
|
fun load(context: Context) {
|
||||||
|
val prefs = prefs(context)
|
||||||
|
val saved = prefs.getString(KEY_STYLE, null)
|
||||||
|
stationFog = prefs.getBoolean(KEY_STATION_FOG, false)
|
||||||
|
apply(context, AppStyle.entries.firstOrNull { it.name == saved } ?: AppStyle.FOGWAVE)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun select(context: Context, style: AppStyle) {
|
||||||
|
prefs(context).edit().putString(KEY_STYLE, style.name).apply()
|
||||||
|
apply(context, style)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setStationFog(context: Context, enabled: Boolean) {
|
||||||
|
prefs(context).edit().putBoolean(KEY_STATION_FOG, enabled).apply()
|
||||||
|
stationFog = enabled
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Colours of a style, also used for the previews in the picker. */
|
||||||
|
fun colorsFor(context: Context, style: AppStyle): GeoColors = when (style) {
|
||||||
|
AppStyle.FOGWAVE -> DarkGeoColors
|
||||||
|
AppStyle.LAVENDER -> styleColors(Color(0xFFC8B6FF), Color(0xFF1E1630), Color(0xFF0F0E14), Color(0xFF1A1822), Color(0xFF25222F))
|
||||||
|
AppStyle.PEACH -> styleColors(Color(0xFFFFB59E), Color(0xFF2A1710), Color(0xFF12100E), Color(0xFF1D1A17), Color(0xFF28231F))
|
||||||
|
AppStyle.MINT -> styleColors(Color(0xFF9EE7C8), Color(0xFF0F231B), Color(0xFF0D110F), Color(0xFF171C1A), Color(0xFF202724))
|
||||||
|
AppStyle.SKY -> styleColors(Color(0xFFA5CBFF), Color(0xFF0F1A2A), Color(0xFF0D1014), Color(0xFF171B21), Color(0xFF20252D))
|
||||||
|
AppStyle.DEVICE -> deviceColors(context)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun apply(context: Context, requested: AppStyle) {
|
||||||
|
val style = if (requested == AppStyle.DEVICE && !AppStyle.deviceSupported) AppStyle.FOGWAVE else requested
|
||||||
|
this.style = style
|
||||||
|
colors = colorsFor(context, style)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun deviceColors(context: Context): GeoColors {
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) return DarkGeoColors
|
||||||
|
val scheme = dynamicDarkColorScheme(context)
|
||||||
|
return styleColors(
|
||||||
|
accent = scheme.primary,
|
||||||
|
onAccent = scheme.onPrimary,
|
||||||
|
background = scheme.background,
|
||||||
|
surface1 = scheme.surfaceContainer,
|
||||||
|
surface2 = scheme.surfaceContainerHigh
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun prefs(context: Context) =
|
||||||
|
context.applicationContext.getSharedPreferences(PREFS, Context.MODE_PRIVATE)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds the full set from a style's few colours. Pastel styles use their accent for buttons too,
|
||||||
|
* with dark text on top, like in Matewave. The live dot and the favourite heart keep their own red.
|
||||||
|
*/
|
||||||
|
private fun styleColors(
|
||||||
|
accent: Color,
|
||||||
|
onAccent: Color,
|
||||||
|
background: Color,
|
||||||
|
surface1: Color,
|
||||||
|
surface2: Color
|
||||||
|
): GeoColors = DarkGeoColors.copy(
|
||||||
|
background = background,
|
||||||
|
surface = background,
|
||||||
|
surfaceContainer = surface1,
|
||||||
|
surfaceContainerHigh = surface2,
|
||||||
|
onSurfaceVariant = lerp(Color(0xFF9AA0AA), accent, 0.12f),
|
||||||
|
outline = lerp(surface2, Color.White, 0.3f),
|
||||||
|
outlineVariant = lerp(surface2, Color.White, 0.06f),
|
||||||
|
primary = accent,
|
||||||
|
onPrimary = onAccent,
|
||||||
|
primaryContainer = lerp(background, accent, 0.22f),
|
||||||
|
onPrimaryContainer = lerp(accent, Color.White, 0.75f),
|
||||||
|
secondary = lerp(accent, Color.White, 0.4f),
|
||||||
|
onSecondary = onAccent,
|
||||||
|
secondaryContainer = lerp(surface2, accent, 0.18f),
|
||||||
|
onSecondaryContainer = lerp(accent, Color.White, 0.75f),
|
||||||
|
accentLavender = accent,
|
||||||
|
onAccentLavender = onAccent,
|
||||||
|
deepPurple = lerp(Color.White, accent, 0.06f)
|
||||||
|
)
|
||||||
@@ -1,33 +1,36 @@
|
|||||||
package cc.skysparkle.fogwave.ui.theme
|
package cc.skysparkle.fogwave.ui.theme
|
||||||
|
|
||||||
|
import androidx.compose.material3.ColorScheme
|
||||||
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
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
|
||||||
private val DarkColorScheme = with(DarkGeoColors) {
|
private fun GeoColors.toColorScheme(): ColorScheme = darkColorScheme(
|
||||||
darkColorScheme(
|
primary = primary,
|
||||||
primary = primary,
|
onPrimary = onPrimary,
|
||||||
onPrimary = onPrimary,
|
primaryContainer = primaryContainer,
|
||||||
primaryContainer = primaryContainer,
|
onPrimaryContainer = onPrimaryContainer,
|
||||||
onPrimaryContainer = onPrimaryContainer,
|
secondary = secondary,
|
||||||
secondary = secondary,
|
onSecondary = onSecondary,
|
||||||
onSecondary = onSecondary,
|
secondaryContainer = secondaryContainer,
|
||||||
secondaryContainer = secondaryContainer,
|
onSecondaryContainer = onSecondaryContainer,
|
||||||
onSecondaryContainer = onSecondaryContainer,
|
background = background,
|
||||||
background = background,
|
onBackground = onBackground,
|
||||||
onBackground = onBackground,
|
surface = surface,
|
||||||
surface = surface,
|
onSurface = onSurface,
|
||||||
onSurface = onSurface,
|
surfaceVariant = outlineVariant,
|
||||||
surfaceVariant = outlineVariant,
|
onSurfaceVariant = onSurfaceVariant,
|
||||||
onSurfaceVariant = onSurfaceVariant,
|
outline = outline
|
||||||
outline = outline
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/** Always dark; the colours follow the style picked in About (see [AppThemeState]). */
|
||||||
@Composable
|
@Composable
|
||||||
fun FogwaveTheme(content: @Composable () -> Unit) {
|
fun FogwaveTheme(content: @Composable () -> Unit) {
|
||||||
CompositionLocalProvider(LocalGeoColors provides DarkGeoColors) {
|
val colors = AppThemeState.colors
|
||||||
MaterialTheme(colorScheme = DarkColorScheme, typography = Typography, content = content)
|
val scheme = remember(colors) { colors.toColorScheme() }
|
||||||
|
CompositionLocalProvider(LocalGeoColors provides colors) {
|
||||||
|
MaterialTheme(colorScheme = scheme, typography = Typography, content = content)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,9 +139,12 @@ class RadioViewModel(application: Application) : AndroidViewModel(application) {
|
|||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
playerManager.currentMediaId.collect { id ->
|
playerManager.currentMediaId.collect { id ->
|
||||||
if (id != null && id != _currentStation.value?.id) {
|
if (id != null && id != _currentStation.value?.id) {
|
||||||
|
// Switched outside the app (notification, headset, Android Auto): count it like a tap.
|
||||||
stations.find { it.id == id }?.let { onAir ->
|
stations.find { it.id == id }?.let { onAir ->
|
||||||
_currentStation.value = onAir
|
_currentStation.value = onAir
|
||||||
repository.setLastStationId(onAir.id)
|
repository.setLastStationId(onAir.id)
|
||||||
|
repository.pushRecent(onAir.id)
|
||||||
|
repository.recordStationPlayed(onAir.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -250,10 +253,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)
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 272 B |
Binary file not shown.
|
Before Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1002 B |
Binary file not shown.
|
Before Width: | Height: | Size: 998 B |
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- MingCute icon "check_line" (Apache License 2.0) -->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:fillType="evenOdd"
|
||||||
|
android:pathData="M21.192 5.465a1 1 0 0 1 0 1.414L9.95 18.122a1.1 1.1 0 0 1-1.556 0l-5.586-5.586a1 1 0 1 1 1.415-1.415l4.95 4.95L19.777 5.465a1 1 0 0 1 1.414 0Z" />
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- MingCute icon "code_line" (Apache License 2.0) -->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:pathData="M14.486 3.143a1 1 0 0 1 .692 1.233l-4.43 15.788a1 1 0 0 1-1.926-.54l4.43-15.788a1 1 0 0 1 1.234-.693M7.207 7.05a1 1 0 0 1 0 1.414L3.672 12l3.535 3.535a1 1 0 1 1-1.414 1.415L1.55 12.707a1 1 0 0 1 0-1.414L5.793 7.05a1 1 0 0 1 1.414 0m9.586 1.414a1 1 0 1 1 1.414-1.414l4.243 4.243a1 1 0 0 1 0 1.414l-4.243 4.243a1 1 0 0 1-1.414-1.415L20.328 12z" />
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- MingCute icon "copyright_line" (Apache License 2.0) -->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:pathData="M12 2c5.523 0 10 4.477 10 10s-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2m0 2a8 8 0 1 0 0 16 8 8 0 0 0 0-16m0 3a4.99 4.99 0 0 1 3.75 1.692 1 1 0 1 1-1.5 1.324 3 3 0 1 0 0 3.968 1 1 0 1 1 1.5 1.324A5 5 0 1 1 12 7" />
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- MingCute icon "external_link_line" (Apache License 2.0) -->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:pathData="M11 6a1 1 0 1 1 0 2H5v11h11v-6a1 1 0 1 1 2 0v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2zm9-3a1 1 0 0 1 1 1v5a1 1 0 1 1-2 0V6.414l-8.293 8.293a1 1 0 0 1-1.414-1.414L17.586 5H15a1 1 0 1 1 0-2Z" />
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- MingCute icon "fog_line" (Apache License 2.0) -->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:fillType="evenOdd"
|
||||||
|
android:pathData="M11.5 2A6.5 6.5 0 0 0 5 8.416a5.004 5.004 0 0 0-2.961 3.96 1 1 0 1 0 1.984.248A3.004 3.004 0 0 1 6.27 10.09 1.01 1.01 0 0 0 7.027 9a4.5 4.5 0 0 1 8.817-1.679c.104.382.422.668.811.732a4.001 4.001 0 0 1 3.325 4.348 1 1 0 1 0 1.99.198 6.002 6.002 0 0 0-4.385-6.387A6.502 6.502 0 0 0 11.5 2M3 16a1 1 0 0 1 1-1h16a1 1 0 1 1 0 2H4a1 1 0 0 1-1-1m4 4a1 1 0 0 1 1-1h9a1 1 0 1 1 0 2H8a1 1 0 0 1-1-1" />
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- MingCute icon "palette_line" (Apache License 2.0) -->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:pathData="M12 2c5.523 0 10 4.477 10 10 0 .649-.062 1.284-.18 1.9-.386 2.004-2.397 2.85-4.082 2.57l-1.74-.29a1.29 1.29 0 0 0-1.124.36c-.37.37-.547.879-.298 1.376.423.846.429 1.812.055 2.603C14.131 21.58 13.11 22 12 22 6.477 22 2 17.523 2 12S6.477 2 12 2m0 2a8 8 0 1 0 0 16l.195-.002c.258-.01.5-.06.628-.332a.993.993 0 0 0-.036-.855c-.63-1.262-.302-2.71.673-3.685a3.29 3.29 0 0 1 2.867-.919l1.74.29c.957.16 1.668-.348 1.789-.975A8 8 0 0 0 12 4m-4.5 7a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3m7-4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3m-5 0a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3" />
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- MingCute icon "right_line" (Apache License 2.0) -->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:fillType="evenOdd"
|
||||||
|
android:pathData="M15.707 11.293a1 1 0 0 1 0 1.414l-5.657 5.657a1 1 0 1 1-1.414-1.414l4.95-4.95-4.95-4.95a1 1 0 0 1 1.414-1.414l5.657 5.657Z" />
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- MingCute icon "safe_shield_line" (Apache License 2.0) -->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:fillType="evenOdd"
|
||||||
|
android:pathData="M11.298 2.195a2 2 0 0 1 1.232-.055l.172.055 7 2.625a2 2 0 0 1 1.291 1.708l.007.165v5.363a9 9 0 0 1-4.709 7.911l-.266.139-3.354 1.677a1.5 1.5 0 0 1-1.198.062l-.144-.062-3.354-1.677a9 9 0 0 1-4.97-7.75l-.005-.3V6.693a2 2 0 0 1 1.145-1.808l.153-.065zM12 4.068 5 6.693v5.363a7 7 0 0 0 3.635 6.138l.235.123L12 19.882l3.13-1.565a7 7 0 0 0 3.865-5.997l.005-.264V6.693zm-.492 3.448a1.4 1.4 0 0 1 .846-.043l.138.043 2.8 1.05a1.4 1.4 0 0 1 .902 1.178l.006.133v2.145a4.2 4.2 0 0 1-2.131 3.655l-.19.102-1.342.67a1.2 1.2 0 0 1-.944.056l-.13-.055-1.341-.671a4.2 4.2 0 0 1-2.316-3.54l-.006-.217V9.877a1.4 1.4 0 0 1 .786-1.258l.122-.053zM12 9.468l-2.2.825v1.73a2.2 2.2 0 0 0 1.07 1.887l.146.08.984.492.984-.492a2.2 2.2 0 0 0 1.21-1.802l.006-.166v-1.729z" />
|
||||||
|
</vector>
|
||||||
@@ -114,4 +114,19 @@
|
|||||||
<string name="share_content_desc">Teilen</string>
|
<string name="share_content_desc">Teilen</string>
|
||||||
<string name="share_text">Ich höre %1$s mit Fogwave</string>
|
<string name="share_text">Ich höre %1$s mit Fogwave</string>
|
||||||
<string name="share_text_track">Ich höre „%1$s“ auf %2$s mit Fogwave</string>
|
<string name="share_text_track">Ich höre „%1$s“ auf %2$s mit Fogwave</string>
|
||||||
|
<string name="about_appearance">Darstellung</string>
|
||||||
|
<string name="about_more">Mehr</string>
|
||||||
|
<string name="app_style_title">App-Farben</string>
|
||||||
|
<string name="app_style_lavender">Lavendel</string>
|
||||||
|
<string name="app_style_peach">Pfirsich</string>
|
||||||
|
<string name="app_style_mint">Minze</string>
|
||||||
|
<string name="app_style_sky">Himmel</string>
|
||||||
|
<string name="app_style_device">Gerät</string>
|
||||||
|
<string name="app_style_device_hint">Die Farben kommen aus deinem Hintergrundbild (Material You) und ändern sich mit ihm.</string>
|
||||||
|
<string name="station_fog_title">Nebel in Senderfarbe</string>
|
||||||
|
<string name="station_fog_subtitle">Der Nebel und der Ring um das Cover nehmen die Farbe des laufenden Senders an</string>
|
||||||
|
<!-- Equalizer value labels; %1$s is the formatted number -->
|
||||||
|
<string name="eq_gain_db">%1$s dB</string>
|
||||||
|
<string name="eq_freq_hz">%1$s Hz</string>
|
||||||
|
<string name="eq_freq_khz">%1$s kHz</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -113,4 +113,19 @@
|
|||||||
<string name="share_content_desc">共有</string>
|
<string name="share_content_desc">共有</string>
|
||||||
<string name="share_text">Fogwaveで%1$sを聴いています</string>
|
<string name="share_text">Fogwaveで%1$sを聴いています</string>
|
||||||
<string name="share_text_track">Fogwaveで%2$sの「%1$s」を聴いています</string>
|
<string name="share_text_track">Fogwaveで%2$sの「%1$s」を聴いています</string>
|
||||||
|
<string name="about_appearance">外観</string>
|
||||||
|
<string name="about_more">その他</string>
|
||||||
|
<string name="app_style_title">アプリの色</string>
|
||||||
|
<string name="app_style_lavender">ラベンダー</string>
|
||||||
|
<string name="app_style_peach">ピーチ</string>
|
||||||
|
<string name="app_style_mint">ミント</string>
|
||||||
|
<string name="app_style_sky">スカイ</string>
|
||||||
|
<string name="app_style_device">端末</string>
|
||||||
|
<string name="app_style_device_hint">色は壁紙から取得され(Material You)、壁紙に合わせて変わります。</string>
|
||||||
|
<string name="station_fog_title">局の色の霧</string>
|
||||||
|
<string name="station_fog_subtitle">霧とディスクの周りのリングが再生中の局の色になります</string>
|
||||||
|
<!-- Equalizer value labels; %1$s is the formatted number -->
|
||||||
|
<string name="eq_gain_db">%1$s dB</string>
|
||||||
|
<string name="eq_freq_hz">%1$s Hz</string>
|
||||||
|
<string name="eq_freq_khz">%1$s kHz</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -116,4 +116,19 @@
|
|||||||
<string name="share_content_desc">Bendrinti</string>
|
<string name="share_content_desc">Bendrinti</string>
|
||||||
<string name="share_text">Klausausi %1$s per Fogwave</string>
|
<string name="share_text">Klausausi %1$s per Fogwave</string>
|
||||||
<string name="share_text_track">Klausausi „%1$s“ per %2$s su Fogwave</string>
|
<string name="share_text_track">Klausausi „%1$s“ per %2$s su Fogwave</string>
|
||||||
|
<string name="about_appearance">Išvaizda</string>
|
||||||
|
<string name="about_more">Daugiau</string>
|
||||||
|
<string name="app_style_title">Programėlės spalvos</string>
|
||||||
|
<string name="app_style_lavender">Levanda</string>
|
||||||
|
<string name="app_style_peach">Persikas</string>
|
||||||
|
<string name="app_style_mint">Mėta</string>
|
||||||
|
<string name="app_style_sky">Dangus</string>
|
||||||
|
<string name="app_style_device">Fonas</string>
|
||||||
|
<string name="app_style_device_hint">Spalvos paimamos iš ekrano fono („Material You“) ir keičiasi kartu su juo.</string>
|
||||||
|
<string name="station_fog_title">Rūkas stoties spalva</string>
|
||||||
|
<string name="station_fog_subtitle">Rūkas ir žiedas aplink diską nusidažo grojančios stoties spalva</string>
|
||||||
|
<!-- Equalizer value labels; %1$s is the formatted number -->
|
||||||
|
<string name="eq_gain_db">%1$s dB</string>
|
||||||
|
<string name="eq_freq_hz">%1$s Hz</string>
|
||||||
|
<string name="eq_freq_khz">%1$s kHz</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -116,4 +116,19 @@
|
|||||||
<string name="share_content_desc">Поделиться</string>
|
<string name="share_content_desc">Поделиться</string>
|
||||||
<string name="share_text">Слушаю %1$s в Fogwave</string>
|
<string name="share_text">Слушаю %1$s в Fogwave</string>
|
||||||
<string name="share_text_track">Слушаю «%1$s» на %2$s в Fogwave</string>
|
<string name="share_text_track">Слушаю «%1$s» на %2$s в Fogwave</string>
|
||||||
|
<string name="about_appearance">Оформление</string>
|
||||||
|
<string name="about_more">Ещё</string>
|
||||||
|
<string name="app_style_title">Цвета приложения</string>
|
||||||
|
<string name="app_style_lavender">Лаванда</string>
|
||||||
|
<string name="app_style_peach">Персик</string>
|
||||||
|
<string name="app_style_mint">Мята</string>
|
||||||
|
<string name="app_style_sky">Небо</string>
|
||||||
|
<string name="app_style_device">Обои</string>
|
||||||
|
<string name="app_style_device_hint">Цвета берутся из обоев (Material You) и меняются вместе с ними.</string>
|
||||||
|
<string name="station_fog_title">Туман в цвете станции</string>
|
||||||
|
<string name="station_fog_subtitle">Туман и кольцо вокруг диска окрашиваются в цвет играющей станции</string>
|
||||||
|
<!-- Equalizer value labels; %1$s is the formatted number -->
|
||||||
|
<string name="eq_gain_db">%1$s дБ</string>
|
||||||
|
<string name="eq_freq_hz">%1$s Гц</string>
|
||||||
|
<string name="eq_freq_khz">%1$s кГц</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -113,4 +113,19 @@
|
|||||||
<string name="share_content_desc">分享</string>
|
<string name="share_content_desc">分享</string>
|
||||||
<string name="share_text">我正在用 Fogwave 收听 %1$s</string>
|
<string name="share_text">我正在用 Fogwave 收听 %1$s</string>
|
||||||
<string name="share_text_track">我正在用 Fogwave 收听 %2$s 的“%1$s”</string>
|
<string name="share_text_track">我正在用 Fogwave 收听 %2$s 的“%1$s”</string>
|
||||||
|
<string name="about_appearance">外观</string>
|
||||||
|
<string name="about_more">更多</string>
|
||||||
|
<string name="app_style_title">应用配色</string>
|
||||||
|
<string name="app_style_lavender">薰衣草</string>
|
||||||
|
<string name="app_style_peach">蜜桃</string>
|
||||||
|
<string name="app_style_mint">薄荷</string>
|
||||||
|
<string name="app_style_sky">天空</string>
|
||||||
|
<string name="app_style_device">设备</string>
|
||||||
|
<string name="app_style_device_hint">颜色取自壁纸(Material You),并随壁纸变化。</string>
|
||||||
|
<string name="station_fog_title">电台颜色的雾</string>
|
||||||
|
<string name="station_fog_subtitle">雾和唱片周围的圆环会变成正在播放电台的颜色</string>
|
||||||
|
<!-- Equalizer value labels; %1$s is the formatted number -->
|
||||||
|
<string name="eq_gain_db">%1$s dB</string>
|
||||||
|
<string name="eq_freq_hz">%1$s Hz</string>
|
||||||
|
<string name="eq_freq_khz">%1$s kHz</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -114,4 +114,20 @@
|
|||||||
<string name="share_content_desc">Share</string>
|
<string name="share_content_desc">Share</string>
|
||||||
<string name="share_text">I\'m listening to %1$s on Fogwave</string>
|
<string name="share_text">I\'m listening to %1$s on Fogwave</string>
|
||||||
<string name="share_text_track">I\'m listening to “%1$s” on %2$s with Fogwave</string>
|
<string name="share_text_track">I\'m listening to “%1$s” on %2$s with Fogwave</string>
|
||||||
|
<string name="about_appearance">Appearance</string>
|
||||||
|
<string name="about_more">More</string>
|
||||||
|
<string name="app_style_title">App colors</string>
|
||||||
|
<string name="app_style_fogwave" translatable="false">Fogwave</string>
|
||||||
|
<string name="app_style_lavender">Lavender</string>
|
||||||
|
<string name="app_style_peach">Peach</string>
|
||||||
|
<string name="app_style_mint">Mint</string>
|
||||||
|
<string name="app_style_sky">Sky</string>
|
||||||
|
<string name="app_style_device">Device</string>
|
||||||
|
<string name="app_style_device_hint">Colors are taken from your wallpaper (Material You) and change with it.</string>
|
||||||
|
<string name="station_fog_title">Fog in station color</string>
|
||||||
|
<string name="station_fog_subtitle">The fog and the ring around the disc take the color of the playing station</string>
|
||||||
|
<!-- Equalizer value labels; %1$s is the formatted number -->
|
||||||
|
<string name="eq_gain_db">%1$s dB</string>
|
||||||
|
<string name="eq_freq_hz">%1$s Hz</string>
|
||||||
|
<string name="eq_freq_khz">%1$s kHz</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<full-backup-content>
|
|
||||||
|
|
||||||
</full-backup-content>
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<data-extraction-rules>
|
|
||||||
<cloud-backup>
|
|
||||||
|
|
||||||
</cloud-backup>
|
|
||||||
|
|
||||||
</data-extraction-rules>
|
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
package cc.skysparkle.fogwave.data
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import androidx.core.content.edit
|
||||||
|
import androidx.test.core.app.ApplicationProvider
|
||||||
|
import cc.skysparkle.fogwave.data.repository.RadioRepository
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertFalse
|
||||||
|
import org.junit.Assert.assertTrue
|
||||||
|
import org.junit.Before
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.robolectric.RobolectricTestRunner
|
||||||
|
import org.robolectric.annotation.Config
|
||||||
|
|
||||||
|
@RunWith(RobolectricTestRunner::class)
|
||||||
|
@Config(sdk = [36])
|
||||||
|
class RadioRepositoryTest {
|
||||||
|
|
||||||
|
private val context: Context = ApplicationProvider.getApplicationContext()
|
||||||
|
|
||||||
|
@Before
|
||||||
|
fun clearPrefs() {
|
||||||
|
context.getSharedPreferences("fogwave_prefs", Context.MODE_PRIVATE).edit { clear() }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun favoritesToggleAndSurviveARestart() {
|
||||||
|
val repository = RadioRepository(context)
|
||||||
|
assertTrue(repository.toggleFavorite("zip"))
|
||||||
|
assertTrue(repository.toggleFavorite("lrt"))
|
||||||
|
assertFalse(repository.toggleFavorite("zip"))
|
||||||
|
|
||||||
|
assertEquals(setOf("lrt"), RadioRepository(context).favoritesFlow.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun unknownStationsAreDroppedFromSavedFavorites() {
|
||||||
|
context.getSharedPreferences("fogwave_prefs", Context.MODE_PRIVATE)
|
||||||
|
.edit { putStringSet("favorites", setOf("zip", "removed_station")) }
|
||||||
|
|
||||||
|
assertEquals(setOf("zip"), RadioRepository(context).favoritesFlow.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun recentsPutTheLatestFirstWithoutDuplicatesAndKeepTen() {
|
||||||
|
val repository = RadioRepository(context)
|
||||||
|
val ids = repository.stations.map { it.id }
|
||||||
|
ids.forEach { repository.pushRecent(it) }
|
||||||
|
repository.pushRecent(ids[3])
|
||||||
|
|
||||||
|
val recents = RadioRepository(context).recentsFlow.value
|
||||||
|
assertEquals(10, recents.size)
|
||||||
|
assertEquals(ids[3], recents.first())
|
||||||
|
assertEquals(recents.size, recents.toSet().size)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun mostPlayedStationsComeFirst() {
|
||||||
|
val repository = RadioRepository(context)
|
||||||
|
repeat(3) { repository.recordStationPlayed("lr2") }
|
||||||
|
repository.recordStationPlayed("rc")
|
||||||
|
|
||||||
|
val sorted = RadioRepository(context).stationsSortedByPopularity()
|
||||||
|
assertEquals(listOf("lr2", "rc"), sorted.take(2).map { it.id })
|
||||||
|
assertEquals(repository.stations.size, sorted.size)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
package cc.skysparkle.fogwave.player
|
||||||
|
|
||||||
|
import android.net.Uri
|
||||||
|
import android.os.Looper
|
||||||
|
import androidx.annotation.OptIn
|
||||||
|
import androidx.media3.common.PlaybackException
|
||||||
|
import androidx.media3.common.Player
|
||||||
|
import androidx.media3.common.SimpleBasePlayer
|
||||||
|
import androidx.media3.common.util.UnstableApi
|
||||||
|
import androidx.media3.datasource.DataSpec
|
||||||
|
import androidx.media3.datasource.HttpDataSource
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.robolectric.RobolectricTestRunner
|
||||||
|
import org.robolectric.annotation.Config
|
||||||
|
|
||||||
|
@OptIn(UnstableApi::class)
|
||||||
|
@RunWith(RobolectricTestRunner::class)
|
||||||
|
@Config(sdk = [36])
|
||||||
|
class PlaybackPolicyTest {
|
||||||
|
|
||||||
|
private fun httpError(code: Int) = PlaybackException(
|
||||||
|
"HTTP $code",
|
||||||
|
HttpDataSource.InvalidResponseCodeException(
|
||||||
|
code, null, null, emptyMap(), DataSpec(Uri.parse("https://example.com/stream")), ByteArray(0)
|
||||||
|
),
|
||||||
|
PlaybackException.ERROR_CODE_IO_BAD_HTTP_STATUS
|
||||||
|
)
|
||||||
|
|
||||||
|
private fun error(code: Int) = PlaybackException("error", null, code)
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun clientErrorsGetOnlyAFewAttempts() {
|
||||||
|
assertEquals(MAX_PERMANENT_ERROR_RETRY_ATTEMPTS, maxRetryAttemptsFor(httpError(404)))
|
||||||
|
assertEquals(MAX_PERMANENT_ERROR_RETRY_ATTEMPTS, maxRetryAttemptsFor(httpError(403)))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun timeoutsRateLimitsAndServerErrorsGetTheFullBackoff() {
|
||||||
|
assertEquals(MAX_RETRY_ATTEMPTS, maxRetryAttemptsFor(httpError(408)))
|
||||||
|
assertEquals(MAX_RETRY_ATTEMPTS, maxRetryAttemptsFor(httpError(429)))
|
||||||
|
assertEquals(MAX_RETRY_ATTEMPTS, maxRetryAttemptsFor(httpError(503)))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun unsupportedStreamsArePermanentAndNetworkErrorsAreNot() {
|
||||||
|
assertEquals(
|
||||||
|
MAX_PERMANENT_ERROR_RETRY_ATTEMPTS,
|
||||||
|
maxRetryAttemptsFor(error(PlaybackException.ERROR_CODE_PARSING_CONTAINER_UNSUPPORTED))
|
||||||
|
)
|
||||||
|
assertEquals(
|
||||||
|
MAX_PERMANENT_ERROR_RETRY_ATTEMPTS,
|
||||||
|
maxRetryAttemptsFor(error(PlaybackException.ERROR_CODE_IO_CLEARTEXT_NOT_PERMITTED))
|
||||||
|
)
|
||||||
|
assertEquals(
|
||||||
|
MAX_RETRY_ATTEMPTS,
|
||||||
|
maxRetryAttemptsFor(error(PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_FAILED))
|
||||||
|
)
|
||||||
|
assertEquals(
|
||||||
|
MAX_RETRY_ATTEMPTS,
|
||||||
|
maxRetryAttemptsFor(error(PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_TIMEOUT))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A player that only reports the given state. */
|
||||||
|
private class FakePlayer(private val fixed: State) : SimpleBasePlayer(Looper.getMainLooper()) {
|
||||||
|
override fun getState(): State = fixed
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun player(
|
||||||
|
playbackState: Int,
|
||||||
|
playWhenReady: Boolean,
|
||||||
|
hasItem: Boolean = true,
|
||||||
|
error: PlaybackException? = null
|
||||||
|
): Player = FakePlayer(
|
||||||
|
SimpleBasePlayer.State.Builder()
|
||||||
|
.setAvailableCommands(Player.Commands.Builder().addAllCommands().build())
|
||||||
|
.setPlaylist(if (hasItem) listOf(SimpleBasePlayer.MediaItemData.Builder("station").build()) else emptyList())
|
||||||
|
.setPlaybackState(playbackState)
|
||||||
|
.setPlayWhenReady(playWhenReady, Player.PLAY_WHEN_READY_CHANGE_REASON_USER_REQUEST)
|
||||||
|
.setPlayerError(error)
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
|
||||||
|
private fun derive(p: Player) = deriveState(p) { "failed" }
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun readyMapsToPlayingOrPaused() {
|
||||||
|
assertEquals(PlayerState.Playing, derive(player(Player.STATE_READY, playWhenReady = true)))
|
||||||
|
assertEquals(PlayerState.Paused, derive(player(Player.STATE_READY, playWhenReady = false)))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun bufferingAndADroppedStreamShowConnectingWhilePlayRequested() {
|
||||||
|
assertEquals(PlayerState.Connecting, derive(player(Player.STATE_BUFFERING, playWhenReady = true)))
|
||||||
|
assertEquals(PlayerState.Connecting, derive(player(Player.STATE_ENDED, playWhenReady = true)))
|
||||||
|
assertEquals(PlayerState.Paused, derive(player(Player.STATE_BUFFERING, playWhenReady = false)))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun idleDependsOnWhetherAStationIsLoaded() {
|
||||||
|
assertEquals(PlayerState.Idle, derive(player(Player.STATE_IDLE, playWhenReady = false, hasItem = false)))
|
||||||
|
assertEquals(PlayerState.Connecting, derive(player(Player.STATE_IDLE, playWhenReady = true)))
|
||||||
|
assertEquals(PlayerState.Paused, derive(player(Player.STATE_IDLE, playWhenReady = false)))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun anErrorWinsOverThePlaybackState() {
|
||||||
|
val state = derive(
|
||||||
|
player(
|
||||||
|
Player.STATE_IDLE,
|
||||||
|
playWhenReady = true,
|
||||||
|
error = error(PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_FAILED)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
assertEquals(PlayerState.Error("failed"), state)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
• Farbstile, auch Material You; Nebel in Senderfarbe ist jetzt optional
|
||||||
|
• Weiter/Zurück funktioniert in der Benachrichtigung, am Kopfhörer und in Android Auto
|
||||||
|
• Sprachbefehle über Assistant und Android Auto stoppen den Player nicht mehr
|
||||||
|
• Die Wiedergabe läuft von selbst weiter, wenn das Netz zurück ist
|
||||||
|
• Der Lautstärke-Booster macht jetzt wirklich lauter
|
||||||
|
• Kleinere App, weniger Akkuverbrauch
|
||||||
|
|
||||||
|
Neue Versionen gibt es auch auf Gitea: https://git.skysparkle.cc/kalarina/Fogwave/releases
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
• Color styles, including Material You; fog in the station's color is now optional
|
||||||
|
• Next/previous now work from the notification, headphones and Android Auto
|
||||||
|
• Voice requests from Assistant and Android Auto no longer stop the player
|
||||||
|
• Playback resumes by itself when the network comes back
|
||||||
|
• Loudness Enhancer now really makes the sound louder
|
||||||
|
• Smaller app and lower battery use
|
||||||
|
|
||||||
|
New versions are also available on Gitea: https://git.skysparkle.cc/kalarina/Fogwave/releases
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
• Material You を含むカラースタイル。局の色の霧はオプションに
|
||||||
|
• 通知、ヘッドホン、Android Auto から次/前の局に切り替え可能に
|
||||||
|
• Assistant や Android Auto の音声操作でプレーヤーが止まらなくなりました
|
||||||
|
• ネットワークが戻ると自動で再生を再開
|
||||||
|
• ラウドネス強化が実際に音量を上げるように
|
||||||
|
• アプリが軽くなり、電池消費も減少
|
||||||
|
|
||||||
|
新しいバージョンは Gitea でも入手できます: https://git.skysparkle.cc/kalarina/Fogwave/releases
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
• Spalvų stiliai, taip pat Material You; rūkas stoties spalva – pasirinktinai
|
||||||
|
• Kita/ankstesnė stotis veikia iš pranešimo, ausinių ir Android Auto
|
||||||
|
• Balso komandos iš Assistant ir Android Auto nebestabdo grotuvo
|
||||||
|
• Grojimas pats atsinaujina, kai grįžta ryšys
|
||||||
|
• Garsumo stiprintuvas dabar tikrai garsina
|
||||||
|
• Mažesnė programėlė ir mažesnės baterijos sąnaudos
|
||||||
|
|
||||||
|
Naujos versijos taip pat pasiekiamos Gitea: https://git.skysparkle.cc/kalarina/Fogwave/releases
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
• Цветовые стили, в том числе Material You; туман в цвете станции — по желанию
|
||||||
|
• «Следующая/предыдущая» работают из уведомления, наушников и Android Auto
|
||||||
|
• Голосовые команды Assistant и Android Auto больше не роняют плеер
|
||||||
|
• Воспроизведение само продолжается, когда возвращается сеть
|
||||||
|
• Усиление громкости теперь действительно работает
|
||||||
|
• Приложение стало легче и экономнее к батарее
|
||||||
|
|
||||||
|
Новые версии также доступны в Gitea: https://git.skysparkle.cc/kalarina/Fogwave/releases
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
• 多种配色风格,包括 Material You;电台颜色的雾改为可选
|
||||||
|
• 可在通知、耳机和 Android Auto 中切换上一个/下一个电台
|
||||||
|
• Assistant 和 Android Auto 的语音指令不再导致播放器停止
|
||||||
|
• 网络恢复后自动继续播放
|
||||||
|
• 响度增强现在真正提高音量
|
||||||
|
• 应用更小,更省电
|
||||||
|
|
||||||
|
新版本也可在 Gitea 获取:https://git.skysparkle.cc/kalarina/Fogwave/releases
|
||||||
@@ -11,7 +11,6 @@ kotlin = "2.4.20"
|
|||||||
composeBom = "2026.09.00"
|
composeBom = "2026.09.00"
|
||||||
core = "1.6.1"
|
core = "1.6.1"
|
||||||
runner = "1.6.2"
|
runner = "1.6.2"
|
||||||
coilCompose = "2.7.0"
|
|
||||||
kotlinxCoroutinesAndroid = "1.11.0"
|
kotlinxCoroutinesAndroid = "1.11.0"
|
||||||
kotlinxCoroutinesCore = "1.11.0"
|
kotlinxCoroutinesCore = "1.11.0"
|
||||||
robolectric = "4.16.1"
|
robolectric = "4.16.1"
|
||||||
@@ -35,7 +34,6 @@ androidx-compose-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-te
|
|||||||
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-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" }
|
|
||||||
androidx-media3-exoplayer = { group = "androidx.media3", name = "media3-exoplayer", version.ref = "media3" }
|
androidx-media3-exoplayer = { group = "androidx.media3", name = "media3-exoplayer", version.ref = "media3" }
|
||||||
androidx-media3-exoplayer-hls = { group = "androidx.media3", name = "media3-exoplayer-hls", version.ref = "media3" }
|
androidx-media3-exoplayer-hls = { group = "androidx.media3", name = "media3-exoplayer-hls", version.ref = "media3" }
|
||||||
androidx-media3-common = { group = "androidx.media3", name = "media3-common", version.ref = "media3" }
|
androidx-media3-common = { group = "androidx.media3", name = "media3-common", version.ref = "media3" }
|
||||||
|
|||||||
+1
@@ -1,5 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
|
distributionSha256Sum=acd53f1edaf02f1a8ff99879f8a34b302661a057d9b063ae9e35b552f804d20a
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.1-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
|
|||||||
Reference in New Issue
Block a user