I’m seeing conflicting information regarding wheth...
# compose-android
m
I’m seeing conflicting information regarding whether Developer Options “Animator Duration scale” affects compose animations. In my own testing it doesn’t, and I’ve seen other say the same. But officially compose animations are supposed to respect that setting.
m
The system setting was indeed impacting my animations (it just took a little while to kick in). Your solution works perfectly. Thanks very much! This is so much better than the old workaround which I did like this:
Copy code
// NO-LONGER-RELEVANT LEGACY ANDROID VIEW-BASED WORKAROUND
fun fixAnimatorDurationScale(context: Context) {
    val definitelyDisabled = !ValueAnimator.areAnimatorsEnabled()
    val durationScale = if (definitelyDisabled) {
        0f
    } else {
        try {
            // possibly enabled but we want to make sure we are using scale 1f
            Global.getFloat(context.contentResolver, Global.ANIMATOR_DURATION_SCALE)
        } catch (t: Throwable) {
            // android.provider.Settings$SettingNotFoundException: animator_duration_scale
            // this can happen if the user has never set this setting (confirmed on API27 emulator)
            if (t is Settings.SettingNotFoundException) {
                println("Unable to get animator duration scale system setting (probably user never set it)")
            } else {
                println("Unable to get animator duration scale system setting", t)
            }
            return
        }
    }
    if (durationScale == 1f) {
        return
    }
    println("fixing animator duration scale: $durationScale")
    try {
        ValueAnimator::class.java.getMethod("setDurationScale", Float::class.javaPrimitiveType).invoke(null, 1f)
    } catch (t: Throwable) {
        println("unable to fix animator duration scale", t)
    }
}
e
ah right. if you restart your app I'd expect it to pick up the current value of the global animator scale