[Android] Fix ANR when setting a replay preamp value in a comma separated locale

Nicolas Pomepuy git at videolan.org
Mon Jul 11 11:41:44 UTC 2022


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Jul 11 07:07:16 2022 +0200| [35694eeba1304302e1af4ac28f374355ced9824e] | committer: Nicolas Pomepuy

Fix ANR when setting a replay preamp value in a comma separated locale

Fixes #2599

> https://code.videolan.org/videolan/vlc-android/commit/35694eeba1304302e1af4ac28f374355ced9824e
---

 .../java/org/videolan/television/ui/preferences/PreferencesAudio.kt   | 4 +++-
 .../src/org/videolan/vlc/gui/preferences/PreferencesAudio.kt          | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

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 9be6cbb2a..608f5fcba 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
@@ -45,6 +45,8 @@ import org.videolan.vlc.BuildConfig
 import org.videolan.vlc.R
 import org.videolan.vlc.util.LocaleUtil
 import java.text.DecimalFormat
+import java.text.DecimalFormatSymbols
+import java.util.*
 
 private const val TAG = "VLC/PreferencesAudio"
 
@@ -133,7 +135,7 @@ class PreferencesAudio : BasePreferenceFragment(), SharedPreferences.OnSharedPre
                 val newValue = sharedPreferences.getString(key, defValue)
                 var fmtValue = defValue
                 try {
-                    fmtValue = DecimalFormat("###0.0###").format(newValue?.toDouble())
+                    fmtValue = DecimalFormat("###0.0###", DecimalFormatSymbols(Locale.ENGLISH)).format(newValue?.toDouble())
                 } catch (e: IllegalArgumentException) {
                     Log.w(TAG, "Could not parse value: $newValue. Setting $key to $fmtValue", e)
                 } finally {
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 2fda4cb2b..61790a585 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
@@ -51,6 +51,8 @@ import org.videolan.vlc.media.MediaUtils
 import org.videolan.vlc.providers.PickerType
 import org.videolan.vlc.util.LocaleUtil
 import java.text.DecimalFormat
+import java.text.DecimalFormatSymbols
+import java.util.*
 
 private const val TAG = "VLC/PreferencesAudio"
 private const val FILE_PICKER_RESULT_CODE = 10000
@@ -157,7 +159,7 @@ class PreferencesAudio : BasePreferenceFragment(), SharedPreferences.OnSharedPre
                 val newValue = sharedPreferences.getString(key, defValue)
                 var fmtValue = defValue
                 try {
-                    fmtValue = DecimalFormat("###0.0###").format(newValue?.toDouble())
+                    fmtValue = DecimalFormat("###0.0###", DecimalFormatSymbols(Locale.ENGLISH)).format(newValue?.toDouble())
                 } catch (e: IllegalArgumentException) {
                     Log.w(TAG, "Could not parse value: $newValue. Setting $key to $fmtValue", e)
                 } finally {



More information about the Android mailing list