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 000000000..66a198496 Binary files /dev/null and b/samples/SupportVectorDrawable/animated/res/drawable/app_sample_code.png differ diff --git a/samples/SupportVectorDrawable/animated/res/drawable/vector_drawable_grouping_1.xml b/samples/SupportVectorDrawable/animated/res/drawable/vector_drawable_grouping_1.xml new file mode 100644 index 000000000..06f098e3d --- /dev/null +++ b/samples/SupportVectorDrawable/animated/res/drawable/vector_drawable_grouping_1.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + \ 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 000000000..66a198496 Binary files /dev/null and b/samples/SupportVectorDrawable/static/res/drawable/app_sample_code.png differ diff --git a/samples/SupportVectorDrawable/static/res/drawable/vector_drawable01.xml b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable01.xml new file mode 100644 index 000000000..286b4879c --- /dev/null +++ b/samples/SupportVectorDrawable/static/res/drawable/vector_drawable01.xml @@ -0,0 +1,29 @@ + + + + + + + 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); + } + } +}