Merge "Make AnimatedVectorDrawable public."
diff --git a/api/current.txt b/api/current.txt
index c683a71..c8b3b3b 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -11253,6 +11253,17 @@
method public void addTransition(int, int, android.graphics.drawable.AnimationDrawable, boolean);
}
+ public class AnimatedVectorDrawable extends android.graphics.drawable.Drawable implements android.graphics.drawable.Animatable {
+ ctor public AnimatedVectorDrawable();
+ method public void draw(android.graphics.Canvas);
+ method public int getOpacity();
+ method public boolean isRunning();
+ method public void setAlpha(int);
+ method public void setColorFilter(android.graphics.ColorFilter);
+ method public void start();
+ method public void stop();
+ }
+
public class AnimationDrawable extends android.graphics.drawable.DrawableContainer implements android.graphics.drawable.Animatable java.lang.Runnable {
ctor public AnimationDrawable();
method public void addFrame(android.graphics.drawable.Drawable, int);
@@ -11652,8 +11663,6 @@
method public int getOpacity();
method public void setAlpha(int);
method public void setColorFilter(android.graphics.ColorFilter);
- method public void setPadding(android.graphics.Rect);
- method public void setPadding(int, int, int, int);
}
}
diff --git a/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java b/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java
index 968c0ec..c787fb0 100644
--- a/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java
+++ b/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java
@@ -34,10 +34,91 @@
import java.util.ArrayList;
/**
- * AnimatedVectorDrawable can use ObjectAnimator and AnimatorSet to animate
- * the property of the VectorDrawable.
+ * This class uses {@link android.animation.ObjectAnimator} and
+ * {@link android.animation.AnimatorSet} to animate the properties of a
+ * {@link android.graphics.drawable.VectorDrawable} to create an animated drawable.
+ * <p>
+ * AnimatedVectorDrawable are normally defined as 3 separate XML files.
+ * </p>
+ * <p>
+ * First is the XML file for {@link android.graphics.drawable.VectorDrawable}.
+ * Note that we allow the animation happen on the group's attributes and path's
+ * attributes, which requires they are uniquely named in this xml file. Groups
+ * and paths without animations do not need names.
+ * </p>
+ * <li>Here is a simple VectorDrawable in this vectordrawable.xml file.
+ * <pre>
+ * <vector xmlns:android="http://schemas.android.com/apk/res/android" >
+ * <size
+ * android:height="64dp"
+ * android:width="64dp" />
+ * <viewport
+ * android:viewportHeight="600"
+ * android:viewportWidth="600" />
+ * <group
+ * android:name="rotationGroup"
+ * android:pivotX="300.0"
+ * android:pivotY="300.0"
+ * android:rotation="45.0" >
+ * <path
+ * android:name="v"
+ * android:fill="#000000"
+ * android:pathData="M300,70 l 0,-70 70,70 0,0 -70,70z" />
+ * </group>
+ * </vector>
+ * </pre></li>
+ * <p>
+ * Second is the AnimatedVectorDrawable's xml file, which defines the target
+ * VectorDrawable, the target paths and groups to animate, the properties of the
+ * path and group to animate and the animations defined as the ObjectAnimators
+ * or AnimatorSets.
+ * </p>
+ * <li>Here is a simple AnimatedVectorDrawable defined in this avd.xml file.
+ * Note how we use the names to refer to the groups and paths in the vectordrawable.xml.
+ * <pre>
+ * <animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
+ * android:drawable="@drawable/vectordrawable" >
+ * <target
+ * android:name="rotationGroup"
+ * android:animation="@anim/rotation" />
+ * <target
+ * android:name="v"
+ * android:animation="@anim/path_morph" />
+ * </animated-vector>
+ * </pre></li>
+ * <p>
+ * Last is the Animator xml file, which is the same as a normal ObjectAnimator
+ * or AnimatorSet.
+ * To complete this example, here are the 2 animator files used in avd.xml:
+ * rotation.xml and path_morph.xml.
+ * </p>
+ * <li>Here is the rotation.xml, which will rotate the target group for 360 degrees.
+ * <pre>
+ * <objectAnimator
+ * android:duration="6000"
+ * android:propertyName="rotation"
+ * android:valueFrom="0"
+ * android:valueTo="360" />
+ * </pre></li>
+ * <li>Here is the path_morph.xml, which will morph the path from one shape to
+ * the other. Note that the paths must be compatible for morphing.
+ * In more details, the paths should have exact same length of commands , and
+ * exact same length of parameters for each commands.
+ * Note that the path string are better stored in strings.xml for reusing.
+ * <pre>
+ * <set xmlns:android="http://schemas.android.com/apk/res/android">
+ * <objectAnimator
+ * android:duration="3000"
+ * android:propertyName="pathData"
+ * android:valueFrom="M300,70 l 0,-70 70,70 0,0 -70,70z"
+ * android:valueTo="M300,70 l 0,-70 70,0 0,140 -70,0 z"
+ * android:valueType="pathType"/>
+ * </set>
+ * </pre></li>
*
- * @hide
+ * @attr ref android.R.styleable#AnimatedVectorDrawable_drawable
+ * @attr ref android.R.styleable#AnimatedVectorDrawableTarget_name
+ * @attr ref android.R.styleable#AnimatedVectorDrawableTarget_animation
*/
public class AnimatedVectorDrawable extends Drawable implements Animatable {
private static final String LOGTAG = AnimatedVectorDrawable.class.getSimpleName();
diff --git a/graphics/java/android/graphics/drawable/VectorDrawable.java b/graphics/java/android/graphics/drawable/VectorDrawable.java
index 3773a9b..c98f2a1 100644
--- a/graphics/java/android/graphics/drawable/VectorDrawable.java
+++ b/graphics/java/android/graphics/drawable/VectorDrawable.java
@@ -237,34 +237,6 @@
return PixelFormat.TRANSLUCENT;
}
- /**
- * Sets padding for this shape, defined by a Rect object. Define the padding
- * in the Rect object as: left, top, right, bottom.
- */
- public void setPadding(Rect padding) {
- setPadding(padding.left, padding.top, padding.right, padding.bottom);
- }
-
- /**
- * Sets padding for the shape.
- *
- * @param left padding for the left side (in pixels)
- * @param top padding for the top (in pixels)
- * @param right padding for the right side (in pixels)
- * @param bottom padding for the bottom (in pixels)
- */
- public void setPadding(int left, int top, int right, int bottom) {
- if ((left | top | right | bottom) == 0) {
- mVectorState.mPadding = null;
- } else {
- if (mVectorState.mPadding == null) {
- mVectorState.mPadding = new Rect();
- }
- mVectorState.mPadding.set(left, top, right, bottom);
- }
- invalidateSelf();
- }
-
@Override
public int getIntrinsicWidth() {
return (int) mVectorState.mVPathRenderer.mBaseWidth;
@@ -276,16 +248,6 @@
}
@Override
- public boolean getPadding(Rect padding) {
- if (mVectorState.mPadding != null) {
- padding.set(mVectorState.mPadding);
- return true;
- } else {
- return super.getPadding(padding);
- }
- }
-
- @Override
public boolean canApplyTheme() {
return super.canApplyTheme() || mVectorState != null && mVectorState.canApplyTheme();
}
@@ -462,7 +424,6 @@
int[] mThemeAttrs;
int mChangingConfigurations;
VPathRenderer mVPathRenderer;
- Rect mPadding;
ColorStateList mTint;
Mode mTintMode;
@@ -472,7 +433,6 @@
mChangingConfigurations = copy.mChangingConfigurations;
// TODO: Make sure the constant state are handled correctly.
mVPathRenderer = new VPathRenderer(copy.mVPathRenderer);
- mPadding = new Rect(copy.mPadding);
mTint = copy.mTint;
mTintMode = copy.mTintMode;
}