diff options
| author | 2019-02-08 16:54:55 -0800 | |
|---|---|---|
| committer | 2019-02-14 14:08:58 -0800 | |
| commit | 3b07045a3f80c434d570e6dbfc9015b598b604cc (patch) | |
| tree | cfb7e61bd63ae5fd5cfb0483e64629e86b7dcc82 | |
| parent | b9218244e61995da9dd47e9bdf8f61dccc2d0eb2 (diff) | |
Removing reflection access ProgressBar#mDuration
For the following reasons:
1. Developers can set this via XML
2. Using this value is inferior to setting an
indeterminate drawable that implements Animatable.
Fixes: 124052713
Test: No new implementation, so no tests.
Change-Id: Ie1e23f75328cce5d8f4d317625d8f38c0a166352
| -rw-r--r-- | core/java/android/widget/ProgressBar.java | 41 | ||||
| -rw-r--r-- | core/res/res/values/attrs.xml | 15 |
2 files changed, 49 insertions, 7 deletions
diff --git a/core/java/android/widget/ProgressBar.java b/core/java/android/widget/ProgressBar.java index 6b48c6584ad2..9be1466137a3 100644 --- a/core/java/android/widget/ProgressBar.java +++ b/core/java/android/widget/ProgressBar.java @@ -199,7 +199,9 @@ public class ProgressBar extends View { private boolean mMaxInitialized; private int mBehavior; - @UnsupportedAppUsage + // Better to define a Drawable that implements Animatable if you want to modify animation + // characteristics programatically. + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 124052713) private int mDuration; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) private boolean mIndeterminate; @@ -277,7 +279,6 @@ public class ProgressBar extends View { } } - mDuration = a.getInt(R.styleable.ProgressBar_indeterminateDuration, mDuration); mMinWidth = a.getDimensionPixelSize(R.styleable.ProgressBar_minWidth, mMinWidth); @@ -702,7 +703,17 @@ public class ProgressBar extends View { /** * Define the drawable used to draw the progress bar in indeterminate mode. * + * <p>For the Drawable to animate, it must implement {@link Animatable}, or override + * {@link Drawable#onLevelChange(int)}. A Drawable that implements Animatable will be animated + * via that interface and therefore provides the greatest amount of customization. A Drawable + * that only overrides onLevelChange(int) is animated directly by ProgressBar and only the + * animation {@link android.R.styleable#ProgressBar_indeterminateDuration duration}, + * {@link android.R.styleable#ProgressBar_indeterminateBehavior repeating behavior}, and + * {@link #setInterpolator(Interpolator) interpolator} can be modified, and only before the + * indeterminate animation begins. + * * @param d the new drawable + * @attr ref android.R.styleable#ProgressBar_indeterminateDrawable * @see #getIndeterminateDrawable() * @see #setIndeterminate(boolean) */ @@ -1762,10 +1773,21 @@ public class ProgressBar extends View { /** * Sets the acceleration curve for the indeterminate animation. - * The interpolator is loaded as a resource from the specified context. + * + * <p>The interpolator is loaded as a resource from the specified context. Defaults to a linear + * interpolation. + * + * <p>The interpolator only affects the indeterminate animation if the + * {@link #setIndeterminateDrawable(Drawable) supplied indeterminate drawable} does not + * implement {@link Animatable}. + * + * <p>This call must be made before the indeterminate animation starts for it to have an affect. * * @param context The application environment * @param resID The resource identifier of the interpolator to load + * @attr ref android.R.styleable#ProgressBar_interpolator + * @see #setInterpolator(Interpolator) + * @see #getInterpolator() */ public void setInterpolator(Context context, @InterpolatorRes int resID) { setInterpolator(AnimationUtils.loadInterpolator(context, resID)); @@ -1775,7 +1797,17 @@ public class ProgressBar extends View { * Sets the acceleration curve for the indeterminate animation. * Defaults to a linear interpolation. * + * <p>The interpolator only affects the indeterminate animation if the + * {@link #setIndeterminateDrawable(Drawable) supplied indeterminate drawable} does not + * implement {@link Animatable}. + * + * <p>This call must be made before the indeterminate animation starts for it to have + * an affect. + * * @param interpolator The interpolator which defines the acceleration curve + * @attr ref android.R.styleable#ProgressBar_interpolator + * @see #setInterpolator(Context, int) + * @see #getInterpolator() */ public void setInterpolator(Interpolator interpolator) { mInterpolator = interpolator; @@ -1785,6 +1817,9 @@ public class ProgressBar extends View { * Gets the acceleration curve type for the indeterminate animation. * * @return the {@link Interpolator} associated to this animation + * @attr ref android.R.styleable#ProgressBar_interpolator + * @see #setInterpolator(Context, int) + * @see #setInterpolator(Interpolator) */ @InspectableProperty public Interpolator getInterpolator() { diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 46e14b41960c..224f54c64b63 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -4349,14 +4349,18 @@ <attr name="indeterminate" format="boolean" /> <!-- Restricts to ONLY indeterminate mode (state-keeping progress mode will not work). --> <attr name="indeterminateOnly" format="boolean" /> - <!-- Drawable used for the indeterminate mode. --> + <!-- Drawable used for the indeterminate mode. One that implements Animatable offers more + control over the animation.--> <attr name="indeterminateDrawable" format="reference" /> <!-- Drawable used for the progress mode. --> <attr name="progressDrawable" format="reference" /> - <!-- Duration of the indeterminate animation. --> + <!-- Duration of the indeterminate animation. Only affects the indeterminate animation + if the indeterminate Drawable does not implement + android.graphics.drawable.Animatable. --> <attr name="indeterminateDuration" format="integer" min="1" /> - <!-- Defines how the indeterminate mode should behave when the progress - reaches max. --> + <!-- Defines how the indeterminate mode should behave when the progress reaches max. Only + affects the indeterminate animation if the indeterminate Drawable does not implement + android.graphics.drawable.Animatable. --> <attr name="indeterminateBehavior"> <!-- Progress starts over from 0. --> <enum name="repeat" value="1" /> @@ -4367,6 +4371,9 @@ <attr name="maxWidth" /> <attr name="minHeight" format="dimension" /> <attr name="maxHeight" /> + <!-- Sets the acceleration curve for the indeterminate animation. Defaults to a linear + interpolation. Only affects the indeterminate animation if the indeterminate Drawable + does not implement android.graphics.drawable.Animatable.--> <attr name="interpolator" format="reference" /> <!-- Timeout between frames of animation in milliseconds. {@deprecated Not used by the framework}. --> |