Merge branch 'dev' into state
This commit is contained in:
commit
03c0b2f68b
8 changed files with 69 additions and 6 deletions
|
@ -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"
|
||||
|
|
|
@ -11,7 +11,11 @@ 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.state.NowPlayingPanelState
|
||||
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
|
@ -95,8 +99,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())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package code.name.monkey.retromusic.model
|
||||
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import java.util.*
|
||||
|
||||
data class Artist(
|
||||
|
@ -25,6 +26,9 @@ data class Artist(
|
|||
val name: String
|
||||
get() {
|
||||
val name = safeGetFirstAlbum().safeGetFirstSong().albumArtist
|
||||
if (PreferenceUtil.albumArtistsOnly && MusicUtil.isVariousArtists(name)) {
|
||||
return VARIOUS_ARTISTS_DISPLAY_NAME
|
||||
}
|
||||
return if (MusicUtil.isArtistNameUnknown(name)) {
|
||||
UNKNOWN_ARTIST_DISPLAY_NAME
|
||||
} else safeGetFirstAlbum().safeGetFirstSong().artistName
|
||||
|
@ -51,6 +55,8 @@ data class Artist(
|
|||
|
||||
companion object {
|
||||
const val UNKNOWN_ARTIST_DISPLAY_NAME = "Unknown Artist"
|
||||
const val VARIOUS_ARTISTS_DISPLAY_NAME = "Various Artists"
|
||||
const val VARIOUS_ARTISTS_ID : Long = -2
|
||||
val empty = Artist(-1, emptyList())
|
||||
|
||||
}
|
||||
|
|
|
@ -40,6 +40,19 @@ class RealArtistRepository(
|
|||
PreferenceUtil.artistSongSortOrder
|
||||
}
|
||||
override fun artist(artistId: Long): Artist {
|
||||
if (artistId == Artist.VARIOUS_ARTISTS_ID) {
|
||||
// Get Various Artists
|
||||
val songs = songRepository.songs(
|
||||
songRepository.makeSongCursor(
|
||||
null,
|
||||
null,
|
||||
getSongLoaderSortOrder()
|
||||
)
|
||||
)
|
||||
val albums = albumRepository.splitIntoAlbums(songs).filter { it.albumArtist == Artist.VARIOUS_ARTISTS_DISPLAY_NAME }
|
||||
return Artist(Artist.VARIOUS_ARTISTS_ID, albums)
|
||||
}
|
||||
|
||||
val songs = songRepository.songs(
|
||||
songRepository.makeSongCursor(
|
||||
AudioColumns.ARTIST_ID + "=?",
|
||||
|
@ -67,6 +80,7 @@ class RealArtistRepository(
|
|||
getSongLoaderSortOrder()
|
||||
)
|
||||
)
|
||||
|
||||
return splitIntoAlbumArtists(albumRepository.splitIntoAlbums(songs))
|
||||
}
|
||||
|
||||
|
@ -86,8 +100,12 @@ class RealArtistRepository(
|
|||
return albums.groupBy { it.albumArtist }
|
||||
.map {
|
||||
val currentAlbums = it.value
|
||||
if (albums.isNotEmpty()) {
|
||||
Artist(currentAlbums[0].id, currentAlbums)
|
||||
if (currentAlbums.isNotEmpty()) {
|
||||
if (currentAlbums[0].albumArtist == Artist.VARIOUS_ARTISTS_DISPLAY_NAME) {
|
||||
Artist(Artist.VARIOUS_ARTISTS_ID, currentAlbums)
|
||||
} else {
|
||||
Artist(currentAlbums[0].artistId, currentAlbums)
|
||||
}
|
||||
} else {
|
||||
Artist.empty
|
||||
}
|
||||
|
@ -100,4 +118,4 @@ class RealArtistRepository(
|
|||
return albums.groupBy { it.artistId }
|
||||
.map { Artist(it.key, it.value) }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -299,6 +299,16 @@ object MusicUtil : KoinComponent {
|
|||
return tempName == "unknown" || tempName == "<unknown>"
|
||||
}
|
||||
|
||||
fun isVariousArtists(artistName: String?): Boolean {
|
||||
if (TextUtils.isEmpty(artistName)) {
|
||||
return false
|
||||
}
|
||||
if (artistName == Artist.VARIOUS_ARTISTS_DISPLAY_NAME) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun isFavorite(context: Context, song: Song): Boolean {
|
||||
return PlaylistsUtil
|
||||
.doPlaylistContains(context, getFavoritesPlaylist(context).id, song.id)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -69,6 +69,8 @@
|
|||
|
||||
<string name="action_sort_order">Sort order</string>
|
||||
|
||||
<string name="action_album_artists_only">Album artists only</string>
|
||||
|
||||
<string name="action_tag_editor">Tag editor</string>
|
||||
|
||||
<string name="action_toggle_favorite">Toggle favorite</string>
|
||||
|
@ -517,6 +519,7 @@
|
|||
|
||||
<string name="pref_snow_fall_title">Snow fall effect</string>
|
||||
|
||||
<string name="pref_summary_album_artists_only">Show Album Artists in the Artist category</string>
|
||||
<string name="pref_summary_album_art_on_lockscreen">Use the currently playing song album cover as the lockscreen wallpaper</string>
|
||||
<string name="pref_summary_audio_ducking">Lower the volume when a system sound is played or a notification is received</string>
|
||||
<string name="pref_summary_blacklist">The content of blacklisted folders is hidden from your library.</string>
|
||||
|
@ -546,6 +549,7 @@
|
|||
<string name="pref_summary_toggle_shuffle">Shuffle mode will turn off when playing a new list of songs</string>
|
||||
<string name="pref_summary_toggle_volume">If enough space is available, show volume controls in the now playing screen</string>
|
||||
|
||||
<string name="pref_title_album_artists_only">Navigate by Album Artist</string>
|
||||
<string name="pref_title_album_art_on_lockscreen">Show album cover</string>
|
||||
<string name="pref_title_album_cover_style">Album cover theme</string>
|
||||
<string name="pref_title_album_cover_transform">Album cover skip</string>
|
||||
|
|
|
@ -45,6 +45,13 @@
|
|||
android:negativeButtonText="@null"
|
||||
android:positiveButtonText="@null"
|
||||
android:title="@string/pref_title_tab_text_mode" />
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATESwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="album_artists_only"
|
||||
android:layout="@layout/list_item_view_switch"
|
||||
android:summary="@string/pref_summary_album_artists_only"
|
||||
android:title="@string/pref_title_album_artists_only" />
|
||||
</code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory>
|
||||
|
||||
<code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory
|
||||
|
|
Loading…
Reference in a new issue