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() =
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 -> "?"
}

View file

@ -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(

View file

@ -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, "<init>", "(Ljava/lang/String;JII)V");
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.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)

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
import android.net.Uri
@ -8,4 +26,4 @@ data class DeviceFile(
val path: Path,
val size: Long,
val lastModified: Long
)
)

View file

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

View file

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

View file

@ -15,7 +15,7 @@
* 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.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<MusicLocation>, storage: Storage): Flow<ExploreNode>
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<MusicLocation>, storage: Storage): Flow<ExploreNode> {
val audios =
deviceFiles

View file

@ -31,7 +31,11 @@ internal sealed interface 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(
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
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<Song>) {
playlistDao.replacePlaylistSongs(
uid,
songs.map { PlaylistSong(it.uid) }
)
playlistDao.replacePlaylistSongs(uid, songs.map { PlaylistSong(it.uid) })
}
override suspend fun add(songs: List<Song>) {
playlistDao.insertPlaylistSongs(
uid,
songs.map { PlaylistSong(it.uid) }
)
playlistDao.insertPlaylistSongs(uid, songs.map { PlaylistSong(it.uid) })
}
override suspend fun delete() {
playlistDao.deletePlaylist(uid)
}
}
}

View file

@ -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))
}
}

View file

@ -67,8 +67,11 @@ sealed interface Name : Comparable<Name> {
}
/** 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> {
val value: String get() = collationKey.sourceString
data class Token
internal constructor(internal val collationKey: CollationKey, internal val type: Type) :
Comparable<Token> {
val value: String
get() = collationKey.sourceString
override fun compareTo(other: Token): Int {
// Numeric tokens should always be lower than lexicographic tokens.

View file

@ -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
)

View file

@ -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 {

View file

@ -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
}
}
}

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
/**

View file

@ -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 {