mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 20:18:36 +00:00
Fix Do not animate spoilers if system animations are disabled.
Closes #13016
This commit is contained in:
@@ -11,7 +11,6 @@ import androidx.annotation.MainThread
|
||||
import org.signal.core.util.DimensionUnit
|
||||
import org.signal.core.util.dp
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
import org.thoughtcrime.securesms.util.AccessibilityUtil
|
||||
import org.thoughtcrime.securesms.util.Util
|
||||
import kotlin.random.Random
|
||||
|
||||
@@ -65,14 +64,14 @@ object SpoilerPaint {
|
||||
bounds.bottom + strokeWidth.toInt()
|
||||
)
|
||||
|
||||
update(!AccessibilityUtil.areAnimationsDisabled(ApplicationDependencies.getApplication()))
|
||||
update()
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke every time before you need to use the [shader].
|
||||
*/
|
||||
@MainThread
|
||||
fun update(animationsEnabled: Boolean) {
|
||||
fun update() {
|
||||
val now = System.currentTimeMillis()
|
||||
var dt = now - lastDrawTime
|
||||
if (dt < 48) {
|
||||
@@ -87,7 +86,7 @@ object SpoilerPaint {
|
||||
// To avoid that, we draw into a buffer, then swap the buffer into the shader when it's fully drawn.
|
||||
val canvas = Canvas(bufferBitmap)
|
||||
bufferBitmap.eraseColor(Color.TRANSPARENT)
|
||||
draw(canvas, if (animationsEnabled) dt else 0)
|
||||
draw(canvas, dt)
|
||||
|
||||
val swap = shaderBitmap
|
||||
shaderBitmap = bufferBitmap
|
||||
|
||||
@@ -38,7 +38,7 @@ class SpoilerRendererDelegate @JvmOverloads constructor(
|
||||
|
||||
private val animator = TimeAnimator().apply {
|
||||
setTimeListener { _, _, _ ->
|
||||
SpoilerPaint.update(systemAnimationsEnabled)
|
||||
SpoilerPaint.update()
|
||||
view.invalidate()
|
||||
}
|
||||
}
|
||||
@@ -114,7 +114,7 @@ class SpoilerRendererDelegate @JvmOverloads constructor(
|
||||
hasSpoilersToRender = true
|
||||
}
|
||||
|
||||
if (hasSpoilersToRender) {
|
||||
if (hasSpoilersToRender && systemAnimationsEnabled) {
|
||||
if (!animatorRunning) {
|
||||
animator.start()
|
||||
animatorRunning = true
|
||||
|
||||
Reference in New Issue
Block a user