diff options
author | ztenghui <ztenghui@google.com> | 2014-06-27 12:06:48 -0700 |
---|---|---|
committer | ztenghui <ztenghui@google.com> | 2014-06-30 12:43:52 -0700 |
commit | 9cb5b4c2d93acb9d6f5e14167e265c328c487d6b (patch) | |
tree | 4c070cc42cdc6c4a438f4e870d00293429ed5533 | |
parent | 66d3d8a09eb6a0238e3c189d8c3d598dc62dc0ab (diff) | |
download | frameworks_base-9cb5b4c2d93acb9d6f5e14167e265c328c487d6b.zip frameworks_base-9cb5b4c2d93acb9d6f5e14167e265c328c487d6b.tar.gz frameworks_base-9cb5b4c2d93acb9d6f5e14167e265c328c487d6b.tar.bz2 |
Use AnimatedVectorDrawable for progress bar.
Change-Id: I419197ef38a611757f27ca3192350ad4bd403875
13 files changed, 245 insertions, 23 deletions
diff --git a/core/res/res/anim/progress_indeterminate_material.xml b/core/res/res/anim/progress_indeterminate_material.xml new file mode 100644 index 0000000..98555e8 --- /dev/null +++ b/core/res/res/anim/progress_indeterminate_material.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2014 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. +--> + +<set xmlns:android="http://schemas.android.com/apk/res/android" > + + <objectAnimator + android:duration="1333" + android:interpolator="@interpolator/trim_start_interpolator" + android:propertyName="trimPathStart" + android:repeatCount="-1" + android:valueFrom="0" + android:valueTo="0.75" + android:valueType="floatType" /> + <objectAnimator + android:duration="1333" + android:interpolator="@interpolator/trim_end_interpolator" + android:propertyName="trimPathEnd" + android:repeatCount="-1" + android:valueFrom="0" + android:valueTo="0.75" + android:valueType="floatType" /> + <objectAnimator + android:duration="1333" + android:interpolator="@android:anim/linear_interpolator" + android:propertyName="trimPathOffset" + android:repeatCount="-1" + android:valueFrom="0" + android:valueTo="0.25" + android:valueType="floatType" /> + +</set>
\ No newline at end of file diff --git a/core/res/res/drawable/progress_large_material.xml b/core/res/res/drawable/progress_large_material.xml index 965b288..341d2a9 100644 --- a/core/res/res/drawable/progress_large_material.xml +++ b/core/res/res/drawable/progress_large_material.xml @@ -14,9 +14,11 @@ limitations under the License. --> -<material-progress xmlns:android="http://schemas.android.com/apk/res/android" - android:color="?attr/colorControlActivated" - android:width="76dp" - android:height="76dp" - android:thickness="6.3dp" - android:innerRadius="30.1dp" /> +<animated-vector xmlns:android="http://schemas.android.com/apk/res/android" + android:drawable="@drawable/vector_drawable_progress_bar_large" > + + <target + android:name="progressBar" + android:animation="@anim/progress_indeterminate_material" /> + +</animated-vector> diff --git a/core/res/res/drawable/progress_medium_material.xml b/core/res/res/drawable/progress_medium_material.xml index c656026..1f2622c 100644 --- a/core/res/res/drawable/progress_medium_material.xml +++ b/core/res/res/drawable/progress_medium_material.xml @@ -13,10 +13,11 @@ See the License for the specific language governing permissions and limitations under the License. --> +<animated-vector xmlns:android="http://schemas.android.com/apk/res/android" + android:drawable="@drawable/vector_drawable_progress_bar_medium" > -<material-progress xmlns:android="http://schemas.android.com/apk/res/android" - android:color="?attr/colorControlActivated" - android:width="48dp" - android:height="48dp" - android:thickness="4dp" - android:innerRadius="19dp" /> + <target + android:name="progressBar" + android:animation="@anim/progress_indeterminate_material" /> + +</animated-vector>
\ No newline at end of file diff --git a/core/res/res/drawable/progress_small_material.xml b/core/res/res/drawable/progress_small_material.xml index 67ae268..43bc569 100644 --- a/core/res/res/drawable/progress_small_material.xml +++ b/core/res/res/drawable/progress_small_material.xml @@ -14,9 +14,11 @@ limitations under the License. --> -<material-progress xmlns:android="http://schemas.android.com/apk/res/android" - android:color="?attr/colorControlActivated" - android:width="16dp" - android:height="16dp" - android:thickness="1.3dp" - android:innerRadius="6.3dp" /> +<animated-vector xmlns:android="http://schemas.android.com/apk/res/android" + android:drawable="@drawable/vector_drawable_progress_bar_small" > + + <target + android:name="progressBar" + android:animation="@anim/progress_indeterminate_material" /> + +</animated-vector> diff --git a/core/res/res/drawable/vector_drawable_progress_bar_large.xml b/core/res/res/drawable/vector_drawable_progress_bar_large.xml new file mode 100644 index 0000000..b1900cb --- /dev/null +++ b/core/res/res/drawable/vector_drawable_progress_bar_large.xml @@ -0,0 +1,45 @@ +<!-- + Copyright (C) 2014 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. +--> +<vector xmlns:android="http://schemas.android.com/apk/res/android" > + + <size + android:height="76dp" + android:width="76dp" /> + + <viewport + android:viewportHeight="48" + android:viewportWidth="48" /> + + <group + android:name="root" + android:scaleX="1.0" + android:scaleY="1.0" + android:translateX="24.0" + android:translateY="24.0" > + <path + android:name="progressBar" + android:fill="#00000000" + android:pathData="M0, 0 m 0, -19 a 19,19 0 1,1 0,38 a 19,19 0 1,1 0,-38" + android:stroke="?attr/colorControlActivated" + android:strokeLineCap="round" + android:strokeLineJoin="miter" + android:strokeWidth="4" + android:trimPathEnd="0" + android:trimPathOffset="0" + android:trimPathStart="0" /> + </group> + +</vector>
\ No newline at end of file diff --git a/core/res/res/drawable/vector_drawable_progress_bar_medium.xml b/core/res/res/drawable/vector_drawable_progress_bar_medium.xml new file mode 100644 index 0000000..57a6163 --- /dev/null +++ b/core/res/res/drawable/vector_drawable_progress_bar_medium.xml @@ -0,0 +1,45 @@ +<!-- + Copyright (C) 2014 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. +--> +<vector xmlns:android="http://schemas.android.com/apk/res/android" > + + <size + android:height="48dp" + android:width="48dp" /> + + <viewport + android:viewportHeight="48" + android:viewportWidth="48" /> + + <group + android:name="root" + android:scaleX="1.0" + android:scaleY="1.0" + android:translateX="24.0" + android:translateY="24.0" > + <path + android:name="progressBar" + android:fill="#00000000" + android:pathData="M0, 0 m 0, -19 a 19,19 0 1,1 0,38 a 19,19 0 1,1 0,-38" + android:stroke="?attr/colorControlActivated" + android:strokeLineCap="round" + android:strokeLineJoin="miter" + android:strokeWidth="4" + android:trimPathEnd="0" + android:trimPathOffset="0" + android:trimPathStart="0" /> + </group> + +</vector>
\ No newline at end of file diff --git a/core/res/res/drawable/vector_drawable_progress_bar_small.xml b/core/res/res/drawable/vector_drawable_progress_bar_small.xml new file mode 100644 index 0000000..ea949b7 --- /dev/null +++ b/core/res/res/drawable/vector_drawable_progress_bar_small.xml @@ -0,0 +1,45 @@ +<!-- + Copyright (C) 2014 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. +--> +<vector xmlns:android="http://schemas.android.com/apk/res/android" > + + <size + android:height="16dp" + android:width="16dp" /> + + <viewport + android:viewportHeight="48" + android:viewportWidth="48" /> + + <group + android:name="root" + android:scaleX="1.0" + android:scaleY="1.0" + android:translateX="24.0" + android:translateY="24.0" > + <path + android:name="progressBar" + android:fill="#00000000" + android:pathData="M0, 0 m 0, -19 a 19,19 0 1,1 0,38 a 19,19 0 1,1 0,-38" + android:stroke="?attr/colorControlActivated" + android:strokeLineCap="round" + android:strokeLineJoin="miter" + android:strokeWidth="4" + android:trimPathEnd="0" + android:trimPathOffset="0" + android:trimPathStart="0" /> + </group> + +</vector>
\ No newline at end of file diff --git a/core/res/res/interpolator/trim_end_interpolator.xml b/core/res/res/interpolator/trim_end_interpolator.xml new file mode 100644 index 0000000..bfaa8e2 --- /dev/null +++ b/core/res/res/interpolator/trim_end_interpolator.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2014 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. +--> +<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android" + android:pathData="C0.2,0 0.1,1 0.5, 1 L 1,1" />
\ No newline at end of file diff --git a/core/res/res/interpolator/trim_start_interpolator.xml b/core/res/res/interpolator/trim_start_interpolator.xml new file mode 100644 index 0000000..14ea90d --- /dev/null +++ b/core/res/res/interpolator/trim_start_interpolator.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2014 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. +--> +<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android" + android:pathData="L0.5,0 C 0.7,0 0.6,1 1, 1" />
\ No newline at end of file diff --git a/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java b/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java index c787fb0..8560685 100644 --- a/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java +++ b/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java @@ -208,7 +208,7 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable { R.styleable.AnimatedVectorDrawable_drawable, 0); if (drawableRes != 0) { mAnimatedVectorState.mVectorDrawable = (VectorDrawable) res.getDrawable( - drawableRes); + drawableRes, theme); } a.recycle(); } else if (TARGET.equals(tagName)) { @@ -234,7 +234,8 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable { @Override public boolean canApplyTheme() { return super.canApplyTheme() || mAnimatedVectorState != null - && mAnimatedVectorState.canApplyTheme(); + && mAnimatedVectorState.mVectorDrawable != null + && mAnimatedVectorState.mVectorDrawable.canApplyTheme(); } @Override diff --git a/graphics/java/android/graphics/drawable/VectorDrawable.java b/graphics/java/android/graphics/drawable/VectorDrawable.java index c98f2a1..b37204d 100644 --- a/graphics/java/android/graphics/drawable/VectorDrawable.java +++ b/graphics/java/android/graphics/drawable/VectorDrawable.java @@ -166,7 +166,7 @@ public class VectorDrawable extends Drawable { @Override public ConstantState getConstantState() { - return mVectorState; + return null; } @Override diff --git a/tests/VectorDrawableTest/res/anim/trim_path_animation_progress_bar.xml b/tests/VectorDrawableTest/res/anim/trim_path_animation_progress_bar.xml index f510256..c9fd676 100644 --- a/tests/VectorDrawableTest/res/anim/trim_path_animation_progress_bar.xml +++ b/tests/VectorDrawableTest/res/anim/trim_path_animation_progress_bar.xml @@ -39,7 +39,7 @@ android:propertyName="trimPathOffset" android:repeatCount="-1" android:valueFrom="0" - android:valueTo="1.25" + android:valueTo="0.25" android:valueType="floatType" /> </set>
\ No newline at end of file diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable_progress_bar.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable_progress_bar.xml index 956c600..f1b2996 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_drawable_progress_bar.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_drawable_progress_bar.xml @@ -39,7 +39,7 @@ android:name="pie1" android:fill="#00000000" android:pathData="M0, 0 m 0, -9.5 a 9.5,9.5 0 1,1 0,19 a 9.5,9.5 0 1,1 0,-19" - android:stroke="#89cff0" + android:stroke="?android:attr/colorControlActivated" android:strokeLineCap="round" android:strokeLineJoin="miter" android:strokeWidth="2" |