diff options
Diffstat (limited to 'graphics')
3 files changed, 45 insertions, 0 deletions
diff --git a/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java b/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java index b8f64a4..d0535e7 100644 --- a/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java +++ b/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java @@ -25,6 +25,7 @@ import android.content.res.Resources.Theme; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.ColorFilter; +import android.graphics.Insets; import android.graphics.Outline; import android.graphics.PorterDuff; import android.graphics.Rect; @@ -271,6 +272,12 @@ public class AnimatedVectorDrawable extends Drawable implements Animatable { mAnimatedVectorState.mVectorDrawable.getOutline(outline); } + /** @hide */ + @Override + public Insets getOpticalInsets() { + return mAnimatedVectorState.mVectorDrawable.getOpticalInsets(); + } + @Override public void inflate(Resources res, XmlPullParser parser, AttributeSet attrs, Theme theme) throws XmlPullParserException, IOException { diff --git a/graphics/java/android/graphics/drawable/GradientDrawable.java b/graphics/java/android/graphics/drawable/GradientDrawable.java index 4c2817c..ed47eed 100644 --- a/graphics/java/android/graphics/drawable/GradientDrawable.java +++ b/graphics/java/android/graphics/drawable/GradientDrawable.java @@ -25,6 +25,7 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.ColorFilter; import android.graphics.DashPathEffect; +import android.graphics.Insets; import android.graphics.LinearGradient; import android.graphics.Outline; import android.graphics.Paint; @@ -1107,6 +1108,16 @@ public class GradientDrawable extends Drawable { if (tint != null) { state.mTint = tint; } + + final int insetLeft = a.getDimensionPixelSize( + R.styleable.GradientDrawable_opticalInsetLeft, state.mOpticalInsets.left); + final int insetTop = a.getDimensionPixelSize( + R.styleable.GradientDrawable_opticalInsetTop, state.mOpticalInsets.top); + final int insetRight = a.getDimensionPixelSize( + R.styleable.GradientDrawable_opticalInsetRight, state.mOpticalInsets.right); + final int insetBottom = a.getDimensionPixelSize( + R.styleable.GradientDrawable_opticalInsetBottom, state.mOpticalInsets.bottom); + state.mOpticalInsets = Insets.of(insetLeft, insetTop, insetRight, insetBottom); } @Override @@ -1469,6 +1480,12 @@ public class GradientDrawable extends Drawable { return mGradientState.mHeight; } + /** @hide */ + @Override + public Insets getOpticalInsets() { + return mGradientState.mOpticalInsets; + } + @Override public ConstantState getConstantState() { mGradientState.mChangingConfigurations = getChangingConfigurations(); @@ -1573,6 +1590,7 @@ public class GradientDrawable extends Drawable { public int mInnerRadius = -1; public int mThickness = -1; public boolean mDither = false; + public Insets mOpticalInsets = Insets.NONE; float mCenterX = 0.5f; float mCenterY = 0.5f; @@ -1631,6 +1649,7 @@ public class GradientDrawable extends Drawable { mInnerRadius = state.mInnerRadius; mThickness = state.mThickness; mDither = state.mDither; + mOpticalInsets = state.mOpticalInsets; mCenterX = state.mCenterX; mCenterY = state.mCenterY; mGradientRadius = state.mGradientRadius; diff --git a/graphics/java/android/graphics/drawable/VectorDrawable.java b/graphics/java/android/graphics/drawable/VectorDrawable.java index f4df14e..b9f3f2a 100644 --- a/graphics/java/android/graphics/drawable/VectorDrawable.java +++ b/graphics/java/android/graphics/drawable/VectorDrawable.java @@ -23,6 +23,7 @@ import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.ColorFilter; +import android.graphics.Insets; import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.Path; @@ -361,6 +362,12 @@ public class VectorDrawable extends Drawable { return (int) mVectorState.mVPathRenderer.mBaseHeight; } + /** @hide */ + @Override + public Insets getOpticalInsets() { + return mVectorState.mVPathRenderer.mOpticalInsets; + } + @Override public boolean canApplyTheme() { return (mVectorState != null && mVectorState.canApplyTheme()) || super.canApplyTheme(); @@ -524,6 +531,16 @@ public class VectorDrawable extends Drawable { "<vector> tag requires height > 0"); } + final int insetLeft = a.getDimensionPixelSize( + R.styleable.VectorDrawable_opticalInsetLeft, pathRenderer.mOpticalInsets.left); + final int insetTop = a.getDimensionPixelSize( + R.styleable.VectorDrawable_opticalInsetTop, pathRenderer.mOpticalInsets.top); + final int insetRight = a.getDimensionPixelSize( + R.styleable.VectorDrawable_opticalInsetRight, pathRenderer.mOpticalInsets.right); + final int insetBottom = a.getDimensionPixelSize( + R.styleable.VectorDrawable_opticalInsetBottom, pathRenderer.mOpticalInsets.bottom); + pathRenderer.mOpticalInsets = Insets.of(insetLeft, insetTop, insetRight, insetBottom); + final float alphaInFloat = a.getFloat(R.styleable.VectorDrawable_alpha, pathRenderer.getAlpha()); pathRenderer.setAlpha(alphaInFloat); @@ -821,6 +838,7 @@ public class VectorDrawable extends Drawable { float mBaseHeight = 0; float mViewportWidth = 0; float mViewportHeight = 0; + Insets mOpticalInsets = Insets.NONE; int mRootAlpha = 0xFF; String mRootName = null; @@ -859,6 +877,7 @@ public class VectorDrawable extends Drawable { mBaseHeight = copy.mBaseHeight; mViewportWidth = copy.mViewportWidth; mViewportHeight = copy.mViewportHeight; + mOpticalInsets = copy.mOpticalInsets; mChangingConfigurations = copy.mChangingConfigurations; mRootAlpha = copy.mRootAlpha; mRootName = copy.mRootName; |