diff --git a/app/src/main/java/org/oxycblt/auxio/detail/SongDetailDialog.kt b/app/src/main/java/org/oxycblt/auxio/detail/SongDetailDialog.kt index d7c682ce6..9bad4e225 100644 --- a/app/src/main/java/org/oxycblt/auxio/detail/SongDetailDialog.kt +++ b/app/src/main/java/org/oxycblt/auxio/detail/SongDetailDialog.kt @@ -38,6 +38,7 @@ import org.oxycblt.auxio.music.info.Name import org.oxycblt.auxio.music.metadata.AudioProperties import org.oxycblt.auxio.music.resolveNames import org.oxycblt.auxio.playback.formatDurationMs +import org.oxycblt.auxio.playback.replaygain.formatDb import org.oxycblt.auxio.ui.ViewBindingMaterialDialogFragment import org.oxycblt.auxio.util.collectImmediately import org.oxycblt.auxio.util.concatLocalized @@ -118,6 +119,12 @@ class SongDetailDialog : ViewBindingMaterialDialogFragment= 0) { - getString(R.string.fmt_db_pos, valueDb) - } else { - getString(R.string.fmt_db_neg, abs(valueDb)) - } + ticker.text = valueDb.formatDb(requireContext()) } } diff --git a/app/src/main/java/org/oxycblt/auxio/playback/replaygain/ReplayGain.kt b/app/src/main/java/org/oxycblt/auxio/playback/replaygain/ReplayGain.kt index 1495fd6fb..5a19c7df3 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/replaygain/ReplayGain.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/replaygain/ReplayGain.kt @@ -18,7 +18,10 @@ package org.oxycblt.auxio.playback.replaygain +import android.content.Context +import kotlin.math.abs import org.oxycblt.auxio.IntegerTable +import org.oxycblt.auxio.R /** * The current ReplayGain configuration. @@ -67,3 +70,16 @@ data class ReplayGainAdjustment(val track: Float?, val album: Float?) * @author Alexander Capehart (OxygenCobalt) */ data class ReplayGainPreAmp(val with: Float, val without: Float) + +/** + * Format a decibel value in a human-readable format. + * + * @param context The context to resolve resources from. + * @return A formatted decibel value. Will be prefixed by a + or - sign. + */ +fun Float.formatDb(context: Context) = + if (this >= 0) { + context.getString(R.string.fmt_db_pos, this) + } else { + context.getString(R.string.fmt_db_neg, abs(this)) + } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 045965a4d..ec7bb6010 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -146,6 +146,8 @@ Size Bit rate Sample rate + ReplayGain Track Adjustment + ReplayGain Album Adjustment Shuffle