all: cleanup

General app cleanup.
This commit is contained in:
OxygenCobalt 2022-02-18 19:00:33 -07:00
parent 83dc6cd4c9
commit d4513293a7
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
8 changed files with 21 additions and 18 deletions

View file

@ -36,7 +36,7 @@ import org.oxycblt.auxio.playback.system.PlaybackService
import org.oxycblt.auxio.settings.SettingsManager import org.oxycblt.auxio.settings.SettingsManager
import org.oxycblt.auxio.util.isNight import org.oxycblt.auxio.util.isNight
import org.oxycblt.auxio.util.logD import org.oxycblt.auxio.util.logD
import org.oxycblt.auxio.util.replaceInsetsCompat import org.oxycblt.auxio.util.replaceSystemBarInsetsCompat
import org.oxycblt.auxio.util.systemBarInsetsCompat import org.oxycblt.auxio.util.systemBarInsetsCompat
/** /**
@ -158,7 +158,7 @@ class MainActivity : AppCompatActivity() {
right = bars.right right = bars.right
) )
return replaceInsetsCompat(0, bars.top, 0, bars.bottom) return replaceSystemBarInsetsCompat(0, bars.top, 0, bars.bottom)
} }
companion object { companion object {

View file

@ -101,7 +101,7 @@ data class Song(
/** The album of this song. */ /** The album of this song. */
val album: Album get() = requireNotNull(mAlbum) 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. */ /** The genre of this song. Will be an "unknown genre" if the song does not have any. */
val genre: Genre get() = requireNotNull(mGenre) val genre: Genre get() = requireNotNull(mGenre)

View file

@ -259,8 +259,8 @@ class MusicLoader {
} }
val artistAlbums = entry.value val artistAlbums = entry.value
// Due to the black magic we do to get a good artist field, the ID is unreliable. // Album deduplication does not eliminate every case of fragmented artists, do
// Take a hash of the artist name instead. // we deduplicate in the artist creation step as well.
val previousArtistIndex = artists.indexOfFirst { artist -> val previousArtistIndex = artists.indexOfFirst { artist ->
artist.name.lowercase() == artistName.lowercase() artist.name.lowercase() == artistName.lowercase()
} }

View file

@ -26,7 +26,7 @@ import org.oxycblt.auxio.music.Song
import org.oxycblt.auxio.util.getAttrColorSafe import org.oxycblt.auxio.util.getAttrColorSafe
import org.oxycblt.auxio.util.getDimenSizeSafe import org.oxycblt.auxio.util.getDimenSizeSafe
import org.oxycblt.auxio.util.getDrawableSafe 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.stateList
import org.oxycblt.auxio.util.systemBarInsetsCompat import org.oxycblt.auxio.util.systemBarInsetsCompat
import kotlin.math.abs import kotlin.math.abs
@ -383,7 +383,7 @@ class PlaybackLayout @JvmOverloads constructor(
val consumedByPanel = computePanelTopPosition(panelOffset) - measuredHeight val consumedByPanel = computePanelTopPosition(panelOffset) - measuredHeight
val adjustedBottomInset = (consumedByPanel + bars.bottom).coerceAtLeast(0) 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 { override fun onSaveInstanceState(): Parcelable = Bundle().apply {

View file

@ -75,8 +75,7 @@ fun Context.getPluralSafe(@PluralsRes pluralsRes: Int, value: Int): String {
return try { return try {
resources.getQuantityString(pluralsRes, value, value) resources.getQuantityString(pluralsRes, value, value)
} catch (e: Exception) { } catch (e: Exception) {
logE("plural load failed") handleResourceFailure(e, "plural", "<plural error>")
return "<plural error>"
} }
} }

View file

@ -63,7 +63,7 @@ fun RecyclerView.applySpans(shouldBeFullWidth: ((Int) -> Boolean)? = null) {
fun RecyclerView.canScroll(): Boolean = computeVerticalScrollRange() > height 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. * a view that properly follows all the frustrating changes that were made between 8-11.
*/ */
val WindowInsets.systemBarInsetsCompat: Rect get() { 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 { return when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.R -> { Build.VERSION.SDK_INT >= Build.VERSION_CODES.R -> {
WindowInsets.Builder(this) WindowInsets.Builder(this)

View file

@ -19,14 +19,14 @@
<android.widget.TextView <android.widget.TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:textAppearance="@style/Widget.Auxio.TextView.Primary.AppWidget" style="@style/Widget.Auxio.TextView.Primary.AppWidget"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:ellipsize="none"
android:singleLine="false"
android:textAlignment="center"
android:gravity="center" android:gravity="center"
android:padding="@dimen/spacing_medium" android:padding="@dimen/spacing_medium"
android:text="@string/def_playback" android:text="@string/def_playback" />
android:fontFamily="sans-serif-medium"
android:textStyle="normal"
android:textColor="?android:attr/textColorPrimary" />
</FrameLayout> </FrameLayout>

View file

@ -32,8 +32,8 @@ This is for a couple reason:
- Auxio doesn't extract ReplayGain tags for your format. - 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 - Auxio doesn't recognize your ReplayGain tags. This is usually because of a non-standard tag like ID3v2's `RVAD` or
an unrecognized name. an unrecognized name.
- Your tags use a ReplayGain value higher than 0. Due to technical limitations, Auxio does not support this right now. - 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. but I can work on it if the demand for this is sufficient.
#### What is dynamic ReplayGain? #### What is dynamic ReplayGain?
Dynamic ReplayGain is a quirk setting based off the FooBar2000 plugin that dynamically switches from track gain to album Dynamic ReplayGain is a quirk setting based off the FooBar2000 plugin that dynamically switches from track gain to album