Better defaults when adding music to home page

This commit is contained in:
Damontecres 2026-03-11 00:03:17 -04:00
parent f062aedadf
commit c91ac434e0
No known key found for this signature in database
3 changed files with 47 additions and 4 deletions

View file

@ -29,6 +29,7 @@ data class HomeRowPresets(
val tvLibrary: HomeRowViewOptions,
val videoLibrary: HomeRowViewOptions,
val photoLibrary: HomeRowViewOptions,
val musicLibrary: HomeRowViewOptions,
val playlist: HomeRowViewOptions,
val liveTv: HomeRowViewOptions,
val genreSize: Int,
@ -51,8 +52,9 @@ data class HomeRowPresets(
CollectionType.LIVETV -> liveTv
CollectionType.MUSIC -> musicLibrary
CollectionType.UNKNOWN,
CollectionType.MUSIC,
CollectionType.BOOKS,
CollectionType.PLAYLISTS,
CollectionType.FOLDERS,
@ -74,6 +76,10 @@ data class HomeRowPresets(
aspectRatio = AspectRatio.WIDE,
contentScale = PrefContentScale.CROP,
),
musicLibrary =
HomeRowViewOptions(
aspectRatio = AspectRatio.SQUARE,
),
playlist =
HomeRowViewOptions(
aspectRatio = AspectRatio.SQUARE,
@ -111,6 +117,11 @@ data class HomeRowPresets(
aspectRatio = AspectRatio.WIDE,
contentScale = PrefContentScale.CROP,
),
musicLibrary =
HomeRowViewOptions(
heightDp = epHeight,
aspectRatio = AspectRatio.SQUARE,
),
playlist =
HomeRowViewOptions(
heightDp = epHeight,
@ -154,6 +165,11 @@ data class HomeRowPresets(
aspectRatio = AspectRatio.WIDE,
contentScale = PrefContentScale.CROP,
),
musicLibrary =
HomeRowViewOptions(
heightDp = epHeight,
aspectRatio = AspectRatio.SQUARE,
),
playlist =
HomeRowViewOptions(
heightDp = epHeight,
@ -198,6 +214,11 @@ data class HomeRowPresets(
aspectRatio = AspectRatio.WIDE,
contentScale = PrefContentScale.CROP,
),
musicLibrary =
HomeRowViewOptions(
heightDp = epHeight,
aspectRatio = AspectRatio.SQUARE,
),
playlist =
HomeRowViewOptions(
heightDp = epHeight,

View file

@ -59,6 +59,8 @@ val favoriteOptions by lazy {
BaseItemKind.VIDEO to R.string.videos,
BaseItemKind.PLAYLIST to R.string.playlists,
BaseItemKind.PERSON to R.string.people,
BaseItemKind.MUSIC_ARTIST to R.string.artists,
BaseItemKind.MUSIC_ALBUM to R.string.albums,
)
}
val favoriteOptionsList by lazy { favoriteOptions.keys.toList() }

View file

@ -33,6 +33,7 @@ import com.github.damontecres.wholphin.services.UnsupportedHomeSettingsVersionEx
import com.github.damontecres.wholphin.services.UserPreferencesService
import com.github.damontecres.wholphin.services.hilt.IoCoroutineScope
import com.github.damontecres.wholphin.services.tvAccess
import com.github.damontecres.wholphin.ui.AspectRatio
import com.github.damontecres.wholphin.ui.launchIO
import com.github.damontecres.wholphin.ui.showToast
import com.github.damontecres.wholphin.util.HomeRowLoadingState
@ -258,6 +259,24 @@ class HomeSettingsViewModel
rowType: LibraryRowType,
): Job =
viewModelScope.launchIO {
val viewOptions =
when (library.collectionType) {
CollectionType.MUSIC -> {
HomeRowViewOptions(aspectRatio = AspectRatio.SQUARE)
}
CollectionType.HOMEVIDEOS,
CollectionType.MUSICVIDEOS,
-> {
HomeRowViewOptions(
aspectRatio = AspectRatio.WIDE,
)
}
else -> {
HomeRowViewOptions()
}
}
val id = idCounter++
val newRow =
when (rowType) {
@ -267,7 +286,7 @@ class HomeSettingsViewModel
HomeRowConfigDisplay(
id = id,
title = title,
config = RecentlyAdded(library.itemId),
config = RecentlyAdded(library.itemId, viewOptions),
)
}
@ -282,7 +301,7 @@ class HomeSettingsViewModel
HomeRowConfigDisplay(
id = id,
title = title,
config = RecentlyReleased(library.itemId),
config = RecentlyReleased(library.itemId, viewOptions),
)
}
@ -301,7 +320,7 @@ class HomeSettingsViewModel
HomeRowConfigDisplay(
id = id,
title = title,
config = Suggestions(library.itemId),
config = Suggestions(library.itemId, viewOptions),
)
}
@ -662,6 +681,7 @@ class HomeSettingsViewModel
BaseItemKind.VIDEO -> preset.videoLibrary
BaseItemKind.PLAYLIST -> preset.playlist
BaseItemKind.PERSON -> preset.movieLibrary
BaseItemKind.MUSIC_ARTIST, BaseItemKind.MUSIC_ALBUM -> preset.musicLibrary
else -> preset.movieLibrary
}
it.config.updateViewOptions(viewOptions)