playback: add tab icons
|
@ -19,10 +19,15 @@
|
|||
package org.oxycblt.auxio.music.service
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
import android.os.Bundle
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.media.utils.MediaConstants
|
||||
import androidx.media3.common.MediaItem
|
||||
import androidx.media3.common.MediaMetadata
|
||||
import java.io.ByteArrayOutputStream
|
||||
import org.oxycblt.auxio.BuildConfig
|
||||
import org.oxycblt.auxio.R
|
||||
import org.oxycblt.auxio.music.Album
|
||||
|
@ -37,14 +42,27 @@ import org.oxycblt.auxio.music.resolveNames
|
|||
import org.oxycblt.auxio.util.getPlural
|
||||
|
||||
fun MediaSessionUID.Category.toMediaItem(context: Context): MediaItem {
|
||||
// TODO: Make custom overflow menu for compat
|
||||
val style =
|
||||
Bundle().apply {
|
||||
putInt(
|
||||
MediaConstants.DESCRIPTION_EXTRAS_KEY_CONTENT_STYLE_SINGLE_ITEM,
|
||||
MediaConstants.DESCRIPTION_EXTRAS_VALUE_CONTENT_STYLE_CATEGORY_LIST_ITEM)
|
||||
}
|
||||
val metadata =
|
||||
MediaMetadata.Builder()
|
||||
.setTitle(context.getString(nameRes))
|
||||
.setIsPlayable(false)
|
||||
.setIsBrowsable(true)
|
||||
.setMediaType(mediaType)
|
||||
.build()
|
||||
return MediaItem.Builder().setMediaId(toString()).setMediaMetadata(metadata).build()
|
||||
.setExtras(style)
|
||||
if (bitmapRes != null) {
|
||||
val data = ByteArrayOutputStream()
|
||||
BitmapFactory.decodeResource(context.resources, bitmapRes)
|
||||
.compress(Bitmap.CompressFormat.PNG, 100, data)
|
||||
metadata.setArtworkData(data.toByteArray(), MediaMetadata.PICTURE_TYPE_FILE_ICON)
|
||||
}
|
||||
return MediaItem.Builder().setMediaId(toString()).setMediaMetadata(metadata.build()).build()
|
||||
}
|
||||
|
||||
fun Song.toMediaItem(context: Context, parent: MusicParent?): MediaItem {
|
||||
|
@ -205,14 +223,38 @@ fun MediaItem.toSong(deviceLibrary: DeviceLibrary): Song? {
|
|||
}
|
||||
|
||||
sealed interface MediaSessionUID {
|
||||
enum class Category(val id: String, @StringRes val nameRes: Int, val mediaType: Int?) :
|
||||
MediaSessionUID {
|
||||
ROOT("root", R.string.info_app_name, null),
|
||||
SONGS("songs", R.string.lbl_songs, MediaMetadata.MEDIA_TYPE_MUSIC),
|
||||
ALBUMS("albums", R.string.lbl_albums, MediaMetadata.MEDIA_TYPE_FOLDER_ALBUMS),
|
||||
ARTISTS("artists", R.string.lbl_artists, MediaMetadata.MEDIA_TYPE_FOLDER_ARTISTS),
|
||||
GENRES("genres", R.string.lbl_genres, MediaMetadata.MEDIA_TYPE_FOLDER_GENRES),
|
||||
PLAYLISTS("playlists", R.string.lbl_playlists, MediaMetadata.MEDIA_TYPE_FOLDER_PLAYLISTS);
|
||||
enum class Category(
|
||||
val id: String,
|
||||
@StringRes val nameRes: Int,
|
||||
@DrawableRes val bitmapRes: Int?,
|
||||
val mediaType: Int?
|
||||
) : MediaSessionUID {
|
||||
ROOT("root", R.string.info_app_name, null, null),
|
||||
SONGS(
|
||||
"songs",
|
||||
R.string.lbl_songs,
|
||||
R.drawable.ic_song_bitmap_24,
|
||||
MediaMetadata.MEDIA_TYPE_MUSIC),
|
||||
ALBUMS(
|
||||
"albums",
|
||||
R.string.lbl_albums,
|
||||
R.drawable.ic_album_bitmap_24,
|
||||
MediaMetadata.MEDIA_TYPE_FOLDER_ALBUMS),
|
||||
ARTISTS(
|
||||
"artists",
|
||||
R.string.lbl_artists,
|
||||
R.drawable.ic_artist_bitmap_24,
|
||||
MediaMetadata.MEDIA_TYPE_FOLDER_ARTISTS),
|
||||
GENRES(
|
||||
"genres",
|
||||
R.string.lbl_genres,
|
||||
R.drawable.ic_genre_bitmap_24,
|
||||
MediaMetadata.MEDIA_TYPE_FOLDER_GENRES),
|
||||
PLAYLISTS(
|
||||
"playlists",
|
||||
R.string.lbl_playlists,
|
||||
R.drawable.ic_playlist_bitmap_24,
|
||||
MediaMetadata.MEDIA_TYPE_FOLDER_PLAYLISTS);
|
||||
|
||||
override fun toString() = "$ID_CATEGORY:$id"
|
||||
|
||||
|
|
BIN
app/src/main/res/drawable-hdpi/ic_album_bitmap_24.png
Normal file
After Width: | Height: | Size: 676 B |
BIN
app/src/main/res/drawable-hdpi/ic_artist_bitmap_24.png
Normal file
After Width: | Height: | Size: 531 B |
BIN
app/src/main/res/drawable-hdpi/ic_genre_bitmap_24.png
Normal file
After Width: | Height: | Size: 432 B |
BIN
app/src/main/res/drawable-hdpi/ic_playlist_bitmap_24.png
Normal file
After Width: | Height: | Size: 259 B |
BIN
app/src/main/res/drawable-hdpi/ic_song_bitmap_24.png
Normal file
After Width: | Height: | Size: 291 B |
BIN
app/src/main/res/drawable-mdpi/ic_album_bitmap_24.png
Normal file
After Width: | Height: | Size: 375 B |
BIN
app/src/main/res/drawable-mdpi/ic_artist_bitmap_24.png
Normal file
After Width: | Height: | Size: 313 B |
BIN
app/src/main/res/drawable-mdpi/ic_genre_bitmap_24.png
Normal file
After Width: | Height: | Size: 241 B |
BIN
app/src/main/res/drawable-mdpi/ic_playlist_bitmap_24.png
Normal file
After Width: | Height: | Size: 182 B |
BIN
app/src/main/res/drawable-mdpi/ic_song_bitmap_24.png
Normal file
After Width: | Height: | Size: 175 B |
BIN
app/src/main/res/drawable-xhdpi/ic_album_bitmap_24.png
Normal file
After Width: | Height: | Size: 894 B |
BIN
app/src/main/res/drawable-xhdpi/ic_artist_bitmap_24.png
Normal file
After Width: | Height: | Size: 642 B |
BIN
app/src/main/res/drawable-xhdpi/ic_genre_bitmap_24.png
Normal file
After Width: | Height: | Size: 422 B |
BIN
app/src/main/res/drawable-xhdpi/ic_playlist_bitmap_24.png
Normal file
After Width: | Height: | Size: 328 B |
BIN
app/src/main/res/drawable-xhdpi/ic_song_bitmap_24.png
Normal file
After Width: | Height: | Size: 326 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_album_bitmap_24.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
app/src/main/res/drawable-xxhdpi/ic_artist_bitmap_24.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/drawable-xxhdpi/ic_genre_bitmap_24.png
Normal file
After Width: | Height: | Size: 812 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_playlist_bitmap_24.png
Normal file
After Width: | Height: | Size: 559 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_song_bitmap_24.png
Normal file
After Width: | Height: | Size: 560 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_album_bitmap_24.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/ic_artist_bitmap_24.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/ic_genre_bitmap_24.png
Normal file
After Width: | Height: | Size: 784 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_playlist_bitmap_24.png
Normal file
After Width: | Height: | Size: 672 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_song_bitmap_24.png
Normal file
After Width: | Height: | Size: 687 B |