Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
zyrouge committed Nov 14, 2024
1 parent 19e717c commit 3b853fd
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ class Radio(private val symphony: Symphony) : Symphony.Hooks {
var autostart: Boolean
var nextSongIndex: Int
when (queue.currentLoopMode) {
RadioLoopMode.Song -> {
RadioQueue.LoopMode.Song -> {
nextSongIndex = queue.currentSongIndex
autostart = source == SongFinishSource.Finish
if (!queue.hasSongAt(nextSongIndex)) {
Expand All @@ -372,7 +372,7 @@ class Radio(private val symphony: Symphony) : Symphony.Hooks {
autostart = true
if (!queue.hasSongAt(nextSongIndex)) {
nextSongIndex = 0
autostart = queue.currentLoopMode == RadioLoopMode.Queue
autostart = queue.currentLoopMode == RadioQueue.LoopMode.Queue
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class RadioObservatory(private val symphony: Symphony) {
val queueIndex = _queueIndex.asStateFlow()
private val _queue = MutableStateFlow(emptyList<String>())
val queue = _queue.asStateFlow()
private val _loopMode = MutableStateFlow(RadioLoopMode.None)
private val _loopMode = MutableStateFlow(RadioQueue.LoopMode.None)
val loopMode = _loopMode.asStateFlow()
private val _shuffleMode = MutableStateFlow(false)
val shuffleMode = _shuffleMode.asStateFlow()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ package io.github.zyrouge.symphony.services.radio
import io.github.zyrouge.symphony.Symphony
import io.github.zyrouge.symphony.utils.ConcurrentList

enum class RadioLoopMode {
None,
Queue,
Song;
class RadioQueue(private val symphony: Symphony) {
enum class LoopMode {
None,
Queue,
Song;

companion object {
val values = enumValues<RadioLoopMode>()
companion object {
val values = enumValues<LoopMode>()
}
}
}

class RadioQueue(private val symphony: Symphony) {
val originalQueue = ConcurrentList<String>()
val currentQueue = ConcurrentList<String>()

Expand All @@ -29,7 +29,7 @@ class RadioQueue(private val symphony: Symphony) {
symphony.radio.onUpdate.dispatch(Radio.Events.QueueOption.ShuffleModeChanged)
}

var currentLoopMode = RadioLoopMode.None
var currentLoopMode = LoopMode.None
set(value) {
field = value
symphony.radio.onUpdate.dispatch(Radio.Events.QueueOption.LoopModeChanged)
Expand Down Expand Up @@ -110,13 +110,13 @@ class RadioQueue(private val symphony: Symphony) {
}
}

fun setLoopMode(loopMode: RadioLoopMode) {
fun setLoopMode(loopMode: LoopMode) {
currentLoopMode = loopMode
}

fun toggleLoopMode() {
val next = (currentLoopMode.ordinal + 1) % RadioLoopMode.values.size
setLoopMode(RadioLoopMode.values[next])
val next = (currentLoopMode.ordinal + 1) % LoopMode.values.size
setLoopMode(LoopMode.values[next])
}

fun toggleShuffleMode() = setShuffleMode(!currentShuffleMode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ class RadioSession(val symphony: Symphony) {
val isPlaying: Boolean,
)

val artworkCacher = RadioArtworkCacher(symphony)
val mediaSession = MediaSessionCompat(
symphony.applicationContext,
MEDIA_SESSION_ID
)
val notification = RadioNotification(symphony)
internal val mediaSession = MediaSessionCompat(symphony.applicationContext, MEDIA_SESSION_ID)
private val artworkCacher = RadioArtworkCacher(symphony)
private val notification = RadioNotification(symphony)

private var currentSongId: String? = null
private var receiver = object : BroadcastReceiver() {
Expand All @@ -46,7 +43,6 @@ class RadioSession(val symphony: Symphony) {

fun start() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
// As per Tiramisu requirements, we need to add Context attributes.
symphony.applicationContext.registerReceiver(
receiver,
IntentFilter().apply {
Expand All @@ -55,7 +51,7 @@ class RadioSession(val symphony: Symphony) {
addAction(ACTION_NEXT)
addAction(ACTION_STOP)
},
Context.RECEIVER_EXPORTED
Context.RECEIVER_EXPORTED,
// https://developer.android.com/reference/android/content/Context#RECEIVER_EXPORTED
// really, RECEIVER_EXPORTED and RECEIVER_NOT_EXPORTED makes no difference.
// the notification appears perfectly, Pano Scrobbler sees it,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import io.github.zyrouge.symphony.services.groove.Song
import io.github.zyrouge.symphony.services.radio.RadioLoopMode
import io.github.zyrouge.symphony.services.radio.RadioQueue
import io.github.zyrouge.symphony.ui.helpers.ViewContext
import io.github.zyrouge.symphony.ui.view.nowPlaying.NothingPlaying
import io.github.zyrouge.symphony.ui.view.nowPlaying.NowPlayingBody
Expand All @@ -20,7 +20,7 @@ data class NowPlayingData(
val isPlaying: Boolean,
val currentSongIndex: Int,
val queueSize: Int,
val currentLoopMode: RadioLoopMode,
val currentLoopMode: RadioQueue.LoopMode,
val currentShuffleMode: Boolean,
val currentSpeed: Float,
val currentPitch: Float,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import io.github.zyrouge.symphony.services.radio.RadioLoopMode
import io.github.zyrouge.symphony.services.radio.RadioQueue
import io.github.zyrouge.symphony.ui.helpers.ViewContext
import io.github.zyrouge.symphony.ui.view.LyricsViewRoute
import io.github.zyrouge.symphony.ui.view.NowPlayingData
Expand Down Expand Up @@ -141,12 +141,12 @@ fun NowPlayingBodyBottomBar(
) {
Icon(
when (currentLoopMode) {
RadioLoopMode.Song -> Icons.Filled.RepeatOne
RadioQueue.LoopMode.Song -> Icons.Filled.RepeatOne
else -> Icons.Filled.Repeat
},
null,
tint = when (currentLoopMode) {
RadioLoopMode.None -> LocalContentColor.current
RadioQueue.LoopMode.None -> LocalContentColor.current
else -> MaterialTheme.colorScheme.primary
}
)
Expand Down

0 comments on commit 3b853fd

Please sign in to comment.