Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ fun LibraryAlbumPane(
items(shown, key = { it.id }) { s ->
PlaylistMemberRow(
s = s,
subtitle = s.artist,
current = current,
playing = playing,
queue = shown,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ fun LibraryArtistPane(
items(shown, key = { it.id }) { s ->
PlaylistMemberRow(
s = s,
subtitle = s.albumArtistAlbum,
current = current,
playing = playing,
queue = shown,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ internal fun PlaylistMemberRow(
queue: List<Station>,
onPlay: (Station, List<Station>) -> Unit,
onOpenMenu: (Station) -> Unit,
subtitle: String = s.artistAlbum,
) {
val p = LocalPalette.current
ListRow(
Expand All @@ -385,7 +386,7 @@ internal fun PlaylistMemberRow(
) {
Mono(s.name, KleeampType.rowPrimary, if (current?.url == s.url) p.accent else p.ink, maxLines = 1)
Mono(
s.artistAlbum.ifBlank {
subtitle.ifBlank {
when {
s.source == StationSource.Local -> durationLabel(s.durationMs)
s.source == StationSource.Podcast -> "podcast"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ data class Station(
.filter { it.isNotBlank() }
.joinToString(" · ")

/** `album artist · album`, falling back to track artist when album artist is blank. */
val albumArtistAlbum: String
get() = listOf(albumArtist.ifBlank { artist }, album)
.filter { it.isNotBlank() }
.joinToString(" · ")

/**
* A finite thing with an end, as opposed to a live stream. Decides whether
* the queue is handed to the player as a real playlist it can advance
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package stream.kleeamp.mobile.model

import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
Expand All @@ -12,6 +13,34 @@ class StationTest {
source = source,
)

@Test fun albumArtistAlbumPrefersAlbumArtist() {
val song = station(StationSource.Local, "l1").copy(
artist = "Daft Punk / Gabrielle",
albumArtist = "Daft Punk",
album = "Alive 2007",
)
assertEquals("Daft Punk · Alive 2007", song.albumArtistAlbum)
assertEquals("Daft Punk / Gabrielle · Alive 2007", song.artistAlbum)
}

@Test fun albumArtistAlbumFallsBackToTrackArtist() {
val song = station(StationSource.Local, "l1").copy(
artist = "Track Artist",
album = "Album",
)
assertEquals("Track Artist · Album", song.albumArtistAlbum)
assertEquals("Track Artist · Album", song.copy(albumArtist = " ").albumArtistAlbum)
}

@Test fun albumArtistAlbumOmitsBlankFieldsAndSeparators() {
val song = station(StationSource.Local, "l1")
assertEquals("", song.albumArtistAlbum)
assertEquals("Album Artist", song.copy(albumArtist = "Album Artist").albumArtistAlbum)
assertEquals("Track Artist", song.copy(artist = "Track Artist").albumArtistAlbum)
assertEquals("Album", song.copy(album = "Album").albumArtistAlbum)
assertEquals("", song.copy(artist = " ", albumArtist = " ", album = " ").albumArtistAlbum)
}

@Test fun channelTrackIdIsATrack() {
val track = station(StationSource.Cliamp, "cliamp:edm:42")
assertTrue(track.isChannelTrack)
Expand Down
Loading