[Android] Replay gain settings should only be enabled when function is active. Clarify summary text.

Robert Stone git at videolan.org
Tue Apr 19 08:31:21 UTC 2022


vlc-android | branch: master | Robert Stone <rhstone at gmail.com> | Mon Apr 18 22:12:55 2022 -0700| [6da77653600fbb97360848b61b3cb8b25f29769a] | committer: Robert Stone

Replay gain settings should only be enabled when function is active. Clarify summary text.

> https://code.videolan.org/videolan/vlc-android/commit/6da77653600fbb97360848b61b3cb8b25f29769a
---

 .../main/java/org/videolan/resources/VLCOptions.kt   |  5 ++---
 application/resources/src/main/res/values/arrays.xml |  2 --
 .../resources/src/main/res/values/strings.xml        |  7 ++++---
 .../television/ui/preferences/PreferencesAudio.kt    |  3 ++-
 .../vlc-android/res/xml/preferences_audio.xml        | 20 +++++++++++++++-----
 .../videolan/vlc/gui/preferences/PreferencesAudio.kt |  2 +-
 6 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/application/resources/src/main/java/org/videolan/resources/VLCOptions.kt b/application/resources/src/main/java/org/videolan/resources/VLCOptions.kt
index 68ddd34aa..badf2e62b 100644
--- a/application/resources/src/main/java/org/videolan/resources/VLCOptions.kt
+++ b/application/resources/src/main/java/org/videolan/resources/VLCOptions.kt
@@ -137,9 +137,8 @@ object VLCOptions {
                 options.add("--hrtf-file")
                 options.add(hstfPath)
             }
-            val replayGainMode = pref.getString("audio-replay-gain-mode", "none")
-            if (replayGainMode != "none") {
-                options.add("--audio-replay-gain-mode=$replayGainMode")
+            if (pref.getBoolean("audio-replay-gain-enable", false)) {
+                options.add("--audio-replay-gain-mode=${pref.getString("audio-replay-gain-mode", "track")}")
                 options.add("--audio-replay-gain-preamp=${pref.getString("audio-replay-gain-preamp", "0.0")}")
                 options.add("--audio-replay-gain-default=${pref.getString("audio-replay-gain-default", "-7.0")}")
                 if (pref.getBoolean("audio-replay-gain-peak-protection", true))
diff --git a/application/resources/src/main/res/values/arrays.xml b/application/resources/src/main/res/values/arrays.xml
index 30a3e9a0b..ca70e0573 100644
--- a/application/resources/src/main/res/values/arrays.xml
+++ b/application/resources/src/main/res/values/arrays.xml
@@ -353,12 +353,10 @@
     </string-array>
 
     <string-array name="replaygain">
-        <item>@string/replaygain_none</item>
         <item>@string/replaygain_track</item>
         <item>@string/replaygain_album</item>
     </string-array>
     <string-array name="replaygain_values" translatable="false">
-        <item>none</item>
         <item>track</item>
         <item>album</item>
     </string-array>
diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index 606ede7a7..0ec15947b 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -383,15 +383,16 @@
     <string name="enable_play_on_headset_insertion">Resume on headset insertion</string>
     <string name="enable_play_on_headset_insertion_summary">Pause otherwise</string>
     <string name="replaygain_prefs_category">Replay Gain</string>
+    <string name="replaygain_enable">Enable replay gain</string>
+    <string name="replaygain_enable_summary">Streams without replay gain information may be quieter due to the default gain</string>
     <string name="replaygain_mode">Replay gain mode</string>
     <string name="replaygain_mode_summary">Track mode plays streams with replay gain information at the same loudness. Album mode preserves relative stream loudness on the same album.</string>
     <string name="replaygain_preamp">Replay preamp</string>
-    <string name="replaygain_preamp_summary">This allows you to change the default target level (89 dB) for streams with replay gain information</string>
+    <string name="replaygain_preamp_summary">Changes the default target level (89 dB) for streams with replay gain information</string>
     <string name="replaygain_default">Default replay gain</string>
-    <string name="replaygain_default_summary">This is the gain used for streams without replay gain information</string>
+    <string name="replaygain_default_summary">Applies to streams without replay gain information\nSet to 0 to disable</string>
     <string name="replaygain_peak_protection">Peak protection</string>
     <string name="replaygain_peak_protection_summary">Protect against sound clipping</string>
-    <string name="replaygain_none">None</string>
     <string name="replaygain_track">Track</string>
     <string name="replaygain_album">Album</string>
     <string name="aout">Audio output</string>
diff --git a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAudio.kt b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAudio.kt
index e4f1ccb6b..9be6cbb2a 100644
--- a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAudio.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesAudio.kt
@@ -48,6 +48,7 @@ import java.text.DecimalFormat
 
 private const val TAG = "VLC/PreferencesAudio"
 
+ at Suppress("DEPRECATION")
 @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
 class PreferencesAudio : BasePreferenceFragment(), SharedPreferences.OnSharedPreferenceChangeListener {
 
@@ -126,7 +127,7 @@ class PreferencesAudio : BasePreferenceFragment(), SharedPreferences.OnSharedPre
             }
             "audio_digital_output" -> updatePassThroughSummary()
             "audio_preferred_language" -> updatePreferredAudioTrack()
-            "audio-replay-gain-mode", "audio-replay-gain-peak-protection" -> restartLibVLC()
+            "audio-replay-gain-enable", "audio-replay-gain-mode", "audio-replay-gain-peak-protection" -> restartLibVLC()
             "audio-replay-gain-default", "audio-replay-gain-preamp" -> {
                 val defValue = if (key == "audio-replay-gain-default") "-7.0" else "0.0"
                 val newValue = sharedPreferences.getString(key, defValue)
diff --git a/application/vlc-android/res/xml/preferences_audio.xml b/application/vlc-android/res/xml/preferences_audio.xml
index 4891d3079..d9d360322 100644
--- a/application/vlc-android/res/xml/preferences_audio.xml
+++ b/application/vlc-android/res/xml/preferences_audio.xml
@@ -71,29 +71,39 @@
     </PreferenceCategory>
 
     <PreferenceCategory android:title="@string/replaygain_prefs_category">
+        <CheckBoxPreference
+            app:singleLineTitle="false"
+            android:defaultValue="false"
+            app:key="audio-replay-gain-enable"
+            app:summary="@string/replaygain_enable_summary"
+            app:title="@string/replaygain_enable"/>
         <ListPreference
-            android:defaultValue="none"
+            android:defaultValue="track"
             android:entries="@array/replaygain"
             android:entryValues="@array/replaygain_values"
             android:key="audio-replay-gain-mode"
             android:summary="@string/replaygain_mode_summary"
-            android:title="@string/replaygain_mode"/>
+            android:title="@string/replaygain_mode"
+            android:dependency="audio-replay-gain-enable"/>
         <EditTextPreference
             android:defaultValue="0.0"
             android:key="audio-replay-gain-preamp"
             android:summary="@string/replaygain_preamp_summary"
-            android:title="@string/replaygain_preamp"/>
+            android:title="@string/replaygain_preamp"
+            android:dependency="audio-replay-gain-enable"/>
         <EditTextPreference
             android:defaultValue="-7.0"
             android:key="audio-replay-gain-default"
             android:summary="@string/replaygain_default_summary"
-            android:title="@string/replaygain_default"/>
+            android:title="@string/replaygain_default"
+            android:dependency="audio-replay-gain-enable"/>
         <CheckBoxPreference
             app:singleLineTitle="false"
             android:defaultValue="true"
             android:key="audio-replay-gain-peak-protection"
             android:summary="@string/replaygain_peak_protection_summary"
-            android:title="@string/replaygain_peak_protection"/>
+            android:title="@string/replaygain_peak_protection"
+            android:dependency="audio-replay-gain-enable"/>
     </PreferenceCategory>
     <PreferenceCategory android:title="@string/advanced_prefs_category">
         <CheckBoxPreference
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAudio.kt b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAudio.kt
index 9b9a8fef8..ad8360613 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAudio.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesAudio.kt
@@ -151,7 +151,7 @@ class PreferencesAudio : BasePreferenceFragment(), SharedPreferences.OnSharedPre
             }
             "audio_digital_output" -> updatePassThroughSummary()
             "audio_preferred_language" -> updatePreferredAudioTrack()
-            "audio-replay-gain-mode", "audio-replay-gain-peak-protection" -> restartLibVLC()
+            "audio-replay-gain-enable", "audio-replay-gain-mode", "audio-replay-gain-peak-protection" -> restartLibVLC()
             "audio-replay-gain-default", "audio-replay-gain-preamp" -> {
                 val defValue = if (key == "audio-replay-gain-default") "-7.0" else "0.0"
                 val newValue = sharedPreferences.getString(key, defValue)



More information about the Android mailing list