Update SignalDrawable X path drawing.
- Use config resources to specify svg path and cutout width / height - Specify these resources for all 3 themes Fixes: 133343689 Test: mp res sysuig; demo mode; manually change themes Change-Id: Ic29e5da541330c1aa99b0e82e46a14dbb10d7940
This commit is contained in:
parent
33cc350063
commit
408d2d312d
@ -4110,6 +4110,15 @@
|
||||
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
|
||||
</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>
|
||||
|
||||
<!-- 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 -->
|
||||
<bool name="config_batterymeterDualTone">false</bool>
|
||||
|
@ -3263,6 +3263,9 @@
|
||||
<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="dimen" name="config_signalCutoutWidthFraction" />
|
||||
<java-symbol type="dimen" name="config_signalCutoutHeightFraction" />
|
||||
|
||||
<java-symbol type="bool" name="config_debugEnableAutomaticSystemServerHeapDumps" />
|
||||
<java-symbol type="integer" name="config_debugSystemServerPssThresholdBytes" />
|
||||
|
@ -22,6 +22,7 @@ import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.Path.Direction;
|
||||
@ -33,6 +34,7 @@ import android.graphics.drawable.DrawableWrapper;
|
||||
import android.os.Handler;
|
||||
import android.telephony.SignalStrength;
|
||||
import android.util.LayoutDirection;
|
||||
import android.util.PathParser;
|
||||
|
||||
import com.android.settingslib.R;
|
||||
import com.android.settingslib.Utils;
|
||||
@ -48,7 +50,6 @@ public class SignalDrawable extends DrawableWrapper {
|
||||
|
||||
private static final float VIEWPORT = 24f;
|
||||
private static final float PAD = 2f / VIEWPORT;
|
||||
private static final float CUT_OUT = 7.9f / VIEWPORT;
|
||||
|
||||
private static final float DOT_SIZE = 3f / VIEWPORT;
|
||||
private static final float DOT_PADDING = 1.5f / VIEWPORT;
|
||||
@ -65,21 +66,6 @@ public class SignalDrawable extends DrawableWrapper {
|
||||
|
||||
private static final long DOT_DELAY = 1000;
|
||||
|
||||
private static float[][] X_PATH = new float[][]{
|
||||
{21.9f / VIEWPORT, 17.0f / VIEWPORT},
|
||||
{-1.1f / VIEWPORT, -1.1f / VIEWPORT},
|
||||
{-1.9f / VIEWPORT, 1.9f / VIEWPORT},
|
||||
{-1.9f / VIEWPORT, -1.9f / VIEWPORT},
|
||||
{-1.1f / VIEWPORT, 1.1f / VIEWPORT},
|
||||
{1.9f / VIEWPORT, 1.9f / VIEWPORT},
|
||||
{-1.9f / VIEWPORT, 1.9f / VIEWPORT},
|
||||
{1.1f / VIEWPORT, 1.1f / VIEWPORT},
|
||||
{1.9f / VIEWPORT, -1.9f / VIEWPORT},
|
||||
{1.9f / VIEWPORT, 1.9f / VIEWPORT},
|
||||
{1.1f / VIEWPORT, -1.1f / VIEWPORT},
|
||||
{-1.9f / VIEWPORT, -1.9f / VIEWPORT},
|
||||
};
|
||||
|
||||
private final Paint mForegroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
private final Paint mTransparentPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
private final int mDarkModeFillColor;
|
||||
@ -87,7 +73,11 @@ public class SignalDrawable extends DrawableWrapper {
|
||||
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 Handler mHandler;
|
||||
private final float mCutoutWidthFraction;
|
||||
private final float mCutoutHeightFraction;
|
||||
private float mDarkIntensity = -1;
|
||||
private final int mIntrinsicSize;
|
||||
private boolean mAnimating;
|
||||
@ -95,6 +85,14 @@ 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();
|
||||
mCutoutWidthFraction = context.getResources().getFloat(
|
||||
com.android.internal.R.dimen.config_signalCutoutWidthFraction);
|
||||
mCutoutHeightFraction = context.getResources().getFloat(
|
||||
com.android.internal.R.dimen.config_signalCutoutHeightFraction);
|
||||
mDarkModeFillColor = Utils.getColorStateListDefaultColor(context,
|
||||
R.color.dark_mode_icon_color_single_tone);
|
||||
mLightModeFillColor = Utils.getColorStateListDefaultColor(context,
|
||||
@ -106,6 +104,15 @@ public class SignalDrawable extends DrawableWrapper {
|
||||
setDarkIntensity(0);
|
||||
}
|
||||
|
||||
private void updateScaledXPath() {
|
||||
if (getBounds().isEmpty()) {
|
||||
mXScaleMatrix.setScale(1f, 1f);
|
||||
} else {
|
||||
mXScaleMatrix.setScale(getBounds().width() / VIEWPORT, getBounds().height() / VIEWPORT);
|
||||
}
|
||||
mXPath.transform(mXScaleMatrix, mScaledXPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicWidth() {
|
||||
return mIntrinsicSize;
|
||||
@ -170,6 +177,7 @@ public class SignalDrawable extends DrawableWrapper {
|
||||
@Override
|
||||
protected void onBoundsChange(Rect bounds) {
|
||||
super.onBoundsChange(bounds);
|
||||
updateScaledXPath();
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@ -205,19 +213,15 @@ public class SignalDrawable extends DrawableWrapper {
|
||||
canvas.drawPath(mCutoutPath, mTransparentPaint);
|
||||
canvas.drawPath(mForegroundPath, mForegroundPaint);
|
||||
} else if (isInState(STATE_CUT)) {
|
||||
float cut = (CUT_OUT * width);
|
||||
mCutoutPath.moveTo(width - padding, height - padding);
|
||||
mCutoutPath.rLineTo(-cut, 0);
|
||||
mCutoutPath.rLineTo(0, -cut);
|
||||
mCutoutPath.rLineTo(cut, 0);
|
||||
mCutoutPath.rLineTo(0, cut);
|
||||
float cutX = (mCutoutWidthFraction * width / VIEWPORT);
|
||||
float cutY = (mCutoutHeightFraction * height / VIEWPORT);
|
||||
mCutoutPath.moveTo(width, height);
|
||||
mCutoutPath.rLineTo(-cutX, 0);
|
||||
mCutoutPath.rLineTo(0, -cutY);
|
||||
mCutoutPath.rLineTo(cutX, 0);
|
||||
mCutoutPath.rLineTo(0, cutY);
|
||||
canvas.drawPath(mCutoutPath, mTransparentPaint);
|
||||
mXPath.reset();
|
||||
mXPath.moveTo(X_PATH[0][0] * width, X_PATH[0][1] * height);
|
||||
for (int i = 1; i < X_PATH.length; i++) {
|
||||
mXPath.rLineTo(X_PATH[i][0] * width, X_PATH[i][1] * height);
|
||||
}
|
||||
canvas.drawPath(mXPath, mForegroundPaint);
|
||||
canvas.drawPath(mScaledXPath, mForegroundPaint);
|
||||
}
|
||||
if (isRtl) {
|
||||
canvas.restore();
|
||||
|
@ -30,4 +30,12 @@
|
||||
<string name="config_batterymeterPowersavePath" translatable="false">
|
||||
M 3.75,11.25 H 5.25 V 12.75 C 5.25,13.16 5.59,13.5 6,13.5 6.41,13.5 6.75,13.16 6.75,12.75 V 11.25 H 8.25 C 8.66,11.25 9,10.91 9,10.5 9,10.09 8.6601,9.75 8.25,9.75 H 6.75 V 8.25 C 6.75,7.84 6.41,7.5 6,7.5 5.59,7.5 5.25,7.84 5.25,8.25 V 9.75 H 3.75 C 3.34,9.75 3,10.09 3,10.5 3,10.91 3.34,11.25 3.75,11.25 Z
|
||||
</string>
|
||||
<!-- X path for SignalDrawable as defined on a 24x24 canvas. -->
|
||||
<string name="config_signalXPath" translatable="false">
|
||||
M 17.81,18.75 L 19.81,16.75 C 20.01,16.56 20.09,16.28 20.02,16.02 C 19.96,15.75 19.75,15.54 19.48,15.47 C 19.22,15.41 18.94,15.49 18.75,15.69 L 16.75,17.69 L 14.75,15.69 C 14.56,15.49 14.28,15.41 14.02,15.47 C 13.75,15.54 13.54,15.75 13.47,16.02 C 13.41,16.28 13.49,16.56 13.69,16.75 L 15.69,18.75 L 13.69,20.75 C 13.4,21.04 13.4,21.52 13.69,21.81 C 13.98,22.1 14.46,22.1 14.75,21.81 L 16.75,19.81 L 18.75,21.81 C 19.04,22.1 19.52,22.1 19.81,21.81 C 20.1,21.52 20.1,21.04 19.81,20.75 Z
|
||||
</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">10.5</item>
|
||||
<item name="config_signalCutoutHeightFraction" format="float" type="dimen">11</item>
|
||||
</resources>
|
||||
|
@ -33,4 +33,12 @@
|
||||
M 9,11 C 9,11.55 8.55,12 8,12 H 7 V 13 C 7,13.55 6.55,14 6,14 5.45,14 5,13.55 5,13 V 12 H 4 C 3.45,12 3,11.55 3,11 3,10.45 3.45,10.005 4,10 H 5 V 9 C 5,8.45 5.45,8 6,8 6.55,8 7,8.45 7,9 V 10 H 8 C 8.55,10 9,10.45 9,11 Z
|
||||
</string>
|
||||
<bool name="config_batterymeterDualTone">true</bool>
|
||||
<!-- X path for SignalDrawable as defined on a 24x24 canvas. -->
|
||||
<string name="config_signalXPath" translatable="false">
|
||||
M 21.7,20.28 L 19.92,18.5 L 21.7,16.72 C 22.1,16.32 22.1,15.68 21.71,15.29 C 21.32,14.9 20.68,14.9 20.28,15.3 L 18.5,17.08 L 16.72,15.3 C 16.32,14.9 15.68,14.9 15.29,15.29 C 14.9,15.68 14.9,16.32 15.3,16.72 L 17.08,18.5 L 15.3,20.28 C 14.9,20.68 14.9,21.32 15.29,21.71 C 15.68,22.1 16.32,22.1 16.72,21.7 L 18.5,19.92 L 20.28,21.7 C 20.68,22.1 21.32,22.1 21.71,21.71 C 22.1,21.32 22.1,20.68 21.7,20.28
|
||||
</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>
|
||||
</resources>
|
||||
|
@ -30,4 +30,12 @@
|
||||
<string name="config_batterymeterPowersavePath" translatable="false">
|
||||
M 3.75,11.25 H 5.25 V 12.75 C 5.25,13.16 5.59,13.5 6,13.5 6.41,13.5 6.75,13.16 6.75,12.75 V 11.25 H 8.25 C 8.66,11.25 9,10.91 9,10.5 9,10.09 8.66,9.7499 8.25,9.7499 H 6.75 V 8.2499 C 6.75,7.8399 6.41,7.4999 6,7.4999 5.59,7.4999 5.2794,7.841 5.25,8.2499 V 9.7499 H 3.75 C 3.34,9.7499 3,10.09 3,10.5 3,10.91 3.3401,11.25 3.75,11.25 Z
|
||||
</string>
|
||||
<!-- X path for SignalDrawable as defined on a 24x24 canvas. -->
|
||||
<string name="config_signalXPath" translatable="false">
|
||||
M 20.72,16.22 L 19,17.94 L 17.28,16.22 C 16.99,15.93 16.51,15.93 16.22,16.22 C 15.93,16.51 15.93,16.99 16.22,17.28 L 17.94,19 L 16.22,20.72 C 15.93,21.01 15.93,21.49 16.22,21.78 C 16.37,21.93 16.56,22 16.75,22 C 16.94,22 17.13,21.93 17.28,21.78 L 19,20.06 L 20.72,21.78 C 20.87,21.93 21.06,22 21.25,22 C 21.44,22 21.63,21.93 21.78,21.78 C 22.07,21.49 22.07,21.01 21.78,20.72 L 20.06,19 L 21.78,17.28 C 22.07,16.99 22.07,16.51 21.78,16.22 C 21.49,15.93 21.01,15.93 20.72,16.22 Z
|
||||
</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">10</item>
|
||||
<item name="config_signalCutoutHeightFraction" format="float" type="dimen">10</item>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user