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

Commit bd67759a authored by ztenghui's avatar ztenghui Committed by Android (Google) Code Review
Browse files

Merge "Bring the group tag back to VectorDrawable."

parents 60a46d62 6d9c422d
Loading
Loading
Loading
Loading
+34 −16
Original line number Original line Diff line number Diff line
@@ -58,9 +58,10 @@ import java.util.HashMap;
 * <dd>Used to defined the size of the virtual canvas the paths are drawn on.
 * <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>
 * The size is defined using the attributes <code>android:viewportHeight</code>
 * <code>android:viewportWidth</code></dd>
 * <code>android:viewportWidth</code></dd>
 * <dt><code>&lt;group></code></dt>
 * <dd>Defines a group of paths or subgroups, plus transformation information.</dd>
 * <dt><code>&lt;path></code></dt>
 * <dt><code>&lt;path></code></dt>
 * <dd>Defines paths to be drawn. Multiple paths can be defined in one xml file.
 * <dd>Defines paths to be drawn.
 * The paths are drawn in the order of their definition order.
 * <dl>
 * <dl>
 * <dt><code>android:name</code>
 * <dt><code>android:name</code>
 * <dd>Defines the name of the path.</dd></dt>
 * <dd>Defines the name of the path.</dd></dt>
@@ -107,6 +108,7 @@ public class VectorDrawable extends Drawable {


    private static final String SHAPE_SIZE = "size";
    private static final String SHAPE_SIZE = "size";
    private static final String SHAPE_VIEWPORT = "viewport";
    private static final String SHAPE_VIEWPORT = "viewport";
    private static final String SHAPE_GROUP = "group";
    private static final String SHAPE_PATH = "path";
    private static final String SHAPE_PATH = "path";
    private static final String SHAPE_VECTOR = "vector";
    private static final String SHAPE_VECTOR = "vector";


@@ -265,6 +267,7 @@ public class VectorDrawable extends Drawable {


        boolean noSizeTag = true;
        boolean noSizeTag = true;
        boolean noViewportTag = true;
        boolean noViewportTag = true;
        boolean noGroupTag = true;
        boolean noPathTag = true;
        boolean noPathTag = true;


        VGroup currentGroup = new VGroup();
        VGroup currentGroup = new VGroup();
@@ -284,12 +287,20 @@ public class VectorDrawable extends Drawable {
                } else if (SHAPE_VIEWPORT.equals(tagName)) {
                } else if (SHAPE_VIEWPORT.equals(tagName)) {
                    pathRenderer.parseViewport(res, attrs);
                    pathRenderer.parseViewport(res, attrs);
                    noViewportTag = false;
                    noViewportTag = false;
                } else if (SHAPE_GROUP.equals(tagName)) {
                    currentGroup = new VGroup();
                    pathRenderer.mGroupList.add(currentGroup);
                    noGroupTag = false;
                }
                }
            }
            }


            eventType = parser.next();
            eventType = parser.next();
        }
        }


        if (noGroupTag && !noPathTag) {
            pathRenderer.mGroupList.add(currentGroup);
        }

        if (noSizeTag || noViewportTag || noPathTag) {
        if (noSizeTag || noViewportTag || noPathTag) {
            final StringBuffer tag = new StringBuffer();
            final StringBuffer tag = new StringBuffer();


@@ -314,7 +325,6 @@ public class VectorDrawable extends Drawable {
            throw new XmlPullParserException("no " + tag + " defined");
            throw new XmlPullParserException("no " + tag + " defined");
        }
        }


        pathRenderer.mCurrentGroup = currentGroup;
        // post parse cleanup
        // post parse cleanup
        pathRenderer.parseFinish();
        pathRenderer.parseFinish();
        return pathRenderer;
        return pathRenderer;
@@ -369,7 +379,7 @@ public class VectorDrawable extends Drawable {
        private ColorFilter mColorFilter;
        private ColorFilter mColorFilter;
        private PathMeasure mPathMeasure;
        private PathMeasure mPathMeasure;


        private VGroup mCurrentGroup = new VGroup();
        final ArrayList<VGroup> mGroupList = new ArrayList<VGroup>();


        float mBaseWidth = 0;
        float mBaseWidth = 0;
        float mBaseHeight = 0;
        float mBaseHeight = 0;
@@ -380,7 +390,7 @@ public class VectorDrawable extends Drawable {
        }
        }


        public VPathRenderer(VPathRenderer copy) {
        public VPathRenderer(VPathRenderer copy) {
            mCurrentGroup = copy.mCurrentGroup;
            mGroupList.addAll(copy.mGroupList);
            if (copy.mCurrentPaths != null) {
            if (copy.mCurrentPaths != null) {
                mCurrentPaths = new VPath[copy.mCurrentPaths.length];
                mCurrentPaths = new VPath[copy.mCurrentPaths.length];
                for (int i = 0; i < mCurrentPaths.length; i++) {
                for (int i = 0; i < mCurrentPaths.length; i++) {
@@ -395,18 +405,24 @@ public class VectorDrawable extends Drawable {
        }
        }


        public boolean canApplyTheme() {
        public boolean canApplyTheme() {
            final ArrayList<VPath> paths = mCurrentGroup.mVGList;
            final ArrayList<VGroup> groups = mGroupList;
            for (int i = groups.size() - 1; i >= 0; i--) {
                final ArrayList<VPath> paths = groups.get(i).mVGList;
                for (int j = paths.size() - 1; j >= 0; j--) {
                for (int j = paths.size() - 1; j >= 0; j--) {
                    final VPath path = paths.get(j);
                    final VPath path = paths.get(j);
                    if (path.canApplyTheme()) {
                    if (path.canApplyTheme()) {
                        return true;
                        return true;
                    }
                    }
                }
                }
            }

            return false;
            return false;
        }
        }


        public void applyTheme(Theme t) {
        public void applyTheme(Theme t) {
            final ArrayList<VPath> paths = mCurrentGroup.mVGList;
            final ArrayList<VGroup> groups = mGroupList;
            for (int i = groups.size() - 1; i >= 0; i--) {
                final ArrayList<VPath> paths = groups.get(i).mVGList;
                for (int j = paths.size() - 1; j >= 0; j--) {
                for (int j = paths.size() - 1; j >= 0; j--) {
                    final VPath path = paths.get(j);
                    final VPath path = paths.get(j);
                    if (path.canApplyTheme()) {
                    if (path.canApplyTheme()) {
@@ -414,6 +430,7 @@ public class VectorDrawable extends Drawable {
                    }
                    }
                }
                }
            }
            }
        }


        public void setColorFilter(ColorFilter colorFilter) {
        public void setColorFilter(ColorFilter colorFilter) {
            mColorFilter = colorFilter;
            mColorFilter = colorFilter;
@@ -425,6 +442,7 @@ public class VectorDrawable extends Drawable {
            if (mStrokePaint != null) {
            if (mStrokePaint != null) {
                mStrokePaint.setColorFilter(colorFilter);
                mStrokePaint.setColorFilter(colorFilter);
            }
            }

        }
        }


        public void draw(Canvas canvas, int w, int h) {
        public void draw(Canvas canvas, int w, int h) {
@@ -522,7 +540,7 @@ public class VectorDrawable extends Drawable {
         * TODO: improve memory use & performance or move to C++
         * TODO: improve memory use & performance or move to C++
         */
         */
        public void parseFinish() {
        public void parseFinish() {
            final Collection<VPath> paths = mCurrentGroup.getPaths();
            final Collection<VPath> paths = mGroupList.get(0).getPaths();
            mCurrentPaths = paths.toArray(new VPath[paths.size()]);
            mCurrentPaths = paths.toArray(new VPath[paths.size()]);
            for (int i = 0; i < mCurrentPaths.length; i++) {
            for (int i = 0; i < mCurrentPaths.length; i++) {
                mCurrentPaths[i] = new VPath(mCurrentPaths[i]);
                mCurrentPaths[i] = new VPath(mCurrentPaths[i]);
+10 −9
Original line number Original line Diff line number Diff line
@@ -24,12 +24,13 @@
        android:viewportHeight="480"
        android:viewportHeight="480"
        android:viewportWidth="480" />
        android:viewportWidth="480" />


    <group>
        <path
        <path
            android:name="box1"
            android:name="box1"
        android:fill="?android:attr/colorControlActivated"
            android:pathData="m20,200l100,90l180,-180l-35,-35l-145,145l-60,-60l-40,40z"
            android:pathData="m20,200l100,90l180,-180l-35,-35l-145,145l-60,-60l-40,40z"
            android:fill="?android:attr/colorControlActivated"
            android:stroke="?android:attr/colorControlActivated"
            android:stroke="?android:attr/colorControlActivated"
            android:strokeLineCap="round"
            android:strokeLineCap="round"
            android:strokeLineJoin="round" />
            android:strokeLineJoin="round" />

    </group>
</vector>
</vector>
+16 −19
Original line number Original line Diff line number Diff line
<!--
<!-- Copyright (C) 2014 The Android Open Source Project
 Copyright (C) 2014 The Android Open Source Project


     Licensed under the Apache License, Version 2.0 (the "License");
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     you may not use this file except in compliance with the License.
@@ -16,23 +15,21 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" >
<vector xmlns:android="http://schemas.android.com/apk/res/android" >


    <size
    <size
        android:height="64dp"
            android:width="64dp"
        android:width="64dp" />
            android:height="64dp"/>


    <viewport
    <viewport android:viewportWidth="320"
        android:viewportHeight="320"
          android:viewportHeight="320"/>
        android:viewportWidth="320" />


    <path
    <path
            android:name="house"
            android:name="house"
        android:fill="#ff440000"
            android:pathData="M 130,225 L 130,115 L 130,115 L 70,15 L 10,115 L 10,115 L 10,225 z"
            android:pathData="M 130,225 L 130,115 L 130,115 L 70,15 L 10,115 L 10,115 L 10,225 z"
        android:pivotX="70"
            android:fill="#ff440000"
        android:pivotY="120"
        android:rotation="180"
            android:stroke="#FF00FF00"
            android:stroke="#FF00FF00"
            android:strokeWidth="10"
            android:strokeWidth="10"
        android:trimPathEnd=".9"
            android:rotation="180"
        android:trimPathStart=".1" />
            android:pivotX="70"

            android:pivotY="120"
            android:trimPathStart=".1"
            android:trimPathEnd=".9"/>
</vector>
</vector>
+48 −46
Original line number Original line Diff line number Diff line
<!--
<!-- Copyright (C) 2014 The Android Open Source Project
 Copyright (C) 2014 The Android Open Source Project


     Licensed under the Apache License, Version 2.0 (the "License");
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     you may not use this file except in compliance with the License.
@@ -16,46 +15,48 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" >
<vector xmlns:android="http://schemas.android.com/apk/res/android" >


    <size
    <size
        android:height="64dp"
            android:width="64dp"
        android:width="64dp" />
            android:height="64dp"/>


    <viewport
    <viewport
        android:viewportHeight="12.25"
            android:viewportWidth="7.30625"
        android:viewportWidth="7.30625" />
            android:viewportHeight="12.25"/>


    <path
    <path
            android:name="clip1"
            android:name="clip1"
        android:clipToPath="true"
            android:pathData="
            android:pathData="
            M 0, 0
            M 0, 0
            l 7.3, 0
            l 7.3, 0
            l 0, 0
            l 0, 0
            l -7.3, 0
            l -7.3, 0
            z"
            z"
            android:clipToPath="true"
            android:rotation="-30"
            android:pivotX="3.65"
            android:pivotX="3.65"
            android:pivotY="6.125"
            android:pivotY="6.125"
        android:rotation="-30" />
            />
    <path
    <path
            android:name="one"
            android:name="one"
        android:fill="#ff88ff"
            android:pathData="M 1.215625,9.5l 1.9375,0.0 0.0,-6.671875 -2.109375,0.421875 0.0,-1.078125
            android:pathData="M 1.215625,9.5l 1.9375,0.0 0.0,-6.671875 -2.109375,0.421875 0.0,-1.078125
            l 2.09375,-0.421875 1.1874998,0.0 0.0,7.75 1.9375,0.0 0.0,1.0
            l 2.09375,-0.421875 1.1874998,0.0 0.0,7.75 1.9375,0.0 0.0,1.0
                l -5.046875,0.0 0.0,-1.0Z" />
            l -5.046875,0.0 0.0,-1.0Z"
            android:fill="#ff88ff"
            />
    <path
    <path
            android:name="clip2"
            android:name="clip2"
        android:clipToPath="true"
            android:pathData="
            android:pathData="
            M 0, 0
            M 0, 0
            l 7.3, 0
            l 7.3, 0
            l 0, 12.25
            l 0, 12.25
            l -7.3, 0
            l -7.3, 0
            z"
            z"
            android:clipToPath="true"
            android:rotation="-30"
            android:pivotX="3.65"
            android:pivotX="3.65"
            android:pivotY="6.125"
            android:pivotY="6.125"
        android:rotation="-30" />
            />
    <path
    <path
            android:name="two"
            android:name="two"
        android:fill="#ff88ff"
            android:pathData="M 2.534375,9.6875l 4.140625,0.0 0.0,1.0 -5.5625,0.0 0.0,-1.0q 0.671875,-0.6875 1.828125,-1.859375
            android:pathData="M 2.534375,9.6875l 4.140625,0.0 0.0,1.0 -5.5625,0.0 0.0,-1.0q 0.671875,-0.6875 1.828125,-1.859375
                    q 1.1718752,-1.1875 1.4687502,-1.53125 0.578125,-0.625 0.796875,-1.0625
                    q 1.1718752,-1.1875 1.4687502,-1.53125 0.578125,-0.625 0.796875,-1.0625
                    q 0.234375,-0.453125 0.234375,-0.875 0.0,-0.703125 -0.5,-1.140625
                    q 0.234375,-0.453125 0.234375,-0.875 0.0,-0.703125 -0.5,-1.140625
@@ -64,6 +65,7 @@
                    q 0.625,-0.15625 1.140625,-0.15625 1.3593752,0.0 2.1718752,0.6875
                    q 0.625,-0.15625 1.140625,-0.15625 1.3593752,0.0 2.1718752,0.6875
                    q 0.8125,0.671875 0.8125,1.8125 0.0,0.53125 -0.203125,1.015625
                    q 0.8125,0.671875 0.8125,1.8125 0.0,0.53125 -0.203125,1.015625
                    q -0.203125,0.484375 -0.734375,1.140625 -0.15625,0.171875 -0.9375,0.984375
                    q -0.203125,0.484375 -0.734375,1.140625 -0.15625,0.171875 -0.9375,0.984375
                        q -0.78125024,0.8125 -2.2187502,2.265625Z" />
                    q -0.78125024,0.8125 -2.2187502,2.265625Z"

            android:fill="#ff88ff"
            />
</vector>
</vector>
+36 −31
Original line number Original line Diff line number Diff line
<!--
<!-- Copyright (C) 2014 The Android Open Source Project
 Copyright (C) 2014 The Android Open Source Project


     Licensed under the Apache License, Version 2.0 (the "License");
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     you may not use this file except in compliance with the License.
@@ -16,40 +15,44 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android">
<vector xmlns:android="http://schemas.android.com/apk/res/android">


    <size
    <size
        android:height="64dp"
            android:width="64dp"
        android:width="64dp" />
            android:height="64dp"/>


    <viewport
    <viewport
        android:viewportHeight="12.25"
            android:viewportWidth="7.30625"
        android:viewportWidth="7.30625" />
            android:viewportHeight="12.25"/>


    <group>
        <path
        <path
                android:name="clip1"
                android:name="clip1"
        android:clipToPath="true"
        android:fill="#112233"
                android:pathData="
                android:pathData="
                M 3.65, 6.125
                M 3.65, 6.125
                m -.001, 0
                m -.001, 0
                a .001,.001 0 1,0 .002,0
                a .001,.001 0 1,0 .002,0
                a .001,.001 0 1,0 -.002,0z" />
                a .001,.001 0 1,0 -.002,0z"
                android:clipToPath="true"
                android:fill="#112233"
                />

        <path
        <path
                android:name="one"
                android:name="one"
        android:fill="#ff88ff"
                android:pathData="M 1.215625,9.5l 1.9375,0.0 0.0,-6.671875 -2.109375,0.421875 0.0,-1.078125
                android:pathData="M 1.215625,9.5l 1.9375,0.0 0.0,-6.671875 -2.109375,0.421875 0.0,-1.078125
                l 2.09375,-0.421875 1.1874998,0.0 0.0,7.75 1.9375,0.0 0.0,1.0
                l 2.09375,-0.421875 1.1874998,0.0 0.0,7.75 1.9375,0.0 0.0,1.0
                l -5.046875,0.0 0.0,-1.0Z" />
                l -5.046875,0.0 0.0,-1.0Z"
                android:fill="#ff88ff"
                />
        <path
        <path
                android:name="clip2"
                android:name="clip2"
        android:clipToPath="true"
        android:fill="#112233"
                android:pathData="
                android:pathData="
                M 3.65, 6.125
                M 3.65, 6.125
                m -6, 0
                m -6, 0
                a 6,6 0 1,0 12,0
                a 6,6 0 1,0 12,0
                a 6,6 0 1,0 -12,0z" />
                a 6,6 0 1,0 -12,0z"
                android:clipToPath="true"
                android:fill="#112233"
                />
        <path
        <path
                android:name="two"
                android:name="two"
        android:fill="#ff88ff"
                android:pathData="M 2.534375,9.6875l 4.140625,0.0 0.0,1.0 -5.5625,0.0 0.0,-1.0q 0.671875,-0.6875 1.828125,-1.859375
                android:pathData="M 2.534375,9.6875l 4.140625,0.0 0.0,1.0 -5.5625,0.0 0.0,-1.0q 0.671875,-0.6875 1.828125,-1.859375
                        q 1.1718752,-1.1875 1.4687502,-1.53125 0.578125,-0.625 0.796875,-1.0625
                        q 1.1718752,-1.1875 1.4687502,-1.53125 0.578125,-0.625 0.796875,-1.0625
                        q 0.234375,-0.453125 0.234375,-0.875 0.0,-0.703125 -0.5,-1.140625
                        q 0.234375,-0.453125 0.234375,-0.875 0.0,-0.703125 -0.5,-1.140625
@@ -58,6 +61,8 @@
                        q 0.625,-0.15625 1.140625,-0.15625 1.3593752,0.0 2.1718752,0.6875
                        q 0.625,-0.15625 1.140625,-0.15625 1.3593752,0.0 2.1718752,0.6875
                        q 0.8125,0.671875 0.8125,1.8125 0.0,0.53125 -0.203125,1.015625
                        q 0.8125,0.671875 0.8125,1.8125 0.0,0.53125 -0.203125,1.015625
                        q -0.203125,0.484375 -0.734375,1.140625 -0.15625,0.171875 -0.9375,0.984375
                        q -0.203125,0.484375 -0.734375,1.140625 -0.15625,0.171875 -0.9375,0.984375
                        q -0.78125024,0.8125 -2.2187502,2.265625Z" />
                        q -0.78125024,0.8125 -2.2187502,2.265625Z"

                android:fill="#ff88ff"
                />
    </group>
</vector>
</vector>
Loading