get rid of pixelation using svg instead of png

There was only one size of png for the net status arrows. Now there are
svgs that generate the whole range. Also set color programatically to
avoid having to maintain four.
This commit is contained in:
Eric House 2019-12-30 10:37:02 -08:00
parent 2268d48fe2
commit 278275a9cb
7 changed files with 154 additions and 10 deletions

View file

@ -30,6 +30,7 @@ import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.provider.Settings;
import android.text.format.DateUtils;
import android.graphics.PorterDuff.Mode;
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnTypeSet;
@ -47,6 +48,7 @@ public class ConnStatusHandler {
private static final String TAG = ConnStatusHandler.class.getSimpleName();
private static final String RECS_KEY = TAG + "/recs";
private static final String STALL_STATS_KEY = TAG + "/stall_stats";
private static final int ORANGE = 0XFFFFA500;
public interface ConnStatusCBacks {
public void invalidateParent();
@ -487,16 +489,10 @@ public class ConnStatusHandler {
private static void drawArrow( Canvas canvas, Resources res, Rect rect,
boolean isIn )
{
int arrowID;
boolean showSuccesses = s_showSuccesses[isIn? SUCCESS_IN : SUCCESS_OUT];
if ( isIn ) {
arrowID = showSuccesses ?
R.drawable.in_arrow_active : R.drawable.in_arrow;
} else {
arrowID = showSuccesses ?
R.drawable.out_arrow_active : R.drawable.out_arrow;
}
drawIn( canvas, res, arrowID, rect );
int color = showSuccesses ? ORANGE : Color.WHITE;
int arrowID = isIn ? R.drawable.in_arrow__gen : R.drawable.out_arrow__gen;
drawIn( canvas, res, arrowID, rect, color );
}
// This gets rid of lint warning, but I don't like it as it
@ -576,9 +572,19 @@ public class ConnStatusHandler {
}
private static void drawIn( Canvas canvas, Resources res, int id, Rect rect )
{
drawIn( canvas, res, id, rect, Color.WHITE );
}
private static void drawIn( Canvas canvas, Resources res, int id, Rect rect, int color )
{
Drawable icon = res.getDrawable( id );
Assert.assertTrue( icon.getBounds().width() == icon.getBounds().height() );
if ( Color.WHITE != color ) {
icon = icon.mutate();
icon.setColorFilter( color, Mode.MULTIPLY );
}
Assert.assertTrue( icon.getBounds().width() == icon.getBounds().height()
|| !BuildConfig.DEBUG );
icon.setBounds( rect );
icon.draw( canvas );
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 135 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 135 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 B

View file

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="195.92358mm"
height="79.111778mm"
viewBox="0 0 195.92358 79.111778"
version="1.1"
id="svg3810"
inkscape:version="0.92.3 (2405546, 2018-03-11)"
sodipodi:docname="in_arrow.svg">
<defs
id="defs3804" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.9899495"
inkscape:cx="266.75131"
inkscape:cy="51.719447"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1920"
inkscape:window-height="1016"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1" />
<metadata
id="metadata3807">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-6.7984033,-83.405656)">
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.24818733px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 191.75867,98.253193 H 18.036751 l 0.250672,23.805047 49.181436,31.70363 -3.87143,-30.38207 128.420741,3.3716 z"
id="path3898"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccc" />
<path
style="stroke-width:0.42193675"
d="m 191.88842,112.50226 0.12975,14.24913 -14.71489,-0.19817 c -21.90426,-0.29498 -90.295127,-0.92186 -100.512257,-0.9213 l -8.900147,5.7e-4 v 14.06469 c 0,7.95668 -0.183273,14.06469 -0.422017,14.06469 -0.232125,0 -11.392904,-7.13332 -24.801736,-15.85181 l -24.3797,-15.85182 -0.125341,-11.90249 -0.125331,-11.902557 h 86.860959 86.86096 z"
id="path3900"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccsccssscccccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

View file

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="195.92358mm"
height="79.111778mm"
viewBox="0 0 195.92358 79.111778"
version="1.1"
id="svg3810"
inkscape:version="0.92.3 (2405546, 2018-03-11)"
sodipodi:docname="out_arrow.svg">
<defs
id="defs3804" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.9899495"
inkscape:cx="463.73105"
inkscape:cy="51.719447"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1920"
inkscape:window-height="1016"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1" />
<metadata
id="metadata3807">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-6.7984033,-83.405656)">
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.24740678px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 18.283263,143.90286 H 192.0312 l -0.25071,-23.652 -49.1888,-31.499813 3.87201,30.186753 -128.439977,-3.34993 z"
id="path3898"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccc" />
<path
style="stroke-width:0.42060974"
d="m 18.153493,129.7454 -0.12977,-14.15753 14.717103,0.19689 c 21.907537,0.2931 90.308644,0.91595 100.527304,0.91538 l 8.90148,-5.5e-4 v -13.97427 c 0,-7.905537 0.1833,-13.974273 0.42208,-13.974273 0.23216,0 11.39461,7.087454 24.80545,15.749903 l 24.38335,15.74991 0.12536,11.82597 0.12535,11.82603 H 105.15723 18.283263 Z"
id="path3900"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccsccssscccccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB