From d4513293a7fe1570f6cbbab40f1ec7fabb0e4c8d Mon Sep 17 00:00:00 2001 From: OxygenCobalt Date: Fri, 18 Feb 2022 19:00:33 -0700 Subject: [PATCH] all: cleanup General app cleanup. --- app/src/main/java/org/oxycblt/auxio/MainActivity.kt | 4 ++-- app/src/main/java/org/oxycblt/auxio/music/Models.kt | 2 +- .../main/java/org/oxycblt/auxio/music/MusicLoader.kt | 4 ++-- .../java/org/oxycblt/auxio/playback/PlaybackLayout.kt | 4 ++-- .../main/java/org/oxycblt/auxio/util/ContextUtil.kt | 3 +-- app/src/main/java/org/oxycblt/auxio/util/ViewUtil.kt | 8 ++++++-- app/src/main/res/layout/widget_default.xml | 10 +++++----- info/FAQ.md | 4 ++-- 8 files changed, 21 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/org/oxycblt/auxio/MainActivity.kt b/app/src/main/java/org/oxycblt/auxio/MainActivity.kt index 5b3b18aef..8cfc2b966 100644 --- a/app/src/main/java/org/oxycblt/auxio/MainActivity.kt +++ b/app/src/main/java/org/oxycblt/auxio/MainActivity.kt @@ -36,7 +36,7 @@ import org.oxycblt.auxio.playback.system.PlaybackService import org.oxycblt.auxio.settings.SettingsManager import org.oxycblt.auxio.util.isNight import org.oxycblt.auxio.util.logD -import org.oxycblt.auxio.util.replaceInsetsCompat +import org.oxycblt.auxio.util.replaceSystemBarInsetsCompat import org.oxycblt.auxio.util.systemBarInsetsCompat /** @@ -158,7 +158,7 @@ class MainActivity : AppCompatActivity() { right = bars.right ) - return replaceInsetsCompat(0, bars.top, 0, bars.bottom) + return replaceSystemBarInsetsCompat(0, bars.top, 0, bars.bottom) } companion object { diff --git a/app/src/main/java/org/oxycblt/auxio/music/Models.kt b/app/src/main/java/org/oxycblt/auxio/music/Models.kt index 080bd584d..8f35bf4ac 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/Models.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/Models.kt @@ -101,7 +101,7 @@ data class Song( /** The album of this song. */ val album: Album get() = requireNotNull(mAlbum) - var mGenre: Genre? = null + private var mGenre: Genre? = null /** The genre of this song. Will be an "unknown genre" if the song does not have any. */ val genre: Genre get() = requireNotNull(mGenre) diff --git a/app/src/main/java/org/oxycblt/auxio/music/MusicLoader.kt b/app/src/main/java/org/oxycblt/auxio/music/MusicLoader.kt index 12f6dfb4a..9048acf13 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/MusicLoader.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/MusicLoader.kt @@ -259,8 +259,8 @@ class MusicLoader { } val artistAlbums = entry.value - // Due to the black magic we do to get a good artist field, the ID is unreliable. - // Take a hash of the artist name instead. + // Album deduplication does not eliminate every case of fragmented artists, do + // we deduplicate in the artist creation step as well. val previousArtistIndex = artists.indexOfFirst { artist -> artist.name.lowercase() == artistName.lowercase() } diff --git a/app/src/main/java/org/oxycblt/auxio/playback/PlaybackLayout.kt b/app/src/main/java/org/oxycblt/auxio/playback/PlaybackLayout.kt index eefca4290..33fac4588 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/PlaybackLayout.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/PlaybackLayout.kt @@ -26,7 +26,7 @@ import org.oxycblt.auxio.music.Song import org.oxycblt.auxio.util.getAttrColorSafe import org.oxycblt.auxio.util.getDimenSizeSafe import org.oxycblt.auxio.util.getDrawableSafe -import org.oxycblt.auxio.util.replaceInsetsCompat +import org.oxycblt.auxio.util.replaceSystemBarInsetsCompat import org.oxycblt.auxio.util.stateList import org.oxycblt.auxio.util.systemBarInsetsCompat import kotlin.math.abs @@ -383,7 +383,7 @@ class PlaybackLayout @JvmOverloads constructor( val consumedByPanel = computePanelTopPosition(panelOffset) - measuredHeight val adjustedBottomInset = (consumedByPanel + bars.bottom).coerceAtLeast(0) - return insets.replaceInsetsCompat(bars.left, bars.top, bars.right, adjustedBottomInset) + return insets.replaceSystemBarInsetsCompat(bars.left, bars.top, bars.right, adjustedBottomInset) } override fun onSaveInstanceState(): Parcelable = Bundle().apply { diff --git a/app/src/main/java/org/oxycblt/auxio/util/ContextUtil.kt b/app/src/main/java/org/oxycblt/auxio/util/ContextUtil.kt index 722e23303..148b00110 100644 --- a/app/src/main/java/org/oxycblt/auxio/util/ContextUtil.kt +++ b/app/src/main/java/org/oxycblt/auxio/util/ContextUtil.kt @@ -75,8 +75,7 @@ fun Context.getPluralSafe(@PluralsRes pluralsRes: Int, value: Int): String { return try { resources.getQuantityString(pluralsRes, value, value) } catch (e: Exception) { - logE("plural load failed") - return "" + handleResourceFailure(e, "plural", "") } } diff --git a/app/src/main/java/org/oxycblt/auxio/util/ViewUtil.kt b/app/src/main/java/org/oxycblt/auxio/util/ViewUtil.kt index 1c8a22455..44b8056d3 100644 --- a/app/src/main/java/org/oxycblt/auxio/util/ViewUtil.kt +++ b/app/src/main/java/org/oxycblt/auxio/util/ViewUtil.kt @@ -63,7 +63,7 @@ fun RecyclerView.applySpans(shouldBeFullWidth: ((Int) -> Boolean)? = null) { fun RecyclerView.canScroll(): Boolean = computeVerticalScrollRange() > height /** - * Resolve window insets in a version-aware manner. This can be used to apply padding to + * Resolve system bar insets in a version-aware manner. This can be used to apply padding to * a view that properly follows all the frustrating changes that were made between 8-11. */ val WindowInsets.systemBarInsetsCompat: Rect get() { @@ -86,7 +86,11 @@ val WindowInsets.systemBarInsetsCompat: Rect get() { } } -fun WindowInsets.replaceInsetsCompat(left: Int, top: Int, right: Int, bottom: Int): WindowInsets { +/** + * Replaces the system bar insets in a version-aware manner. This can be used to modify the insets + * for child views in a way that follows all of the frustrating changes that were made between 8-11. + */ +fun WindowInsets.replaceSystemBarInsetsCompat(left: Int, top: Int, right: Int, bottom: Int): WindowInsets { return when { Build.VERSION.SDK_INT >= Build.VERSION_CODES.R -> { WindowInsets.Builder(this) diff --git a/app/src/main/res/layout/widget_default.xml b/app/src/main/res/layout/widget_default.xml index 1a3729aaf..c3c44da3a 100644 --- a/app/src/main/res/layout/widget_default.xml +++ b/app/src/main/res/layout/widget_default.xml @@ -19,14 +19,14 @@ + android:text="@string/def_playback" /> diff --git a/info/FAQ.md b/info/FAQ.md index 0a209f75c..492be2061 100644 --- a/info/FAQ.md +++ b/info/FAQ.md @@ -32,8 +32,8 @@ This is for a couple reason: - Auxio doesn't extract ReplayGain tags for your format. - Auxio doesn't recognize your ReplayGain tags. This is usually because of a non-standard tag like ID3v2's `RVAD` or an unrecognized name. -- Your tags use a ReplayGain value higher than 0. Due to technical limitations, Auxio does not support this right now. -I do plan to add it eventually. +- Your tags use a ReplayGain value higher than 0. Due to technical limitations, Auxio does not support this right now, +but I can work on it if the demand for this is sufficient. #### What is dynamic ReplayGain? Dynamic ReplayGain is a quirk setting based off the FooBar2000 plugin that dynamically switches from track gain to album