diff --git a/app/src/main/java/org/oxycblt/auxio/AuxioService.kt b/app/src/main/java/org/oxycblt/auxio/AuxioService.kt
index eb2c8dc43..4f45fff6a 100644
--- a/app/src/main/java/org/oxycblt/auxio/AuxioService.kt
+++ b/app/src/main/java/org/oxycblt/auxio/AuxioService.kt
@@ -86,8 +86,7 @@ class AuxioService :
rootHints: Bundle?
): BrowserRoot {
val maximumRootChildLimit =
- rootHints?.getInt(
- MediaConstants.BROWSER_ROOT_HINTS_KEY_ROOT_CHILDREN_LIMIT, 4) ?: 4
+ rootHints?.getInt(MediaConstants.BROWSER_ROOT_HINTS_KEY_ROOT_CHILDREN_LIMIT, 4) ?: 4
return musicFragment.getRoot(maximumRootChildLimit)
}
diff --git a/app/src/main/java/org/oxycblt/auxio/music/service/Category.kt b/app/src/main/java/org/oxycblt/auxio/music/service/Category.kt
index c2babde29..46676d3cc 100644
--- a/app/src/main/java/org/oxycblt/auxio/music/service/Category.kt
+++ b/app/src/main/java/org/oxycblt/auxio/music/service/Category.kt
@@ -1,3 +1,21 @@
+/*
+ * Copyright (c) 2024 Auxio Project
+ * Category.kt is part of Auxio.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
package org.oxycblt.auxio.music.service
import org.oxycblt.auxio.R
@@ -79,6 +97,7 @@ sealed interface Category {
val MUSIC = arrayOf(Songs, Albums, Artists, Genres, Playlists)
val DEVICE_MUSIC = arrayOf(Songs, Albums, Artists, Genres)
val USER_MUSIC = arrayOf(Playlists)
+
fun fromString(str: String): Category? =
when {
str.startsWith(Root.ID_PREFIX) -> Root.fromString(str)
@@ -91,4 +110,4 @@ sealed interface Category {
else -> null
}
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/oxycblt/auxio/music/service/MediaItemTranslation.kt b/app/src/main/java/org/oxycblt/auxio/music/service/MediaItemTranslation.kt
index b04afbc23..be320131b 100644
--- a/app/src/main/java/org/oxycblt/auxio/music/service/MediaItemTranslation.kt
+++ b/app/src/main/java/org/oxycblt/auxio/music/service/MediaItemTranslation.kt
@@ -60,8 +60,7 @@ sealed interface MediaSessionUID {
return null
}
return when (parts[0]) {
- ID_CATEGORY ->
- CategoryItem(Category.fromString(parts[1]) ?: return null)
+ ID_CATEGORY -> CategoryItem(Category.fromString(parts[1]) ?: return null)
ID_ITEM -> {
val uids = parts[1].split(">", limit = 2)
if (uids.size == 1) {
diff --git a/app/src/main/java/org/oxycblt/auxio/music/service/MusicBrowser.kt b/app/src/main/java/org/oxycblt/auxio/music/service/MusicBrowser.kt
index 576454204..b62f9b248 100644
--- a/app/src/main/java/org/oxycblt/auxio/music/service/MusicBrowser.kt
+++ b/app/src/main/java/org/oxycblt/auxio/music/service/MusicBrowser.kt
@@ -186,35 +186,35 @@ constructor(
}
}
- private fun getCategoryMediaItems(category: Category, deviceLibrary: DeviceLibrary, userLibrary: UserLibrary) =
+ private fun getCategoryMediaItems(
+ category: Category,
+ deviceLibrary: DeviceLibrary,
+ userLibrary: UserLibrary
+ ) =
when (category) {
is Category.Root -> {
val base = Category.MUSIC.take(category.amount)
if (base.size < Category.MUSIC.size) {
- base + Category.More(Category.MUSIC.size - base.size)
- } else {
- base
- }.map { it.toMediaItem(context) }
- }
- is Category.More -> Category.MUSIC.takeLast(category.remainder).map {
- it.toMediaItem(context)
+ base + Category.More(Category.MUSIC.size - base.size)
+ } else {
+ base
+ }
+ .map { it.toMediaItem(context) }
}
+ is Category.More ->
+ Category.MUSIC.takeLast(category.remainder).map { it.toMediaItem(context) }
is Category.Songs ->
listSettings.songSort.songs(deviceLibrary.songs).map {
it.toMediaItem(context, null)
}
is Category.Albums ->
- listSettings.albumSort.albums(deviceLibrary.albums).map {
- it.toMediaItem(context)
- }
+ listSettings.albumSort.albums(deviceLibrary.albums).map { it.toMediaItem(context) }
is Category.Artists ->
listSettings.artistSort.artists(deviceLibrary.artists).map {
it.toMediaItem(context)
}
is Category.Genres ->
- listSettings.genreSort.genres(deviceLibrary.genres).map {
- it.toMediaItem(context)
- }
+ listSettings.genreSort.genres(deviceLibrary.genres).map { it.toMediaItem(context) }
is Category.Playlists -> userLibrary.playlists.map { it.toMediaItem(context) }
}
diff --git a/app/src/main/java/org/oxycblt/auxio/music/service/MusicServiceFragment.kt b/app/src/main/java/org/oxycblt/auxio/music/service/MusicServiceFragment.kt
index 8d439b2c4..51563a49b 100644
--- a/app/src/main/java/org/oxycblt/auxio/music/service/MusicServiceFragment.kt
+++ b/app/src/main/java/org/oxycblt/auxio/music/service/MusicServiceFragment.kt
@@ -19,8 +19,8 @@
package org.oxycblt.auxio.music.service
import android.support.v4.media.MediaBrowserCompat.MediaItem
-import androidx.media.MediaBrowserServiceCompat.Result
import androidx.media.MediaBrowserServiceCompat.BrowserRoot
+import androidx.media.MediaBrowserServiceCompat.Result
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@@ -82,10 +82,8 @@ constructor(
fun getItem(mediaId: String, result: Result) =
result.dispatch { musicBrowser.getItem(mediaId) }
- fun getChildren(
- mediaId: String,
- result: Result>
- ) = result.dispatch { musicBrowser.getChildren(mediaId)?.toMutableList() }
+ fun getChildren(mediaId: String, result: Result>) =
+ result.dispatch { musicBrowser.getChildren(mediaId)?.toMutableList() }
fun search(query: String, result: Result>) =
result.dispatchAsync { musicBrowser.search(query) }
diff --git a/app/src/main/java/org/oxycblt/auxio/playback/service/MediaSessionHolder.kt b/app/src/main/java/org/oxycblt/auxio/playback/service/MediaSessionHolder.kt
index 6fcda1830..e561b8180 100644
--- a/app/src/main/java/org/oxycblt/auxio/playback/service/MediaSessionHolder.kt
+++ b/app/src/main/java/org/oxycblt/auxio/playback/service/MediaSessionHolder.kt
@@ -21,7 +21,6 @@ package org.oxycblt.auxio.playback.system
import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Bitmap
-import android.media.session.MediaSession
import android.support.v4.media.MediaDescriptionCompat
import android.support.v4.media.MediaMetadataCompat
import android.support.v4.media.session.MediaSessionCompat
diff --git a/app/src/main/java/org/oxycblt/auxio/playback/service/MediaSessionInterface.kt b/app/src/main/java/org/oxycblt/auxio/playback/service/MediaSessionInterface.kt
index 65b55b51f..6688ed956 100644
--- a/app/src/main/java/org/oxycblt/auxio/playback/service/MediaSessionInterface.kt
+++ b/app/src/main/java/org/oxycblt/auxio/playback/service/MediaSessionInterface.kt
@@ -1,3 +1,21 @@
+/*
+ * Copyright (c) 2024 Auxio Project
+ * MediaSessionInterface.kt is part of Auxio.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
package org.oxycblt.auxio.playback.service
import android.content.Context
@@ -8,6 +26,7 @@ import android.support.v4.media.MediaDescriptionCompat
import android.support.v4.media.session.MediaSessionCompat
import android.support.v4.media.session.PlaybackStateCompat
import dagger.hilt.android.qualifiers.ApplicationContext
+import javax.inject.Inject
import org.oxycblt.auxio.music.Album
import org.oxycblt.auxio.music.Artist
import org.oxycblt.auxio.music.Genre
@@ -21,9 +40,10 @@ import org.oxycblt.auxio.playback.state.PlaybackCommand
import org.oxycblt.auxio.playback.state.PlaybackStateManager
import org.oxycblt.auxio.playback.state.RepeatMode
import org.oxycblt.auxio.playback.state.ShuffleMode
-import javax.inject.Inject
-class MediaSessionInterface @Inject constructor(
+class MediaSessionInterface
+@Inject
+constructor(
@ApplicationContext private val context: Context,
private val playbackManager: PlaybackStateManager,
private val commandFactory: PlaybackCommand.Factory,
@@ -130,15 +150,13 @@ class MediaSessionInterface @Inject constructor(
PlaybackStateCompat.REPEAT_MODE_GROUP -> RepeatMode.ALL
PlaybackStateCompat.REPEAT_MODE_ONE -> RepeatMode.TRACK
else -> RepeatMode.NONE
- }
- )
+ })
}
override fun onSetShuffleMode(shuffleMode: Int) {
playbackManager.shuffled(
shuffleMode == PlaybackStateCompat.SHUFFLE_MODE_ALL ||
- shuffleMode == PlaybackStateCompat.SHUFFLE_MODE_GROUP
- )
+ shuffleMode == PlaybackStateCompat.SHUFFLE_MODE_GROUP)
}
override fun onSkipToQueueItem(id: Long) {
@@ -164,12 +182,10 @@ class MediaSessionInterface @Inject constructor(
is MediaSessionUID.SingleItem -> {
music = musicRepository.find(uid.uid) ?: return null
}
-
is MediaSessionUID.ChildItem -> {
music = musicRepository.find(uid.childUid) ?: return null
parent = musicRepository.find(uid.parentUid) as? MusicParent ?: return null
}
-
else -> return null
}
@@ -186,11 +202,9 @@ class MediaSessionInterface @Inject constructor(
when (parent) {
is Album -> commandFactory.songFromAlbum(music, ShuffleMode.IMPLICIT)
is Artist -> commandFactory.songFromArtist(music, parent, ShuffleMode.IMPLICIT)
- ?: commandFactory.songFromArtist(music, music.artists[0], ShuffleMode.IMPLICIT)
-
+ ?: commandFactory.songFromArtist(music, music.artists[0], ShuffleMode.IMPLICIT)
is Genre -> commandFactory.songFromGenre(music, parent, ShuffleMode.IMPLICIT)
- ?: commandFactory.songFromGenre(music, music.genres[0], ShuffleMode.IMPLICIT)
-
+ ?: commandFactory.songFromGenre(music, music.genres[0], ShuffleMode.IMPLICIT)
is Playlist -> commandFactory.songFromPlaylist(music, parent, ShuffleMode.IMPLICIT)
null -> commandFactory.songFromAll(music, ShuffleMode.IMPLICIT)
}
diff --git a/app/src/main/java/org/oxycblt/auxio/playback/service/PlaybackServiceFragment.kt b/app/src/main/java/org/oxycblt/auxio/playback/service/PlaybackServiceFragment.kt
index b6ca0d721..42e60d7fd 100644
--- a/app/src/main/java/org/oxycblt/auxio/playback/service/PlaybackServiceFragment.kt
+++ b/app/src/main/java/org/oxycblt/auxio/playback/service/PlaybackServiceFragment.kt
@@ -108,81 +108,4 @@ constructor(
override fun onSessionEnded() {
foregroundListener?.updateForeground(ForegroundListener.Change.MEDIA_SESSION)
}
-
- // override fun onGetLibraryRoot(
- // session: MediaLibrarySession,
- // browser: MediaSession.ControllerInfo,
- // params: MediaLibraryService.LibraryParams?
- // ): ListenableFuture> =
- // Futures.immediateFuture(LibraryResult.ofItem(mediaItemBrowser.root, params))
- //
- // override fun onGetItem(
- // session: MediaLibrarySession,
- // browser: MediaSession.ControllerInfo,
- // mediaId: String
- // ): ListenableFuture> {
- // val result =
- // mediaItemBrowser.getItem(mediaId)?.let { LibraryResult.ofItem(it, null) }
- // ?: LibraryResult.ofError(LibraryResult.RESULT_ERROR_BAD_VALUE)
- // return Futures.immediateFuture(result)
- // }
- //
- // override fun onSetMediaItems(
- // mediaSession: MediaSession,
- // controller: MediaSession.ControllerInfo,
- // mediaItems: MutableList,
- // startIndex: Int,
- // startPositionMs: Long
- // ): ListenableFuture =
- // Futures.immediateFuture(
- // MediaSession.MediaItemsWithStartPosition(mediaItems, startIndex, startPositionMs))
- //
- // override fun onGetChildren(
- // session: MediaLibrarySession,
- // browser: MediaSession.ControllerInfo,
- // parentId: String,
- // page: Int,
- // pageSize: Int,
- // params: MediaLibraryService.LibraryParams?
- // ): ListenableFuture>> {
- // val children =
- // mediaItemBrowser.getChildren(parentId, page, pageSize)?.let {
- // LibraryResult.ofItemList(it, params)
- // }
- // ?: LibraryResult.ofError>(
- // LibraryResult.RESULT_ERROR_BAD_VALUE)
- // return Futures.immediateFuture(children)
- // }
- //
- // override fun onSearch(
- // session: MediaLibrarySession,
- // browser: MediaSession.ControllerInfo,
- // query: String,
- // params: MediaLibraryService.LibraryParams?
- // ): ListenableFuture> =
- // waitScope
- // .async {
- // mediaItemBrowser.prepareSearch(query, browser)
- // // Invalidator will send the notify result
- // LibraryResult.ofVoid()
- // }
- // .asListenableFuture()
- //
- // override fun onGetSearchResult(
- // session: MediaLibrarySession,
- // browser: MediaSession.ControllerInfo,
- // query: String,
- // page: Int,
- // pageSize: Int,
- // params: MediaLibraryService.LibraryParams?
- // ) =
- // waitScope
- // .async {
- // mediaItemBrowser.getSearchResult(query, page, pageSize)?.let {
- // LibraryResult.ofItemList(it, params)
- // }
- // ?: LibraryResult.ofError(LibraryResult.RESULT_ERROR_BAD_VALUE)
- // }
- // .asListenableFuture()
-
}