Respect disabled system animations (#1187)

If systemAnimationScale == 0, the lottie animation will play then immediately jump to the last frame, or only jump to the last frame if it is a loop animation.
This solution handles if the dev move the animation at some percentage, change first or last frame or play the animation in reverse.

Really useful for testing purpose in order to not overload the main thread

Unittest are OK, I couldn't start the uiTest as it require the AWS key.

I couldn't add unittest as it obviously doesn't try to start the animations in it

Fixes #1129 
diff --git a/lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java b/lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java
index 3a15402..2d7f982 100644
--- a/lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java
+++ b/lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java
@@ -24,6 +24,7 @@
 import android.view.View;
 
 import com.airbnb.lottie.model.KeyPath;
+import com.airbnb.lottie.utils.Utils;
 import com.airbnb.lottie.value.LottieFrameInfo;
 import com.airbnb.lottie.value.LottieValueCallback;
 import com.airbnb.lottie.value.SimpleLottieValueCallback;
@@ -163,6 +164,8 @@
 
     ta.recycle();
 
+    lottieDrawable.setSystemAnimationsAreEnabled(Utils.getAnimationScale(getContext()) != 0f);
+
     enableOrDisableHardwareLayer();
   }
 
diff --git a/lottie/src/main/java/com/airbnb/lottie/LottieDrawable.java b/lottie/src/main/java/com/airbnb/lottie/LottieDrawable.java
index 7c14f39..1f0a2c9 100644
--- a/lottie/src/main/java/com/airbnb/lottie/LottieDrawable.java
+++ b/lottie/src/main/java/com/airbnb/lottie/LottieDrawable.java
@@ -64,6 +64,7 @@
   private LottieComposition composition;
   private final LottieValueAnimator animator = new LottieValueAnimator();
   private float scale = 1f;
+  private boolean systemAnimationsEnabled = true;
 
   private final Set<ColorFilterData> colorFilterData = new HashSet<>();
   private final ArrayList<LazyCompositionTask> lazyCompositionTasks = new ArrayList<>();
@@ -375,7 +376,13 @@
       });
       return;
     }
-    animator.playAnimation();
+
+    if (systemAnimationsEnabled || getRepeatCount() == 0) {
+      animator.playAnimation();
+    }
+    if (!systemAnimationsEnabled) {
+      setFrame((int) (getSpeed() < 0 ? getMinFrame() : getMaxFrame()));
+    }
   }
 
   @MainThread
@@ -732,6 +739,10 @@
     return animator.isRunning();
   }
 
+  void setSystemAnimationsAreEnabled(Boolean areEnabled) {
+    systemAnimationsEnabled = areEnabled;
+  }
+
 // </editor-fold>
 
   /**
diff --git a/lottie/src/main/java/com/airbnb/lottie/utils/Utils.java b/lottie/src/main/java/com/airbnb/lottie/utils/Utils.java
index d8cbe08..cad6e2b 100644
--- a/lottie/src/main/java/com/airbnb/lottie/utils/Utils.java
+++ b/lottie/src/main/java/com/airbnb/lottie/utils/Utils.java
@@ -1,5 +1,6 @@
 package com.airbnb.lottie.utils;
 
+import android.content.Context;
 import android.content.res.Resources;
 import android.graphics.Bitmap;
 import android.graphics.Canvas;
@@ -10,6 +11,8 @@
 import android.graphics.PathMeasure;
 import android.graphics.PointF;
 import android.graphics.RectF;
+import android.os.Build;
+import android.provider.Settings;
 
 import androidx.annotation.Nullable;
 
@@ -213,6 +216,17 @@
     return dpScale;
   }
 
+  public static float getAnimationScale(Context context) {
+    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
+      return Settings.Global.getFloat(context.getContentResolver(),
+              Settings.Global.ANIMATOR_DURATION_SCALE, 1.0f);
+    } else {
+      //noinspection deprecation
+      return Settings.System.getFloat(context.getContentResolver(),
+              Settings.System.ANIMATOR_DURATION_SCALE, 1.0f);
+    }
+  }
+
   /**
    * For testing purposes only. DO NOT USE IN PRODUCTION.
    */