Loading api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -14013,6 +14013,8 @@ package android.graphics.drawable.shapes { public class ArcShape extends android.graphics.drawable.shapes.RectShape { ctor public ArcShape(float, float); method public final float getStartAngle(); method public final float getSweepAngle(); } public class OvalShape extends android.graphics.drawable.shapes.RectShape { api/system-current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -14649,6 +14649,8 @@ package android.graphics.drawable.shapes { public class ArcShape extends android.graphics.drawable.shapes.RectShape { ctor public ArcShape(float, float); method public final float getStartAngle(); method public final float getSweepAngle(); } public class OvalShape extends android.graphics.drawable.shapes.RectShape { api/test-current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -14051,6 +14051,8 @@ package android.graphics.drawable.shapes { public class ArcShape extends android.graphics.drawable.shapes.RectShape { ctor public ArcShape(float, float); method public final float getStartAngle(); method public final float getSweepAngle(); } public class OvalShape extends android.graphics.drawable.shapes.RectShape { graphics/java/android/graphics/drawable/ShapeDrawable.java +57 −49 Original line number Diff line number Diff line Loading @@ -16,9 +16,11 @@ package android.graphics.drawable; import android.annotation.NonNull; import android.content.pm.ActivityInfo.Config; import android.content.res.ColorStateList; import android.content.res.Resources; import android.content.res.Resources.Theme; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.ColorFilter; Loading @@ -31,10 +33,10 @@ import android.graphics.PorterDuffColorFilter; import android.graphics.Rect; import android.graphics.Shader; import android.graphics.drawable.shapes.Shape; import android.content.res.Resources.Theme; import android.util.AttributeSet; import com.android.internal.R; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; Loading Loading @@ -69,7 +71,7 @@ import java.io.IOException; * @attr ref android.R.styleable#ShapeDrawable_height */ public class ShapeDrawable extends Drawable { private ShapeState mShapeState; private @NonNull ShapeState mShapeState; private PorterDuffColorFilter mTintFilter; private boolean mMutated; Loading @@ -77,7 +79,7 @@ public class ShapeDrawable extends Drawable { * ShapeDrawable constructor. */ public ShapeDrawable() { this(new ShapeState(null), null); this(new ShapeState(), null); } /** Loading @@ -86,7 +88,7 @@ public class ShapeDrawable extends Drawable { * @param s the Shape that this ShapeDrawable should be */ public ShapeDrawable(Shape s) { this(new ShapeState(null), null); this(new ShapeState(), null); mShapeState.mShape = s; } Loading Loading @@ -402,7 +404,7 @@ public class ShapeDrawable extends Drawable { } // Update local properties. updateLocalState(r); updateLocalState(); } @Override Loading @@ -426,7 +428,7 @@ public class ShapeDrawable extends Drawable { } // Update local properties. updateLocalState(t.getResources()); updateLocalState(); } private void updateStateFromTypedArray(TypedArray a) { Loading @@ -447,10 +449,10 @@ public class ShapeDrawable extends Drawable { dither = a.getBoolean(R.styleable.ShapeDrawable_dither, dither); paint.setDither(dither); setIntrinsicWidth((int) a.getDimension( R.styleable.ShapeDrawable_width, state.mIntrinsicWidth)); setIntrinsicHeight((int) a.getDimension( R.styleable.ShapeDrawable_height, state.mIntrinsicHeight)); state.mIntrinsicWidth = (int) a.getDimension( R.styleable.ShapeDrawable_width, state.mIntrinsicWidth); state.mIntrinsicHeight = (int) a.getDimension( R.styleable.ShapeDrawable_height, state.mIntrinsicHeight); final int tintMode = a.getInt(R.styleable.ShapeDrawable_tintMode, -1); if (tintMode != -1) { Loading Loading @@ -494,21 +496,8 @@ public class ShapeDrawable extends Drawable { @Override public Drawable mutate() { if (!mMutated && super.mutate() == this) { if (mShapeState.mPaint != null) { mShapeState.mPaint = new Paint(mShapeState.mPaint); } else { mShapeState.mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); } if (mShapeState.mPadding != null) { mShapeState.mPadding = new Rect(mShapeState.mPadding); } else { mShapeState.mPadding = new Rect(); } try { mShapeState.mShape = mShapeState.mShape.clone(); } catch (CloneNotSupportedException e) { return null; } mShapeState = new ShapeState(mShapeState); updateLocalState(); mMutated = true; } return this; Loading @@ -525,12 +514,13 @@ public class ShapeDrawable extends Drawable { /** * Defines the intrinsic properties of this ShapeDrawable's Shape. */ final static class ShapeState extends ConstantState { int[] mThemeAttrs; static final class ShapeState extends ConstantState { final @NonNull Paint mPaint; @Config int mChangingConfigurations; Paint mPaint; int[] mThemeAttrs; Shape mShape; ColorStateList mTint = null; ColorStateList mTint; Mode mTintMode = DEFAULT_TINT_MODE; Rect mPadding; int mIntrinsicWidth; Loading @@ -538,21 +528,43 @@ public class ShapeDrawable extends Drawable { int mAlpha = 255; ShaderFactory mShaderFactory; ShapeState(ShapeState orig) { if (orig != null) { /** * Constructs a new ShapeState. */ ShapeState() { mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); } /** * Constructs a new ShapeState that contains a deep copy of the * specified ShapeState. * * @param orig the state to create a deep copy of */ ShapeState(@NonNull ShapeState orig) { mChangingConfigurations = orig.mChangingConfigurations; mPaint = new Paint(orig.mPaint); mThemeAttrs = orig.mThemeAttrs; mPaint = orig.mPaint; if (mShape != null) { try { mShape = orig.mShape.clone(); } catch (CloneNotSupportedException e) { // Well, at least we tried. mShape = orig.mShape; } } mTint = orig.mTint; mTintMode = orig.mTintMode; mPadding = orig.mPadding; if (orig.mPadding != null) { mPadding = new Rect(orig.mPadding); } mIntrinsicWidth = orig.mIntrinsicWidth; mIntrinsicHeight = orig.mIntrinsicHeight; mAlpha = orig.mAlpha; // We don't have any way to clone a shader factory, so hopefully // this class doesn't contain any local state. mShaderFactory = orig.mShaderFactory; } else { mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); } } @Override Loading Loading @@ -585,7 +597,7 @@ public class ShapeDrawable extends Drawable { private ShapeDrawable(ShapeState state, Resources res) { mShapeState = state; updateLocalState(res); updateLocalState(); } /** Loading @@ -593,7 +605,7 @@ public class ShapeDrawable extends Drawable { * after significant state changes, e.g. from the One True Constructor and * after inflating or applying a theme. */ private void updateLocalState(Resources res) { private void updateLocalState() { mTintFilter = updateTintFilter(mTintFilter, mShapeState.mTint, mShapeState.mTintMode); } Loading @@ -617,8 +629,4 @@ public class ShapeDrawable extends Drawable { */ public abstract Shader resize(int width, int height); } // other subclass could wack the Shader's localmatrix based on the // resize params (e.g. scaletofit, etc.). This could be used to scale // a bitmap to fill the bounds without needing any other special casing. } graphics/java/android/graphics/drawable/shapes/ArcShape.java +36 −15 Original line number Diff line number Diff line Loading @@ -21,15 +21,17 @@ import android.graphics.Outline; import android.graphics.Paint; /** * Creates an arc shape. The arc shape starts at a specified * angle and sweeps clockwise, drawing slices of pie. * The arc can be drawn to a Canvas with its own draw() method, * but more graphical control is available if you instead pass * the ArcShape to a {@link android.graphics.drawable.ShapeDrawable}. * Creates an arc shape. The arc shape starts at a specified angle and sweeps * clockwise, drawing slices of pie. * <p> * The arc can be drawn to a {@link Canvas} with its own * {@link #draw(Canvas, Paint)} method, but more graphical control is available * if you instead pass the ArcShape to a * {@link android.graphics.drawable.ShapeDrawable}. */ public class ArcShape extends RectShape { private float mStart; private float mSweep; private final float mStartAngle; private final float mSweepAngle; /** * ArcShape constructor. Loading @@ -39,13 +41,27 @@ public class ArcShape extends RectShape { * greater than 360 results in a complete circle/oval. */ public ArcShape(float startAngle, float sweepAngle) { mStart = startAngle; mSweep = sweepAngle; mStartAngle = startAngle; mSweepAngle = sweepAngle; } /** * @return the angle (in degrees) where the arc begins */ public final float getStartAngle() { return mStartAngle; } /** * @return the sweep angle (in degrees) */ public final float getSweepAngle() { return mSweepAngle; } @Override public void draw(Canvas canvas, Paint paint) { canvas.drawArc(rect(), mStart, mSweep, true, paint); canvas.drawArc(rect(), mStartAngle, mSweepAngle, true, paint); } @Override Loading @@ -53,5 +69,10 @@ public class ArcShape extends RectShape { // Since we don't support concave outlines, arc shape does not attempt // to provide an outline. } @Override public ArcShape clone() throws CloneNotSupportedException { return (ArcShape) super.clone(); } } Loading
api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -14013,6 +14013,8 @@ package android.graphics.drawable.shapes { public class ArcShape extends android.graphics.drawable.shapes.RectShape { ctor public ArcShape(float, float); method public final float getStartAngle(); method public final float getSweepAngle(); } public class OvalShape extends android.graphics.drawable.shapes.RectShape {
api/system-current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -14649,6 +14649,8 @@ package android.graphics.drawable.shapes { public class ArcShape extends android.graphics.drawable.shapes.RectShape { ctor public ArcShape(float, float); method public final float getStartAngle(); method public final float getSweepAngle(); } public class OvalShape extends android.graphics.drawable.shapes.RectShape {
api/test-current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -14051,6 +14051,8 @@ package android.graphics.drawable.shapes { public class ArcShape extends android.graphics.drawable.shapes.RectShape { ctor public ArcShape(float, float); method public final float getStartAngle(); method public final float getSweepAngle(); } public class OvalShape extends android.graphics.drawable.shapes.RectShape {
graphics/java/android/graphics/drawable/ShapeDrawable.java +57 −49 Original line number Diff line number Diff line Loading @@ -16,9 +16,11 @@ package android.graphics.drawable; import android.annotation.NonNull; import android.content.pm.ActivityInfo.Config; import android.content.res.ColorStateList; import android.content.res.Resources; import android.content.res.Resources.Theme; import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.ColorFilter; Loading @@ -31,10 +33,10 @@ import android.graphics.PorterDuffColorFilter; import android.graphics.Rect; import android.graphics.Shader; import android.graphics.drawable.shapes.Shape; import android.content.res.Resources.Theme; import android.util.AttributeSet; import com.android.internal.R; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; Loading Loading @@ -69,7 +71,7 @@ import java.io.IOException; * @attr ref android.R.styleable#ShapeDrawable_height */ public class ShapeDrawable extends Drawable { private ShapeState mShapeState; private @NonNull ShapeState mShapeState; private PorterDuffColorFilter mTintFilter; private boolean mMutated; Loading @@ -77,7 +79,7 @@ public class ShapeDrawable extends Drawable { * ShapeDrawable constructor. */ public ShapeDrawable() { this(new ShapeState(null), null); this(new ShapeState(), null); } /** Loading @@ -86,7 +88,7 @@ public class ShapeDrawable extends Drawable { * @param s the Shape that this ShapeDrawable should be */ public ShapeDrawable(Shape s) { this(new ShapeState(null), null); this(new ShapeState(), null); mShapeState.mShape = s; } Loading Loading @@ -402,7 +404,7 @@ public class ShapeDrawable extends Drawable { } // Update local properties. updateLocalState(r); updateLocalState(); } @Override Loading @@ -426,7 +428,7 @@ public class ShapeDrawable extends Drawable { } // Update local properties. updateLocalState(t.getResources()); updateLocalState(); } private void updateStateFromTypedArray(TypedArray a) { Loading @@ -447,10 +449,10 @@ public class ShapeDrawable extends Drawable { dither = a.getBoolean(R.styleable.ShapeDrawable_dither, dither); paint.setDither(dither); setIntrinsicWidth((int) a.getDimension( R.styleable.ShapeDrawable_width, state.mIntrinsicWidth)); setIntrinsicHeight((int) a.getDimension( R.styleable.ShapeDrawable_height, state.mIntrinsicHeight)); state.mIntrinsicWidth = (int) a.getDimension( R.styleable.ShapeDrawable_width, state.mIntrinsicWidth); state.mIntrinsicHeight = (int) a.getDimension( R.styleable.ShapeDrawable_height, state.mIntrinsicHeight); final int tintMode = a.getInt(R.styleable.ShapeDrawable_tintMode, -1); if (tintMode != -1) { Loading Loading @@ -494,21 +496,8 @@ public class ShapeDrawable extends Drawable { @Override public Drawable mutate() { if (!mMutated && super.mutate() == this) { if (mShapeState.mPaint != null) { mShapeState.mPaint = new Paint(mShapeState.mPaint); } else { mShapeState.mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); } if (mShapeState.mPadding != null) { mShapeState.mPadding = new Rect(mShapeState.mPadding); } else { mShapeState.mPadding = new Rect(); } try { mShapeState.mShape = mShapeState.mShape.clone(); } catch (CloneNotSupportedException e) { return null; } mShapeState = new ShapeState(mShapeState); updateLocalState(); mMutated = true; } return this; Loading @@ -525,12 +514,13 @@ public class ShapeDrawable extends Drawable { /** * Defines the intrinsic properties of this ShapeDrawable's Shape. */ final static class ShapeState extends ConstantState { int[] mThemeAttrs; static final class ShapeState extends ConstantState { final @NonNull Paint mPaint; @Config int mChangingConfigurations; Paint mPaint; int[] mThemeAttrs; Shape mShape; ColorStateList mTint = null; ColorStateList mTint; Mode mTintMode = DEFAULT_TINT_MODE; Rect mPadding; int mIntrinsicWidth; Loading @@ -538,21 +528,43 @@ public class ShapeDrawable extends Drawable { int mAlpha = 255; ShaderFactory mShaderFactory; ShapeState(ShapeState orig) { if (orig != null) { /** * Constructs a new ShapeState. */ ShapeState() { mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); } /** * Constructs a new ShapeState that contains a deep copy of the * specified ShapeState. * * @param orig the state to create a deep copy of */ ShapeState(@NonNull ShapeState orig) { mChangingConfigurations = orig.mChangingConfigurations; mPaint = new Paint(orig.mPaint); mThemeAttrs = orig.mThemeAttrs; mPaint = orig.mPaint; if (mShape != null) { try { mShape = orig.mShape.clone(); } catch (CloneNotSupportedException e) { // Well, at least we tried. mShape = orig.mShape; } } mTint = orig.mTint; mTintMode = orig.mTintMode; mPadding = orig.mPadding; if (orig.mPadding != null) { mPadding = new Rect(orig.mPadding); } mIntrinsicWidth = orig.mIntrinsicWidth; mIntrinsicHeight = orig.mIntrinsicHeight; mAlpha = orig.mAlpha; // We don't have any way to clone a shader factory, so hopefully // this class doesn't contain any local state. mShaderFactory = orig.mShaderFactory; } else { mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); } } @Override Loading Loading @@ -585,7 +597,7 @@ public class ShapeDrawable extends Drawable { private ShapeDrawable(ShapeState state, Resources res) { mShapeState = state; updateLocalState(res); updateLocalState(); } /** Loading @@ -593,7 +605,7 @@ public class ShapeDrawable extends Drawable { * after significant state changes, e.g. from the One True Constructor and * after inflating or applying a theme. */ private void updateLocalState(Resources res) { private void updateLocalState() { mTintFilter = updateTintFilter(mTintFilter, mShapeState.mTint, mShapeState.mTintMode); } Loading @@ -617,8 +629,4 @@ public class ShapeDrawable extends Drawable { */ public abstract Shader resize(int width, int height); } // other subclass could wack the Shader's localmatrix based on the // resize params (e.g. scaletofit, etc.). This could be used to scale // a bitmap to fill the bounds without needing any other special casing. }
graphics/java/android/graphics/drawable/shapes/ArcShape.java +36 −15 Original line number Diff line number Diff line Loading @@ -21,15 +21,17 @@ import android.graphics.Outline; import android.graphics.Paint; /** * Creates an arc shape. The arc shape starts at a specified * angle and sweeps clockwise, drawing slices of pie. * The arc can be drawn to a Canvas with its own draw() method, * but more graphical control is available if you instead pass * the ArcShape to a {@link android.graphics.drawable.ShapeDrawable}. * Creates an arc shape. The arc shape starts at a specified angle and sweeps * clockwise, drawing slices of pie. * <p> * The arc can be drawn to a {@link Canvas} with its own * {@link #draw(Canvas, Paint)} method, but more graphical control is available * if you instead pass the ArcShape to a * {@link android.graphics.drawable.ShapeDrawable}. */ public class ArcShape extends RectShape { private float mStart; private float mSweep; private final float mStartAngle; private final float mSweepAngle; /** * ArcShape constructor. Loading @@ -39,13 +41,27 @@ public class ArcShape extends RectShape { * greater than 360 results in a complete circle/oval. */ public ArcShape(float startAngle, float sweepAngle) { mStart = startAngle; mSweep = sweepAngle; mStartAngle = startAngle; mSweepAngle = sweepAngle; } /** * @return the angle (in degrees) where the arc begins */ public final float getStartAngle() { return mStartAngle; } /** * @return the sweep angle (in degrees) */ public final float getSweepAngle() { return mSweepAngle; } @Override public void draw(Canvas canvas, Paint paint) { canvas.drawArc(rect(), mStart, mSweep, true, paint); canvas.drawArc(rect(), mStartAngle, mSweepAngle, true, paint); } @Override Loading @@ -53,5 +69,10 @@ public class ArcShape extends RectShape { // Since we don't support concave outlines, arc shape does not attempt // to provide an outline. } @Override public ArcShape clone() throws CloneNotSupportedException { return (ArcShape) super.clone(); } }