mirror of
https://github.com/jellyfin/jellyfin-android.git
synced 2026-10-26 16:45:26 +00:00
Add fallback icons to Android Auto items
This commit is contained in:
1 parent
c2be814647
commit
dc3b8e8a5b
11 files changed
+101
-1
No files matched your search
@@ -1,7 +1,9 @@
|
||||
package org.jellyfin.mobile.sessionbrowser
|
||||
|
||||
import android.net.Uri
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.core.net.toUri
|
||||
import org.jellyfin.mobile.R
|
||||
import org.jellyfin.sdk.api.client.ApiClient
|
||||
import org.jellyfin.sdk.api.client.extensions.imageApi
|
||||
import org.jellyfin.sdk.model.api.BaseItemDto
|
||||
@@ -24,6 +26,7 @@ sealed interface LibraryPageElement {
|
||||
val artist: String? = null,
|
||||
val album: String? = null,
|
||||
val image: Uri? = null,
|
||||
@DrawableRes val iconRes: Int? = null,
|
||||
val action: LibraryItemAction,
|
||||
) : LibraryPageElement
|
||||
|
||||
@@ -35,12 +38,14 @@ sealed interface LibraryPageElement {
|
||||
artist: String? = item.artists?.joinToString(),
|
||||
album: String? = item.album,
|
||||
image: Uri? = item.getImage(api),
|
||||
@DrawableRes iconRes: Int? = R.drawable.ic_notification,
|
||||
action: LibraryItemAction = LibraryItemAction.Play(item),
|
||||
): Item = Item(
|
||||
title = title,
|
||||
artist = artist,
|
||||
album = album,
|
||||
image = image,
|
||||
iconRes = iconRes,
|
||||
action = action,
|
||||
)
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.jellyfin.mobile.sessionbrowser
|
||||
|
||||
import android.content.ContentResolver
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.media3.common.MediaItem
|
||||
@@ -105,13 +107,25 @@ class SessionBrowserCallback(
|
||||
setAlbumTitle(album)
|
||||
setIsBrowsable(action is LibraryItemAction.Navigate)
|
||||
setIsPlayable(action is LibraryItemAction.Play)
|
||||
if (image != null) setArtworkUri(image)
|
||||
|
||||
if (image != null) {
|
||||
setArtworkUri(image)
|
||||
} else if (iconRes != null) {
|
||||
setArtworkUri(iconRes.asResourceUri())
|
||||
}
|
||||
|
||||
setExtras(extras)
|
||||
}.build(),
|
||||
)
|
||||
}.build()
|
||||
|
||||
private fun Int.asResourceUri() = Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
|
||||
.authority(context.resources.getResourcePackageName(this))
|
||||
.appendPath(context.resources.getResourceTypeName(this))
|
||||
.appendPath(context.resources.getResourceEntryName(this))
|
||||
.build()
|
||||
|
||||
private fun List<LibraryPageElement>.toMediaItems(): List<MediaItem> = flatMap { element ->
|
||||
when (element) {
|
||||
is LibraryPageElement.Group -> element.items.map { item -> item.toMediaItem(groupTitle = element.title) }
|
||||
|
||||
@@ -27,6 +27,7 @@ val RootLibraryPage = { api: ApiClient ->
|
||||
api = api,
|
||||
item = it,
|
||||
image = null,
|
||||
iconRes = null,
|
||||
action = LibraryItemAction.Navigate(LibraryRoute.Library(it.id, it.collectionType)),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ val UserViewLibraryPage = { context: Context ->
|
||||
add(
|
||||
LibraryPageElement.Item(
|
||||
title = context.getString(R.string.media_service_car_section_albums),
|
||||
iconRes = R.drawable.ic_album,
|
||||
action = LibraryItemAction.Navigate(LibraryRoute.AlbumsAlpha(route.libraryId)),
|
||||
),
|
||||
)
|
||||
@@ -25,6 +26,7 @@ val UserViewLibraryPage = { context: Context ->
|
||||
add(
|
||||
LibraryPageElement.Item(
|
||||
title = context.getString(R.string.media_service_car_section_artists),
|
||||
iconRes = R.drawable.ic_artist,
|
||||
action = LibraryItemAction.Navigate(LibraryRoute.ArtistsAlpha(route.libraryId)),
|
||||
),
|
||||
)
|
||||
@@ -34,6 +36,7 @@ val UserViewLibraryPage = { context: Context ->
|
||||
add(
|
||||
LibraryPageElement.Item(
|
||||
title = context.getString(R.string.media_service_car_section_audiobooks),
|
||||
iconRes = R.drawable.ic_audiobooks,
|
||||
action = LibraryItemAction.Navigate(LibraryRoute.AudioBooksAlpha(route.libraryId)),
|
||||
),
|
||||
)
|
||||
@@ -42,6 +45,7 @@ val UserViewLibraryPage = { context: Context ->
|
||||
add(
|
||||
LibraryPageElement.Item(
|
||||
title = context.getString(R.string.media_service_car_section_favorites),
|
||||
iconRes = R.drawable.ic_favorite,
|
||||
action = LibraryItemAction.Navigate(LibraryRoute.Favorites(route.libraryId)),
|
||||
),
|
||||
)
|
||||
@@ -49,6 +53,7 @@ val UserViewLibraryPage = { context: Context ->
|
||||
add(
|
||||
LibraryPageElement.Item(
|
||||
title = context.getString(R.string.media_service_car_section_genres),
|
||||
iconRes = R.drawable.ic_genres,
|
||||
action = LibraryItemAction.Navigate(LibraryRoute.Genres(route.libraryId)),
|
||||
),
|
||||
)
|
||||
@@ -56,6 +61,7 @@ val UserViewLibraryPage = { context: Context ->
|
||||
add(
|
||||
LibraryPageElement.Item(
|
||||
title = context.getString(R.string.media_service_car_section_playlists),
|
||||
iconRes = R.drawable.ic_playlist,
|
||||
action = LibraryItemAction.Navigate(LibraryRoute.Playlists(route.libraryId)),
|
||||
),
|
||||
)
|
||||
@@ -63,6 +69,7 @@ val UserViewLibraryPage = { context: Context ->
|
||||
add(
|
||||
LibraryPageElement.Item(
|
||||
title = context.getString(R.string.media_service_car_section_recents),
|
||||
iconRes = R.drawable.ic_recently_played,
|
||||
action = LibraryItemAction.Navigate(LibraryRoute.Recent(route.libraryId)),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="#FFFFFF"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="m12,4c-4.416,0 -8,3.584 -8,8s3.584,8 8,8 8,-3.584 8,-8 -3.584,-8 -8,-8zM12,15.6c-1.992,0 -3.6,-1.608 -3.6,-3.6s1.608,-3.6 3.6,-3.6 3.6,1.608 3.6,3.6 -1.608,3.6 -3.6,3.6zM12,11.2c-0.44,0 -0.8,0.36 -0.8,0.8s0.36,0.8 0.8,0.8 0.8,-0.36 0.8,-0.8 -0.36,-0.8 -0.8,-0.8z" />
|
||||
</vector>
|
||||
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="#FFFFFF"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M11,14C12,14 13.05,14.16 14.2,14.44C13.39,15.31 13,16.33 13,17.5C13,18.39 13.25,19.23 13.78,20H3V18C3,16.81 3.91,15.85 5.74,15.12C7.57,14.38 9.33,14 11,14M11,12C9.92,12 9,11.61 8.18,10.83C7.38,10.05 7,9.11 7,8C7,6.92 7.38,6 8.18,5.18C9,4.38 9.92,4 11,4C12.11,4 13.05,4.38 13.83,5.18C14.61,6 15,6.92 15,8C15,9.11 14.61,10.05 13.83,10.83C13.05,11.61 12.11,12 11,12M18.5,10H20L22,10V12H20V17.5A2.5,2.5 0 0,1 17.5,20A2.5,2.5 0 0,1 15,17.5A2.5,2.5 0 0,1 17.5,15C17.86,15 18.19,15.07 18.5,15.21V10Z" />
|
||||
</vector>
|
||||
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="#FFFFFF"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M9 3V18H12V3H9M12 5L16 18L19 17L15 4L12 5M5 5V18H8V5H5M3 19V21H21V19H3Z" />
|
||||
</vector>
|
||||
@@ -0,0 +1,11 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="#FFFFFF"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M12,15.39L8.24,17.66L9.23,13.38L5.91,10.5L10.29,10.13L12,6.09L13.71,10.13L18.09,10.5L14.77,13.38L15.76,17.66M22,9.24L14.81,8.63L12,2L9.19,8.63L2,9.24L7.45,13.97L5.82,21L12,17.27L18.18,21L16.54,13.97L22,9.24Z" />
|
||||
</vector>
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="#FFFFFF"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M8.11,19.45C5.94,18.65 4.22,16.78 3.71,14.35L2.05,6.54C1.81,5.46 2.5,4.4 3.58,4.17L13.35,2.1L13.38,2.09C14.45,1.88 15.5,2.57 15.72,3.63L16.07,5.3L20.42,6.23H20.45C21.5,6.47 22.18,7.53 21.96,8.59L20.3,16.41C19.5,20.18 15.78,22.6 12,21.79C10.42,21.46 9.08,20.61 8.11,19.45V19.45M20,8.18L10.23,6.1L8.57,13.92V13.95C8,16.63 9.73,19.27 12.42,19.84C15.11,20.41 17.77,18.69 18.34,16L20,8.18M16,16.5C15.37,17.57 14.11,18.16 12.83,17.89C11.56,17.62 10.65,16.57 10.5,15.34L16,16.5M8.47,5.17L4,6.13L5.66,13.94L5.67,13.97C5.82,14.68 6.12,15.32 6.53,15.87C6.43,15.1 6.45,14.3 6.62,13.5L7.05,11.5C6.6,11.42 6.21,11.17 6,10.81C6.06,10.2 6.56,9.66 7.25,9.5C7.33,9.5 7.4,9.5 7.5,9.5L8.28,5.69C8.32,5.5 8.38,5.33 8.47,5.17M15.03,12.23C15.35,11.7 16.03,11.42 16.72,11.57C17.41,11.71 17.91,12.24 18,12.86C17.67,13.38 17,13.66 16.3,13.5C15.61,13.37 15.11,12.84 15.03,12.23M10.15,11.19C10.47,10.66 11.14,10.38 11.83,10.53C12.5,10.67 13.03,11.21 13.11,11.82C12.78,12.34 12.11,12.63 11.42,12.5C10.73,12.33 10.23,11.8 10.15,11.19M11.97,4.43L13.93,4.85L13.77,4.05L11.97,4.43Z" />
|
||||
</vector>
|
||||
@@ -0,0 +1,11 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="#FFFFFF"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M3 10H14V12H3V10M3 6H14V8H3V6M3 14H10V16H3V14M16 13V21L22 17L16 13Z" />
|
||||
</vector>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="#FFFFFF"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M13.5,8H12V13L16.28,15.54L17,14.33L13.5,12.25V8M13,3A9,9 0 0,0 4,12H1L4.96,16.03L9,12H6A7,7 0 0,1 13,5A7,7 0 0,1 20,12A7,7 0 0,1 13,19C11.07,19 9.32,18.21 8.06,16.94L6.64,18.36C8.27,20 10.5,21 13,21A9,9 0 0,0 22,12A9,9 0 0,0 13,3" />
|
||||
</vector>
|
||||
|
||||
Reference in new issue
Block a user