about: add full library statistics

Split off the "songs loaded" about item into it's own card called
"library statistics"

This card includes the song, album, artist, and genre counts,
alongside a total duration of the music library. This is just more
informative and useful to the user.

Resolves #121.
This commit is contained in:
OxygenCobalt
2022-05-04 20:20:47 -06:00
parent ac6a471318
commit 1a9e55e73b
8 changed files with 238 additions and 127 deletions
@@ -112,7 +112,7 @@ private constructor(
private val genre: Genre,
) : BaseFetcher() {
override suspend fun fetch(): FetchResult? {
// We don't need to sort here, as the way we
// Don't sort here to preserve compatibility with previous variations of this image.
val albums = genre.songs.groupBy { it.album }.keys
val results = albums.mapAtMost(4) { album -> fetchArt(context, album) }
@@ -88,9 +88,6 @@ import org.oxycblt.auxio.util.logD
* I wish I was born in the neolithic.
*
* @author OxygenCobalt
*
* TODO: Experiment with making the exoplayer metadata system more effificent so that we could
* leverage it here (maybe)
*/
object Indexer {
/**
@@ -65,8 +65,8 @@ import org.oxycblt.auxio.widgets.WidgetProvider
* therefore there's no need to bind to it to deliver commands.
* @author OxygenCobalt
*
* TODO: Synchronize components in a less awful way (Fix issue where rapid-fire updates results
* in a desynced notification)
* TODO: Synchronize components in a less awful way (Fix issue where rapid-fire updates results in a
* desynced notification)
*/
class PlaybackService :
Service(), Player.Listener, PlaybackStateManager.Callback, SettingsManager.Callback {
@@ -219,7 +219,9 @@ class PlaybackService :
newPosition: Player.PositionInfo,
reason: Int
) {
playbackManager.synchronizePosition(player.currentPosition)
if (reason == Player.DISCONTINUITY_REASON_SEEK) {
playbackManager.synchronizePosition(player.currentPosition)
}
}
override fun onTracksInfoChanged(tracksInfo: TracksInfo) {
@@ -32,6 +32,7 @@ import org.oxycblt.auxio.BuildConfig
import org.oxycblt.auxio.R
import org.oxycblt.auxio.databinding.FragmentAboutBinding
import org.oxycblt.auxio.home.HomeViewModel
import org.oxycblt.auxio.music.toDuration
import org.oxycblt.auxio.ui.ViewBindingFragment
import org.oxycblt.auxio.util.logD
import org.oxycblt.auxio.util.showToast
@@ -62,6 +63,20 @@ class AboutFragment : ViewBindingFragment<FragmentAboutBinding>() {
homeModel.songs.observe(viewLifecycleOwner) { songs ->
binding.aboutSongCount.textSafe = getString(R.string.fmt_songs_loaded, songs.size)
binding.aboutTotalDuration.textSafe =
getString(R.string.fmt_total_duration, songs.sumOf { it.seconds }.toDuration(false))
}
homeModel.albums.observe(viewLifecycleOwner) { albums ->
binding.aboutAlbumCount.textSafe = getString(R.string.fmt_albums_loaded, albums.size)
}
homeModel.artists.observe(viewLifecycleOwner) { artists ->
binding.aboutArtistCount.textSafe = getString(R.string.fmt_artists_loaded, artists.size)
}
homeModel.genres.observe(viewLifecycleOwner) { genres ->
binding.aboutGenreCount.textSafe = getString(R.string.fmt_genres_loaded, genres.size)
}
}