Skip to content

Commit

Permalink
all: reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
OxygenCobalt committed Dec 16, 2024
1 parent 6e3b03d commit b6f6213
Show file tree
Hide file tree
Showing 18 changed files with 127 additions and 48 deletions.
4 changes: 1 addition & 3 deletions app/src/main/java/org/oxycblt/auxio/home/list/ListUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 -> "?"
}
10 changes: 8 additions & 2 deletions app/src/main/java/org/oxycblt/auxio/music/MusicRepository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion musikr/src/main/cpp/JVMMetadataBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 5 additions & 1 deletion musikr/src/main/java/org/oxycblt/musikr/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
20 changes: 19 additions & 1 deletion musikr/src/main/java/org/oxycblt/musikr/fs/DeviceFile.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -8,4 +26,4 @@ data class DeviceFile(
val path: Path,
val size: Long,
val lastModified: Long
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ private class DeviceFilesImpl(private val contentResolver: ContentResolver) : De
mimeType,
newPath,
size,
lastModified)
)
lastModified))
}
}
emitAll(recursive.asFlow().flattenMerge())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
18 changes: 18 additions & 0 deletions musikr/src/main/java/org/oxycblt/musikr/metadata/Metadata.kt
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
12 changes: 4 additions & 8 deletions musikr/src/main/java/org/oxycblt/musikr/pipeline/ExploreStep.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion musikr/src/main/java/org/oxycblt/musikr/pipeline/FlowUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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)
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
7 changes: 5 additions & 2 deletions musikr/src/main/java/org/oxycblt/musikr/tag/Name.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 5 additions & 4 deletions musikr/src/main/java/org/oxycblt/musikr/util/LangUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
18 changes: 18 additions & 0 deletions musikr/src/main/java/org/oxycblt/musikr/util/ParseUtil.kt
Original file line number Diff line number Diff line change
@@ -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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b6f6213

Please sign in to comment.