mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
accept Settings.Global.TRANSITION_ANIMATION_SCALE with a comma decimal separator (#50864)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/50864 Changelog: [Android][Fixed] Settings.Global.TRANSITION_ANIMATION_SCALE accepts comma as decimal separator Reviewed By: javache Differential Revision: D73501445 fbshipit-source-id: f7f54dbbcbc4cea1e746222febf8ec63638a73ac
This commit is contained in:
committed by
Facebook GitHub Bot
parent
5ed486cc8f
commit
8b11970adb
+13
-3
@@ -105,9 +105,19 @@ internal class AccessibilityInfoModule(context: ReactApplicationContext) :
|
||||
val rawValue =
|
||||
Settings.Global.getString(contentResolver, Settings.Global.TRANSITION_ANIMATION_SCALE)
|
||||
|
||||
// Parse the value as a float so we can check for a single value.
|
||||
val parsedValue = rawValue?.toFloat() ?: 1f
|
||||
return parsedValue == 0f
|
||||
if (rawValue == null) {
|
||||
return false
|
||||
}
|
||||
|
||||
try {
|
||||
// In some locales, the decimal separator is a comma instead of a dot,
|
||||
// but "toFloat" would crash failing to conver these.
|
||||
val parsedValue = rawValue.replace(',', '.').toFloat()
|
||||
return parsedValue == 0f
|
||||
} catch (e: NumberFormatException) {
|
||||
// If the value is not a valid number, we assume reduced motion is not enabled
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
private val isInvertColorsEnabledValue: Boolean
|
||||
|
||||
Reference in New Issue
Block a user