diff --git a/api/current.txt b/api/current.txt index 0a8965f7aeaf4..491883bc0951c 100644 --- a/api/current.txt +++ b/api/current.txt @@ -3265,6 +3265,7 @@ package android.animation { public class ValueAnimator extends android.animation.Animator { ctor public ValueAnimator(); method public void addUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener); + method public static boolean areAnimatorsEnabled(); method public float getAnimatedFraction(); method public java.lang.Object getAnimatedValue(); method public java.lang.Object getAnimatedValue(java.lang.String); diff --git a/api/system-current.txt b/api/system-current.txt index 2b5c33d09cca6..519bfb81feadc 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -3380,6 +3380,7 @@ package android.animation { public class ValueAnimator extends android.animation.Animator { ctor public ValueAnimator(); method public void addUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener); + method public static boolean areAnimatorsEnabled(); method public float getAnimatedFraction(); method public java.lang.Object getAnimatedValue(); method public java.lang.Object getAnimatedValue(java.lang.String); diff --git a/api/test-current.txt b/api/test-current.txt index 4de2c6173b2e0..841fe431524d1 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -3265,6 +3265,7 @@ package android.animation { public class ValueAnimator extends android.animation.Animator { ctor public ValueAnimator(); method public void addUpdateListener(android.animation.ValueAnimator.AnimatorUpdateListener); + method public static boolean areAnimatorsEnabled(); method public float getAnimatedFraction(); method public java.lang.Object getAnimatedValue(); method public java.lang.Object getAnimatedValue(java.lang.String); diff --git a/core/java/android/animation/ValueAnimator.java b/core/java/android/animation/ValueAnimator.java index a09c9204239e6..ed7e89dff353c 100644 --- a/core/java/android/animation/ValueAnimator.java +++ b/core/java/android/animation/ValueAnimator.java @@ -275,6 +275,23 @@ public class ValueAnimator extends Animator implements AnimationHandler.Animatio return sDurationScale; } + /** + * Returns whether animators are currently enabled, system-wide. By default, all + * animators are enabled. This can change if either the user sets a Developer Option + * to set the animator duration scale to 0 or by Battery Savery mode being enabled + * (which disables all animations). + * + *
Developers should not typically need to call this method, but should an app wish
+ * to show a different experience when animators are disabled, this return value
+ * can be used as a decider of which experience to offer.
+ *
+ * @return boolean Whether animators are currently enabled. The default value is
+ * true.
+ */
+ public static boolean areAnimatorsEnabled() {
+ return !(sDurationScale == 0);
+ }
+
/**
* Creates a new ValueAnimator object. This default constructor is primarily for
* use internally; the factory methods which take parameters are more generally