I'm trying to check for the status of Remove animations
accessibility setting in order to enable/disable some UI and GIFs animations on my app, but i don't see any exposed method in AccessibilityManager
in order to access this value:
Is there any easy way to access this value? Even with reflection
I have checked and when this value is toggled 3 values are modified:
//global settings
animator_duration_scale=0
transition_animation_scale=0
window_animation_scale=0
You can programmatically determine these by checking:
if (Settings.Global.getFloat(context.contentResolver, Settings.Global.ANIMATOR_DURATION_SCALE, 1.0f) == 0f)
// Animations Off behaviour
else
// Animations On behaviour
I made a method that checks all three are not 0 (since all 3 would be aligned, and I think that these can sometimes be toggled elsewhere):
fun animationsEnabled(): Boolean =
!(Settings.Global.getFloat(contentResolver, Settings.Global.ANIMATOR_DURATION_SCALE, 1.0f) == 0f
&& Settings.Global.getFloat(contentResolver, Settings.Global.TRANSITION_ANIMATION_SCALE, 1.0f) == 0f
&& Settings.Global.getFloat(contentResolver, Settings.Global.WINDOW_ANIMATION_SCALE, 1.0f) == 0f)
Remember these are scaling numbers so they are not just 0 and 1! That's why we need to get their float values and also why we check against 0. Then we need to remember that they will ALL be set to 0 if animations are off.
Sources: