Loading packages/SystemUI/res/values/dimens.xml +3 −0 Original line number Diff line number Diff line Loading @@ -815,4 +815,7 @@ <dimen name="qs_gutter_height">6dp</dimen> <!-- Intended corner radius when drawing the mobile signal --> <dimen name="stat_sys_mobile_signal_corner_radius">0.75dp</dimen> </resources> packages/SystemUI/src/com/android/systemui/statusbar/phone/SignalDrawable.java +55 −6 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Handler; import android.util.LayoutDirection; import android.util.Log; import com.android.settingslib.R; import com.android.settingslib.Utils; Loading Loading @@ -82,6 +81,22 @@ public class SignalDrawable extends Drawable { {-1.9f / VIEWPORT, -1.9f / VIEWPORT}, }; // Rounded corners are achieved by arcing a circle of radius `mCornerRadius` from its tangent // points along the curve. On the top and left corners of the triangle, the tangents are as // follows: // 1) Along the straight lines (y = 0 and x = width): // Ps = R / tan(45) // 2) Along the diagonal line (y = x): // Pd = √((Ps^2) / 2) // // I.e., the points where we stop the straight lines lie at (starting drawing from the bottom- // right corner and counter-clockwise): (width, height - Radius), (width, Ps), (width - Pd, Pd), // (Pd, height - Pd), (Ps, height), and finally (width - Radius, height). private static final double TAN_THETA = Math.tan(Math.PI / 8.f); private final float mCornerRadius; private final float mCircleOffsetStraight; private final float mCircleOffsetDiag; private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); private final Paint mForegroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG); private final int mDarkModeBackgroundColor; Loading Loading @@ -113,6 +128,11 @@ public class SignalDrawable extends Drawable { mIntrinsicSize = context.getResources().getDimensionPixelSize(R.dimen.signal_icon_size); mHandler = new Handler(); setDarkIntensity(0); mCornerRadius = context.getResources() .getDimensionPixelSize(R.dimen.stat_sys_mobile_signal_corner_radius); mCircleOffsetStraight = mCornerRadius / (float) TAN_THETA; mCircleOffsetDiag = (float) Math.sqrt(Math.pow(mCircleOffsetStraight, 2.f) / 2.f); } @Override Loading Loading @@ -204,11 +224,40 @@ public class SignalDrawable extends Drawable { mFullPath.setFillType(FillType.WINDING); float width = getBounds().width(); float height = getBounds().height(); float padding = (PAD * width); mFullPath.moveTo(width - padding, height - padding); mFullPath.lineTo(width - padding, padding); mFullPath.lineTo(padding, height - padding); mFullPath.lineTo(width - padding, height - padding); float padding = (int) (PAD * width); // Stay on pixel boundary // 1 - Bottom right, above corner mFullPath.moveTo(width - padding, height - padding - mCornerRadius); // 2 - Line to top right, below corner mFullPath.lineTo(width - padding, padding + mCircleOffsetStraight); // 3 - Arc to top right, on hypotenuse mFullPath.arcTo( width - padding - (2 * mCornerRadius), padding + mCircleOffsetStraight - mCornerRadius, width - padding, padding + mCircleOffsetStraight + mCornerRadius, 0.f, -135.f, false ); // 4 - Line to bottom left, on hypotenuse mFullPath.lineTo(padding + mCircleOffsetDiag, height - padding - mCircleOffsetDiag); // 5 - Arc to bottom left, on leg mFullPath.arcTo( padding + mCircleOffsetStraight - mCornerRadius, height - padding - (2 * mCornerRadius), padding + mCircleOffsetStraight + mCornerRadius, height - padding, -135.f, -135.f, false ); // 6 - Line to bottom rght, before corner mFullPath.lineTo(width - padding - mCornerRadius, height - padding); // 7 - Arc to beginning (bottom right, above corner) mFullPath.arcTo( width - padding - (2 * mCornerRadius), height - padding - (2 * mCornerRadius), width - padding, height - padding, 90.f, -90.f, false ); if (mState == STATE_CARRIER_CHANGE) { float cutWidth = (DOT_CUT_WIDTH * width); Loading Loading
packages/SystemUI/res/values/dimens.xml +3 −0 Original line number Diff line number Diff line Loading @@ -815,4 +815,7 @@ <dimen name="qs_gutter_height">6dp</dimen> <!-- Intended corner radius when drawing the mobile signal --> <dimen name="stat_sys_mobile_signal_corner_radius">0.75dp</dimen> </resources>
packages/SystemUI/src/com/android/systemui/statusbar/phone/SignalDrawable.java +55 −6 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.Handler; import android.util.LayoutDirection; import android.util.Log; import com.android.settingslib.R; import com.android.settingslib.Utils; Loading Loading @@ -82,6 +81,22 @@ public class SignalDrawable extends Drawable { {-1.9f / VIEWPORT, -1.9f / VIEWPORT}, }; // Rounded corners are achieved by arcing a circle of radius `mCornerRadius` from its tangent // points along the curve. On the top and left corners of the triangle, the tangents are as // follows: // 1) Along the straight lines (y = 0 and x = width): // Ps = R / tan(45) // 2) Along the diagonal line (y = x): // Pd = √((Ps^2) / 2) // // I.e., the points where we stop the straight lines lie at (starting drawing from the bottom- // right corner and counter-clockwise): (width, height - Radius), (width, Ps), (width - Pd, Pd), // (Pd, height - Pd), (Ps, height), and finally (width - Radius, height). private static final double TAN_THETA = Math.tan(Math.PI / 8.f); private final float mCornerRadius; private final float mCircleOffsetStraight; private final float mCircleOffsetDiag; private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); private final Paint mForegroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG); private final int mDarkModeBackgroundColor; Loading Loading @@ -113,6 +128,11 @@ public class SignalDrawable extends Drawable { mIntrinsicSize = context.getResources().getDimensionPixelSize(R.dimen.signal_icon_size); mHandler = new Handler(); setDarkIntensity(0); mCornerRadius = context.getResources() .getDimensionPixelSize(R.dimen.stat_sys_mobile_signal_corner_radius); mCircleOffsetStraight = mCornerRadius / (float) TAN_THETA; mCircleOffsetDiag = (float) Math.sqrt(Math.pow(mCircleOffsetStraight, 2.f) / 2.f); } @Override Loading Loading @@ -204,11 +224,40 @@ public class SignalDrawable extends Drawable { mFullPath.setFillType(FillType.WINDING); float width = getBounds().width(); float height = getBounds().height(); float padding = (PAD * width); mFullPath.moveTo(width - padding, height - padding); mFullPath.lineTo(width - padding, padding); mFullPath.lineTo(padding, height - padding); mFullPath.lineTo(width - padding, height - padding); float padding = (int) (PAD * width); // Stay on pixel boundary // 1 - Bottom right, above corner mFullPath.moveTo(width - padding, height - padding - mCornerRadius); // 2 - Line to top right, below corner mFullPath.lineTo(width - padding, padding + mCircleOffsetStraight); // 3 - Arc to top right, on hypotenuse mFullPath.arcTo( width - padding - (2 * mCornerRadius), padding + mCircleOffsetStraight - mCornerRadius, width - padding, padding + mCircleOffsetStraight + mCornerRadius, 0.f, -135.f, false ); // 4 - Line to bottom left, on hypotenuse mFullPath.lineTo(padding + mCircleOffsetDiag, height - padding - mCircleOffsetDiag); // 5 - Arc to bottom left, on leg mFullPath.arcTo( padding + mCircleOffsetStraight - mCornerRadius, height - padding - (2 * mCornerRadius), padding + mCircleOffsetStraight + mCornerRadius, height - padding, -135.f, -135.f, false ); // 6 - Line to bottom rght, before corner mFullPath.lineTo(width - padding - mCornerRadius, height - padding); // 7 - Arc to beginning (bottom right, above corner) mFullPath.arcTo( width - padding - (2 * mCornerRadius), height - padding - (2 * mCornerRadius), width - padding, height - padding, 90.f, -90.f, false ); if (mState == STATE_CARRIER_CHANGE) { float cutWidth = (DOT_CUT_WIDTH * width); Loading