Merge branch 'develop' into fix-debug-file-size2

This commit is contained in:
Nite 2022-03-15 11:33:44 +01:00 committed by GitHub
commit e8c31db90f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 58 deletions

View File

@ -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() }
)

View File

@ -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<MusicDirectory.Child>() {
super.onDestroyView()
}
private fun playNow(append: Boolean) {
val selectedSongs = getSelectedSongs()
private fun playNow(
append: Boolean,
selectedSongs: List<MusicDirectory.Entry> = getSelectedSongs()
) {
if (selectedSongs.isNotEmpty()) {
downloadHandler.download(
this, append, false, !append, playNext = false,
@ -374,7 +376,10 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
downloadBackground(save, songs)
}
private fun downloadBackground(save: Boolean, songs: List<MusicDirectory.Entry?>) {
private fun downloadBackground(
save: Boolean,
songs: List<MusicDirectory.Entry?>
) {
val onValid = Runnable {
networkAndStorageChecker.warnIfNetworkOrStorageUnavailable()
mediaPlayerController.downloadBackground(songs, save)
@ -398,9 +403,7 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
onValid.run()
}
internal fun delete() {
val songs = getSelectedSongs()
internal fun delete(songs: List<MusicDirectory.Entry> = getSelectedSongs()) {
Util.toast(
context,
resources.getQuantityString(
@ -411,8 +414,7 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
mediaPlayerController.delete(songs)
}
internal fun unpin() {
val songs = getSelectedSongs()
internal fun unpin(songs: List<MusicDirectory.Entry> = getSelectedSongs()) {
Util.toast(
context,
resources.getQuantityString(
@ -619,56 +621,40 @@ open class TrackCollectionFragment : MultiListFragment<MusicDirectory.Child>() {
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<MusicDirectory.Child>() {
return true
}
internal fun getClickedSong(item: MusicDirectory.Child): List<MusicDirectory.Entry> {
// 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 -> {

View File

@ -217,8 +217,8 @@
<string name="settings.disc_sort_summary">Sort song list by disc number and track number</string>
<string name="settings.display_bitrate">Display Bitrate and File Suffix</string>
<string name="settings.display_bitrate_summary">Append artist name with bitrate and file suffix</string>
<string name="settings.download_transition">Show Downloads on Play</string>
<string name="settings.download_transition_summary">Transition to download activity when starting playback</string>
<string name="settings.download_transition">Stay in Downloads on Play</string>
<string name="settings.download_transition_summary">Stay in media view when starting playback (do not switch to player view)</string>
<string name="settings.gapless_playback">Gapless Playback</string>
<string name="settings.gapless_playback_summary">Enable gapless playback</string>
<string name="settings.hide_media_summary">Hide music files from other apps.</string>
@ -285,12 +285,12 @@
<string name="settings.search_75">75</string>
<string name="settings.search_history_cleared">Search history cleared</string>
<string name="settings.search_title">Search Settings</string>
<string name="settings.send_bluetooth_notification_summary">Send playback notifications via Bluetooth</string>
<string name="settings.send_bluetooth_notification">Send Bluetooth Notification</string>
<string name="settings.send_bluetooth_album_art_summary">Send album art over Bluetooth (May cause Bluetooth notifications to fail)</string>
<string name="settings.send_bluetooth_album_art">Album Art Over Bluetooth</string>
<string name="settings.disable_send_now_playing_list_summary">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</string>
<string name="settings.disable_send_now_playing_list">Disable sending of Now Playing List</string>
<string name="settings.send_bluetooth_notification_summary">Send playback notifications via Bluetooth</string>
<string name="settings.send_bluetooth_notification">Send Bluetooth Notification</string>
<string name="settings.server_manage_servers">Manage Servers</string>
<string name="settings.server_address">Server Address</string>
<string name="settings.server_name">Name</string>
@ -320,8 +320,7 @@
<string name="settings.theme_title">Theme</string>
<string name="settings.title.allow_self_signed_certificate">Allow self-signed HTTPS certificate</string>
<string name="settings.title.enable_ldap_users_support">Force plain password authentication</string>
<string name="settings.summary.enable_ldap_users_support">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.</string>
<string name="settings.summary.enable_ldap_users_support">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.</string>
<string name="settings.use_folder_for_album_artist">Use Folders For Artist Name</string>
<string name="settings.use_folder_for_album_artist_summary">Assume top-level folder is the name of the album artist</string>
<string name="settings.use_id3">Browse Using ID3 Tags</string>
@ -389,7 +388,7 @@
<string name="settings.playback.bluetooth_all">All Bluetooth devices</string>
<string name="settings.playback.bluetooth_a2dp">Only audio (A2DP) devices</string>
<string name="settings.playback.bluetooth_disabled">Disabled</string>
<string name="settings.playback.single_button_bluetooth_device">Bluetooth device with only a single Play/Pause button</string>
<string name="settings.playback.single_button_bluetooth_device">Bluetooth device with a single Play/Pause button</string>
<string name="settings.playback.single_button_bluetooth_device_summary">Enabling this may help with older Bluetooth devices when Play/Pause doesn\'t work correctly</string>
<string name="settings.debug.title">Debug options</string>
<string name="settings.debug.log_to_file">Write debug log to file</string>
@ -469,8 +468,7 @@
<!-- Subsonic features -->
<string name="settings.features_title">Features</string>
<string name="settings.five_star_rating_title">Use five star rating for songs</string>
<string name="settings.five_star_rating_description">Use five star rating system for songs
instead of simply starring/unstarring items.
<string name="settings.five_star_rating_description">Use five star rating system for songs instead of simply starring/unstarring items.
</string>
</resources>

View File

@ -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