diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/domain/APISearchConverter.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/domain/APISearchConverter.kt index a8833bbe..ff9ffd74 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/domain/APISearchConverter.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/domain/APISearchConverter.kt @@ -13,7 +13,7 @@ fun APISearchResult.toDomainEntity(): SearchResult = SearchResult( ) fun SearchTwoResult.toDomainEntity(): SearchResult = SearchResult( - this.artistList.map { it.toDomainEntity() }, + this.artistList.map { it.toIndexEntity() }, this.albumList.map { it.toDomainEntity() }, this.songList.map { it.toTrackEntity() } ) diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/TrackCollectionFragment.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/TrackCollectionFragment.kt index 50e3d6e7..bbc9a963 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/TrackCollectionFragment.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/fragment/TrackCollectionFragment.kt @@ -46,6 +46,7 @@ import org.moire.ultrasonic.util.Constants import org.moire.ultrasonic.util.EntryByDiscAndTrackComparator import org.moire.ultrasonic.util.Settings import org.moire.ultrasonic.util.Util +import org.moire.ultrasonic.util.Util.toast /** * Displays a group of tracks, eg. the songs of an album, of a playlist etc. @@ -246,9 +247,10 @@ open class TrackCollectionFragment : MultiListFragment() { super.onDestroyView() } - private fun playNow(append: Boolean) { - val selectedSongs = getSelectedSongs() - + private fun playNow( + append: Boolean, + selectedSongs: List = getSelectedSongs() + ) { if (selectedSongs.isNotEmpty()) { downloadHandler.download( this, append, false, !append, playNext = false, @@ -374,7 +376,10 @@ open class TrackCollectionFragment : MultiListFragment() { downloadBackground(save, songs) } - private fun downloadBackground(save: Boolean, songs: List) { + private fun downloadBackground( + save: Boolean, + songs: List + ) { val onValid = Runnable { networkAndStorageChecker.warnIfNetworkOrStorageUnavailable() mediaPlayerController.downloadBackground(songs, save) @@ -398,9 +403,7 @@ open class TrackCollectionFragment : MultiListFragment() { onValid.run() } - internal fun delete() { - val songs = getSelectedSongs() - + internal fun delete(songs: List = getSelectedSongs()) { Util.toast( context, resources.getQuantityString( @@ -411,8 +414,7 @@ open class TrackCollectionFragment : MultiListFragment() { mediaPlayerController.delete(songs) } - internal fun unpin() { - val songs = getSelectedSongs() + internal fun unpin(songs: List = getSelectedSongs()) { Util.toast( context, resources.getQuantityString( @@ -619,56 +621,40 @@ open class TrackCollectionFragment : MultiListFragment() { menuItem: MenuItem, item: MusicDirectory.Child ): Boolean { - val entryId = item.id + val songs = getClickedSong(item) when (menuItem.itemId) { - R.id.menu_play_now -> { - downloadHandler.downloadRecursively( - this, entryId, save = false, append = false, - autoPlay = true, shuffle = false, background = false, - playNext = false, unpin = false, isArtist = false + R.id.song_menu_play_now -> { + playNow(false, songs) + } + R.id.song_menu_play_next -> { + downloadHandler.download( + fragment = this@TrackCollectionFragment, + append = true, + save = false, + autoPlay = false, + playNext = true, + shuffle = false, + songs = songs ) } - R.id.menu_play_next -> { - downloadHandler.downloadRecursively( - this, entryId, save = false, append = false, - autoPlay = false, shuffle = false, background = false, - playNext = true, unpin = false, isArtist = false - ) + R.id.song_menu_play_last -> { + playNow(true, songs) } - R.id.menu_play_last -> { - downloadHandler.downloadRecursively( - this, entryId, save = false, append = true, - autoPlay = false, shuffle = false, background = false, - playNext = false, unpin = false, isArtist = false - ) + R.id.song_menu_pin -> { + downloadBackground(true, songs) } - R.id.menu_pin -> { - downloadHandler.downloadRecursively( - this, entryId, save = true, append = true, - autoPlay = false, shuffle = false, background = false, - playNext = false, unpin = false, isArtist = false - ) + R.id.song_menu_unpin -> { + unpin(songs) } - R.id.menu_unpin -> { - downloadHandler.downloadRecursively( - this, entryId, save = false, append = false, - autoPlay = false, shuffle = false, background = false, - playNext = false, unpin = true, isArtist = false - ) - } - R.id.menu_download -> { - downloadHandler.downloadRecursively( - this, entryId, save = false, append = false, - autoPlay = false, shuffle = false, background = true, - playNext = false, unpin = false, isArtist = false - ) + R.id.song_menu_download -> { + downloadBackground(false, songs) } R.id.select_album_play_all -> { // TODO: Why is this being handled here?! playAll() } - R.id.menu_item_share -> { + R.id.song_menu_share -> { if (item is MusicDirectory.Entry) { shareHandler.createShare( this, listOf(item), refreshListView, @@ -683,6 +669,16 @@ open class TrackCollectionFragment : MultiListFragment() { return true } + internal fun getClickedSong(item: MusicDirectory.Child): List { + // This can probably be done better + return viewAdapter.getCurrentList().mapNotNull { + if (it is MusicDirectory.Entry && (it.id == item.id)) + it + else + null + } + } + override fun onItemClick(item: MusicDirectory.Child) { when { item.isDirectory -> { diff --git a/ultrasonic/src/main/res/values/strings.xml b/ultrasonic/src/main/res/values/strings.xml index 3b40cdfc..3e08db52 100644 --- a/ultrasonic/src/main/res/values/strings.xml +++ b/ultrasonic/src/main/res/values/strings.xml @@ -217,8 +217,8 @@ Sort song list by disc number and track number Display Bitrate and File Suffix Append artist name with bitrate and file suffix - Show Downloads on Play - Transition to download activity when starting playback + Stay in Downloads on Play + Stay in media view when starting playback (do not switch to player view) Gapless Playback Enable gapless playback Hide music files from other apps. @@ -285,12 +285,12 @@ 75 Search history cleared Search Settings + Send playback notifications via Bluetooth + Send Bluetooth Notification Send album art over Bluetooth (May cause Bluetooth notifications to fail) Album Art Over Bluetooth Now Playing List won\'t be sent to connected devices. This may restore compatibility with AVRCP 1.3 devices, when current track display is not updated Disable sending of Now Playing List - Send playback notifications via Bluetooth - Send Bluetooth Notification Manage Servers Server Address Name @@ -320,8 +320,7 @@ Theme Allow self-signed HTTPS certificate Force plain password authentication - This forces the app to always send the password unencrypted. - Useful if the Subsonic server does not support the new authentication API for the users. + This forces the app to always send the password unencrypted. Useful if the Subsonic server does not support the new authentication API for the users. Use Folders For Artist Name Assume top-level folder is the name of the album artist Browse Using ID3 Tags @@ -389,7 +388,7 @@ All Bluetooth devices Only audio (A2DP) devices Disabled - Bluetooth device with only a single Play/Pause button + Bluetooth device with a single Play/Pause button Enabling this may help with older Bluetooth devices when Play/Pause doesn\'t work correctly Debug options Write debug log to file @@ -469,8 +468,7 @@ Features Use five star rating for songs - Use five star rating system for songs - instead of simply starring/unstarring items. + Use five star rating system for songs instead of simply starring/unstarring items. diff --git a/ultrasonic/src/test/kotlin/org/moire/ultrasonic/domain/APISearchConverterTest.kt b/ultrasonic/src/test/kotlin/org/moire/ultrasonic/domain/APISearchConverterTest.kt index d54a3a76..dd2e7d84 100644 --- a/ultrasonic/src/test/kotlin/org/moire/ultrasonic/domain/APISearchConverterTest.kt +++ b/ultrasonic/src/test/kotlin/org/moire/ultrasonic/domain/APISearchConverterTest.kt @@ -50,7 +50,7 @@ class APISearchConverterTest { with(convertedEntity) { artists.size `should be equal to` entity.artistList.size - artists[0] `should be equal to` entity.artistList[0].toDomainEntity() + artists[0] `should be equal to` entity.artistList[0].toIndexEntity() albums.size `should be equal to` entity.albumList.size albums[0] `should be equal to` entity.albumList[0].toDomainEntity() songs.size `should be equal to` entity.songList.size