Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3d295988 authored by Alan Viverette's avatar Alan Viverette Committed by Android (Google) Code Review
Browse files

Merge "Clean up VectorDrawable formatting"

parents a2e86e42 d20974bd
Loading
Loading
Loading
Loading
+44 −37
Original line number Diff line number Diff line
@@ -49,8 +49,8 @@ import java.util.HashMap;
import java.util.HashSet;

/**
 * This lets you create a drawable based on an XML vector graphic
 * It can be defined in an XML file with the <code>&lt;vector></code> element.
 * This lets you create a drawable based on an XML vector graphic It can be
 * defined in an XML file with the <code>&lt;vector></code> element.
 * <p/>
 * The vector drawable has 6 elements:
 * <p/>
@@ -65,8 +65,8 @@ import java.util.HashSet;
 * <code>android:width</code> and <code>android:height</code></dd>
 * <dt><code>&lt;viewport></code></dt>
 * <dd>Used to defined the size of the virtual canvas the paths are drawn on.
 * The size is defined using the attributes <code>android:viewportHeight
 * </code> <code>android:viewportWidth</code></dd>
 * The size is defined using the attributes <code>android:viewportHeight</code>
 * <code>android:viewportWidth</code></dd>
 * <dt><code>&lt;group></code></dt>
 * <dd>Defines a "key frame" in the animation if there is only one group the
 * drawable is static 2D image that has no animation.</dd>
@@ -80,7 +80,8 @@ import java.util.HashSet;
 * <dt><code>android:fill</code>
 * <dd>Defines the color to fill the path (none if not present).</dd></dt>
 * <dt><code>android:stroke</code>
 * <dd>Defines the color to draw the path outline (none if not present).</dd></dt>
 * <dd>Defines the color to draw the path outline (none if not present).</dd>
 * </dt>
 * <dt><code>android:strokeWidth</code>
 * <dd>The width a path stroke</dd></dt>
 * <dt><code>android:strokeOpacity</code>
@@ -98,7 +99,8 @@ import java.util.HashSet;
 * <dt><code>android:trimPathEnd</code>
 * <dd>The fraction of the path to trim from the end from 0 to 1</dd></dt>
 * <dt><code>android:trimPathOffset</code>
 * <dd>Shift trim region (allows showed region to include the start and end) from 0 to 1</dd></dt>
 * <dd>Shift trim region (allows showed region to include the start and end)
 * from 0 to 1</dd></dt>
 * <dt><code>android:clipToPath</code>
 * <dd>Path will set the clip path</dd></dt>
 * <dt><code>android:strokeLineCap</code>
@@ -135,17 +137,18 @@ import java.util.HashSet;
 * <dt><code>android:sequence</code>
 * <dd>Configures this animation sequence between the named paths.</dd></dt>
 * <dt><code>android:limitTo</code>
 * <dd>Limits an animation to only interpolate the selected variable
 * unlimited, path, rotation, trimPathStart, trimPathEnd, trimPathOffset</dd></dt>
 * <dd>Limits an animation to only interpolate the selected variable unlimited,
 * path, rotation, trimPathStart, trimPathEnd, trimPathOffset</dd></dt>
 * <dt><code>android:repeatCount</code>
 * <dd>Number of times to loop this aspect of the animation</dd></dt>
 * <dt><code>android:durations</code>
 * <dd>The duration of each step in the animation in milliseconds
 * Must contain the number of named paths - 1</dd></dt>
 * <dd>The duration of each step in the animation in milliseconds Must contain
 * the number of named paths - 1</dd></dt>
 * <dt><code>android:startDelay</code>
 * <dd></dd></dt>
 * <dt><code>android:repeatStyle</code>
 *  <dd>when repeating how does it repeat back and forth or a to b: forward, inAndOut</dd></dt>
 * <dd>when repeating how does it repeat back and forth or a to b: forward,
 * inAndOut</dd></dt>
 * <dt><code>android:animate</code>
 * <dd>linear, accelerate, decelerate, easing</dd></dt>
 * </dl>
@@ -193,8 +196,10 @@ public class VectorDrawable extends Drawable {
        }

        long duration = mVectorState.mVAnimatedPath.getTotalAnimationDuration();
        if (duration == -1) { // if it set to infinite set to 1 hour
            duration = DEFAULT_INFINITE_DURATION; // TODO define correct approach for infinite
        if (duration == -1) {
            // If duration is infinite, set to 1 hour.
            // TODO: Define correct approach for infinite.
            duration = DEFAULT_INFINITE_DURATION;
            mVectorState.mBasicAnimator.setFloatValues(0, duration / 1000);
            mVectorState.mBasicAnimator.setInterpolator(new LinearInterpolator());
        }
@@ -219,7 +224,7 @@ public class VectorDrawable extends Drawable {
    }

    /**
     * Stops the animation.
     * Stops the animation and moves to the end state.
     */
    public void stop() {
        mVectorState.mBasicAnimator.end();
@@ -255,11 +260,11 @@ public class VectorDrawable extends Drawable {

    /**
     * Defines what this animation should do when it reaches the end. This
     * setting is applied only when the repeat count is either greater than
     * 0 or {@link ValueAnimator#INFINITE}.
     * setting is applied only when the repeat count is either greater than 0 or
     * {@link ValueAnimator#INFINITE}.
     *
     * @param mode the animation mode, either {@link ValueAnimator#RESTART}
     *        or {@link ValueAnimator#REVERSE}
     * @param mode the animation mode, either {@link ValueAnimator#RESTART} or
     *            {@link ValueAnimator#REVERSE}
     */
    public void setRepeatMode(int mode) {
        mVectorState.mBasicAnimator.setRepeatMode(mode);
@@ -347,8 +352,8 @@ public class VectorDrawable extends Drawable {
    }

    /**
     * Sets padding for this shape, defined by a Rect object. Define the padding in the Rect object
     * as: left, top, right, bottom.
     * 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);
@@ -478,7 +483,8 @@ public class VectorDrawable extends Drawable {

                    // Parsing the version information.
                    // Right now, we only support version "1".
                    // If the xml didn't specify the version number, the default version is "1".
                    // If the xml didn't specify the version number, the default
                    // version is "1".
                    final int versionCode = a.getInt(R.styleable.VectorDrawable_versionCode, 1);
                    if (versionCode != 1) {
                        throw new IllegalArgumentException(
@@ -533,7 +539,8 @@ public class VectorDrawable extends Drawable {

        long duration = mVectorState.mVAnimatedPath.getTotalAnimationDuration();
        if (duration == -1) { // if it set to infinite set to 1 hour
            duration = DEFAULT_INFINITE_DURATION; // TODO define correct approach for infinite
            duration = DEFAULT_INFINITE_DURATION; // TODO define correct
                                                  // approach for infinite
            mVectorState.mBasicAnimator.setFloatValues(0, duration / 1000);
            mVectorState.mBasicAnimator.setInterpolator(new LinearInterpolator());
        }