From ddf2bab3ea00116aaa04fd28bb012b86c3265809 Mon Sep 17 00:00:00 2001 From: Teng-Hui Zhu Date: Mon, 7 Dec 2015 15:29:11 -0800 Subject: [PATCH] Add the vector drawable support lib demo code b/22564270 Change-Id: Id4f721cfd6e9450d8346410997ecfc1f2c3926c1 --- .gitignore | 3 + .../SupportVectorDrawable/animated/Android.mk | 38 +++++ .../animated/AndroidManifest.xml | 31 ++++ .../res/anim/alpha_animation_progress_bar.xml | 24 +++ .../res/anim/animation_grouping_1_01.xml | 22 +++ .../anim/trim_path_animation_progress_bar.xml | 45 ++++++ .../animation_vector_drawable_grouping_1.xml | 26 ++++ .../animation_vector_progress_bar.xml | 25 ++++ .../animated/res/drawable/app_sample_code.png | Bin 0 -> 3608 bytes .../drawable/vector_drawable_grouping_1.xml | 52 +++++++ .../drawable/vector_drawable_progress_bar.xml | 49 +++++++ .../animated/res/values/strings.xml | 28 ++++ .../SupportVectorDrawable/animated/rundemo.sh | 6 + .../app/AnimatedButtonBackground.java | 100 +++++++++++++ .../SupportVectorDrawable/static/Android.mk | 23 +++ .../static/AndroidManifest.xml | 32 ++++ .../static/res/drawable/app_sample_code.png | Bin 0 -> 3608 bytes .../static/res/drawable/vector_drawable01.xml | 29 ++++ .../static/res/drawable/vector_drawable02.xml | 32 ++++ .../static/res/drawable/vector_drawable03.xml | 79 ++++++++++ .../static/res/drawable/vector_drawable04.xml | 61 ++++++++ .../static/res/drawable/vector_drawable05.xml | 43 ++++++ .../static/res/drawable/vector_drawable06.xml | 48 ++++++ .../static/res/drawable/vector_drawable07.xml | 29 ++++ .../static/res/drawable/vector_drawable08.xml | 29 ++++ .../static/res/drawable/vector_drawable09.xml | 32 ++++ .../static/res/drawable/vector_drawable10.xml | 42 ++++++ .../static/res/drawable/vector_drawable11.xml | 35 +++++ .../static/res/drawable/vector_drawable12.xml | 97 +++++++++++++ .../static/res/drawable/vector_drawable13.xml | 37 +++++ .../static/res/drawable/vector_drawable14.xml | 38 +++++ .../static/res/drawable/vector_drawable15.xml | 34 +++++ .../static/res/drawable/vector_drawable16.xml | 47 ++++++ .../static/res/drawable/vector_drawable17.xml | 29 ++++ .../static/res/drawable/vector_drawable18.xml | 31 ++++ .../static/res/drawable/vector_drawable19.xml | 33 +++++ .../static/res/drawable/vector_drawable20.xml | 34 +++++ .../static/res/drawable/vector_drawable21.xml | 47 ++++++ .../static/res/drawable/vector_drawable22.xml | 68 +++++++++ .../static/res/drawable/vector_drawable23.xml | 82 +++++++++++ .../static/res/drawable/vector_drawable24.xml | 82 +++++++++++ .../static/res/drawable/vector_drawable25.xml | 82 +++++++++++ .../static/res/drawable/vector_drawable26.xml | 45 ++++++ .../static/res/drawable/vector_drawable27.xml | 45 ++++++ .../static/res/drawable/vector_drawable28.xml | 46 ++++++ .../static/res/drawable/vector_drawable29.xml | 28 ++++ .../static/res/drawable/vector_drawable30.xml | 28 ++++ .../res/drawable/vector_drawable_scale0.xml | 57 ++++++++ .../res/drawable/vector_drawable_scale1.xml | 52 +++++++ .../res/drawable/vector_drawable_scale2.xml | 48 ++++++ .../res/drawable/vector_drawable_scale3.xml | 62 ++++++++ .../static/res/drawable/vector_test01.xml | 31 ++++ .../static/res/drawable/vector_test02.xml | 31 ++++ .../static/res/raw/vector_drawable01.xml | 32 ++++ .../static/res/values/colors.xml | 20 +++ .../static/res/values/strings.xml | 29 ++++ .../SupportVectorDrawable/static/rundemo.sh | 6 + .../app/SimpleButtonBackground.java | 137 ++++++++++++++++++ 58 files changed, 2401 insertions(+) create mode 100644 samples/SupportVectorDrawable/animated/Android.mk create mode 100644 samples/SupportVectorDrawable/animated/AndroidManifest.xml create mode 100644 samples/SupportVectorDrawable/animated/res/anim/alpha_animation_progress_bar.xml create mode 100644 samples/SupportVectorDrawable/animated/res/anim/animation_grouping_1_01.xml create mode 100644 samples/SupportVectorDrawable/animated/res/anim/trim_path_animation_progress_bar.xml create mode 100644 samples/SupportVectorDrawable/animated/res/drawable/animation_vector_drawable_grouping_1.xml create mode 100644 samples/SupportVectorDrawable/animated/res/drawable/animation_vector_progress_bar.xml create mode 100755 samples/SupportVectorDrawable/animated/res/drawable/app_sample_code.png create mode 100644 samples/SupportVectorDrawable/animated/res/drawable/vector_drawable_grouping_1.xml create mode 100644 samples/SupportVectorDrawable/animated/res/drawable/vector_drawable_progress_bar.xml create mode 100644 samples/SupportVectorDrawable/animated/res/values/strings.xml create mode 100755 samples/SupportVectorDrawable/animated/rundemo.sh create mode 100644 samples/SupportVectorDrawable/animated/src/com/example/android/support/vectordrawable/app/AnimatedButtonBackground.java create mode 100644 samples/SupportVectorDrawable/static/Android.mk create mode 100644 samples/SupportVectorDrawable/static/AndroidManifest.xml create mode 100755 samples/SupportVectorDrawable/static/res/drawable/app_sample_code.png create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable01.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable02.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable03.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable04.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable05.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable06.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable07.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable08.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable09.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable10.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable11.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable12.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable13.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable14.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable15.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable16.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable17.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable18.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable19.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable20.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable21.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable22.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable23.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable24.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable25.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable26.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable27.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable28.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable29.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable30.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable_scale0.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable_scale1.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable_scale2.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_drawable_scale3.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_test01.xml create mode 100644 samples/SupportVectorDrawable/static/res/drawable/vector_test02.xml create mode 100644 samples/SupportVectorDrawable/static/res/raw/vector_drawable01.xml create mode 100644 samples/SupportVectorDrawable/static/res/values/colors.xml create mode 100644 samples/SupportVectorDrawable/static/res/values/strings.xml create mode 100755 samples/SupportVectorDrawable/static/rundemo.sh create mode 100644 samples/SupportVectorDrawable/static/src/com/example/android/support/vectordrawable/app/SimpleButtonBackground.java diff --git a/.gitignore b/.gitignore index 60483ff52..42494a2f4 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ *.pyc *.pyc-2.4 Thumbs.db +*.iml +.idea/ +gen/ diff --git a/samples/SupportVectorDrawable/animated/Android.mk b/samples/SupportVectorDrawable/animated/Android.mk new file mode 100644 index 000000000..6a4112b19 --- /dev/null +++ b/samples/SupportVectorDrawable/animated/Android.mk @@ -0,0 +1,38 @@ +# Copyright (C) 2015 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := tests + +LOCAL_SDK_VERSION := current + +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_PACKAGE_NAME := SupportAnimatedVectorDrawable + +LOCAL_STATIC_JAVA_LIBRARIES := android-support-v11-animatedvectordrawable android-support-v4 + +LOCAL_AAPT_FLAGS += --auto-add-overlay \ + --extra-packages android.support.graphics.drawable \ + --no-version-vectors + +include $(BUILD_PACKAGE) + +LOCAL_PROGUARD_FLAG_FILES := proguard.flags + +# Use the following include to make our test apk. +include $(call all-makefiles-under,$(LOCAL_PATH)) \ No newline at end of file diff --git a/samples/SupportVectorDrawable/animated/AndroidManifest.xml b/samples/SupportVectorDrawable/animated/AndroidManifest.xml new file mode 100644 index 000000000..1a5934b1b --- /dev/null +++ b/samples/SupportVectorDrawable/animated/AndroidManifest.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/animated/res/anim/alpha_animation_progress_bar.xml b/samples/SupportVectorDrawable/animated/res/anim/alpha_animation_progress_bar.xml new file mode 100644 index 000000000..2463a8940 --- /dev/null +++ b/samples/SupportVectorDrawable/animated/res/anim/alpha_animation_progress_bar.xml @@ -0,0 +1,24 @@ + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/animated/res/anim/animation_grouping_1_01.xml b/samples/SupportVectorDrawable/animated/res/anim/animation_grouping_1_01.xml new file mode 100644 index 000000000..36c297fbe --- /dev/null +++ b/samples/SupportVectorDrawable/animated/res/anim/animation_grouping_1_01.xml @@ -0,0 +1,22 @@ + + + + diff --git a/samples/SupportVectorDrawable/animated/res/anim/trim_path_animation_progress_bar.xml b/samples/SupportVectorDrawable/animated/res/anim/trim_path_animation_progress_bar.xml new file mode 100644 index 000000000..388c759a7 --- /dev/null +++ b/samples/SupportVectorDrawable/animated/res/anim/trim_path_animation_progress_bar.xml @@ -0,0 +1,45 @@ + + + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/animated/res/drawable/animation_vector_drawable_grouping_1.xml b/samples/SupportVectorDrawable/animated/res/drawable/animation_vector_drawable_grouping_1.xml new file mode 100644 index 000000000..dac981bc9 --- /dev/null +++ b/samples/SupportVectorDrawable/animated/res/drawable/animation_vector_drawable_grouping_1.xml @@ -0,0 +1,26 @@ + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/animated/res/drawable/animation_vector_progress_bar.xml b/samples/SupportVectorDrawable/animated/res/drawable/animation_vector_progress_bar.xml new file mode 100644 index 000000000..2944dc2bf --- /dev/null +++ b/samples/SupportVectorDrawable/animated/res/drawable/animation_vector_progress_bar.xml @@ -0,0 +1,25 @@ + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/animated/res/drawable/app_sample_code.png b/samples/SupportVectorDrawable/animated/res/drawable/app_sample_code.png new file mode 100755 index 0000000000000000000000000000000000000000..66a198496cfb3e77bffb2ca97007e30b2837106a GIT binary patch literal 3608 zcmV+z4(IWSP)>Yjs+!VGP=X>Hec-`Em6es-s;jFtd9cIbfR>gP zFdB^q@$jX-zVr9g)^3~Cop40VIQk#ix^=7O4QOs|hK7cQj_T@~7f_u|Isg&L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w~^M>)w8i$lo?LVVuUkiL^GPs!a_K9>>=<+X{gO=g%@A^1KYhRR>$tY%MR&hWop|36=_VPi` z{}yf1D|fk|xM*qmV1sJ|IFZ`=e7*($VzWU@ODnsU4dGZMrqBe5uMLf4HVlT9*~Nb3 z$PqYr@F1K!dlt@}JI8=H(%C85o^L$(Ae{WiN!Ia1FB_Yhvf5rw`HYx^35u?YSjn#u z$j!|~7IOzHsieBPhLx3*3?gAM6C^}d=d$@;U6z}SOVb2}L*Zbo!;=A^tx194{E9f? zwJ0I>?J0a99RP%L=gyw5tf~s27A#qSLu*|;V;-2AoCGz0Q{c-gl;ZY!JiSu+2r)at zBi|l(yWPJ{wEHm!%o1W)>Bk>`65l7L7x8lX^oMZi(xrF0y8ikfNcvXYxQUYZ1&zF% zoSdq!-+lO*qN1YC#LlNB8?<50;jptw3;O!rYy>oGNoWdm46Q_8U*G9B-gxbYpI*Fp z22W22B0-E40JJEF)`^ri+`gmP<#IJ5^QeeAXKsFe-Z(QoWi=S-mrV+sc+I-@zuPB0 z;dx;WNy<3(*SN`O3ZPF6$7X;rV03%Ep1#*!{pU$Mq^&*_h=fEJamoCK41tgr1%lRr zTM|qbecGbu>C+51)-N& + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/animated/res/drawable/vector_drawable_progress_bar.xml b/samples/SupportVectorDrawable/animated/res/drawable/vector_drawable_progress_bar.xml new file mode 100644 index 000000000..535265e52 --- /dev/null +++ b/samples/SupportVectorDrawable/animated/res/drawable/vector_drawable_progress_bar.xml @@ -0,0 +1,49 @@ + + + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/animated/res/values/strings.xml b/samples/SupportVectorDrawable/animated/res/values/strings.xml new file mode 100644 index 000000000..c5451c884 --- /dev/null +++ b/samples/SupportVectorDrawable/animated/res/values/strings.xml @@ -0,0 +1,28 @@ + + + + + + "M 0,0 v 100 M 0,0 h 100" + "M300,70 l 0,-70 70,70 0,0 -70,70z" + "M300,70 l 0,-70 70,0 0,140 -70,0 z" + "M300,70 l 0,-70 70,0 0,70z M300,70 l 70,0 0,70 -70,0z" + "M300,35 l 0,-35 70,0 0,35z M300,105 l 70,0 0,35 -70,0z" + "m2.10001,-6c-1.9551,0 -0.5,0.02499 -2.10001,0.02499c-1.575,0 0.0031,-0.02499 -1.95,-0.02499c-2.543,0 -4,2.2816 -4,4.85001c0,3.52929 0.25,6.25 5.95,6.25c5.7,0 6,-2.72071 6,-6.25c0,-2.56841 -1.35699,-4.85001 -3.89999,-4.85001" + "m4.5,-7c-1.95509,0 -3.83009,1.26759 -4.5,3c-0.66991,-1.73241 -2.54691,-3 -4.5,-3c-2.543,0 -4.5,1.93159 -4.5,4.5c0,3.5293 3.793,6.2578 9,11.5c5.207,-5.2422 9,-7.9707 9,-11.5c0,-2.56841 -1.957,-4.5 -4.5,-4.5" + "M 0,0 l 200,0 l 0, 200 l -200, 0 z" + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/animated/rundemo.sh b/samples/SupportVectorDrawable/animated/rundemo.sh new file mode 100755 index 000000000..e5972f759 --- /dev/null +++ b/samples/SupportVectorDrawable/animated/rundemo.sh @@ -0,0 +1,6 @@ +. $ANDROID_BUILD_TOP/build/envsetup.sh && \ +mmm -j20 . && \ +adb install -r $OUT/data/app/SupportAnimatedVectorDrawable/SupportAnimatedVectorDrawable.apk && \ +adb shell am start -n com.example.android.support.vectordrawable/com.example.android.support.vectordrawable.app.AnimatedButtonBackground + + diff --git a/samples/SupportVectorDrawable/animated/src/com/example/android/support/vectordrawable/app/AnimatedButtonBackground.java b/samples/SupportVectorDrawable/animated/src/com/example/android/support/vectordrawable/app/AnimatedButtonBackground.java new file mode 100644 index 000000000..e5cb76b71 --- /dev/null +++ b/samples/SupportVectorDrawable/animated/src/com/example/android/support/vectordrawable/app/AnimatedButtonBackground.java @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.android.support.vectordrawable.app; + +import android.animation.ObjectAnimator; +import android.app.Activity; +import android.content.res.Resources; +import android.os.Bundle; +import android.support.graphics.drawable.AnimatedVectorDrawableCompat; +import android.support.test.vectordrawable.R; +import android.view.View; +import android.widget.Button; +import android.widget.LinearLayout; +import android.widget.ScrollView; +import android.widget.TextView; + +import java.text.DecimalFormat; + +public class AnimatedButtonBackground extends Activity implements View.OnClickListener{ + private static final String LOG_TAG = "TestActivity"; + + private static final String LOGCAT = "VectorDrawable1"; + protected int[] icon = { + R.drawable.animation_vector_drawable_grouping_1, + R.drawable.animation_vector_progress_bar, + }; + + + @Override + protected void onCreate(Bundle savedInstanceState) { + ObjectAnimator oa = new ObjectAnimator(); + super.onCreate(savedInstanceState); + ScrollView scrollView = new ScrollView(this); + LinearLayout container = new LinearLayout(this); + scrollView.addView(container); + container.setOrientation(LinearLayout.VERTICAL); + Resources res = this.getResources(); + container.setBackgroundColor(0xFF888888); + AnimatedVectorDrawableCompat []d = new AnimatedVectorDrawableCompat[icon.length]; + long time = android.os.SystemClock.currentThreadTimeMillis(); + for (int i = 0; i < icon.length; i++) { + d[i] = AnimatedVectorDrawableCompat.create(this, icon[i]); + } + time = android.os.SystemClock.currentThreadTimeMillis()-time; + TextView t = new TextView(this); + DecimalFormat df = new DecimalFormat("#.##"); + t.setText("avgL=" + df.format(time / (icon.length)) + " ms"); + container.addView(t); + + addDrawableButtons(container, d); + + // Now test constant state and mutate a bit. + if (d[0].getConstantState() != null) { + AnimatedVectorDrawableCompat[] copies = new AnimatedVectorDrawableCompat[3]; + copies[0] = (AnimatedVectorDrawableCompat) d[0].getConstantState().newDrawable(); + copies[1] = (AnimatedVectorDrawableCompat) d[0].getConstantState().newDrawable(); + copies[2] = (AnimatedVectorDrawableCompat) d[0].getConstantState().newDrawable(); + copies[0].setAlpha(128); + + // Expect to see the copies[0, 1] are showing alpha 128, and [2] are showing 255. + copies[2].mutate(); + copies[2].setAlpha(255); + + addDrawableButtons(container, copies); + } + + setContentView(scrollView); + } + + private void addDrawableButtons(LinearLayout container, AnimatedVectorDrawableCompat[] d) { + for (int i = 0; i < d.length; i++) { + Button button = new Button(this); + button.setWidth(200); + button.setHeight(200); + button.setBackgroundDrawable(d[i]); + container.addView(button); + button.setOnClickListener(this); + } + } + + @Override + public void onClick(View v) { + AnimatedVectorDrawableCompat d = (AnimatedVectorDrawableCompat) v.getBackground(); + d.start(); + } +} diff --git a/samples/SupportVectorDrawable/static/Android.mk b/samples/SupportVectorDrawable/static/Android.mk new file mode 100644 index 000000000..437a0503f --- /dev/null +++ b/samples/SupportVectorDrawable/static/Android.mk @@ -0,0 +1,23 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := samples tests + +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_PACKAGE_NAME := SupportVectorDrawable + +LOCAL_STATIC_JAVA_LIBRARIES := android-support-v7-vectordrawable android-support-v4 + +LOCAL_SDK_VERSION := current + +LOCAL_AAPT_FLAGS += --auto-add-overlay \ + --extra-packages android.support.graphics.drawable \ + --no-version-vectors + +include $(BUILD_PACKAGE) + +LOCAL_PROGUARD_FLAG_FILES := proguard.flags + +# Use the following include to make our test apk. +include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/samples/SupportVectorDrawable/static/AndroidManifest.xml b/samples/SupportVectorDrawable/static/AndroidManifest.xml new file mode 100644 index 000000000..eecaab54b --- /dev/null +++ b/samples/SupportVectorDrawable/static/AndroidManifest.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + diff --git a/samples/SupportVectorDrawable/static/res/drawable/app_sample_code.png b/samples/SupportVectorDrawable/static/res/drawable/app_sample_code.png new file mode 100755 index 0000000000000000000000000000000000000000..66a198496cfb3e77bffb2ca97007e30b2837106a GIT binary patch literal 3608 zcmV+z4(IWSP)>Yjs+!VGP=X>Hec-`Em6es-s;jFtd9cIbfR>gP zFdB^q@$jX-zVr9g)^3~Cop40VIQk#ix^=7O4QOs|hK7cQj_T@~7f_u|Isg&LF_}z_ z>({T(N+b5{*#q_U_4hvd*tdUzAQ*3S6U4Q(cT_u_&N6hsS!+mBQxkoB&t!U{gXj6+ zD(x@MU@+9<=OnhV7t8DI9s7U!`fIQH)dawRjHkZ1xEQiIUvD;BVDH`*sI9HNmFHJ4 zGc7GG1!QmeV`F2jmoE>rA|OXQ@4f%P%P;+DSS;z=cC$ ze<&2vdv`ep->oB z%c41SdT{0P08C7b!)nybd`BKq>E<8p+t3xOi~vBHM-W!t-QfuE`8;s` z{3lSieLLFQ2FS_DS(REaK0dzJ=kx9D>FN3Y(@#Hr3`;kj=9K_IBW^qp2&@PTiV2y( zk&$a~vA-YM+uMLrBFU^`H3{XnNXp8}^18db|BL`Uisg?uhw`}(_QRn=UxSK@3U+QSEF`A39zJ~7+|||f{8LXoHI1F$B{!1AoUnkNeMLR+ z?CdP`UpNn~t*ywlT}&I+Qb8?%0|yS6olfU-Pd@qNCOPM9N)>cuTTuJp0(O2~eI0Ds zQVpv)DwY$MYXdYkHWdZt=YN5R_h1Pwn}#l!g6x)Xn1`!_gHT*l2z7OJzzaO`;qaO) z)b?9%yA>>E^TFfCk8hUJ0+W2_3(K^nkGn|r3?=b!IdkQ!Dh3 zWHxWd0}B>^8URSM4(j|1eV>5cVTZeLv=&Dxm|7$D%MyiC|CvoDFmPO-N*hWjj>oPqW8`D{V*{(0Y-xnM`MBHeHtNv{lf;O zEo~nl)u9w0Tpb!@xqFV?!)G;Kn4Fjdw|f*YMSSt)uynaJ3^Lqk^~&u)j3 z;t~WSKO6lIAtV;j?#bK<)A7{Q6sZ(t04ZaaRh6Ebn}d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wnh#Jp85d@#8Z=mwlAm9|f~&|5&6N|Hl2q&cQjrx!*-(L!5gPaa zN_sUm?S{Ai^`<0E9do-?qrFmfwe0(cGMj!3 z#I7Wq+XZ*EwX?s;JWxQDiR{_C7fTDcM@Qi=FTWID1V&O_Qv=(#Z&%X?%Q^vryaw<| z1tZI_z)&R>)v9#fdq3N6OVM#>=Y7!LzCV6#*RIBlw~^M>)w8i$lo?LVVuUkiL^GPs!a_K9>>=<+X{gO=g%@A^1KYhRR>$tY%MR&hWop|36=_VPi` z{}yf1D|fk|xM*qmV1sJ|IFZ`=e7*($VzWU@ODnsU4dGZMrqBe5uMLf4HVlT9*~Nb3 z$PqYr@F1K!dlt@}JI8=H(%C85o^L$(Ae{WiN!Ia1FB_Yhvf5rw`HYx^35u?YSjn#u z$j!|~7IOzHsieBPhLx3*3?gAM6C^}d=d$@;U6z}SOVb2}L*Zbo!;=A^tx194{E9f? zwJ0I>?J0a99RP%L=gyw5tf~s27A#qSLu*|;V;-2AoCGz0Q{c-gl;ZY!JiSu+2r)at zBi|l(yWPJ{wEHm!%o1W)>Bk>`65l7L7x8lX^oMZi(xrF0y8ikfNcvXYxQUYZ1&zF% zoSdq!-+lO*qN1YC#LlNB8?<50;jptw3;O!rYy>oGNoWdm46Q_8U*G9B-gxbYpI*Fp z22W22B0-E40JJEF)`^ri+`gmP<#IJ5^QeeAXKsFe-Z(QoWi=S-mrV+sc+I-@zuPB0 z;dx;WNy<3(*SN`O3ZPF6$7X;rV03%Ep1#*!{pU$Mq^&*_h=fEJamoCK41tgr1%lRr zTM|qbecGbu>C+51)-N& + + + + + + diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable02.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable02.xml new file mode 100644 index 000000000..7567887ef --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable02.xml @@ -0,0 +1,32 @@ + + + + + + diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable03.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable03.xml new file mode 100644 index 000000000..454468a9f --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable03.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable04.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable04.xml new file mode 100644 index 000000000..e6658a605 --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable04.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable05.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable05.xml new file mode 100644 index 000000000..d1723dc46 --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable05.xml @@ -0,0 +1,43 @@ + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable06.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable06.xml new file mode 100644 index 000000000..4b530fd48 --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable06.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable07.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable07.xml new file mode 100644 index 000000000..bbf245111 --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable07.xml @@ -0,0 +1,29 @@ + + + + + + + diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable08.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable08.xml new file mode 100644 index 000000000..e5b59df88 --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable08.xml @@ -0,0 +1,29 @@ + + + + + + + + diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable09.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable09.xml new file mode 100644 index 000000000..ce2441d2f --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable09.xml @@ -0,0 +1,32 @@ + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable10.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable10.xml new file mode 100644 index 000000000..935d4a5e7 --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable10.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable11.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable11.xml new file mode 100644 index 000000000..05f481b26 --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable11.xml @@ -0,0 +1,35 @@ + + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable12.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable12.xml new file mode 100644 index 000000000..94338a720 --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable12.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable13.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable13.xml new file mode 100644 index 000000000..097e0281f --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable13.xml @@ -0,0 +1,37 @@ + + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable14.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable14.xml new file mode 100644 index 000000000..102ae7ac6 --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable14.xml @@ -0,0 +1,38 @@ + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable15.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable15.xml new file mode 100644 index 000000000..bdfcf811f --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable15.xml @@ -0,0 +1,34 @@ + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable16.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable16.xml new file mode 100644 index 000000000..ed1efa018 --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable16.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable17.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable17.xml new file mode 100644 index 000000000..ba15f418c --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable17.xml @@ -0,0 +1,29 @@ + + + + + + + + diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable18.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable18.xml new file mode 100644 index 000000000..ee2122a7d --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable18.xml @@ -0,0 +1,31 @@ + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable19.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable19.xml new file mode 100644 index 000000000..b98e1ded2 --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable19.xml @@ -0,0 +1,33 @@ + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable20.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable20.xml new file mode 100644 index 000000000..1c8681869 --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable20.xml @@ -0,0 +1,34 @@ + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable21.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable21.xml new file mode 100644 index 000000000..247f6bc62 --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable21.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable22.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable22.xml new file mode 100644 index 000000000..39d891fee --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable22.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable23.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable23.xml new file mode 100644 index 000000000..4a1c062f1 --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable23.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable24.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable24.xml new file mode 100644 index 000000000..a7a8bd3d6 --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable24.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable25.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable25.xml new file mode 100644 index 000000000..7c9e7714a --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable25.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable26.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable26.xml new file mode 100644 index 000000000..eda06d85e --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable26.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable27.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable27.xml new file mode 100644 index 000000000..cd46dd9a7 --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable27.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable28.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable28.xml new file mode 100644 index 000000000..812af6ba4 --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable28.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable29.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable29.xml new file mode 100644 index 000000000..b24d31cc2 --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable29.xml @@ -0,0 +1,28 @@ + + + + + + + diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable30.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable30.xml new file mode 100644 index 000000000..24f737248 --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable30.xml @@ -0,0 +1,28 @@ + + + + + + + diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable_scale0.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable_scale0.xml new file mode 100644 index 000000000..828f0d96f --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable_scale0.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable_scale1.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable_scale1.xml new file mode 100644 index 000000000..530c73b20 --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable_scale1.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable_scale2.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable_scale2.xml new file mode 100644 index 000000000..200eb617a --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable_scale2.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable_scale3.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable_scale3.xml new file mode 100644 index 000000000..a40fc9c21 --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable_scale3.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_test01.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_test01.xml new file mode 100644 index 000000000..8b891d646 --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_test01.xml @@ -0,0 +1,31 @@ + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_test02.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_test02.xml new file mode 100644 index 000000000..e0af3236b --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_test02.xml @@ -0,0 +1,31 @@ + + + + + + + + \ No newline at end of file diff --git a/samples/SupportVectorDrawable/static/res/raw/vector_drawable01.xml b/samples/SupportVectorDrawable/static/res/raw/vector_drawable01.xml new file mode 100644 index 000000000..baa3fc716 --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/raw/vector_drawable01.xml @@ -0,0 +1,32 @@ + + + + + + + diff --git a/samples/SupportVectorDrawable/static/res/values/colors.xml b/samples/SupportVectorDrawable/static/res/values/colors.xml new file mode 100644 index 000000000..6eb303649 --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/values/colors.xml @@ -0,0 +1,20 @@ + + + #a6e4ea + #ff3838 + #ffff51 + #0ed300 + diff --git a/samples/SupportVectorDrawable/static/res/values/strings.xml b/samples/SupportVectorDrawable/static/res/values/strings.xml new file mode 100644 index 000000000..065e7d934 --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/values/strings.xml @@ -0,0 +1,29 @@ + + + + + + "M 0,0 v 100 M 0,0 h 100" + "M300,70 l 0,-70 70,70 0,0 -70,70z" + "M300,70 l 0,-70 70,0 0,140 -70,0 z" + "M300,70 l 0,-70 70,0 0,70z M300,70 l 70,0 0,70 -70,0z" + "M300,35 l 0,-35 70,0 0,35z M300,105 l 70,0 0,35 -70,0z" + "m2.10001,-6c-1.9551,0 -0.5,0.02499 -2.10001,0.02499c-1.575,0 0.0031,-0.02499 -1.95,-0.02499c-2.543,0 -4,2.2816 -4,4.85001c0,3.52929 0.25,6.25 5.95,6.25c5.7,0 6,-2.72071 6,-6.25c0,-2.56841 -1.35699,-4.85001 -3.89999,-4.85001" + "m4.5,-7c-1.95509,0 -3.83009,1.26759 -4.5,3c-0.66991,-1.73241 -2.54691,-3 -4.5,-3c-2.543,0 -4.5,1.93159 -4.5,4.5c0,3.5293 3.793,6.2578 9,11.5c5.207,-5.2422 9,-7.9707 9,-11.5c0,-2.56841 -1.957,-4.5 -4.5,-4.5" + "M 0,0 l 200,0 l 0, 200 l -200, 0 z" + "M 100, 0 l 0, 100, -100, 0 z" + diff --git a/samples/SupportVectorDrawable/static/rundemo.sh b/samples/SupportVectorDrawable/static/rundemo.sh new file mode 100755 index 000000000..2695b53f6 --- /dev/null +++ b/samples/SupportVectorDrawable/static/rundemo.sh @@ -0,0 +1,6 @@ +. $ANDROID_BUILD_TOP/build/envsetup.sh && \ +mmm -j20 . && \ +adb install -r $OUT/data/app/SupportVectorDrawable/SupportVectorDrawable.apk && \ +adb shell am start -n com.example.android.support.vectordrawable/com.example.android.support.vectordrawable.app.SimpleButtonBackground + + diff --git a/samples/SupportVectorDrawable/static/src/com/example/android/support/vectordrawable/app/SimpleButtonBackground.java b/samples/SupportVectorDrawable/static/src/com/example/android/support/vectordrawable/app/SimpleButtonBackground.java new file mode 100644 index 000000000..c5961fb92 --- /dev/null +++ b/samples/SupportVectorDrawable/static/src/com/example/android/support/vectordrawable/app/SimpleButtonBackground.java @@ -0,0 +1,137 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.android.support.vectordrawable.app; + +import android.app.Activity; +import android.content.res.Resources; +import android.graphics.PorterDuff.Mode; +import android.graphics.drawable.Drawable.ConstantState; +import android.os.Bundle; +import android.support.graphics.drawable.VectorDrawableCompat; +import android.support.test.vectordrawable.R; +import android.widget.Button; +import android.widget.LinearLayout; +import android.widget.ScrollView; +import android.widget.TextView; + +import java.text.DecimalFormat; + +public class SimpleButtonBackground extends Activity { + private static final String LOG_TAG = "SimpleButtonBackground"; + + private static final String LOGCAT = "VectorDrawable1"; + protected int[] icon = { + R.drawable.vector_drawable_scale0, + R.drawable.vector_drawable_scale1, + R.drawable.vector_drawable_scale2, + R.drawable.vector_drawable_scale3, + R.drawable.vector_drawable01, + R.drawable.vector_drawable02, + R.drawable.vector_drawable03, + R.drawable.vector_drawable04, + R.drawable.vector_drawable05, + R.drawable.vector_drawable06, + R.drawable.vector_drawable07, + R.drawable.vector_drawable08, + R.drawable.vector_drawable09, + R.drawable.vector_drawable10, + R.drawable.vector_drawable11, + R.drawable.vector_drawable12, + R.drawable.vector_drawable13, + R.drawable.vector_drawable14, + R.drawable.vector_drawable15, + R.drawable.vector_drawable16, + R.drawable.vector_drawable17, + R.drawable.vector_drawable18, + R.drawable.vector_drawable19, + R.drawable.vector_drawable20, + R.drawable.vector_drawable21, + R.drawable.vector_drawable22, + R.drawable.vector_drawable23, + R.drawable.vector_drawable24, + R.drawable.vector_drawable25, + R.drawable.vector_drawable26, + R.drawable.vector_drawable27, + R.drawable.vector_drawable28, + R.drawable.vector_drawable29, + R.drawable.vector_drawable30, + R.drawable.vector_test01, + R.drawable.vector_test02 + }; + + private static final int EXTRA_TESTS = 2; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + ScrollView scrollView = new ScrollView(this); + LinearLayout container = new LinearLayout(this); + scrollView.addView(container); + container.setOrientation(LinearLayout.VERTICAL); + Resources res = this.getResources(); + container.setBackgroundColor(0xFF888888); + VectorDrawableCompat []d = new VectorDrawableCompat[icon.length]; + long time = android.os.SystemClock.currentThreadTimeMillis(); + for (int i = 0; i < icon.length; i++) { + d[i] = VectorDrawableCompat.create(res, icon[i], getTheme()); + } + time = android.os.SystemClock.currentThreadTimeMillis()-time; + + // Testing Tint on one particular case. + if (d.length > 3) { + d[3].setTint(0x8000FF00); + d[3].setTintMode(Mode.MULTIPLY); + } + + // Testing Constant State like operation by creating the first 2 icons + // from the 3rd one's constant state. + VectorDrawableCompat []extras = new VectorDrawableCompat[EXTRA_TESTS]; + ConstantState state = d[0].getConstantState(); + extras[0] = (VectorDrawableCompat) state.newDrawable(); + extras[1] = (VectorDrawableCompat) state.newDrawable(); + + // This alpha change is expected to affect both extra 0, 1, and d0. + extras[0].setAlpha(128); + + d[0].mutate(); + d[0].setAlpha(255); + + // Just show the average create time as the first view. + TextView t = new TextView(this); + DecimalFormat df = new DecimalFormat("#.##"); + t.setText("avgL=" + df.format(time / (icon.length)) + " ms"); + container.addView(t); + + addDrawableButtons(container, extras); + + addDrawableButtons(container, d); + + setContentView(scrollView); + } + + private void addDrawableButtons(LinearLayout container, VectorDrawableCompat[] d) { + // Add the VD into consequent views. + for (int i = 0; i < d.length; i++) { + Button button = new Button(this); + button.setWidth(200); + // Note that setBackgroundResource() will fail b/c createFromXmlInner() failed + // to recognize pre-L. + button.setBackgroundDrawable(d[i]); + container.addView(button); + } + } +}