From 6a7b4fe8d5f333e1d2b7b4b1d5d0406796d01e1a Mon Sep 17 00:00:00 2001 From: crimean Date: Tue, 9 Jul 2019 21:29:39 +0300 Subject: [PATCH] Transport route/stop fixes --- .../BinaryMapTransportReaderAdapter.java | 2 +- .../res/drawable/bg_map_context_menu_dark.xml | 2 +- OsmAnd/res/values/colors.xml | 2 +- .../MapContextMenuFragment.java | 4 +-- .../plus/views/TransportStopsLayer.java | 28 +++++++++++-------- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapTransportReaderAdapter.java b/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapTransportReaderAdapter.java index 5dc434324e..ac30268fb8 100644 --- a/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapTransportReaderAdapter.java +++ b/OsmAnd-java/src/main/java/net/osmand/binary/BinaryMapTransportReaderAdapter.java @@ -482,7 +482,7 @@ public class BinaryMapTransportReaderAdapter { int filePointer) throws IOException { TransportStop dataObject = new TransportStop(); dataObject.setFileOffset(codedIS.getTotalBytesRead()); - // dataObject.setReferencesToRoutes(new int[] {filePointer}); + dataObject.setReferencesToRoutes(new int[] {filePointer}); boolean end = false; while(!end){ int t = codedIS.readTag(); diff --git a/OsmAnd/res/drawable/bg_map_context_menu_dark.xml b/OsmAnd/res/drawable/bg_map_context_menu_dark.xml index e3886d9d3d..8bba6fc50d 100644 --- a/OsmAnd/res/drawable/bg_map_context_menu_dark.xml +++ b/OsmAnd/res/drawable/bg_map_context_menu_dark.xml @@ -6,7 +6,7 @@ + android:color="@color/activity_background_color_dark" /> \ No newline at end of file diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml index 3040418280..409c670626 100644 --- a/OsmAnd/res/values/colors.xml +++ b/OsmAnd/res/values/colors.xml @@ -340,7 +340,7 @@ #f2f2f2 #222526 #e6e6e6 - #2d3133 + #2c3033 #727272 #727272 #536dfe diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index 5caebd957c..7e8858d434 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -537,13 +537,13 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo buttonsBottomBorder.setBackgroundColor(ContextCompat.getColor(mapActivity, nightMode ? R.color.ctx_menu_buttons_divider_dark : R.color.ctx_menu_buttons_divider_light)); buttonsTopBorder.setBackgroundColor(ContextCompat.getColor(mapActivity, nightMode ? R.color.ctx_menu_buttons_divider_dark : R.color.ctx_menu_buttons_divider_light)); View buttons = view.findViewById(R.id.context_menu_buttons); - buttons.setBackgroundColor(ContextCompat.getColor(mapActivity, nightMode ? R.color.ctx_menu_buttons_bg_dark : R.color.ctx_menu_buttons_bg_light)); + buttons.setBackgroundColor(ContextCompat.getColor(mapActivity, nightMode ? R.color.list_background_color_dark : R.color.activity_background_color_light)); if (!menu.buttonsVisible()) { buttonsTopBorder.setVisibility(View.GONE); buttons.setVisibility(View.GONE); } View bottomButtons = view.findViewById(R.id.context_menu_bottom_buttons); - bottomButtons.setBackgroundColor(ContextCompat.getColor(mapActivity, nightMode ? R.color.ctx_menu_buttons_bg_dark : R.color.ctx_menu_buttons_bg_light)); + bottomButtons.setBackgroundColor(ContextCompat.getColor(mapActivity, nightMode ? R.color.list_background_color_dark : R.color.activity_background_color_light)); if (!menu.navigateButtonVisible()) { bottomButtons.findViewById(R.id.context_menu_directions_button).setVisibility(View.GONE); } diff --git a/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java b/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java index 7371e53fe8..7625965c45 100644 --- a/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/TransportStopsLayer.java @@ -42,7 +42,8 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa private OsmandMapTileView view; private Paint paintIcon; - private Paint paintWhiteIcon; + private Paint paintLightIcon; + private Paint paintDarkIcon; private Bitmap backgroundIcon; private Bitmap stopBus; private Bitmap stopSmall; @@ -64,15 +65,17 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa @Override public void initLayer(final OsmandMapTileView view) { backgroundIcon = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_transport_stop_bg); - backgroundIconHalfWidth = backgroundIcon.getWidth() / 2; - backgroundIconHalfHeight = backgroundIcon.getWidth() / 2; + backgroundIconHalfWidth = backgroundIcon.getWidth() / 2f; + backgroundIconHalfHeight = backgroundIcon.getWidth() / 2f; this.view = view; DisplayMetrics dm = new DisplayMetrics(); WindowManager wmgr = (WindowManager) view.getContext().getSystemService(Context.WINDOW_SERVICE); wmgr.getDefaultDisplay().getMetrics(dm); paintIcon = new Paint(); - paintWhiteIcon = new Paint(); - paintWhiteIcon.setColorFilter(new PorterDuffColorFilter(ContextCompat.getColor(mapActivity,R.color.text_color_tab_active_dark), PorterDuff.Mode.SRC_IN)); + paintLightIcon = new Paint(); + paintLightIcon.setColorFilter(new PorterDuffColorFilter(ContextCompat.getColor(mapActivity, R.color.active_buttons_and_links_text_light), PorterDuff.Mode.SRC_IN)); + paintDarkIcon = new Paint(); + paintDarkIcon.setColorFilter(new PorterDuffColorFilter(ContextCompat.getColor(mapActivity, R.color.active_buttons_and_links_text_dark), PorterDuff.Mode.SRC_IN)); path = new Path(); stopBus = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_transport_stop_bus); stopSmall = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_transport_stop_small); @@ -124,8 +127,8 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa }; } - public void getFromPoint(RotatedTileBox tb, PointF point, List res, - List objects) { + private void getFromPoint(RotatedTileBox tb, PointF point, List res, + List objects) { int ex = (int) point.x; int ey = (int) point.y; final int rp = getRadiusPoi(tb); @@ -169,7 +172,7 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa this.showTransportStops = showTransportStops; } - public int getRadiusPoi(RotatedTileBox tb){ + private int getRadiusPoi(RotatedTileBox tb){ final double zoom = tb.getZoom(); int r; if(zoom < startZoomRoute){ @@ -189,10 +192,11 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa @Override public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tb, DrawSettings settings) { List objects = null; + boolean nightMode = settings.isNightMode(); if (tb.getZoom() >= startZoomRoute) { if (stopRoute != null) { objects = stopRoute.route.getForwardStops(); - int color = stopRoute.getColor(mapActivity.getMyApplication(), settings.isNightMode()); + int color = stopRoute.getColor(mapActivity.getMyApplication(), nightMode); attrs.paint.setColor(color); attrs.updatePaints(view.getApplication(), settings, tb); try { @@ -233,7 +237,7 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa float y = tb.getPixYFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude()); if (intersects(boundIntersections, x, y, iconSize, iconSize)) { - canvas.drawBitmap(stopSmall, x - stopSmall.getWidth() / 2, y - stopSmall.getHeight() / 2, paintIcon); + canvas.drawBitmap(stopSmall, x - stopSmall.getWidth() / 2f, y - stopSmall.getHeight() / 2f, paintIcon); } else { fullObjects.add(o); } @@ -247,11 +251,11 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa if (type != null) { Bitmap foregroundIcon = RenderingIcons.getIcon(mapActivity, type.getResName(), false); canvas.drawBitmap(backgroundIcon, x - backgroundIconHalfWidth, y - backgroundIconHalfHeight, paintIcon); - canvas.drawBitmap(foregroundIcon, x - foregroundIcon.getWidth() / 2, y - foregroundIcon.getHeight() / 2, paintWhiteIcon); + canvas.drawBitmap(foregroundIcon, x - foregroundIcon.getWidth() / 2f, y - foregroundIcon.getHeight() / 2f, nightMode ? paintDarkIcon : paintLightIcon); } } else { Bitmap b = stopBus; - canvas.drawBitmap(b, x - b.getWidth() / 2, y - b.getHeight() / 2, paintIcon); + canvas.drawBitmap(b, x - b.getWidth() / 2f, y - b.getHeight() / 2f, paintIcon); } } }