music: only include explicit albums in count

Only include an artists explicit albums (ones directly linked w/album
artist) in their count.

This is arguably more appropriate than the prior behavior, given
Auxio's collaborator/artist distinction.

Resolves #581.
This commit is contained in:
Alexander Capehart 2023-11-12 11:24:06 -07:00
parent bf3c30e8af
commit d6801354ce
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
6 changed files with 33 additions and 7 deletions

View file

@ -6,6 +6,10 @@
- Added ability to rewind/skip tracks by swiping back/forward
- Added support for demo release type
#### What's Changed
- Albums linked to an artist only as a collaborator are no longer included
in an artist's album count
## 3.2.1
#### What's Improved

View file

@ -71,7 +71,11 @@ private constructor(private val binding: ItemDetailHeaderBinding) :
binding.detailInfo.text =
binding.context.getString(
R.string.fmt_two,
binding.context.getPlural(R.plurals.fmt_album_count, artist.albums.size),
if (artist.explicitAlbums.isNotEmpty()) {
binding.context.getPlural(R.plurals.fmt_album_count, artist.explicitAlbums.size)
} else {
binding.context.getString(R.string.def_album_count)
},
if (artist.songs.isNotEmpty()) {
binding.context.getPlural(R.plurals.fmt_song_count, artist.songs.size)
} else {

View file

@ -178,7 +178,11 @@ class ArtistMenuDialogFragment : MenuDialogFragment<Menu.ForArtist>() {
binding.menuInfo.text =
getString(
R.string.fmt_two,
context.getPlural(R.plurals.fmt_album_count, menu.artist.albums.size),
if (menu.artist.explicitAlbums.isNotEmpty()) {
context.getPlural(R.plurals.fmt_album_count, menu.artist.explicitAlbums.size)
} else {
context.getString(R.string.def_album_count)
},
if (menu.artist.songs.isNotEmpty()) {
context.getPlural(R.plurals.fmt_song_count, menu.artist.songs.size)
} else {

View file

@ -164,7 +164,11 @@ class ArtistViewHolder private constructor(private val binding: ItemParentBindin
binding.parentInfo.text =
binding.context.getString(
R.string.fmt_two,
binding.context.getPlural(R.plurals.fmt_album_count, artist.albums.size),
if (artist.explicitAlbums.isNotEmpty()) {
binding.context.getPlural(R.plurals.fmt_album_count, artist.explicitAlbums.size)
} else {
binding.context.getString(R.string.def_album_count)
},
if (artist.songs.isNotEmpty()) {
binding.context.getPlural(R.plurals.fmt_song_count, artist.songs.size)
} else {
@ -199,7 +203,7 @@ class ArtistViewHolder private constructor(private val binding: ItemParentBindin
object : SimpleDiffCallback<Artist>() {
override fun areContentsTheSame(oldItem: Artist, newItem: Artist) =
oldItem.name == newItem.name &&
oldItem.albums.size == newItem.albums.size &&
oldItem.explicitAlbums.size == newItem.explicitAlbums.size &&
oldItem.songs.size == newItem.songs.size
}
}

View file

@ -432,7 +432,7 @@ class ArtistImpl(
?: Name.Unknown(R.string.def_artist)
override val songs: Set<Song>
override val albums: Set<Album>
override val albums: Set<Album> = emptySet()
override val explicitAlbums: Set<Album>
override val implicitAlbums: Set<Album>
override val durationMs: Long?
@ -463,7 +463,7 @@ class ArtistImpl(
}
songs = distinctSongs
albums = albumMap.keys
val albums = albumMap.keys
explicitAlbums = albums.filterTo(mutableSetOf()) { albumMap[it] == true }
implicitAlbums = albums.filterNotTo(mutableSetOf()) { albumMap[it] == true }
durationMs = songs.sumOf { it.durationMs }.positiveOrNull()
@ -506,7 +506,16 @@ class ArtistImpl(
* @return This instance upcasted to [Artist].
*/
fun finalize(): Artist {
check(songs.isNotEmpty() || albums.isNotEmpty()) { "Malformed artist $name: Empty" }
// There are valid artist configurations:
// 1. No songs, no implicit albums, some explicit albums
// 2. Some songs, no implicit albums, some explicit albums
// 3. Some songs, some implicit albums, no implicit albums
// 4. Some songs, some implicit albums, some explicit albums
// I'm pretty sure the latter check could be reduced to just explicitAlbums.isNotEmpty,
// but I can't be 100% certain.
check(songs.isNotEmpty() || (implicitAlbums.size + explicitAlbums.size) > 0) {
"Malformed artist $name: Empty"
}
genres =
Sort(Sort.Mode.ByName, Sort.Direction.ASCENDING)
.genres(songs.flatMapTo(mutableSetOf()) { it.genres })

View file

@ -357,6 +357,7 @@
<string name="def_disc">No disc</string>
<string name="def_track">No track</string>
<string name="def_song_count">No songs</string>
<string name="def_album_count">No albums</string>
<string name="def_playback">No music playing</string>
<!-- Codec Namespace | Format names -->