From 10362b9efc07f0122e2fe3925a498cb343e6f6fe Mon Sep 17 00:00:00 2001 From: OxygenCobalt Date: Sun, 17 Jul 2022 16:11:16 -0600 Subject: [PATCH] music: lowercase names when hashing Lowercase music names when hashing them to prevent drift stemming from grouping. The addition of the song may change the case of an artist if such mitigations are in effect. To prevent such from invalidating music hashes, we take the lowercase of every name hashed. --- CHANGELOG.md | 1 + app/src/main/java/org/oxycblt/auxio/music/Music.kt | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe1cf5c52..7b0d3bb16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ at the cost of longer loading times - Fixed shuffle shortcut and file opening not working on startup on some devices #### What's Changed +- Play and skip icons are filled again - Updated music hashing (Will wipe playback state) ## 2.5.0 diff --git a/app/src/main/java/org/oxycblt/auxio/music/Music.kt b/app/src/main/java/org/oxycblt/auxio/music/Music.kt index f11a563ac..a5c4a7d04 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/Music.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/Music.kt @@ -110,9 +110,9 @@ data class Song( ) : Music() { override val id: Long get() { - var result = rawName.hashCode().toLong() - result = 31 * result + album.rawName.hashCode() - result = 31 * result + (album.artist.rawName ?: MediaStore.UNKNOWN_STRING).hashCode() + var result = rawName.lowercase().hashCode().toLong() + result = 31 * result + album.rawName.lowercase().hashCode() + result = 31 * result + (album.artist.rawName?.lowercase() ?: MediaStore.UNKNOWN_STRING).hashCode() result = 31 * result + (track ?: 0) result = 31 * result + (disc ?: 0) result = 31 * result + durationMs @@ -218,8 +218,8 @@ data class Album( override val id: Long get() { - var result = rawName.hashCode().toLong() - result = 31 * result + (artist.rawName ?: MediaStore.UNKNOWN_STRING).hashCode() + var result = rawName.lowercase().hashCode().toLong() + result = 31 * result + (artist.rawName?.lowercase() ?: MediaStore.UNKNOWN_STRING).hashCode() result = 31 * result + (date?.year ?: 0) return result } @@ -262,7 +262,7 @@ data class Artist( } override val id: Long - get() = (rawName ?: MediaStore.UNKNOWN_STRING).hashCode().toLong() + get() = (rawName?.lowercase() ?: MediaStore.UNKNOWN_STRING).hashCode().toLong() override fun resolveName(context: Context) = rawName ?: context.getString(R.string.def_artist) @@ -283,7 +283,7 @@ data class Genre(override val rawName: String?, override val songs: List) get() = rawName override val id: Long - get() = (rawName ?: MediaStore.UNKNOWN_STRING).hashCode().toLong() + get() = (rawName?.lowercase() ?: MediaStore.UNKNOWN_STRING).hashCode().toLong() override fun resolveName(context: Context) = rawName ?: context.getString(R.string.def_genre) }