From bbd1853e78011d544672a8dace7c82d55acce99a Mon Sep 17 00:00:00 2001 From: thomas Date: Sun, 13 Sep 2020 21:42:12 -0400 Subject: [PATCH] Minimum working prototype --- .../java/code/name/monkey/retromusic/Constants.kt | 1 + .../monkey/retromusic/fragments/LibraryViewModel.kt | 11 +++++++++-- .../monkey/retromusic/repository/ArtistRepository.kt | 5 ++++- .../name/monkey/retromusic/util/PreferenceUtil.kt | 9 ++++++++- app/src/main/res/values/strings.xml | 4 ++++ app/src/main/res/xml/pref_ui.xml | 7 +++++++ 6 files changed, 33 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/code/name/monkey/retromusic/Constants.kt b/app/src/main/java/code/name/monkey/retromusic/Constants.kt index 4e3a7a24..f0ce5dbd 100644 --- a/app/src/main/java/code/name/monkey/retromusic/Constants.kt +++ b/app/src/main/java/code/name/monkey/retromusic/Constants.kt @@ -123,6 +123,7 @@ const val AUTO_DOWNLOAD_IMAGES_POLICY = "auto_download_images_policy" const val START_DIRECTORY = "start_directory" const val RECENTLY_PLAYED_CUTOFF = "recently_played_interval" const val LOCK_SCREEN = "lock_screen" +const val ALBUM_ARTISTS_ONLY = "album_artists_only" const val ALBUM_DETAIL_SONG_SORT_ORDER = "album_detail_song_sort_order" const val LYRICS_OPTIONS = "lyrics_tab_position" const val CHOOSE_EQUALIZER = "choose_equalizer" diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/LibraryViewModel.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/LibraryViewModel.kt index 3999ee70..ffccd49c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/LibraryViewModel.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/LibraryViewModel.kt @@ -12,6 +12,7 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.interfaces.MusicServiceEventListener import code.name.monkey.retromusic.model.* import code.name.monkey.retromusic.repository.RealRepository +import code.name.monkey.retromusic.util.PreferenceUtil import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.launch @@ -91,8 +92,14 @@ class LibraryViewModel( } private fun fetchArtists() { - viewModelScope.launch(IO) { - artists.postValue(repository.fetchArtists()) + if (PreferenceUtil.albumArtistsOnly) { + viewModelScope.launch(IO) { + artists.postValue(repository.albumArtists()) + } + } else { + viewModelScope.launch(IO) { + artists.postValue(repository.fetchArtists()) + } } } diff --git a/app/src/main/java/code/name/monkey/retromusic/repository/ArtistRepository.kt b/app/src/main/java/code/name/monkey/retromusic/repository/ArtistRepository.kt index 9a309b2a..bf1b41e3 100644 --- a/app/src/main/java/code/name/monkey/retromusic/repository/ArtistRepository.kt +++ b/app/src/main/java/code/name/monkey/retromusic/repository/ArtistRepository.kt @@ -69,7 +69,10 @@ class RealArtistRepository( getSongLoaderSortOrder() ) ) - return splitIntoAlbumArtists(albumRepository.splitIntoAlbums(songs)) + + val sortString = if (PreferenceUtil.artistSortOrder.contains("DESC")) String.CASE_INSENSITIVE_ORDER.reversed() else String.CASE_INSENSITIVE_ORDER + + return splitIntoAlbumArtists(albumRepository.splitIntoAlbums(songs)).sortedWith(compareBy(sortString) { it.name }) } private fun splitIntoAlbumArtists(albums: List): List { diff --git a/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.kt b/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.kt index 88333684..22221639 100644 --- a/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.kt +++ b/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.kt @@ -122,6 +122,13 @@ object PreferenceUtil { "only_wifi" ) + var albumArtistsOnly + get() = sharedPreferences.getBoolean( + ALBUM_ARTISTS_ONLY, + false + ) + set(value) = sharedPreferences.edit { putBoolean(ALBUM_ARTISTS_ONLY, value) } + var albumDetailSongSortOrder get() = sharedPreferences.getStringOrDefault( ALBUM_DETAIL_SONG_SORT_ORDER, @@ -150,7 +157,7 @@ object PreferenceUtil { var artistSortOrder get() = sharedPreferences.getStringOrDefault( ARTIST_SORT_ORDER, - AlbumSortOrder.ALBUM_A_Z + ArtistSortOrder.ARTIST_A_Z ) set(value) = sharedPreferences.edit { putString(ARTIST_SORT_ORDER, value) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 018bdc9f..be213e12 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -69,6 +69,8 @@ Sort order + Album artists only + Tag editor Toggle favorite @@ -517,6 +519,7 @@ Snow fall effect + Show Album Artists in the Artist category Use the currently playing song album cover as the lockscreen wallpaper Lower the volume when a system sound is played or a notification is received The content of blacklisted folders is hidden from your library. @@ -546,6 +549,7 @@ Shuffle mode will turn off when playing a new list of songs If enough space is available, show volume controls in the now playing screen + Navigate by Album Artist Show album cover Album cover theme Album cover skip diff --git a/app/src/main/res/xml/pref_ui.xml b/app/src/main/res/xml/pref_ui.xml index 36475624..50c1e7d2 100644 --- a/app/src/main/res/xml/pref_ui.xml +++ b/app/src/main/res/xml/pref_ui.xml @@ -45,6 +45,13 @@ android:negativeButtonText="@null" android:positiveButtonText="@null" android:title="@string/pref_title_tab_text_mode" /> + +