Fix infinite animation loop when system animations are disabled.
This commit is contained in:
parent
2cfa31a9b0
commit
b1d1aee373
2 changed files with 16 additions and 0 deletions
|
@ -19,6 +19,7 @@ import com.bumptech.glide.request.target.Target
|
|||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.blurhash.BlurHash
|
||||
import org.thoughtcrime.securesms.mms.GlideApp
|
||||
import org.thoughtcrime.securesms.util.areSystemAnimationsDisabled
|
||||
import org.thoughtcrime.securesms.util.visible
|
||||
|
||||
class StoryFirstTimeNavigationView @JvmOverloads constructor(
|
||||
|
@ -118,6 +119,10 @@ class StoryFirstTimeNavigationView @JvmOverloads constructor(
|
|||
}
|
||||
|
||||
private fun startLottieAnimations() {
|
||||
if (context.contentResolver.areSystemAnimationsDisabled()) {
|
||||
return
|
||||
}
|
||||
|
||||
isPlayingAnimations = true
|
||||
tapToAdvance.addAnimatorListener(object : AnimatorListenerAdapter() {
|
||||
override fun onAnimationEnd(animation: Animator?) {
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package org.thoughtcrime.securesms.util
|
||||
|
||||
import android.content.ContentResolver
|
||||
import android.provider.Settings
|
||||
|
||||
fun ContentResolver.areSystemAnimationsDisabled(): Boolean {
|
||||
val durationScale = Settings.System.getFloat(this, Settings.Global.ANIMATOR_DURATION_SCALE)
|
||||
val transitionScale = Settings.System.getFloat(this, Settings.Global.TRANSITION_ANIMATION_SCALE)
|
||||
|
||||
return !(durationScale > 0f && transitionScale > 0f)
|
||||
}
|
Loading…
Add table
Reference in a new issue