summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorztenghui <ztenghui@google.com>2014-03-31 15:55:35 -0700
committerztenghui <ztenghui@google.com>2014-04-02 11:28:32 -0700
commit177dffd869ff1f5bdf816faead01a7dc4980bf75 (patch)
tree78f539d2298a96fc3d28ea812907afcc6aea11b1
parent30cac644f161433fca92ca65edcb26b351a04e5a (diff)
downloadframeworks_base-177dffd869ff1f5bdf816faead01a7dc4980bf75.zip
frameworks_base-177dffd869ff1f5bdf816faead01a7dc4980bf75.tar.gz
frameworks_base-177dffd869ff1f5bdf816faead01a7dc4980bf75.tar.bz2
Getting the version information into the VectorDrawable
This will allow version controling for later API improvement. We will only support version 1 so far. Change-Id: I322e63f6cff157ebb6df5d80625c39bf96ff3659
-rw-r--r--core/res/res/values/attrs.xml1
-rw-r--r--graphics/java/android/graphics/drawable/VectorDrawable.java16
-rw-r--r--tests/DynamicDrawableTest/res/drawable/vector_drawable01.xml2
3 files changed, 16 insertions, 3 deletions
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index bd53e49..c225a7c 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -4555,6 +4555,7 @@
<enum name="state_activated" value="8" />
<enum name="state_window_focused" value="9" />
</attr>
+ <attr name="versionCode" />
</declare-styleable>
<!-- Define the virtual size of the drawing surface paths will draw to. -->
diff --git a/graphics/java/android/graphics/drawable/VectorDrawable.java b/graphics/java/android/graphics/drawable/VectorDrawable.java
index f3dd2fc..b2e7fda 100644
--- a/graphics/java/android/graphics/drawable/VectorDrawable.java
+++ b/graphics/java/android/graphics/drawable/VectorDrawable.java
@@ -60,9 +60,11 @@ import java.util.HashSet;
* The vector drawable has 6 elements:
* <p/>
* <dl>
- * <dt><code>&lt;vector></code></dt><dd>
- * The attribute <code>android:trigger</code> which defines a state change that
+ * <dt><code>&lt;vector></code></dt>
+ * <dd> * The attribute <code>android:trigger</code> defines a state change that
* will drive the animation </dd>
+ * <dd> * The attribute <code>android:versionCode</code> defines the version of
+ * VectorDrawable </dd>
* <dt><code>&lt;size></code></dt>
* <dd>Used to defined the intrinsic Width Height size of the drawable using
* <code>android:width</code> and <code>android:height</code> </dd>
@@ -494,6 +496,16 @@ public class VectorDrawable extends Drawable {
} else if (SHAPE_VECTOR.equals(tagName)) {
TypedArray a = res.obtainAttributes(attrs, R.styleable.VectorDrawable);
animatedPath.setTrigger(a.getInteger(R.styleable.VectorDrawable_trigger, 0));
+
+ // 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".
+ int versionCode = a.getInt(R.styleable.VectorDrawable_versionCode, 1);
+ if (versionCode != 1) {
+ throw new IllegalArgumentException(
+ "So far, VectorDrawable only support version 1");
+ }
+
a.recycle();
}
}
diff --git a/tests/DynamicDrawableTest/res/drawable/vector_drawable01.xml b/tests/DynamicDrawableTest/res/drawable/vector_drawable01.xml
index 4f4b386..538993f 100644
--- a/tests/DynamicDrawableTest/res/drawable/vector_drawable01.xml
+++ b/tests/DynamicDrawableTest/res/drawable/vector_drawable01.xml
@@ -14,7 +14,7 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:trigger="state_checked" >
+ android:trigger="state_checked" android:versionCode="1" >
<size
android:height="64dp"