Merge "Use '!' instead of 'x' in signal drawable" into sc-dev am: e850823da0 am: 57e372bc2a

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14946255

Change-Id: If6df3bd8ad71bf8a26be22280a9e38d913d0b3f0
This commit is contained in:
TreeHugger Robot
2021-07-16 15:38:54 +00:00
committed by Automerger Merge Worker
3 changed files with 21 additions and 20 deletions

View File

@@ -4408,14 +4408,14 @@
M9,10l-2,0l0,-2l-2,0l0,2l-2,0l0,2l2,0l0,2l2,0l0,-2l2,0z M9,10l-2,0l0,-2l-2,0l0,2l-2,0l0,2l2,0l0,2l2,0l0,-2l2,0z
</string> </string>
<!-- X path for SignalDrawable as defined on a 24x24 canvas. --> <!-- Attribution path for SignalDrawable as defined on a 24x24 canvas. -->
<string name="config_signalXPath" translatable="false"> <string name="config_signalAttributionPath" 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 M20,10h2v8h-2z M20,20h2v2h-2z
</string> </string>
<!-- config_signalCutout{Height,Width}Fraction define fraction of the 24x24 canvas that <!-- config_signalCutout{Height,Width}Fraction define fraction of the 24x24 canvas that
should be cut out to display config_signalXPath.--> should be cut out to display config_signalAttributionPath. -->
<item name="config_signalCutoutWidthFraction" format="float" type="dimen">11</item> <item name="config_signalCutoutWidthFraction" format="float" type="dimen">7</item>
<item name="config_signalCutoutHeightFraction" format="float" type="dimen">11</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 <!-- 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 --> and a second time clipped to the fill level to indicate charge -->

View File

@@ -3369,7 +3369,7 @@
<java-symbol type="string" name="config_batterymeterBoltPath" /> <java-symbol type="string" name="config_batterymeterBoltPath" />
<java-symbol type="string" name="config_batterymeterPowersavePath" /> <java-symbol type="string" name="config_batterymeterPowersavePath" />
<java-symbol type="bool" name="config_batterymeterDualTone" /> <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_signalCutoutWidthFraction" />
<java-symbol type="dimen" name="config_signalCutoutHeightFraction" /> <java-symbol type="dimen" name="config_signalCutoutHeightFraction" />

View File

@@ -72,9 +72,9 @@ public class SignalDrawable extends DrawableWrapper {
private final int mLightModeFillColor; private final int mLightModeFillColor;
private final Path mCutoutPath = new Path(); private final Path mCutoutPath = new Path();
private final Path mForegroundPath = new Path(); private final Path mForegroundPath = new Path();
private final Path mXPath = new Path(); private final Path mAttributionPath = new Path();
private final Matrix mXScaleMatrix = new Matrix(); private final Matrix mAttributionScaleMatrix = new Matrix();
private final Path mScaledXPath = new Path(); private final Path mScaledAttributionPath = new Path();
private final Handler mHandler; private final Handler mHandler;
private final float mCutoutWidthFraction; private final float mCutoutWidthFraction;
private final float mCutoutHeightFraction; private final float mCutoutHeightFraction;
@@ -85,10 +85,10 @@ public class SignalDrawable extends DrawableWrapper {
public SignalDrawable(Context context) { public SignalDrawable(Context context) {
super(context.getDrawable(com.android.internal.R.drawable.ic_signal_cellular)); super(context.getDrawable(com.android.internal.R.drawable.ic_signal_cellular));
final String xPathString = context.getString( final String attributionPathString = context.getString(
com.android.internal.R.string.config_signalXPath); com.android.internal.R.string.config_signalAttributionPath);
mXPath.set(PathParser.createPathFromPathData(xPathString)); mAttributionPath.set(PathParser.createPathFromPathData(attributionPathString));
updateScaledXPath(); updateScaledAttributionPath();
mCutoutWidthFraction = context.getResources().getFloat( mCutoutWidthFraction = context.getResources().getFloat(
com.android.internal.R.dimen.config_signalCutoutWidthFraction); com.android.internal.R.dimen.config_signalCutoutWidthFraction);
mCutoutHeightFraction = context.getResources().getFloat( mCutoutHeightFraction = context.getResources().getFloat(
@@ -104,13 +104,14 @@ public class SignalDrawable extends DrawableWrapper {
setDarkIntensity(0); setDarkIntensity(0);
} }
private void updateScaledXPath() { private void updateScaledAttributionPath() {
if (getBounds().isEmpty()) { if (getBounds().isEmpty()) {
mXScaleMatrix.setScale(1f, 1f); mAttributionScaleMatrix.setScale(1f, 1f);
} else { } 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 @Override
@@ -177,7 +178,7 @@ public class SignalDrawable extends DrawableWrapper {
@Override @Override
protected void onBoundsChange(Rect bounds) { protected void onBoundsChange(Rect bounds) {
super.onBoundsChange(bounds); super.onBoundsChange(bounds);
updateScaledXPath(); updateScaledAttributionPath();
invalidateSelf(); invalidateSelf();
} }
@@ -221,7 +222,7 @@ public class SignalDrawable extends DrawableWrapper {
mCutoutPath.rLineTo(cutX, 0); mCutoutPath.rLineTo(cutX, 0);
mCutoutPath.rLineTo(0, cutY); mCutoutPath.rLineTo(0, cutY);
canvas.drawPath(mCutoutPath, mTransparentPaint); canvas.drawPath(mCutoutPath, mTransparentPaint);
canvas.drawPath(mScaledXPath, mForegroundPaint); canvas.drawPath(mScaledAttributionPath, mForegroundPaint);
} }
if (isRtl) { if (isRtl) {
canvas.restore(); canvas.restore();