From 360dab928c7467ce47d8f8a377c7e19e1b2ac0bf Mon Sep 17 00:00:00 2001 From: Alexander Capehart Date: Tue, 3 Jan 2023 18:45:12 -0700 Subject: [PATCH] all: misc cleanup Miscellanious cleanup in preparation for 3.0.1. --- CHANGELOG.md | 4 ++++ app/proguard-rules.pro | 2 +- .../java/org/oxycblt/auxio/detail/DetailViewModel.kt | 7 ++++--- app/src/main/java/org/oxycblt/auxio/music/Date.kt | 9 ++++++--- .../main/java/org/oxycblt/auxio/music/system/Indexer.kt | 1 - .../oxycblt/auxio/playback/state/PlaybackStateManager.kt | 9 ++++----- app/src/main/res/values-es/strings.xml | 2 -- app/src/main/res/values-nb-rNO/strings.xml | 2 +- app/src/main/res/values-pt-rBR/strings.xml | 1 - 9 files changed, 20 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cc15b708..f0d47c38f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,10 @@ #### What's Fixed - Fixed mangled multi-value ID3v2 tags when UTF-16 is used - Fixed crash when playing certain MP3 files +- Detail UI will no longer crash if the music library is unavailable + +#### Dev/Meta +- Add CI workflow ## 3.0.0 diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index f3c0f68db..b63d5e026 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -21,5 +21,5 @@ #-renamesourcefileattribute SourceFile # Obsfucation is what proprietary software does to keep the user unaware of it's abuses. -# Also it's easier to debug if the class names remain unmangled. +# Also it's easier to fix issues if the stack trace symbols remain unmangled. -dontobfuscate \ No newline at end of file diff --git a/app/src/main/java/org/oxycblt/auxio/detail/DetailViewModel.kt b/app/src/main/java/org/oxycblt/auxio/detail/DetailViewModel.kt index be5f9e3fb..2f7a404e0 100644 --- a/app/src/main/java/org/oxycblt/auxio/detail/DetailViewModel.kt +++ b/app/src/main/java/org/oxycblt/auxio/detail/DetailViewModel.kt @@ -173,8 +173,8 @@ class DetailViewModel(application: Application) : } /** - * Set a new [currentSong] from it's [Music.UID]. If the [Music.UID] differs, a new loading - * process will begin and the newly-loaded [DetailSong] will be set to [currentSong]. + * Set a new [currentSong] from it's [Music.UID]. If the [Music.UID] differs, [currentSong] + * and [songProperties] will be updated to align with the new [Song]. * @param uid The UID of the [Song] to load. Must be valid. */ fun setSongUid(uid: Music.UID) { @@ -231,7 +231,8 @@ class DetailViewModel(application: Application) : private fun requireMusic(uid: Music.UID) = musicStore.library?.find(uid) /** - * Start a new job to load a [DetailSong] based on the properties of the given [Song]'s file. + * Start a new job to load a given [Song]'s [SongProperties]. Result is pushed to + * [songProperties]. * @param song The song to load. */ private fun loadProperties(song: Song) { diff --git a/app/src/main/java/org/oxycblt/auxio/music/Date.kt b/app/src/main/java/org/oxycblt/auxio/music/Date.kt index 510eebb84..f6f7b1221 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/Date.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/Date.kt @@ -140,9 +140,12 @@ class Date private constructor(private val tokens: List) : Comparable min.resolveDate(context) } - override fun compareTo(other: Range): Int { - return min.compareTo(other.min) - } + override fun equals(other: Any?) = + other is Range && min == other.min && max == other.max + + override fun hashCode() = 31 * max.hashCode() + min.hashCode() + + override fun compareTo(other: Range) = min.compareTo(other.min) companion object { /** diff --git a/app/src/main/java/org/oxycblt/auxio/music/system/Indexer.kt b/app/src/main/java/org/oxycblt/auxio/music/system/Indexer.kt index 9a84ac851..1557ec4a8 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/system/Indexer.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/system/Indexer.kt @@ -416,7 +416,6 @@ class Indexer private constructor() { /** * Music loading has completed. * @param result The outcome of the music loading process. - * @see Response */ data class Complete(val result: Result) : State() } diff --git a/app/src/main/java/org/oxycblt/auxio/playback/state/PlaybackStateManager.kt b/app/src/main/java/org/oxycblt/auxio/playback/state/PlaybackStateManager.kt index 049967a12..fb2995839 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/state/PlaybackStateManager.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/state/PlaybackStateManager.kt @@ -72,6 +72,7 @@ class PlaybackStateManager private constructor() { val queue get() = _queue /** The position of the currently playing item in the queue. */ + @Volatile var index = -1 private set /** The current [InternalPlayer] state. */ @@ -525,10 +526,9 @@ class PlaybackStateManager private constructor() { * @param database The [PlaybackStateDatabase] to clear te state from * @return If the state was cleared, false otherwise. */ - suspend fun wipeState(database: PlaybackStateDatabase): Boolean { - logD("Wiping state") - - return try { + suspend fun wipeState(database: PlaybackStateDatabase) = + try { + logD("Wiping state") withContext(Dispatchers.IO) { database.write(null) } true } catch (e: Exception) { @@ -536,7 +536,6 @@ class PlaybackStateManager private constructor() { logE(e.stackTraceToString()) false } - } /** * Update the playback state to align with a new [MusicStore.Library]. diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index c2a47e201..519b81be3 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -128,12 +128,10 @@ Canciones cargadas: %d %d canción - %d canciones %d canciones %d álbum - %d álbumes %d álbumes Tamaño diff --git a/app/src/main/res/values-nb-rNO/strings.xml b/app/src/main/res/values-nb-rNO/strings.xml index a6b3daec9..3a0906840 100644 --- a/app/src/main/res/values-nb-rNO/strings.xml +++ b/app/src/main/res/values-nb-rNO/strings.xml @@ -1,2 +1,2 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 2e4539fc0..6ee2cd8e1 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -245,7 +245,6 @@ Mix %d artista - %d artistas %d artistas Re-escanear músicas