Fix media viewer not being dismissed with reduced motion enabled (#5555)

This is also called 'remove animations' in some Android versions. It seems like the associated coroutine dispatcher never allows the `delay` calls to complete, or maybe they take too long and the coroutine is cancelled before they finish.
This commit is contained in:
Jorge Martin Espinosa 2025-10-17 12:10:13 +02:00 committed by GitHub
parent ebe94f873e
commit c0d6862b6e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 1 deletions

View file

@ -0,0 +1,19 @@
/*
* Copyright 2025 New Vector Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
* Please see LICENSE files in the repository root for full details.
*/
package io.element.android.libraries.androidutils.system
import android.content.Context
import android.provider.Settings
fun Context.getAnimationScale(): Float {
return Settings.Global.getFloat(contentResolver, Settings.Global.ANIMATOR_DURATION_SCALE, 1.0f)
}
fun Context.areAnimationsEnabled(): Boolean {
return getAnimationScale() > 0f
}