diff --git a/api/current.txt b/api/current.txt index bb8bc16035b63..4dbe887c114fe 100644 --- a/api/current.txt +++ b/api/current.txt @@ -588,6 +588,7 @@ package android { field public static final int fastScrollThumbDrawable = 16843574; // 0x1010336 field public static final int fastScrollTrackDrawable = 16843577; // 0x1010339 field public static final int fillAfter = 16843197; // 0x10101bd + field public static final int fillAlpha = 16843981; // 0x10104cd field public static final int fillBefore = 16843196; // 0x10101bc field public static final int fillColor = 16843806; // 0x101041e field public static final int fillEnabled = 16843343; // 0x101024f @@ -1203,6 +1204,7 @@ package android { field public static final int streamType = 16843273; // 0x1010209 field public static final int stretchColumns = 16843081; // 0x1010149 field public static final int stretchMode = 16843030; // 0x1010116 + field public static final int strokeAlpha = 16843980; // 0x10104cc field public static final int strokeColor = 16843808; // 0x1010420 field public static final int strokeLineCap = 16843813; // 0x1010425 field public static final int strokeLineJoin = 16843814; // 0x1010426 diff --git a/core/res/res/drawable/ic_corp_icon_badge.xml b/core/res/res/drawable/ic_corp_icon_badge.xml index 834ae68f57df4..0021a8f1d9f70 100644 --- a/core/res/res/drawable/ic_corp_icon_badge.xml +++ b/core/res/res/drawable/ic_corp_icon_badge.xml @@ -20,11 +20,13 @@ Copyright (C) 2014 The Android Open Source Project android:viewportHeight="64.0"> + android:fillColor="#FF000000" + android:pathData="M49.062,50.0m-14.0,0.0a14.0,14.0 0.0,1.0 1.0,28.0 0.0a14.0,14.0 0.0,1.0 1.0,-28.0 0.0" + android:fillAlpha="0.2"/> + android:fillColor="#FF000000" + android:pathData="M49.0,49.5m-14.0,0.0a14.0,14.0 0.0,1.0 1.0,28.0 0.0a14.0,14.0 0.0,1.0 1.0,-28.0 0.0" + android:fillAlpha="0.2"/> diff --git a/core/res/res/drawable/vector_drawable_progress_indeterminate_horizontal.xml b/core/res/res/drawable/vector_drawable_progress_indeterminate_horizontal.xml index 7ceb7722c8976..cd999d5d26d46 100644 --- a/core/res/res/drawable/vector_drawable_progress_indeterminate_horizontal.xml +++ b/core/res/res/drawable/vector_drawable_progress_indeterminate_horizontal.xml @@ -26,11 +26,11 @@ android:translateY="5" > + android:name="rectangle_path_1_position"> - - @@ -5298,8 +5296,14 @@ + + + + diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 8bb3cdf1de3bc..38b1e130377df 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -2291,6 +2291,8 @@ + + diff --git a/graphics/java/android/graphics/drawable/VectorDrawable.java b/graphics/java/android/graphics/drawable/VectorDrawable.java index 65ab4543bc054..4407a3cfd98cc 100644 --- a/graphics/java/android/graphics/drawable/VectorDrawable.java +++ b/graphics/java/android/graphics/drawable/VectorDrawable.java @@ -104,8 +104,6 @@ import java.util.Stack; *
android:translateY
*
The amount of translation on the Y coordinate. * This is defined in the viewport space.
- *
android:alpha
- *
The amount of transparency.
* * * @@ -124,6 +122,10 @@ import java.util.Stack; *
Defines the color to draw the path outline (none if not present).
*
android:strokeWidth
*
The width a path stroke.
+ *
android:strokeAlpha
+ *
The opacity of a path stroke.
+ *
android:fillAlpha
+ *
The opacity to fill the path with.
*
android:trimPathStart
*
The fraction of the path to trim from the start, in the range from 0 to 1.
*
android:trimPathEnd
@@ -825,7 +827,7 @@ public class VectorDrawable extends Drawable { } private void drawGroupTree(VGroup currentGroup, Matrix currentMatrix, - float currentAlpha, Canvas canvas, int w, int h) { + Canvas canvas, int w, int h) { // Calculate current group's matrix by preConcat the parent's and // and the current one on the top of the stack. // Basically the Mfinal = Mviewport * M0 * M1 * M2; @@ -834,30 +836,26 @@ public class VectorDrawable extends Drawable { currentGroup.mStackedMatrix.preConcat(currentGroup.mLocalMatrix); - float stackedAlpha = currentAlpha * currentGroup.mGroupAlpha; - // Draw the group tree in the same order as the XML file. for (int i = 0; i < currentGroup.mChildren.size(); i++) { Object child = currentGroup.mChildren.get(i); if (child instanceof VGroup) { VGroup childGroup = (VGroup) child; drawGroupTree(childGroup, currentGroup.mStackedMatrix, - stackedAlpha, canvas, w, h); + canvas, w, h); } else if (child instanceof VPath) { VPath childPath = (VPath) child; - drawPath(currentGroup, childPath, stackedAlpha, canvas, w, h); + drawPath(currentGroup, childPath, canvas, w, h); } } } public void draw(Canvas canvas, int w, int h) { // Travese the tree in pre-order to draw. - drawGroupTree(mRootGroup, IDENTITY_MATRIX, ((float) mRootAlpha) / 0xFF, - canvas, w, h); + drawGroupTree(mRootGroup, IDENTITY_MATRIX, canvas, w, h); } - private void drawPath(VGroup vGroup, VPath vPath, float stackedAlpha, - Canvas canvas, int w, int h) { + private void drawPath(VGroup vGroup, VPath vPath, Canvas canvas, int w, int h) { final float scaleX = w / mViewportWidth; final float scaleY = h / mViewportHeight; final float minScale = Math.min(scaleX, scaleY); @@ -905,7 +903,8 @@ public class VectorDrawable extends Drawable { mFillPaint.setStyle(Paint.Style.FILL); mFillPaint.setAntiAlias(true); } - mFillPaint.setColor(applyAlpha(fullPath.mFillColor, stackedAlpha)); + mFillPaint.setColor(applyAlpha(fullPath.mFillColor, + fullPath.mFillAlpha)); canvas.drawPath(mRenderPath, mFillPaint); } @@ -928,7 +927,8 @@ public class VectorDrawable extends Drawable { strokePaint.setStrokeMiter(fullPath.mStrokeMiterlimit); - strokePaint.setColor(applyAlpha(fullPath.mStrokeColor, stackedAlpha)); + strokePaint.setColor(applyAlpha(fullPath.mStrokeColor, + fullPath.mStrokeAlpha)); strokePaint.setStrokeWidth(fullPath.mStrokeWidth * minScale); canvas.drawPath(mRenderPath, strokePaint); } @@ -952,7 +952,6 @@ public class VectorDrawable extends Drawable { private float mScaleY = 1; private float mTranslateX = 0; private float mTranslateY = 0; - private float mGroupAlpha = 1; // mLocalMatrix is updated based on the update of transformation information, // either parsed from the XML or by animation. @@ -969,7 +968,6 @@ public class VectorDrawable extends Drawable { mScaleY = copy.mScaleY; mTranslateX = copy.mTranslateX; mTranslateY = copy.mTranslateY; - mGroupAlpha = copy.mGroupAlpha; mThemeAttrs = copy.mThemeAttrs; mGroupName = copy.mGroupName; mChangingConfigurations = copy.mChangingConfigurations; @@ -1038,7 +1036,6 @@ public class VectorDrawable extends Drawable { mScaleY = a.getFloat(R.styleable.VectorDrawableGroup_scaleY, mScaleY); mTranslateX = a.getFloat(R.styleable.VectorDrawableGroup_translateX, mTranslateX); mTranslateY = a.getFloat(R.styleable.VectorDrawableGroup_translateY, mTranslateY); - mGroupAlpha = a.getFloat(R.styleable.VectorDrawableGroup_alpha, mGroupAlpha); final String groupName = a.getString(R.styleable.VectorDrawableGroup_name); if (groupName != null) { @@ -1160,18 +1157,6 @@ public class VectorDrawable extends Drawable { updateLocalMatrix(); } } - - @SuppressWarnings("unused") - public float getAlpha() { - return mGroupAlpha; - } - - @SuppressWarnings("unused") - public void setAlpha(float groupAlpha) { - if (groupAlpha != mGroupAlpha) { - mGroupAlpha = groupAlpha; - } - } } /** @@ -1275,8 +1260,11 @@ public class VectorDrawable extends Drawable { int mStrokeColor = Color.TRANSPARENT; float mStrokeWidth = 0; + int mFillColor = Color.TRANSPARENT; + float mStrokeAlpha = 1.0f; int mFillRule; + float mFillAlpha = 1.0f; float mTrimPathStart = 0; float mTrimPathEnd = 1; float mTrimPathOffset = 0; @@ -1295,8 +1283,10 @@ public class VectorDrawable extends Drawable { mStrokeColor = copy.mStrokeColor; mStrokeWidth = copy.mStrokeWidth; + mStrokeAlpha = copy.mStrokeAlpha; mFillColor = copy.mFillColor; mFillRule = copy.mFillRule; + mFillAlpha = copy.mFillAlpha; mTrimPathStart = copy.mTrimPathStart; mTrimPathEnd = copy.mTrimPathEnd; mTrimPathOffset = copy.mTrimPathOffset; @@ -1357,6 +1347,8 @@ public class VectorDrawable extends Drawable { mFillColor = a.getColor(R.styleable.VectorDrawablePath_fillColor, mFillColor); + mFillAlpha = a.getFloat(R.styleable.VectorDrawablePath_fillAlpha, + mFillAlpha); mStrokeLineCap = getStrokeLineCap(a.getInt( R.styleable.VectorDrawablePath_strokeLineCap, -1), mStrokeLineCap); mStrokeLineJoin = getStrokeLineJoin(a.getInt( @@ -1365,6 +1357,8 @@ public class VectorDrawable extends Drawable { R.styleable.VectorDrawablePath_strokeMiterLimit, mStrokeMiterlimit); mStrokeColor = a.getColor(R.styleable.VectorDrawablePath_strokeColor, mStrokeColor); + mStrokeAlpha = a.getFloat(R.styleable.VectorDrawablePath_strokeAlpha, + mStrokeAlpha); mStrokeWidth = a.getFloat(R.styleable.VectorDrawablePath_strokeWidth, mStrokeWidth); mTrimPathEnd = a.getFloat(R.styleable.VectorDrawablePath_trimPathEnd, @@ -1408,6 +1402,16 @@ public class VectorDrawable extends Drawable { mStrokeWidth = strokeWidth; } + @SuppressWarnings("unused") + float getstrokeAlpha() { + return mStrokeAlpha; + } + + @SuppressWarnings("unused") + void setstrokeAlpha(float strokeAlpha) { + mStrokeAlpha = strokeAlpha; + } + @SuppressWarnings("unused") int getFill() { return mFillColor; @@ -1418,6 +1422,16 @@ public class VectorDrawable extends Drawable { mFillColor = fillColor; } + @SuppressWarnings("unused") + float getfillAlpha() { + return mFillAlpha; + } + + @SuppressWarnings("unused") + void setfillAlpha(float fillAlpha) { + mFillAlpha = fillAlpha; + } + @SuppressWarnings("unused") float getTrimPathStart() { return mTrimPathStart; diff --git a/tests/VectorDrawableTest/res/drawable/vector_drawable05.xml b/tests/VectorDrawableTest/res/drawable/vector_drawable05.xml index bbf1a17d35b1a..f94ecba1ffb87 100644 --- a/tests/VectorDrawableTest/res/drawable/vector_drawable05.xml +++ b/tests/VectorDrawableTest/res/drawable/vector_drawable05.xml @@ -28,7 +28,8 @@ l-5.046875,0.0 0.0-1.0Z" />