mirror of
https://gitlab.com/ultrasonic/ultrasonic.git
synced 2025-04-25 05:10:55 +03:00
Merge branch 'moreOfflineAlbums' into 'develop'
Use AlbumType class instead of string, enable more Album types in Offline mode See merge request ultrasonic/ultrasonic!795
This commit is contained in:
commit
7bc6adb3f5
@ -25,6 +25,24 @@ interface AlbumDao : GenericDao<Album> {
|
||||
@Query("SELECT * FROM albums LIMIT :offset,:size")
|
||||
fun get(size: Int, offset: Int = 0): List<Album>
|
||||
|
||||
/**
|
||||
* Get all albums in a specific range in a certain order
|
||||
*/
|
||||
@Query("SELECT * FROM albums ORDER BY artist ASC LIMIT :offset,:size ")
|
||||
fun orderedByArtist(size: Int, offset: Int = 0): List<Album>
|
||||
|
||||
/**
|
||||
* Get all albums in a specific range in a certain order
|
||||
*/
|
||||
@Query("SELECT * FROM albums ORDER BY created DESC LIMIT :offset,:size ")
|
||||
fun orderedByAge(size: Int, offset: Int = 0): List<Album>
|
||||
|
||||
/**
|
||||
* Get all albums in a specific range in a certain order
|
||||
*/
|
||||
@Query("SELECT * FROM albums ORDER BY title ASC LIMIT :offset,:size ")
|
||||
fun orderedByName(size: Int, offset: Int = 0): List<Album>
|
||||
|
||||
/**
|
||||
* Get album by id
|
||||
*/
|
||||
|
@ -126,15 +126,15 @@ class MainFragment : Fragment(), KoinComponent {
|
||||
songsStarredButton.isVisible = isOnline
|
||||
|
||||
// Albums
|
||||
albumsTitle.isVisible = isOnline
|
||||
albumsNewestButton.isVisible = isOnline
|
||||
albumsTitle.isVisible = isOnline || useId3Offline
|
||||
albumsNewestButton.isVisible = isOnline || useId3Offline
|
||||
albumsRecentButton.isVisible = isOnline
|
||||
albumsFrequentButton.isVisible = isOnline
|
||||
albumsHighestButton.isVisible = isOnline && !useId3
|
||||
albumsRandomButton.isVisible = isOnline
|
||||
albumsStarredButton.isVisible = isOnline
|
||||
albumsAlphaByNameButton.isVisible = isOnline
|
||||
albumsAlphaByArtistButton.isVisible = isOnline
|
||||
albumsAlphaByNameButton.isVisible = isOnline || useId3Offline
|
||||
albumsAlphaByArtistButton.isVisible = isOnline || useId3Offline
|
||||
|
||||
// Videos
|
||||
videosTitle.isVisible = isOnline
|
||||
|
@ -82,20 +82,22 @@ class AlbumListModel(application: Application) : GenericListModel(application) {
|
||||
)
|
||||
}
|
||||
|
||||
val type = AlbumListType.fromName(albumListType)
|
||||
|
||||
if (useId3Tags) {
|
||||
musicDirectory =
|
||||
musicService.getAlbumList2(
|
||||
albumListType, size,
|
||||
type, size,
|
||||
offset, musicFolderId
|
||||
)
|
||||
} else {
|
||||
musicDirectory = musicService.getAlbumList(
|
||||
albumListType, size,
|
||||
type, size,
|
||||
offset, musicFolderId
|
||||
)
|
||||
}
|
||||
|
||||
currentListIsSortable = isCollectionSortable(albumListType)
|
||||
currentListIsSortable = isCollectionSortable(type)
|
||||
|
||||
if (append && list.value != null) {
|
||||
val newList = ArrayList<Album>()
|
||||
@ -112,17 +114,23 @@ class AlbumListModel(application: Application) : GenericListModel(application) {
|
||||
override fun showSelectFolderHeader(args: Bundle?): Boolean {
|
||||
if (args == null) return false
|
||||
|
||||
val albumListType = args.getString(Constants.INTENT_ALBUM_LIST_TYPE)!!
|
||||
val albumListType =
|
||||
AlbumListType.fromName(args.getString(Constants.INTENT_ALBUM_LIST_TYPE)!!)
|
||||
|
||||
val isAlphabetical = (albumListType == AlbumListType.SORTED_BY_NAME.toString()) ||
|
||||
(albumListType == AlbumListType.SORTED_BY_ARTIST.toString())
|
||||
val isAlphabetical = (albumListType == AlbumListType.SORTED_BY_NAME) ||
|
||||
(albumListType == AlbumListType.SORTED_BY_ARTIST)
|
||||
|
||||
return !isOffline() && !Settings.shouldUseId3Tags && isAlphabetical
|
||||
}
|
||||
|
||||
private fun isCollectionSortable(albumListType: String): Boolean {
|
||||
return albumListType != "newest" && albumListType != "random" &&
|
||||
albumListType != "highest" && albumListType != "recent" &&
|
||||
albumListType != "frequent"
|
||||
private fun isCollectionSortable(albumListType: AlbumListType): Boolean {
|
||||
return when (albumListType) {
|
||||
AlbumListType.RANDOM -> false
|
||||
AlbumListType.NEWEST -> false
|
||||
AlbumListType.HIGHEST -> false
|
||||
AlbumListType.FREQUENT -> false
|
||||
AlbumListType.RECENT -> false
|
||||
else -> true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -735,13 +735,13 @@ class AutoMediaBrowserCallback(var player: Player, val libraryService: MediaLibr
|
||||
if (useId3Tags) {
|
||||
callWithErrorHandling {
|
||||
musicService.getAlbumList2(
|
||||
type.typeName, DISPLAY_LIMIT, offset, null
|
||||
type, DISPLAY_LIMIT, offset, null
|
||||
)
|
||||
}
|
||||
} else {
|
||||
callWithErrorHandling {
|
||||
musicService.getAlbumList(
|
||||
type.typeName, DISPLAY_LIMIT, offset, null
|
||||
type, DISPLAY_LIMIT, offset, null
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -756,7 +756,7 @@ class AutoMediaBrowserCallback(var player: Player, val libraryService: MediaLibr
|
||||
)
|
||||
}
|
||||
|
||||
if (albums?.size ?: 0 >= DISPLAY_LIMIT)
|
||||
if ((albums?.size ?: 0) >= DISPLAY_LIMIT)
|
||||
mediaItems.add(
|
||||
R.string.search_more,
|
||||
listOf(MEDIA_ALBUM_PAGE_ID, type.typeName, (page ?: 0) + 1).joinToString("|"),
|
||||
|
@ -11,6 +11,7 @@ import java.util.concurrent.TimeUnit
|
||||
import kotlin.Pair
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.inject
|
||||
import org.moire.ultrasonic.api.subsonic.models.AlbumListType
|
||||
import org.moire.ultrasonic.data.ActiveServerProvider
|
||||
import org.moire.ultrasonic.data.MetaDatabase
|
||||
import org.moire.ultrasonic.domain.Album
|
||||
@ -256,7 +257,7 @@ class CachedMusicService(private val musicService: MusicService) : MusicService,
|
||||
|
||||
@Throws(Exception::class)
|
||||
override fun getAlbumList(
|
||||
type: String,
|
||||
type: AlbumListType,
|
||||
size: Int,
|
||||
offset: Int,
|
||||
musicFolderId: String?
|
||||
@ -266,7 +267,7 @@ class CachedMusicService(private val musicService: MusicService) : MusicService,
|
||||
|
||||
@Throws(Exception::class)
|
||||
override fun getAlbumList2(
|
||||
type: String,
|
||||
type: AlbumListType,
|
||||
size: Int,
|
||||
offset: Int,
|
||||
musicFolderId: String?
|
||||
|
@ -7,6 +7,7 @@
|
||||
package org.moire.ultrasonic.service
|
||||
|
||||
import java.io.InputStream
|
||||
import org.moire.ultrasonic.api.subsonic.models.AlbumListType
|
||||
import org.moire.ultrasonic.domain.Album
|
||||
import org.moire.ultrasonic.domain.Artist
|
||||
import org.moire.ultrasonic.domain.Bookmark
|
||||
@ -93,7 +94,7 @@ interface MusicService {
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun getAlbumList(
|
||||
type: String,
|
||||
type: AlbumListType,
|
||||
size: Int,
|
||||
offset: Int,
|
||||
musicFolderId: String?
|
||||
@ -101,7 +102,7 @@ interface MusicService {
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun getAlbumList2(
|
||||
type: String,
|
||||
type: AlbumListType,
|
||||
size: Int,
|
||||
offset: Int,
|
||||
musicFolderId: String?
|
||||
|
@ -22,6 +22,7 @@ import java.util.concurrent.TimeUnit
|
||||
import java.util.regex.Pattern
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.inject
|
||||
import org.moire.ultrasonic.api.subsonic.models.AlbumListType
|
||||
import org.moire.ultrasonic.data.ActiveServerProvider
|
||||
import org.moire.ultrasonic.data.MetaDatabase
|
||||
import org.moire.ultrasonic.domain.Album
|
||||
@ -313,7 +314,7 @@ class OfflineMusicService : MusicService, KoinComponent {
|
||||
|
||||
@Throws(Exception::class)
|
||||
override fun getAlbumList(
|
||||
type: String,
|
||||
type: AlbumListType,
|
||||
size: Int,
|
||||
offset: Int,
|
||||
musicFolderId: String?
|
||||
@ -323,13 +324,17 @@ class OfflineMusicService : MusicService, KoinComponent {
|
||||
|
||||
@Throws(OfflineException::class)
|
||||
override fun getAlbumList2(
|
||||
type: String,
|
||||
type: AlbumListType,
|
||||
size: Int,
|
||||
offset: Int,
|
||||
musicFolderId: String?
|
||||
): List<Album> {
|
||||
// TODO: Implement filtering by musicFolder?
|
||||
return cachedAlbums.get(size, offset)
|
||||
return when (type) {
|
||||
AlbumListType.NEWEST -> cachedAlbums.orderedByAge(size, offset)
|
||||
AlbumListType.SORTED_BY_ARTIST -> cachedAlbums.orderedByArtist(size, offset)
|
||||
else -> cachedAlbums.orderedByName(size, offset)
|
||||
}
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
|
@ -13,7 +13,7 @@ import okhttp3.Response
|
||||
import okhttp3.ResponseBody.Companion.toResponseBody
|
||||
import org.moire.ultrasonic.api.subsonic.ApiNotSupportedException
|
||||
import org.moire.ultrasonic.api.subsonic.SubsonicAPIClient
|
||||
import org.moire.ultrasonic.api.subsonic.models.AlbumListType.Companion.fromName
|
||||
import org.moire.ultrasonic.api.subsonic.models.AlbumListType
|
||||
import org.moire.ultrasonic.api.subsonic.models.JukeboxAction
|
||||
import org.moire.ultrasonic.api.subsonic.throwOnFailure
|
||||
import org.moire.ultrasonic.api.subsonic.toStreamResponse
|
||||
@ -351,13 +351,13 @@ open class RESTMusicService(
|
||||
|
||||
@Throws(Exception::class)
|
||||
override fun getAlbumList(
|
||||
type: String,
|
||||
type: AlbumListType,
|
||||
size: Int,
|
||||
offset: Int,
|
||||
musicFolderId: String?
|
||||
): List<Album> {
|
||||
val response = API.getAlbumList(
|
||||
fromName(type),
|
||||
type,
|
||||
size,
|
||||
offset,
|
||||
null,
|
||||
@ -371,13 +371,13 @@ open class RESTMusicService(
|
||||
|
||||
@Throws(Exception::class)
|
||||
override fun getAlbumList2(
|
||||
type: String,
|
||||
type: AlbumListType,
|
||||
size: Int,
|
||||
offset: Int,
|
||||
musicFolderId: String?
|
||||
): List<Album> {
|
||||
val response = API.getAlbumList2(
|
||||
fromName(type),
|
||||
type,
|
||||
size,
|
||||
offset,
|
||||
null,
|
||||
|
Loading…
x
Reference in New Issue
Block a user