all: reformat/fixes
This commit is contained in:
parent
a4838cefaa
commit
aec08bb48b
7 changed files with 23 additions and 25 deletions
|
@ -26,14 +26,14 @@ import androidx.media3.session.MediaLibraryService
|
||||||
import androidx.media3.session.MediaSession
|
import androidx.media3.session.MediaSession
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import org.oxycblt.auxio.music.service.IndexingServiceFragment
|
import org.oxycblt.auxio.music.service.IndexerServiceFragment
|
||||||
import org.oxycblt.auxio.playback.service.MediaSessionServiceFragment
|
import org.oxycblt.auxio.playback.service.MediaSessionServiceFragment
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class AuxioService : MediaLibraryService(), ForegroundListener {
|
class AuxioService : MediaLibraryService(), ForegroundListener {
|
||||||
@Inject lateinit var mediaSessionFragment: MediaSessionServiceFragment
|
@Inject lateinit var mediaSessionFragment: MediaSessionServiceFragment
|
||||||
|
|
||||||
@Inject lateinit var indexingFragment: IndexingServiceFragment
|
@Inject lateinit var indexingFragment: IndexerServiceFragment
|
||||||
|
|
||||||
@SuppressLint("WrongConstant")
|
@SuppressLint("WrongConstant")
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
|
|
|
@ -27,10 +27,10 @@ sealed interface Cover {
|
||||||
val mediaStoreCoverUri: Uri
|
val mediaStoreCoverUri: Uri
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The song has an embedded cover art we support, so we can operate with it on a per-song
|
* The song has an embedded cover art we support, so we can operate with it on a per-song basis.
|
||||||
* basis.
|
|
||||||
*/
|
*/
|
||||||
data class Embedded(val songCoverUri: Uri, val songUri: Uri, val perceptualHash: String) : Cover {
|
data class Embedded(val songCoverUri: Uri, val songUri: Uri, val perceptualHash: String) :
|
||||||
|
Cover {
|
||||||
override val mediaStoreCoverUri = songCoverUri
|
override val mediaStoreCoverUri = songCoverUri
|
||||||
override val key = perceptualHash
|
override val key = perceptualHash
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,6 @@ constructor(
|
||||||
CoverMode.MEDIA_STORE -> extractMediaStoreCover(cover)
|
CoverMode.MEDIA_STORE -> extractMediaStoreCover(cover)
|
||||||
CoverMode.QUALITY -> extractQualityCover(cover)
|
CoverMode.QUALITY -> extractQualityCover(cover)
|
||||||
}
|
}
|
||||||
|
|
||||||
is Cover.External -> {
|
is Cover.External -> {
|
||||||
extractMediaStoreCover(cover)
|
extractMediaStoreCover(cover)
|
||||||
}
|
}
|
||||||
|
@ -193,7 +192,9 @@ constructor(
|
||||||
|
|
||||||
private suspend fun extractMediaStoreCover(cover: Cover) =
|
private suspend fun extractMediaStoreCover(cover: Cover) =
|
||||||
// Eliminate any chance that this blocking call might mess up the loading process
|
// Eliminate any chance that this blocking call might mess up the loading process
|
||||||
withContext(Dispatchers.IO) { context.contentResolver.openInputStream(cover.mediaStoreCoverUri) }
|
withContext(Dispatchers.IO) {
|
||||||
|
context.contentResolver.openInputStream(cover.mediaStoreCoverUri)
|
||||||
|
}
|
||||||
|
|
||||||
/** Derived from phonograph: https://github.com/kabouzeid/Phonograph */
|
/** Derived from phonograph: https://github.com/kabouzeid/Phonograph */
|
||||||
private suspend fun createMosaic(streams: List<InputStream>, size: Size): FetchResult {
|
private suspend fun createMosaic(streams: List<InputStream>, size: Size): FetchResult {
|
||||||
|
|
|
@ -64,7 +64,7 @@ abstract class MaterialDragCallback : ItemTouchHelper.Callback() {
|
||||||
totalSize: Int,
|
totalSize: Int,
|
||||||
msSinceStartScroll: Long
|
msSinceStartScroll: Long
|
||||||
): Int {
|
): Int {
|
||||||
// Clamp the scroll speed to prevent thefrom freaking out
|
// Clamp the scroll speed to prevent the lists from freaking out
|
||||||
// Adapted from NewPipe: https://github.com/TeamNewPipe/NewPipe
|
// Adapted from NewPipe: https://github.com/TeamNewPipe/NewPipe
|
||||||
val standardSpeed =
|
val standardSpeed =
|
||||||
super.interpolateOutOfBoundsScroll(
|
super.interpolateOutOfBoundsScroll(
|
||||||
|
|
|
@ -77,8 +77,7 @@ class SongImpl(
|
||||||
override val name =
|
override val name =
|
||||||
nameFactory.parse(
|
nameFactory.parse(
|
||||||
requireNotNull(rawSong.name) { "Invalid raw ${rawSong.path}: No title" },
|
requireNotNull(rawSong.name) { "Invalid raw ${rawSong.path}: No title" },
|
||||||
rawSong.sortName
|
rawSong.sortName)
|
||||||
)
|
|
||||||
|
|
||||||
override val track = rawSong.track
|
override val track = rawSong.track
|
||||||
override val disc = rawSong.disc?.let { Disc(it, rawSong.subtitle) }
|
override val disc = rawSong.disc?.let { Disc(it, rawSong.subtitle) }
|
||||||
|
@ -122,14 +121,12 @@ class SongImpl(
|
||||||
// it implies either a cover.jpg pattern is used (likely) or ExoPlayer does not
|
// it implies either a cover.jpg pattern is used (likely) or ExoPlayer does not
|
||||||
// support the cover metadata of a given spec (unlikely).
|
// support the cover metadata of a given spec (unlikely).
|
||||||
Cover.Embedded(
|
Cover.Embedded(
|
||||||
requireNotNull(rawSong.mediaStoreId) { "Invalid raw ${rawSong.path}: No id" }.toSongCoverUri(),
|
requireNotNull(rawSong.mediaStoreId) { "Invalid raw ${rawSong.path}: No id" }
|
||||||
uid,
|
.toSongCoverUri(),
|
||||||
it
|
uri,
|
||||||
)
|
it)
|
||||||
}
|
}
|
||||||
?: Cover.External(
|
?: Cover.External(requireNotNull(rawSong.albumMediaStoreId).toAlbumCoverUri())
|
||||||
requireNotNull(rawSong.albumMediaStoreId).toAlbumCoverUri()
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The [RawAlbum] instances collated by the [Song]. This can be used to group [Song]s into an
|
* The [RawAlbum] instances collated by the [Song]. This can be used to group [Song]s into an
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2024 Auxio Project
|
* Copyright (c) 2024 Auxio Project
|
||||||
* IndexerComponent.kt is part of Auxio.
|
* IndexerServiceFragment.kt is part of Auxio.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -35,7 +35,7 @@ import org.oxycblt.auxio.playback.state.PlaybackStateManager
|
||||||
import org.oxycblt.auxio.util.getSystemServiceCompat
|
import org.oxycblt.auxio.util.getSystemServiceCompat
|
||||||
import org.oxycblt.auxio.util.logD
|
import org.oxycblt.auxio.util.logD
|
||||||
|
|
||||||
class IndexingServiceFragment
|
class IndexerServiceFragment
|
||||||
@Inject
|
@Inject
|
||||||
constructor(
|
constructor(
|
||||||
@ApplicationContext override val workerContext: Context,
|
@ApplicationContext override val workerContext: Context,
|
|
@ -74,7 +74,7 @@ fun Song.toMediaItem(context: Context, parent: MusicParent?): MediaItem {
|
||||||
.setMediaType(MediaMetadata.MEDIA_TYPE_MUSIC)
|
.setMediaType(MediaMetadata.MEDIA_TYPE_MUSIC)
|
||||||
.setIsPlayable(true)
|
.setIsPlayable(true)
|
||||||
.setIsBrowsable(false)
|
.setIsBrowsable(false)
|
||||||
.setArtworkUri(album.cover.single.mediaStoreUri)
|
.setArtworkUri(album.cover.single.mediaStoreCoverUri)
|
||||||
.setExtras(
|
.setExtras(
|
||||||
Bundle().apply {
|
Bundle().apply {
|
||||||
putString("uid", mediaSessionUID.toString())
|
putString("uid", mediaSessionUID.toString())
|
||||||
|
@ -105,7 +105,7 @@ fun Album.toMediaItem(context: Context): MediaItem {
|
||||||
.setMediaType(MediaMetadata.MEDIA_TYPE_ALBUM)
|
.setMediaType(MediaMetadata.MEDIA_TYPE_ALBUM)
|
||||||
.setIsPlayable(true)
|
.setIsPlayable(true)
|
||||||
.setIsBrowsable(true)
|
.setIsBrowsable(true)
|
||||||
.setArtworkUri(cover.single.mediaStoreUri)
|
.setArtworkUri(cover.single.mediaStoreCoverUri)
|
||||||
.setExtras(Bundle().apply { putString("uid", mediaSessionUID.toString()) })
|
.setExtras(Bundle().apply { putString("uid", mediaSessionUID.toString()) })
|
||||||
.build()
|
.build()
|
||||||
return MediaItem.Builder()
|
return MediaItem.Builder()
|
||||||
|
@ -136,7 +136,7 @@ fun Artist.toMediaItem(context: Context): MediaItem {
|
||||||
.setIsPlayable(true)
|
.setIsPlayable(true)
|
||||||
.setIsBrowsable(true)
|
.setIsBrowsable(true)
|
||||||
.setGenre(genres.resolveNames(context))
|
.setGenre(genres.resolveNames(context))
|
||||||
.setArtworkUri(cover.single.mediaStoreUri)
|
.setArtworkUri(cover.single.mediaStoreCoverUri)
|
||||||
.setExtras(Bundle().apply { putString("uid", mediaSessionUID.toString()) })
|
.setExtras(Bundle().apply { putString("uid", mediaSessionUID.toString()) })
|
||||||
.build()
|
.build()
|
||||||
return MediaItem.Builder()
|
return MediaItem.Builder()
|
||||||
|
@ -159,7 +159,7 @@ fun Genre.toMediaItem(context: Context): MediaItem {
|
||||||
.setMediaType(MediaMetadata.MEDIA_TYPE_GENRE)
|
.setMediaType(MediaMetadata.MEDIA_TYPE_GENRE)
|
||||||
.setIsPlayable(true)
|
.setIsPlayable(true)
|
||||||
.setIsBrowsable(true)
|
.setIsBrowsable(true)
|
||||||
.setArtworkUri(cover.single.mediaStoreUri)
|
.setArtworkUri(cover.single.mediaStoreCoverUri)
|
||||||
.setExtras(Bundle().apply { putString("uid", mediaSessionUID.toString()) })
|
.setExtras(Bundle().apply { putString("uid", mediaSessionUID.toString()) })
|
||||||
.build()
|
.build()
|
||||||
return MediaItem.Builder()
|
return MediaItem.Builder()
|
||||||
|
@ -182,7 +182,7 @@ fun Playlist.toMediaItem(context: Context): MediaItem {
|
||||||
.setMediaType(MediaMetadata.MEDIA_TYPE_PLAYLIST)
|
.setMediaType(MediaMetadata.MEDIA_TYPE_PLAYLIST)
|
||||||
.setIsPlayable(true)
|
.setIsPlayable(true)
|
||||||
.setIsBrowsable(true)
|
.setIsBrowsable(true)
|
||||||
.setArtworkUri(cover?.single?.mediaStoreUri)
|
.setArtworkUri(cover?.single?.mediaStoreCoverUri)
|
||||||
.setExtras(Bundle().apply { putString("uid", mediaSessionUID.toString()) })
|
.setExtras(Bundle().apply { putString("uid", mediaSessionUID.toString()) })
|
||||||
.build()
|
.build()
|
||||||
return MediaItem.Builder()
|
return MediaItem.Builder()
|
||||||
|
|
Loading…
Reference in a new issue