From 55db01e9b4de973d1b73690f97d1838e438a4b8e Mon Sep 17 00:00:00 2001 From: Dmitriy Ruban Date: Wed, 11 Dec 2019 15:44:17 +0200 Subject: [PATCH] exit shield in top bar --- .../net/osmand/binary/RouteDataObject.java | 22 +++++ .../main/java/net/osmand/router/ExitInfo.java | 45 ++++++++++ .../drawable/bg_topbar_shield_exit_ref.xml | 12 +-- OsmAnd/res/layout/map_hud_top.xml | 26 +++--- .../osmand/plus/render/OsmandRenderer.java | 7 ++ .../plus/routing/RouteCalculationResult.java | 26 +++++- .../plus/routing/RouteDirectionInfo.java | 35 +++----- .../mapwidgets/MapInfoWidgetsFactory.java | 86 ++++++++++--------- 8 files changed, 169 insertions(+), 90 deletions(-) create mode 100644 OsmAnd-java/src/main/java/net/osmand/router/ExitInfo.java diff --git a/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java b/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java index a02c265265..bb8ee66748 100644 --- a/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java +++ b/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java @@ -742,6 +742,28 @@ public class RouteDataObject { return null; } + public String getShieldColor() { + int sz = types.length; + for (int i = 0; i < sz; i++) { + RouteTypeRule r = region.quickGetEncodingRule(types[i]); + if (r.getTag().equals("road_shield_color_1")) { + return r.getValue(); + } + } + return null; + } + + public String getShieldShape() { + int sz = types.length; + for (int i = 0; i < sz; i++) { + RouteTypeRule r = region.quickGetEncodingRule(types[i]); + if (r.getTag().equals("road_shield_shape_1")) { + return r.getValue(); + } + } + return null; + } + public int getOneway() { int sz = types.length; for (int i = 0; i < sz; i++) { diff --git a/OsmAnd-java/src/main/java/net/osmand/router/ExitInfo.java b/OsmAnd-java/src/main/java/net/osmand/router/ExitInfo.java new file mode 100644 index 0000000000..e7e14226f5 --- /dev/null +++ b/OsmAnd-java/src/main/java/net/osmand/router/ExitInfo.java @@ -0,0 +1,45 @@ +package net.osmand.router; + + +public class ExitInfo { + + private String ref; + + private String shieldName; + + private String shieldIconName; + + private String exitStreetName; + + public String getRef() { + return ref; + } + + public void setRef(String ref) { + this.ref = ref; + } + + public String getShieldName() { + return shieldName; + } + + public void setShieldName(String shieldName) { + this.shieldName = shieldName; + } + + public String getExitStreetName() { + return exitStreetName; + } + + public void setExitStreetName(String exitStreetName) { + this.exitStreetName = exitStreetName; + } + + public String getShieldIconName() { + return shieldIconName; + } + + public void setShieldIconName(String shieldIconName) { + this.shieldIconName = shieldIconName; + } +} diff --git a/OsmAnd/res/drawable/bg_topbar_shield_exit_ref.xml b/OsmAnd/res/drawable/bg_topbar_shield_exit_ref.xml index ea8037de6d..fff0e2dbf0 100644 --- a/OsmAnd/res/drawable/bg_topbar_shield_exit_ref.xml +++ b/OsmAnd/res/drawable/bg_topbar_shield_exit_ref.xml @@ -1,9 +1,5 @@ - - - - - - - - \ No newline at end of file + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/map_hud_top.xml b/OsmAnd/res/layout/map_hud_top.xml index ca7347b4a7..2ee8ebf003 100644 --- a/OsmAnd/res/layout/map_hud_top.xml +++ b/OsmAnd/res/layout/map_hud_top.xml @@ -124,22 +124,22 @@ 0); boolean update = turnDrawable.setTurnType(type[0]) || showMarker != this.showMarker; this.showMarker = showMarker; - int h = addressText.getHeight() / 4 * 3; - if (h != turnDrawable.getBounds().bottom) { - turnDrawable.setBounds(0, 0, h, h); + if (!showExitInfo) { + int h = addressText.getHeight() / 4 * 3; + if (h != turnDrawable.getBounds().bottom) { + turnDrawable.setBounds(0, 0, h, h); + } } - if (update) { - if (type[0] != null) { - if (showShield) { - addressTextShadow.setCompoundDrawables(null, null, null, null); - addressTextShadow.setCompoundDrawablePadding(4); - addressText.setCompoundDrawables(null, null, null, null); - addressText.setCompoundDrawablePadding(4); - exitShield.setText(exitShieldName); - turnIcon.setImageDrawable(turnDrawable); - AndroidUiHelper.updateVisibility(turnIcon, true); - AndroidUiHelper.updateVisibility(exitShield, true); - } else { - addressTextShadow.setCompoundDrawables(turnDrawable, null, null, null); - addressTextShadow.setCompoundDrawablePadding(4); - addressText.setCompoundDrawables(turnDrawable, null, null, null); - addressText.setCompoundDrawablePadding(4); - AndroidUiHelper.updateVisibility(turnIcon, false); - AndroidUiHelper.updateVisibility(exitShield, false); + if (showExitInfo) { + addressTextShadow.setCompoundDrawables(null, null, null, null); + addressText.setCompoundDrawables(null, null, null, null); + turnIcon.setImageDrawable(turnDrawable); + AndroidUiHelper.updateVisibility(turnIcon, true); + String ref = exitInfo.getRef(); + if (!Algorithms.isEmpty(ref)){ + exitRefText.setText(ref); + AndroidUiHelper.updateVisibility(exitRefText, true); + } + String shieldName = exitInfo.getShieldName(); + if (!Algorithms.isEmpty(shieldName)){ + exitShield.setText(shieldName); + AndroidUiHelper.updateVisibility(exitShield, true); + if (exitInfo.getShieldIconName() != null) { + MapRenderRepositories mapRenderRepo = map.getMyApplication().getResourceManager().getRenderer(); + Drawable shield = mapRenderRepo.getRenderer().getShieldDrawable(exitInfo.getShieldIconName()); + exitShield.setBackgroundDrawable(shield); } + } + } else if (update) { + if (type[0] != null) { + addressTextShadow.setCompoundDrawables(turnDrawable, null, null, null); + addressTextShadow.setCompoundDrawablePadding(4); + addressText.setCompoundDrawables(turnDrawable, null, null, null); + addressText.setCompoundDrawablePadding(4); + AndroidUiHelper.updateVisibility(turnIcon, false); + AndroidUiHelper.updateVisibility(exitRefText, false); + AndroidUiHelper.updateVisibility(exitShield, false); } else if (showMarker) { Drawable marker = map.getMyApplication().getUIUtilities().getIcon(R.drawable.ic_action_start_navigation, R.color.color_myloc_distance); addressTextShadow.setCompoundDrawablesWithIntrinsicBounds(marker, null, null, null);