all: reformat

This commit is contained in:
Alexander Capehart 2024-12-16 18:46:54 -05:00
parent 6e3b03d4c6
commit b6f6213ac4
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
18 changed files with 127 additions and 48 deletions

View file

@ -24,8 +24,6 @@ import org.oxycblt.musikr.tag.Name
fun Name.thumb() = fun Name.thumb() =
when (this) { when (this) {
is Name.Known -> is Name.Known ->
tokens.firstOrNull()?.let { tokens.firstOrNull()?.let { if (it.value.isDigitsOnly()) "#" else it.value }
if (it.value.isDigitsOnly()) "#" else it.value
}
is Name.Unknown -> "?" is Name.Unknown -> "?"
} }

View file

@ -364,10 +364,16 @@ constructor(
val storage = val storage =
if (withCache) { if (withCache) {
Storage(Cache.full(cacheDatabase), StoredCovers.from(context, "covers"), StoredPlaylists.from(playlistDatabase)) Storage(
Cache.full(cacheDatabase),
StoredCovers.from(context, "covers"),
StoredPlaylists.from(playlistDatabase))
} else { } else {
// TODO: Revisioned cache (as a stateful extension of musikr) // TODO: Revisioned cache (as a stateful extension of musikr)
Storage(Cache.writeOnly(cacheDatabase), StoredCovers.from(context, "covers"), StoredPlaylists.from(playlistDatabase)) Storage(
Cache.writeOnly(cacheDatabase),
StoredCovers.from(context, "covers"),
StoredPlaylists.from(playlistDatabase))
} }
val newLibrary = val newLibrary =
musikr.run( musikr.run(

View file

@ -129,7 +129,8 @@ void JVMMetadataBuilder::setProperties(TagLib::AudioProperties *properties) {
} }
jobject JVMMetadataBuilder::build() { jobject JVMMetadataBuilder::build() {
jclass propertiesClass = env->FindClass("org/oxycblt/musikr/metadata/Properties"); jclass propertiesClass =
env->FindClass("org/oxycblt/musikr/metadata/Properties");
jmethodID propertiesInit = jmethodID propertiesInit =
env->GetMethodID(propertiesClass, "<init>", "(Ljava/lang/String;JII)V"); env->GetMethodID(propertiesClass, "<init>", "(Ljava/lang/String;JII)V");
jobject propertiesObj = env->NewObject( jobject propertiesObj = env->NewObject(

View file

@ -24,6 +24,10 @@ import org.oxycblt.musikr.playlist.db.StoredPlaylists
import org.oxycblt.musikr.tag.interpret.Naming import org.oxycblt.musikr.tag.interpret.Naming
import org.oxycblt.musikr.tag.interpret.Separators import org.oxycblt.musikr.tag.interpret.Separators
data class Storage(val cache: Cache, val storedCovers: StoredCovers, val storedPlaylists: StoredPlaylists) data class Storage(
val cache: Cache,
val storedCovers: StoredCovers,
val storedPlaylists: StoredPlaylists
)
data class Interpretation(val naming: Naming, val separators: Separators) data class Interpretation(val naming: Naming, val separators: Separators)

View file

@ -1,3 +1,21 @@
/*
* Copyright (c) 2024 Auxio Project
* DeviceFile.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 <https://www.gnu.org/licenses/>.
*/
package org.oxycblt.musikr.fs package org.oxycblt.musikr.fs
import android.net.Uri import android.net.Uri

View file

@ -92,8 +92,7 @@ private class DeviceFilesImpl(private val contentResolver: ContentResolver) : De
mimeType, mimeType,
newPath, newPath,
size, size,
lastModified) lastModified))
)
} }
} }
emitAll(recursive.asFlow().flattenMerge()) emitAll(recursive.asFlow().flattenMerge())

View file

@ -235,7 +235,7 @@ private class MusicGraphBuilderImpl : MusicGraph.Builder {
private fun simplifyAlbumCluster(cluster: Collection<AlbumVertex>) { private fun simplifyAlbumCluster(cluster: Collection<AlbumVertex>) {
if (cluster.size == 1) { if (cluster.size == 1) {
// Nothing to do. // Nothing to do.
return; return
} }
val fullMusicBrainzIdCoverage = cluster.all { it.preAlbum.musicBrainzId != null } val fullMusicBrainzIdCoverage = cluster.all { it.preAlbum.musicBrainzId != null }
if (fullMusicBrainzIdCoverage) { if (fullMusicBrainzIdCoverage) {

View file

@ -1,3 +1,21 @@
/*
* Copyright (c) 2024 Auxio Project
* Metadata.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 <https://www.gnu.org/licenses/>.
*/
package org.oxycblt.musikr.metadata package org.oxycblt.musikr.metadata
internal data class Metadata( internal data class Metadata(

View file

@ -30,25 +30,21 @@ import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.mapNotNull import kotlinx.coroutines.flow.mapNotNull
import kotlinx.coroutines.flow.merge import kotlinx.coroutines.flow.merge
import org.oxycblt.musikr.Storage import org.oxycblt.musikr.Storage
import org.oxycblt.musikr.fs.MusicLocation
import org.oxycblt.musikr.fs.DeviceFile import org.oxycblt.musikr.fs.DeviceFile
import org.oxycblt.musikr.fs.MusicLocation
import org.oxycblt.musikr.fs.query.DeviceFiles import org.oxycblt.musikr.fs.query.DeviceFiles
import org.oxycblt.musikr.playlist.PlaylistFile import org.oxycblt.musikr.playlist.PlaylistFile
import org.oxycblt.musikr.playlist.db.StoredPlaylists
import org.oxycblt.musikr.playlist.m3u.M3U import org.oxycblt.musikr.playlist.m3u.M3U
internal interface ExploreStep { internal interface ExploreStep {
fun explore(locations: List<MusicLocation>, storage: Storage): Flow<ExploreNode> fun explore(locations: List<MusicLocation>, storage: Storage): Flow<ExploreNode>
companion object { companion object {
fun from(context: Context): ExploreStep = fun from(context: Context): ExploreStep = ExploreStepImpl(DeviceFiles.from(context))
ExploreStepImpl(DeviceFiles.from(context))
} }
} }
private class ExploreStepImpl( private class ExploreStepImpl(private val deviceFiles: DeviceFiles) : ExploreStep {
private val deviceFiles: DeviceFiles
) : ExploreStep {
override fun explore(locations: List<MusicLocation>, storage: Storage): Flow<ExploreNode> { override fun explore(locations: List<MusicLocation>, storage: Storage): Flow<ExploreNode> {
val audios = val audios =
deviceFiles deviceFiles

View file

@ -31,7 +31,11 @@ internal sealed interface Divert<L, R> {
data class Right<L, R>(val value: R) : Divert<L, R> data class Right<L, R>(val value: R) : Divert<L, R>
} }
internal class DivertedFlow<L, R>(val manager: Flow<Nothing>, val left: Flow<L>, val right: Flow<R>) internal class DivertedFlow<L, R>(
val manager: Flow<Nothing>,
val left: Flow<L>,
val right: Flow<R>
)
internal inline fun <T, L, R> Flow<T>.divert( internal inline fun <T, L, R> Flow<T>.divert(
crossinline predicate: (T) -> Divert<L, R> crossinline predicate: (T) -> Divert<L, R>

View file

@ -1,9 +1,25 @@
/*
* Copyright (c) 2024 Auxio Project
* StoredPlaylistHandle.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 <https://www.gnu.org/licenses/>.
*/
package org.oxycblt.musikr.playlist.db package org.oxycblt.musikr.playlist.db
import org.oxycblt.musikr.Music
import org.oxycblt.musikr.Song import org.oxycblt.musikr.Song
import org.oxycblt.musikr.playlist.PlaylistHandle import org.oxycblt.musikr.playlist.PlaylistHandle
import java.util.UUID
internal class StoredPlaylistHandle( internal class StoredPlaylistHandle(
private val playlistInfo: PlaylistInfo, private val playlistInfo: PlaylistInfo,
@ -16,21 +32,14 @@ internal class StoredPlaylistHandle(
} }
override suspend fun rewrite(songs: List<Song>) { override suspend fun rewrite(songs: List<Song>) {
playlistDao.replacePlaylistSongs( playlistDao.replacePlaylistSongs(uid, songs.map { PlaylistSong(it.uid) })
uid,
songs.map { PlaylistSong(it.uid) }
)
} }
override suspend fun add(songs: List<Song>) { override suspend fun add(songs: List<Song>) {
playlistDao.insertPlaylistSongs( playlistDao.insertPlaylistSongs(uid, songs.map { PlaylistSong(it.uid) })
uid,
songs.map { PlaylistSong(it.uid) }
)
} }
override suspend fun delete() { override suspend fun delete() {
playlistDao.deletePlaylist(uid) playlistDao.deletePlaylist(uid)
} }
} }

View file

@ -31,11 +31,11 @@ interface StoredPlaylists {
} }
private class StoredPlaylistsImpl(private val playlistDao: PlaylistDao) : StoredPlaylists { private class StoredPlaylistsImpl(private val playlistDao: PlaylistDao) : StoredPlaylists {
override suspend fun read() = playlistDao.readRawPlaylists().map { override suspend fun read() =
playlistDao.readRawPlaylists().map {
PlaylistFile( PlaylistFile(
it.playlistInfo.name, it.playlistInfo.name,
it.songs.map { song -> SongPointer.UID(song.songUid) }, it.songs.map { song -> SongPointer.UID(song.songUid) },
StoredPlaylistHandle(it.playlistInfo, playlistDao) StoredPlaylistHandle(it.playlistInfo, playlistDao))
)
} }
} }

View file

@ -67,8 +67,11 @@ sealed interface Name : Comparable<Name> {
} }
/** An individual part of a name string that can be compared intelligently. */ /** An individual part of a name string that can be compared intelligently. */
data class Token internal constructor(internal val collationKey: CollationKey, internal val type: Type) : Comparable<Token> { data class Token
val value: String get() = collationKey.sourceString internal constructor(internal val collationKey: CollationKey, internal val type: Type) :
Comparable<Token> {
val value: String
get() = collationKey.sourceString
override fun compareTo(other: Token): Int { override fun compareTo(other: Token): Int {
// Numeric tokens should always be lower than lexicographic tokens. // Numeric tokens should always be lower than lexicographic tokens.

View file

@ -85,4 +85,8 @@ internal data class PreGenre(
val rawName: String?, val rawName: String?,
) )
internal data class PrePlaylist(val name: Name.Known, val rawName: String?, val handle: PlaylistHandle) internal data class PrePlaylist(
val name: Name.Known,
val rawName: String?,
val handle: PlaylistHandle
)

View file

@ -26,8 +26,8 @@ import org.oxycblt.musikr.tag.Name
import org.oxycblt.musikr.tag.Placeholder import org.oxycblt.musikr.tag.Placeholder
import org.oxycblt.musikr.tag.ReleaseType import org.oxycblt.musikr.tag.ReleaseType
import org.oxycblt.musikr.tag.ReplayGainAdjustment import org.oxycblt.musikr.tag.ReplayGainAdjustment
import org.oxycblt.musikr.tag.parse.ParsedTags
import org.oxycblt.musikr.tag.format.parseId3GenreNames import org.oxycblt.musikr.tag.format.parseId3GenreNames
import org.oxycblt.musikr.tag.parse.ParsedTags
import org.oxycblt.musikr.util.toUuidOrNull import org.oxycblt.musikr.util.toUuidOrNull
internal interface TagInterpreter { internal interface TagInterpreter {

View file

@ -126,8 +126,9 @@ internal fun MessageDigest.update(n: Int?) {
* @param clazz The [KClass] to reflect into. * @param clazz The [KClass] to reflect into.
* @param method The name of the method to obtain. * @param method The name of the method to obtain.
*/ */
internal fun lazyReflectedMethod(clazz: KClass<*>, method: String, vararg params: KClass<*>) = lazy { internal fun lazyReflectedMethod(clazz: KClass<*>, method: String, vararg params: KClass<*>) =
lazy {
clazz.java.getDeclaredMethod(method, *params.map { it.java }.toTypedArray()).also { clazz.java.getDeclaredMethod(method, *params.map { it.java }.toTypedArray()).also {
it.isAccessible = true it.isAccessible = true
} }
} }

View file

@ -1,3 +1,21 @@
/*
* Copyright (c) 2024 Auxio Project
* ParseUtil.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 <https://www.gnu.org/licenses/>.
*/
package org.oxycblt.musikr.util package org.oxycblt.musikr.util
/** /**

View file

@ -20,10 +20,10 @@ package org.oxycblt.musikr.tag.parse
import org.junit.Assert.assertEquals import org.junit.Assert.assertEquals
import org.junit.Test import org.junit.Test
import org.oxycblt.musikr.util.correctWhitespace
import org.oxycblt.musikr.tag.format.parseId3GenreNames import org.oxycblt.musikr.tag.format.parseId3GenreNames
import org.oxycblt.musikr.tag.format.parseId3v2PositionField import org.oxycblt.musikr.tag.format.parseId3v2PositionField
import org.oxycblt.musikr.tag.format.parseXiphPositionField import org.oxycblt.musikr.tag.format.parseXiphPositionField
import org.oxycblt.musikr.util.correctWhitespace
import org.oxycblt.musikr.util.splitEscaped import org.oxycblt.musikr.util.splitEscaped
class TagUtilTest { class TagUtilTest {