musikr: api fixes
This commit is contained in:
parent
5a65a6aa25
commit
00520f7fda
6 changed files with 12 additions and 14 deletions
|
@ -25,8 +25,7 @@ fun Name.thumb() =
|
|||
when (this) {
|
||||
is Name.Known ->
|
||||
tokens.firstOrNull()?.let {
|
||||
val value = it.collationKey.sourceString
|
||||
if (value.isDigitsOnly()) "#" else value
|
||||
if (it.value.isDigitsOnly()) "#" else it.value
|
||||
}
|
||||
is Name.Unknown -> "?"
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ import dagger.hilt.android.qualifiers.ApplicationContext
|
|||
import javax.inject.Inject
|
||||
import org.oxycblt.auxio.music.MusicRepository
|
||||
import org.oxycblt.auxio.music.MusicSettings
|
||||
import org.oxycblt.musikr.fs.query.contentResolverSafe
|
||||
import timber.log.Timber as L
|
||||
|
||||
/**
|
||||
|
@ -45,7 +44,7 @@ constructor(
|
|||
private val handler = Handler(Looper.getMainLooper())
|
||||
|
||||
fun attach() {
|
||||
context.contentResolverSafe.registerContentObserver(
|
||||
context.applicationContext.contentResolver.registerContentObserver(
|
||||
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, true, this)
|
||||
}
|
||||
|
||||
|
@ -55,7 +54,7 @@ constructor(
|
|||
*/
|
||||
fun release() {
|
||||
handler.removeCallbacks(this)
|
||||
context.contentResolverSafe.unregisterContentObserver(this)
|
||||
context.applicationContext.contentResolver.unregisterContentObserver(this)
|
||||
}
|
||||
|
||||
override fun onChange(selfChange: Boolean) {
|
||||
|
|
|
@ -126,14 +126,14 @@ sealed interface Music {
|
|||
@TypeConverter fun toMusicUid(string: String?) = string?.let(Companion::fromString)
|
||||
}
|
||||
|
||||
internal companion object {
|
||||
companion object {
|
||||
/**
|
||||
* Creates an Auxio-style [UID] of random composition. Used if there is no
|
||||
* non-subjective, unlikely-to-change metadata of the music.
|
||||
*
|
||||
* @param item The type of [Item] that created this [UID].
|
||||
*/
|
||||
fun auxio(item: Item): UID {
|
||||
internal fun auxio(item: Item): UID {
|
||||
return UID(Format.AUXIO, item, UUID.randomUUID())
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ sealed interface Music {
|
|||
* specification.
|
||||
* @return A new auxio-style [UID].
|
||||
*/
|
||||
fun auxio(item: Item, updates: MessageDigest.() -> Unit): UID {
|
||||
internal fun auxio(item: Item, updates: MessageDigest.() -> Unit): UID {
|
||||
val digest =
|
||||
MessageDigest.getInstance("SHA-256").run {
|
||||
updates()
|
||||
|
@ -189,7 +189,7 @@ sealed interface Music {
|
|||
* file.
|
||||
* @return A new MusicBrainz-style [UID].
|
||||
*/
|
||||
fun musicBrainz(item: Item, mbid: UUID) = UID(Format.MUSICBRAINZ, item, mbid)
|
||||
internal fun musicBrainz(item: Item, mbid: UUID) = UID(Format.MUSICBRAINZ, item, mbid)
|
||||
|
||||
/**
|
||||
* Convert a [UID]'s string representation back into a concrete [UID] instance.
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.oxycblt.musikr.fs.path.DocumentPathFactory
|
|||
import org.oxycblt.musikr.fs.query.contentResolverSafe
|
||||
import org.oxycblt.musikr.util.splitEscaped
|
||||
|
||||
class MusicLocation private constructor(internal val uri: Uri, internal val path: Path) {
|
||||
class MusicLocation private constructor(val uri: Uri, val path: Path) {
|
||||
override fun equals(other: Any?) = other is MusicLocation && uri == other.uri
|
||||
|
||||
override fun hashCode() = 31 * uri.hashCode()
|
||||
|
|
|
@ -47,14 +47,14 @@ data class Path(
|
|||
* @param fileName The name of the file to append to the path.
|
||||
* @return The new [Path] instance.
|
||||
*/
|
||||
internal fun file(fileName: String) = Path(volume, components.child(fileName))
|
||||
fun file(fileName: String) = Path(volume, components.child(fileName))
|
||||
|
||||
/**
|
||||
* Resolves the [Path] in a human-readable format.
|
||||
*
|
||||
* @param context [Context] required to obtain human-readable strings.
|
||||
*/
|
||||
internal fun resolve(context: Context) = "${volume.resolveName(context)}/$components"
|
||||
fun resolve(context: Context) = "${volume.resolveName(context)}/$components"
|
||||
}
|
||||
|
||||
sealed interface Volume {
|
||||
|
|
|
@ -67,7 +67,7 @@ sealed interface Name : Comparable<Name> {
|
|||
}
|
||||
|
||||
/** An individual part of a name string that can be compared intelligently. */
|
||||
data class Token(internal val collationKey: CollationKey, internal val type: Type) : Comparable<Token> {
|
||||
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 {
|
||||
|
@ -88,7 +88,7 @@ data class Token(internal val collationKey: CollationKey, internal val type: Typ
|
|||
}
|
||||
|
||||
/** Denotes the type of comparison to be performed with this token. */
|
||||
enum class Type {
|
||||
internal enum class Type {
|
||||
/** Compare as a digit string, like "65". */
|
||||
NUMERIC,
|
||||
/** Compare as a standard alphanumeric string, like "65daysofstatic" */
|
||||
|
|
Loading…
Reference in a new issue