mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix check of "reduce motion" setting on android (#36508)
Summary: On Android `AccessibilityInfo.isReduceMotionEnabled()` returns false even when "Disable Animations" is enabled. This fixes https://github.com/facebook/react-native/issues/31221. ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> [ANDROID] [FIXED] - Fix check of "reduce motion" setting on android Pull Request resolved: https://github.com/facebook/react-native/pull/36508 Test Plan: Have some code logging the value of `AccessibilityInfo.isReduceMotionEnabled()` or using it to change the UI. Run that code on Android without and with "Disable Animations" enabled. See the value is always `false` without the fix, but changes to `true` when "Disable Animations" is enabled with the fix. Reviewed By: cortinico, rshest Differential Revision: D44163583 Pulled By: javache fbshipit-source-id: ad239454ea68b381e0c7f024df797b3646aeefd7
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b0c30ada21
commit
790df10fa9
+7
-2
@@ -100,10 +100,15 @@ public class AccessibilityInfoModule extends NativeAccessibilityInfoSpec
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
private boolean getIsReduceMotionEnabledValue() {
|
||||
String value =
|
||||
// Disabling animations in developer settings will set the animation scale to "0.0"
|
||||
// but setting "reduce motion" / "disable animations" will set the animation scale to "0".
|
||||
String rawValue =
|
||||
Settings.Global.getString(mContentResolver, Settings.Global.TRANSITION_ANIMATION_SCALE);
|
||||
|
||||
return value != null && value.equals("0.0");
|
||||
// Parse the value as a float so we can check for a single value.
|
||||
Float parsedValue = rawValue != null ? Float.parseFloat(rawValue) : 1f;
|
||||
|
||||
return parsedValue == 0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user