diff --git a/app/src/main/java/org/oxycblt/auxio/home/list/ListUtil.kt b/app/src/main/java/org/oxycblt/auxio/home/list/ListUtil.kt index d03a11478..766feb236 100644 --- a/app/src/main/java/org/oxycblt/auxio/home/list/ListUtil.kt +++ b/app/src/main/java/org/oxycblt/auxio/home/list/ListUtil.kt @@ -24,8 +24,6 @@ import org.oxycblt.musikr.tag.Name fun Name.thumb() = when (this) { is Name.Known -> - tokens.firstOrNull()?.let { - if (it.value.isDigitsOnly()) "#" else it.value - } + tokens.firstOrNull()?.let { if (it.value.isDigitsOnly()) "#" else it.value } is Name.Unknown -> "?" } diff --git a/app/src/main/java/org/oxycblt/auxio/music/MusicRepository.kt b/app/src/main/java/org/oxycblt/auxio/music/MusicRepository.kt index b73fbe642..7b2a8a3f8 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/MusicRepository.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/MusicRepository.kt @@ -364,10 +364,16 @@ constructor( val storage = 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 { // 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 = musikr.run( diff --git a/musikr/src/main/cpp/JVMMetadataBuilder.cpp b/musikr/src/main/cpp/JVMMetadataBuilder.cpp index e5be63a8b..14e7adfc1 100644 --- a/musikr/src/main/cpp/JVMMetadataBuilder.cpp +++ b/musikr/src/main/cpp/JVMMetadataBuilder.cpp @@ -129,7 +129,8 @@ void JVMMetadataBuilder::setProperties(TagLib::AudioProperties *properties) { } jobject JVMMetadataBuilder::build() { - jclass propertiesClass = env->FindClass("org/oxycblt/musikr/metadata/Properties"); + jclass propertiesClass = + env->FindClass("org/oxycblt/musikr/metadata/Properties"); jmethodID propertiesInit = env->GetMethodID(propertiesClass, "", "(Ljava/lang/String;JII)V"); jobject propertiesObj = env->NewObject( diff --git a/musikr/src/main/java/org/oxycblt/musikr/Config.kt b/musikr/src/main/java/org/oxycblt/musikr/Config.kt index 637dba9cf..8b2ea8807 100644 --- a/musikr/src/main/java/org/oxycblt/musikr/Config.kt +++ b/musikr/src/main/java/org/oxycblt/musikr/Config.kt @@ -24,6 +24,10 @@ import org.oxycblt.musikr.playlist.db.StoredPlaylists import org.oxycblt.musikr.tag.interpret.Naming 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) diff --git a/musikr/src/main/java/org/oxycblt/musikr/fs/DeviceFile.kt b/musikr/src/main/java/org/oxycblt/musikr/fs/DeviceFile.kt index 32a58450f..4d6b39ca5 100644 --- a/musikr/src/main/java/org/oxycblt/musikr/fs/DeviceFile.kt +++ b/musikr/src/main/java/org/oxycblt/musikr/fs/DeviceFile.kt @@ -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 . + */ + package org.oxycblt.musikr.fs import android.net.Uri @@ -8,4 +26,4 @@ data class DeviceFile( val path: Path, val size: Long, val lastModified: Long -) \ No newline at end of file +) diff --git a/musikr/src/main/java/org/oxycblt/musikr/fs/query/DeviceFiles.kt b/musikr/src/main/java/org/oxycblt/musikr/fs/query/DeviceFiles.kt index 596801551..79e41b9eb 100644 --- a/musikr/src/main/java/org/oxycblt/musikr/fs/query/DeviceFiles.kt +++ b/musikr/src/main/java/org/oxycblt/musikr/fs/query/DeviceFiles.kt @@ -92,8 +92,7 @@ private class DeviceFilesImpl(private val contentResolver: ContentResolver) : De mimeType, newPath, size, - lastModified) - ) + lastModified)) } } emitAll(recursive.asFlow().flattenMerge()) diff --git a/musikr/src/main/java/org/oxycblt/musikr/graph/MusicGraph.kt b/musikr/src/main/java/org/oxycblt/musikr/graph/MusicGraph.kt index 615027a7a..2404a3678 100644 --- a/musikr/src/main/java/org/oxycblt/musikr/graph/MusicGraph.kt +++ b/musikr/src/main/java/org/oxycblt/musikr/graph/MusicGraph.kt @@ -235,7 +235,7 @@ private class MusicGraphBuilderImpl : MusicGraph.Builder { private fun simplifyAlbumCluster(cluster: Collection) { if (cluster.size == 1) { // Nothing to do. - return; + return } val fullMusicBrainzIdCoverage = cluster.all { it.preAlbum.musicBrainzId != null } if (fullMusicBrainzIdCoverage) { diff --git a/musikr/src/main/java/org/oxycblt/musikr/metadata/Metadata.kt b/musikr/src/main/java/org/oxycblt/musikr/metadata/Metadata.kt index ab034844e..c375a6694 100644 --- a/musikr/src/main/java/org/oxycblt/musikr/metadata/Metadata.kt +++ b/musikr/src/main/java/org/oxycblt/musikr/metadata/Metadata.kt @@ -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 . + */ + package org.oxycblt.musikr.metadata internal data class Metadata( diff --git a/musikr/src/main/java/org/oxycblt/musikr/pipeline/ExploreStep.kt b/musikr/src/main/java/org/oxycblt/musikr/pipeline/ExploreStep.kt index fd9499da5..47e675d69 100644 --- a/musikr/src/main/java/org/oxycblt/musikr/pipeline/ExploreStep.kt +++ b/musikr/src/main/java/org/oxycblt/musikr/pipeline/ExploreStep.kt @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - + package org.oxycblt.musikr.pipeline import android.content.Context @@ -30,25 +30,21 @@ import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.mapNotNull import kotlinx.coroutines.flow.merge import org.oxycblt.musikr.Storage -import org.oxycblt.musikr.fs.MusicLocation import org.oxycblt.musikr.fs.DeviceFile +import org.oxycblt.musikr.fs.MusicLocation import org.oxycblt.musikr.fs.query.DeviceFiles import org.oxycblt.musikr.playlist.PlaylistFile -import org.oxycblt.musikr.playlist.db.StoredPlaylists import org.oxycblt.musikr.playlist.m3u.M3U internal interface ExploreStep { fun explore(locations: List, storage: Storage): Flow companion object { - fun from(context: Context): ExploreStep = - ExploreStepImpl(DeviceFiles.from(context)) + fun from(context: Context): ExploreStep = ExploreStepImpl(DeviceFiles.from(context)) } } -private class ExploreStepImpl( - private val deviceFiles: DeviceFiles -) : ExploreStep { +private class ExploreStepImpl(private val deviceFiles: DeviceFiles) : ExploreStep { override fun explore(locations: List, storage: Storage): Flow { val audios = deviceFiles diff --git a/musikr/src/main/java/org/oxycblt/musikr/pipeline/FlowUtil.kt b/musikr/src/main/java/org/oxycblt/musikr/pipeline/FlowUtil.kt index fd0a3cce6..6044db976 100644 --- a/musikr/src/main/java/org/oxycblt/musikr/pipeline/FlowUtil.kt +++ b/musikr/src/main/java/org/oxycblt/musikr/pipeline/FlowUtil.kt @@ -31,7 +31,11 @@ internal sealed interface Divert { data class Right(val value: R) : Divert } -internal class DivertedFlow(val manager: Flow, val left: Flow, val right: Flow) +internal class DivertedFlow( + val manager: Flow, + val left: Flow, + val right: Flow +) internal inline fun Flow.divert( crossinline predicate: (T) -> Divert diff --git a/musikr/src/main/java/org/oxycblt/musikr/playlist/db/StoredPlaylistHandle.kt b/musikr/src/main/java/org/oxycblt/musikr/playlist/db/StoredPlaylistHandle.kt index a025ed4df..36867202e 100644 --- a/musikr/src/main/java/org/oxycblt/musikr/playlist/db/StoredPlaylistHandle.kt +++ b/musikr/src/main/java/org/oxycblt/musikr/playlist/db/StoredPlaylistHandle.kt @@ -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 . + */ + package org.oxycblt.musikr.playlist.db -import org.oxycblt.musikr.Music import org.oxycblt.musikr.Song import org.oxycblt.musikr.playlist.PlaylistHandle -import java.util.UUID internal class StoredPlaylistHandle( private val playlistInfo: PlaylistInfo, @@ -16,21 +32,14 @@ internal class StoredPlaylistHandle( } override suspend fun rewrite(songs: List) { - playlistDao.replacePlaylistSongs( - uid, - songs.map { PlaylistSong(it.uid) } - ) + playlistDao.replacePlaylistSongs(uid, songs.map { PlaylistSong(it.uid) }) } override suspend fun add(songs: List) { - playlistDao.insertPlaylistSongs( - uid, - songs.map { PlaylistSong(it.uid) } - ) + playlistDao.insertPlaylistSongs(uid, songs.map { PlaylistSong(it.uid) }) } override suspend fun delete() { playlistDao.deletePlaylist(uid) } - -} \ No newline at end of file +} diff --git a/musikr/src/main/java/org/oxycblt/musikr/playlist/db/StoredPlaylists.kt b/musikr/src/main/java/org/oxycblt/musikr/playlist/db/StoredPlaylists.kt index 682cfaadc..dd940583c 100644 --- a/musikr/src/main/java/org/oxycblt/musikr/playlist/db/StoredPlaylists.kt +++ b/musikr/src/main/java/org/oxycblt/musikr/playlist/db/StoredPlaylists.kt @@ -31,11 +31,11 @@ interface StoredPlaylists { } private class StoredPlaylistsImpl(private val playlistDao: PlaylistDao) : StoredPlaylists { - override suspend fun read() = playlistDao.readRawPlaylists().map { - PlaylistFile( - it.playlistInfo.name, - it.songs.map { song -> SongPointer.UID(song.songUid) }, - StoredPlaylistHandle(it.playlistInfo, playlistDao) - ) - } + override suspend fun read() = + playlistDao.readRawPlaylists().map { + PlaylistFile( + it.playlistInfo.name, + it.songs.map { song -> SongPointer.UID(song.songUid) }, + StoredPlaylistHandle(it.playlistInfo, playlistDao)) + } } diff --git a/musikr/src/main/java/org/oxycblt/musikr/tag/Name.kt b/musikr/src/main/java/org/oxycblt/musikr/tag/Name.kt index 5cafa625a..a0ac67fda 100644 --- a/musikr/src/main/java/org/oxycblt/musikr/tag/Name.kt +++ b/musikr/src/main/java/org/oxycblt/musikr/tag/Name.kt @@ -67,8 +67,11 @@ sealed interface Name : Comparable { } /** 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 { - val value: String get() = collationKey.sourceString +data class Token +internal constructor(internal val collationKey: CollationKey, internal val type: Type) : + Comparable { + val value: String + get() = collationKey.sourceString override fun compareTo(other: Token): Int { // Numeric tokens should always be lower than lexicographic tokens. diff --git a/musikr/src/main/java/org/oxycblt/musikr/tag/interpret/PreMusic.kt b/musikr/src/main/java/org/oxycblt/musikr/tag/interpret/PreMusic.kt index b977fa562..5af1770c1 100644 --- a/musikr/src/main/java/org/oxycblt/musikr/tag/interpret/PreMusic.kt +++ b/musikr/src/main/java/org/oxycblt/musikr/tag/interpret/PreMusic.kt @@ -85,4 +85,8 @@ internal data class PreGenre( 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 +) diff --git a/musikr/src/main/java/org/oxycblt/musikr/tag/interpret/TagInterpreter.kt b/musikr/src/main/java/org/oxycblt/musikr/tag/interpret/TagInterpreter.kt index 44d1448b3..551a31611 100644 --- a/musikr/src/main/java/org/oxycblt/musikr/tag/interpret/TagInterpreter.kt +++ b/musikr/src/main/java/org/oxycblt/musikr/tag/interpret/TagInterpreter.kt @@ -26,8 +26,8 @@ import org.oxycblt.musikr.tag.Name import org.oxycblt.musikr.tag.Placeholder import org.oxycblt.musikr.tag.ReleaseType 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.parse.ParsedTags import org.oxycblt.musikr.util.toUuidOrNull internal interface TagInterpreter { diff --git a/musikr/src/main/java/org/oxycblt/musikr/util/LangUtil.kt b/musikr/src/main/java/org/oxycblt/musikr/util/LangUtil.kt index d71e6b576..a1b361370 100644 --- a/musikr/src/main/java/org/oxycblt/musikr/util/LangUtil.kt +++ b/musikr/src/main/java/org/oxycblt/musikr/util/LangUtil.kt @@ -126,8 +126,9 @@ internal fun MessageDigest.update(n: Int?) { * @param clazz The [KClass] to reflect into. * @param method The name of the method to obtain. */ -internal fun lazyReflectedMethod(clazz: KClass<*>, method: String, vararg params: KClass<*>) = lazy { - clazz.java.getDeclaredMethod(method, *params.map { it.java }.toTypedArray()).also { - it.isAccessible = true +internal fun lazyReflectedMethod(clazz: KClass<*>, method: String, vararg params: KClass<*>) = + lazy { + clazz.java.getDeclaredMethod(method, *params.map { it.java }.toTypedArray()).also { + it.isAccessible = true + } } -} diff --git a/musikr/src/main/java/org/oxycblt/musikr/util/ParseUtil.kt b/musikr/src/main/java/org/oxycblt/musikr/util/ParseUtil.kt index 4110c387b..d460d6455 100644 --- a/musikr/src/main/java/org/oxycblt/musikr/util/ParseUtil.kt +++ b/musikr/src/main/java/org/oxycblt/musikr/util/ParseUtil.kt @@ -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 . + */ + package org.oxycblt.musikr.util /** diff --git a/musikr/src/test/java/org/oxycblt/musikr/tag/parse/TagUtilTest.kt b/musikr/src/test/java/org/oxycblt/musikr/tag/parse/TagUtilTest.kt index 0eed70381..bf6d0dc95 100644 --- a/musikr/src/test/java/org/oxycblt/musikr/tag/parse/TagUtilTest.kt +++ b/musikr/src/test/java/org/oxycblt/musikr/tag/parse/TagUtilTest.kt @@ -20,10 +20,10 @@ package org.oxycblt.musikr.tag.parse import org.junit.Assert.assertEquals import org.junit.Test -import org.oxycblt.musikr.util.correctWhitespace import org.oxycblt.musikr.tag.format.parseId3GenreNames import org.oxycblt.musikr.tag.format.parseId3v2PositionField import org.oxycblt.musikr.tag.format.parseXiphPositionField +import org.oxycblt.musikr.util.correctWhitespace import org.oxycblt.musikr.util.splitEscaped class TagUtilTest {