Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e850823d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use '!' instead of 'x' in signal drawable" into sc-dev

parents 8cacd781 6a2d17d4
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -4408,14 +4408,14 @@
        M9,10l-2,0l0,-2l-2,0l0,2l-2,0l0,2l2,0l0,2l2,0l0,-2l2,0z
    </string>

    <!-- X path for SignalDrawable as defined on a 24x24 canvas. -->
    <string name="config_signalXPath" translatable="false">
        M22,16.41L20.59,15l-2.09,2.09L16.41,15L15,16.41l2.09,2.09L15,20.59L16.41,22l2.09-2.08L20.59,22L22,20.59l-2.08-2.09   L22,16.41z
    <!-- Attribution path for SignalDrawable as defined on a 24x24 canvas. -->
    <string name="config_signalAttributionPath" translatable="false">
        M20,10h2v8h-2z M20,20h2v2h-2z
    </string>
    <!-- config_signalCutout{Height,Width}Fraction define fraction of the 24x24 canvas that
         should be cut out to display config_signalXPath.-->
    <item name="config_signalCutoutWidthFraction" format="float" type="dimen">11</item>
    <item name="config_signalCutoutHeightFraction" format="float" type="dimen">11</item>
         should be cut out to display config_signalAttributionPath. -->
    <item name="config_signalCutoutWidthFraction" format="float" type="dimen">7</item>
    <item name="config_signalCutoutHeightFraction" format="float" type="dimen">17</item>

    <!-- A dual tone battery meter draws the perimeter path twice - once to define the shape
     and a second time clipped to the fill level to indicate charge -->
+1 −1
Original line number Diff line number Diff line
@@ -3369,7 +3369,7 @@
  <java-symbol type="string" name="config_batterymeterBoltPath" />
  <java-symbol type="string" name="config_batterymeterPowersavePath" />
  <java-symbol type="bool" name="config_batterymeterDualTone" />
  <java-symbol type="string" name="config_signalXPath" />
  <java-symbol type="string" name="config_signalAttributionPath" />
  <java-symbol type="dimen" name="config_signalCutoutWidthFraction" />
  <java-symbol type="dimen" name="config_signalCutoutHeightFraction" />

+14 −13
Original line number Diff line number Diff line
@@ -72,9 +72,9 @@ public class SignalDrawable extends DrawableWrapper {
    private final int mLightModeFillColor;
    private final Path mCutoutPath = new Path();
    private final Path mForegroundPath = new Path();
    private final Path mXPath = new Path();
    private final Matrix mXScaleMatrix = new Matrix();
    private final Path mScaledXPath = new Path();
    private final Path mAttributionPath = new Path();
    private final Matrix mAttributionScaleMatrix = new Matrix();
    private final Path mScaledAttributionPath = new Path();
    private final Handler mHandler;
    private final float mCutoutWidthFraction;
    private final float mCutoutHeightFraction;
@@ -85,10 +85,10 @@ public class SignalDrawable extends DrawableWrapper {

    public SignalDrawable(Context context) {
        super(context.getDrawable(com.android.internal.R.drawable.ic_signal_cellular));
        final String xPathString = context.getString(
                com.android.internal.R.string.config_signalXPath);
        mXPath.set(PathParser.createPathFromPathData(xPathString));
        updateScaledXPath();
        final String attributionPathString = context.getString(
                com.android.internal.R.string.config_signalAttributionPath);
        mAttributionPath.set(PathParser.createPathFromPathData(attributionPathString));
        updateScaledAttributionPath();
        mCutoutWidthFraction = context.getResources().getFloat(
                com.android.internal.R.dimen.config_signalCutoutWidthFraction);
        mCutoutHeightFraction = context.getResources().getFloat(
@@ -104,13 +104,14 @@ public class SignalDrawable extends DrawableWrapper {
        setDarkIntensity(0);
    }

    private void updateScaledXPath() {
    private void updateScaledAttributionPath() {
        if (getBounds().isEmpty()) {
            mXScaleMatrix.setScale(1f, 1f);
            mAttributionScaleMatrix.setScale(1f, 1f);
        } else {
            mXScaleMatrix.setScale(getBounds().width() / VIEWPORT, getBounds().height() / VIEWPORT);
            mAttributionScaleMatrix.setScale(
                    getBounds().width() / VIEWPORT, getBounds().height() / VIEWPORT);
        }
        mXPath.transform(mXScaleMatrix, mScaledXPath);
        mAttributionPath.transform(mAttributionScaleMatrix, mScaledAttributionPath);
    }

    @Override
@@ -177,7 +178,7 @@ public class SignalDrawable extends DrawableWrapper {
    @Override
    protected void onBoundsChange(Rect bounds) {
        super.onBoundsChange(bounds);
        updateScaledXPath();
        updateScaledAttributionPath();
        invalidateSelf();
    }

@@ -221,7 +222,7 @@ public class SignalDrawable extends DrawableWrapper {
            mCutoutPath.rLineTo(cutX, 0);
            mCutoutPath.rLineTo(0, cutY);
            canvas.drawPath(mCutoutPath, mTransparentPaint);
            canvas.drawPath(mScaledXPath, mForegroundPaint);
            canvas.drawPath(mScaledAttributionPath, mForegroundPaint);
        }
        if (isRtl) {
            canvas.restore();