diff --git a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java index d7393b2cc9..4508ab089b 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java @@ -30,6 +30,7 @@ import net.osmand.data.QuadRect; import net.osmand.data.RotatedTileBox; import net.osmand.data.TransportStop; import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.mapcontextmenu.other.TrackChartPoints; import net.osmand.plus.measurementtool.MeasurementToolFragment; @@ -105,6 +106,10 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont private LayerDrawable projectionIcon; private LayerDrawable previewIcon; + private int routeLineColor; + private float routeLineWidth; + private Integer directionArrowsColor; + public RouteLayer(RoutingHelper helper) { this.helper = helper; this.transportHelper = helper.getTransportRoutingHelper(); @@ -326,7 +331,8 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont DrawSettings settings, RouteLineDrawInfo drawInfo) { updateAttrs(settings, tileBox); - paintRouteLinePreview.setColor(getRouteLineColor(nightMode)); + updateRouteColors(nightMode); + paintRouteLinePreview.setColor(getRouteLineColor()); paintRouteLinePreview.setStrokeWidth(getRouteLineWidth(tileBox)); int centerX = drawInfo.getCenterX(); @@ -418,6 +424,22 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont @ColorInt public int getRouteLineColor(boolean night) { + updateRouteColors(night); + return routeLineColor; + } + + @ColorInt + public int getRouteLineColor() { + return routeLineColor; + } + + @Nullable + @ColorInt + public Integer getDirectionArrowsColor() { + return directionArrowsColor; + } + + public void updateRouteColors(boolean night) { Integer color; if (routeLineDrawInfo != null) { color = routeLineDrawInfo.getColor(night); @@ -429,10 +451,13 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont color = storedValue != 0 ? storedValue : null; } if (color == null) { + directionArrowsColor = null; updateAttrs(new DrawSettings(night), view.getCurrentRotatedTileBox()); color = attrs.paint.getColor(); + } else if (routeLineColor != color) { + directionArrowsColor = UiUtilities.getContrastColor(view.getContext(), color, false); } - return color; + routeLineColor = color; } private float getRouteLineWidth(@NonNull RotatedTileBox tileBox) { @@ -442,7 +467,7 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont } else { widthKey = view.getSettings().ROUTE_LINE_WIDTH.getModeValue(helper.getAppMode()); } - return widthKey != null ? getWidthByKey(tileBox, widthKey) : attrs.paint.getStrokeWidth(); + return routeLineWidth = widthKey != null ? getWidthByKey(tileBox, widthKey) : attrs.paint.getStrokeWidth(); } @Nullable @@ -500,7 +525,8 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont boolean straight = route.getRouteService() == RouteService.STRAIGHT; publicTransportRouteGeometry.clearRoute(); routeGeometry.updateRoute(tb, route); - routeGeometry.setRouteStyleParams(getRouteLineColor(nightMode), getRouteLineWidth(tb)); + updateRouteColors(nightMode); + routeGeometry.setRouteStyleParams(getRouteLineColor(), getRouteLineWidth(tb), getDirectionArrowsColor()); if (directTo) { routeGeometry.drawSegments(tb, canvas, topLatitude, leftLongitude, bottomLatitude, rightLongitude, null, 0); diff --git a/OsmAnd/src/net/osmand/plus/views/layers/geometry/GeometryWayStyle.java b/OsmAnd/src/net/osmand/plus/views/layers/geometry/GeometryWayStyle.java index d5a38ccd5d..f5c77ae804 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/geometry/GeometryWayStyle.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/geometry/GeometryWayStyle.java @@ -8,6 +8,7 @@ public abstract class GeometryWayStyle { private T context; protected Integer color; protected Float width; + protected Integer pointColor; public GeometryWayStyle(T context) { this.context = context; @@ -18,10 +19,11 @@ public abstract class GeometryWayStyle { this.color = color; } - public GeometryWayStyle(T context, Integer color, Float width) { + public GeometryWayStyle(T context, Integer color, Float width, Integer pointColor) { this.context = context; this.color = color; this.width = width; + this.pointColor = pointColor; } public T getContext() { @@ -45,7 +47,7 @@ public abstract class GeometryWayStyle { } public Integer getPointColor() { - return null; + return pointColor; } public boolean isNightMode() { diff --git a/OsmAnd/src/net/osmand/plus/views/layers/geometry/RouteGeometryWay.java b/OsmAnd/src/net/osmand/plus/views/layers/geometry/RouteGeometryWay.java index f6e26b039f..15b16ca51e 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/geometry/RouteGeometryWay.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/geometry/RouteGeometryWay.java @@ -22,15 +22,19 @@ public class RouteGeometryWay extends GeometryWay(context)); this.helper = context.getApp().getRoutingHelper(); } - public void setRouteStyleParams(@Nullable @ColorInt Integer color, @Nullable Float width) { + public void setRouteStyleParams(@Nullable @ColorInt Integer color, + @Nullable Float width, + @Nullable @ColorInt Integer pointColor) { this.customColor = color; this.customWidth = width; + this.customPointColor = pointColor; } @NonNull @@ -39,7 +43,7 @@ public class RouteGeometryWay extends GeometryWay { - GeometrySolidWayStyle(RouteGeometryWayContext context, Integer color, Float width) { - super(context, color, width); + GeometrySolidWayStyle(RouteGeometryWayContext context, Integer color, Float width, + Integer pointColor) { + super(context, color, width, pointColor); } @Override