[New API] Added override for system animations enabled behavior (#1747)

Allow overriding the default behavior of respecting when system animations are disabled.
XML: app:lottie_ignoreDisabledSystemAnimations="true"
Code: setIgnoreDisabledSystemAnimations(boolean)
diff --git a/lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java b/lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java
index 57e113e..eef6012 100644
--- a/lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java
+++ b/lottie/src/main/java/com/airbnb/lottie/LottieAnimationView.java
@@ -219,6 +219,13 @@
       setRenderMode(RenderMode.values()[renderModeOrdinal]);
     }
 
+    setIgnoreDisabledSystemAnimations(
+        ta.getBoolean(
+            R.styleable.LottieAnimationView_lottie_ignoreDisabledSystemAnimations,
+            false
+        )
+    );
+
     ta.recycle();
 
     lottieDrawable.setSystemAnimationsAreEnabled(Utils.getAnimationScale(getContext()) != 0f);
@@ -354,6 +361,17 @@
   }
 
   /**
+   * Allows ignoring system animations settings, therefore allowing animations to run even if they are disabled.
+   *
+   * Defaults to false.
+   *
+   * @param ignore if true animations will run even when they are disabled in the system settings.
+   */
+  public void setIgnoreDisabledSystemAnimations(boolean ignore) {
+    lottieDrawable.setIgnoreDisabledSystemAnimations(ignore);
+  }
+
+  /**
    * Enable this to get merge path support for devices running KitKat (19) and above.
    *
    * Merge paths currently don't work if the the operand shape is entirely contained within the
diff --git a/lottie/src/main/java/com/airbnb/lottie/LottieDrawable.java b/lottie/src/main/java/com/airbnb/lottie/LottieDrawable.java
index 007acba..ce5cd47 100644
--- a/lottie/src/main/java/com/airbnb/lottie/LottieDrawable.java
+++ b/lottie/src/main/java/com/airbnb/lottie/LottieDrawable.java
@@ -59,7 +59,11 @@
   private LottieComposition composition;
   private final LottieValueAnimator animator = new LottieValueAnimator();
   private float scale = 1f;
+
+  //Call animationsEnabled() instead of using these fields directly
   private boolean systemAnimationsEnabled = true;
+  private boolean ignoreSystemAnimationsDisabled = false;
+
   private boolean safeMode = false;
 
   private final ArrayList<LazyCompositionTask> lazyCompositionTasks = new ArrayList<>();
@@ -445,10 +449,10 @@
       return;
     }
 
-    if (systemAnimationsEnabled || getRepeatCount() == 0) {
+    if (animationsEnabled() || getRepeatCount() == 0) {
       animator.playAnimation();
     }
-    if (!systemAnimationsEnabled) {
+    if (!animationsEnabled()) {
       setFrame((int) (getSpeed() < 0 ? getMinFrame() : getMaxFrame()));
       animator.endAnimation();
     }
@@ -476,10 +480,10 @@
       return;
     }
 
-    if (systemAnimationsEnabled || getRepeatCount() == 0) {
+    if (animationsEnabled() || getRepeatCount() == 0) {
       animator.resumeAnimation();
     }
-    if (!systemAnimationsEnabled) {
+    if (!animationsEnabled()) {
       setFrame((int) (getSpeed() < 0 ? getMinFrame() : getMaxFrame()));
       animator.endAnimation();
     }
@@ -866,6 +870,10 @@
     return animator.isRunning();
   }
 
+  private boolean animationsEnabled() {
+    return systemAnimationsEnabled || ignoreSystemAnimationsDisabled;
+  }
+
   void setSystemAnimationsAreEnabled(Boolean areEnabled) {
     systemAnimationsEnabled = areEnabled;
   }
@@ -873,6 +881,17 @@
 // </editor-fold>
 
   /**
+   * Allows ignoring system animations settings, therefore allowing animations to run even if they are disabled.
+   *
+   * Defaults to false.
+   *
+   * @param ignore if true animations will run even when they are disabled in the system settings.
+   */
+  public void setIgnoreDisabledSystemAnimations(boolean ignore) {
+    ignoreSystemAnimationsDisabled = ignore;
+  }
+
+  /**
    * Set the scale on the current composition. The only cost of this function is re-rendering the
    * current frame so you may call it frequent to scale something up or down.
    * <p>
diff --git a/lottie/src/main/res/values/attrs.xml b/lottie/src/main/res/values/attrs.xml
index 31e7dba..1e8f30e 100644
--- a/lottie/src/main/res/values/attrs.xml
+++ b/lottie/src/main/res/values/attrs.xml
@@ -21,6 +21,7 @@
         <attr name="lottie_scale" format="float" />
         <attr name="lottie_speed" format="float" />
         <attr name="lottie_cacheComposition" format="boolean" />
+        <attr name="lottie_ignoreDisabledSystemAnimations" format="boolean" />
         <!-- These values must be kept in sync with the RenderMode enum -->
         <attr name="lottie_renderMode" format="enum">
             <enum name="automatic" value="0" />