From d0eaee60e938ff6dfc153054562591c5b0b9d38b Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Fri, 20 Jul 2018 14:08:58 -0700 Subject: [PATCH] Add additional safeguards for picking an expiration timer frame. Fixes #8010 --- .../securesms/components/ExpirationTimerView.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/components/ExpirationTimerView.java b/src/org/thoughtcrime/securesms/components/ExpirationTimerView.java index 33c7a85860..c3f58ebc55 100644 --- a/src/org/thoughtcrime/securesms/components/ExpirationTimerView.java +++ b/src/org/thoughtcrime/securesms/components/ExpirationTimerView.java @@ -54,6 +54,8 @@ public class ExpirationTimerView extends android.support.v7.widget.AppCompatImag public void setPercentComplete(float percentage) { float percentFull = 1 - percentage; int frame = (int) Math.ceil(percentFull * (frames.length - 1)); + + frame = Math.max(0, Math.min(frame, frames.length - 1)); setImageResource(frames[frame]); } @@ -77,7 +79,7 @@ public class ExpirationTimerView extends android.support.v7.widget.AppCompatImag long progressed = System.currentTimeMillis() - startedAt; float percentComplete = (float)progressed / (float)expiresIn; - return Math.min(percentComplete, 1); + return Math.max(0, Math.min(percentComplete, 1)); } private long calculateAnimationDelay(long startedAt, long expiresIn) {