From 55dde92782516da6e98b173701d20934ea3dd3c7 Mon Sep 17 00:00:00 2001 From: Evan Laird Date: Thu, 22 Jun 2017 14:01:31 -0400 Subject: [PATCH] Better merge fix for empty state signal drawable The cutout for drawing STATE_EMPTY picked up a fudge factor in the merge due to the rounded edges changing the size of the triangle. This change parameterizes the drawing of the cutout based on the placement of the rounded edges. Test: visual Bug: 62905681 Change-Id: Iba2bc0aa240f6bdfb285c2c6535b656bcacbd579 --- .../systemui/statusbar/phone/SignalDrawable.java | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SignalDrawable.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SignalDrawable.java index 394625049df9..deea521b7c2f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SignalDrawable.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SignalDrawable.java @@ -27,6 +27,7 @@ import android.graphics.Path; import android.graphics.Path.Direction; import android.graphics.Path.FillType; import android.graphics.Path.Op; +import android.graphics.PointF; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.drawable.Drawable; @@ -105,11 +106,10 @@ public class SignalDrawable extends Drawable { private final float mEmptyStrokeWidth; private static final float INV_TAN = 1f / (float) Math.tan(Math.PI / 8f); private final float mEmptyDiagInset; // == mEmptyStrokeWidth * INV_TAN - //TODO: This is needed because drawing the triangle is paramterized on the rounded edges. - // We get rounded corners by placing circles at arbitrary points along the legs of the triangle, - // but that means we lose the notion of a triangle being strictly half of its containing square. - // As a result, here's a value to tweak the insets of the cutout for the no-signal icon. - private final float mCutExtraOffset; + + // Where the top and left points of the triangle would be if not for rounding + private final PointF mVirtualTop = new PointF(); + private final PointF mVirtualLeft = new PointF(); private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); private final Paint mForegroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG); @@ -155,7 +155,6 @@ public class SignalDrawable extends Drawable { mAppliedCornerInset = context.getResources() .getDimensionPixelSize(R.dimen.stat_sys_mobile_signal_circle_inset); - mCutExtraOffset = mAppliedCornerInset / 2f; } public void setIntrinsicSize(int size) { @@ -319,14 +318,22 @@ public class SignalDrawable extends Drawable { } if (mState == STATE_EMPTY) { + // Where the corners would be if this were a real triangle + mVirtualTop.set( + width - padding, + (padding + cornerRadius + mAppliedCornerInset) - (INV_TAN * cornerRadius)); + mVirtualLeft.set( + (padding + cornerRadius + mAppliedCornerInset) - (INV_TAN * cornerRadius), + height - padding); + // Cut out a smaller triangle from the center of mFullPath mCutPath.reset(); mCutPath.setFillType(FillType.WINDING); mCutPath.moveTo(width - padding - mEmptyStrokeWidth, height - padding - mEmptyStrokeWidth); mCutPath.lineTo(width - padding - mEmptyStrokeWidth, - padding + mEmptyDiagInset - mCutExtraOffset); - mCutPath.lineTo(padding + mEmptyDiagInset - mCutExtraOffset, + mVirtualTop.y + mEmptyDiagInset); + mCutPath.lineTo(mVirtualLeft.x + mEmptyDiagInset, height - padding - mEmptyStrokeWidth); mCutPath.lineTo(width - padding - mEmptyStrokeWidth, height - padding - mEmptyStrokeWidth); -- 2.11.0