diff --git a/OsmAnd/src/net/osmand/plus/render/TextRenderer.java b/OsmAnd/src/net/osmand/plus/render/TextRenderer.java index 4df7d5db34..5743a40025 100644 --- a/OsmAnd/src/net/osmand/plus/render/TextRenderer.java +++ b/OsmAnd/src/net/osmand/plus/render/TextRenderer.java @@ -317,7 +317,7 @@ public class TextRenderer { float coef = rc.getDensityValue(rc.screenDensityRatio * rc.textScale); Bitmap ico = RenderingIcons.getIcon(context, sr, true); if (ico != null) { - float left = text.centerX - ico.getWidth() / 2 * coef;// - 0.5f; + float left = text.centerX - ico.getWidth() / 2 * coef - 0.5f; float top = text.centerY - ico.getHeight() / 2 * coef - paintText.descent() * 1.5f; if(rc.screenDensityRatio != 1f){ RectF rf = new RectF(left, top, left + ico.getWidth() * coef, diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index 219de52577..186bd88d11 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -834,21 +834,21 @@ public class RoutingHelper { // return false; // } - public synchronized String getCurrentName(TurnType[] next){ - NextDirectionInfo n = getNextRouteDirectionInfo(new NextDirectionInfo(), true); + public synchronized String getCurrentName(TurnType[] next, NextDirectionInfo n){ Location l = lastFixedLocation; float speed = 0; if(l != null && l.hasSpeed()) { speed = l.getSpeed(); } + if(next != null) { + next[0] = n.directionInfo.getTurnType(); + } if(n.distanceTo > 0 && n.directionInfo != null && !n.directionInfo.getTurnType().isSkipToSpeak() && voiceRouter.isDistanceLess(speed, n.distanceTo, voiceRouter.PREPARE_DISTANCE * 0.75f, 0f)) { String nm = n.directionInfo.getStreetName(); -// String rf = n.directionInfo.getRef(); + String rf = n.directionInfo.getRef(); String dn = n.directionInfo.getDestinationName(); - if(next != null) { - next[0] = n.directionInfo.getTurnType(); - } + return formatStreetName(nm, null, dn, "ยป"); } RouteSegmentResult rs = getCurrentSegmentResult(); diff --git a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java index 7a10ee5766..4f03920350 100644 --- a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java +++ b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java @@ -708,13 +708,13 @@ public class VoiceRouter { String tParam = getTurnType(next.getTurnType()); boolean isPlay = true; ExitInfo exitInfo = next.getExitInfo(); - String lang = player.getLanguage(); if (tParam != null) { - if (exitInfo != null) { - p.takeExit(tParam, dist, getSpeakableExitName(next, exitInfo, true)); - } else { - p.turn(tParam, dist, getSpeakableStreetName(currentSegment, next, true)); - } + p.turn(tParam, dist, getSpeakableStreetName(currentSegment, next, true)); +// if (exitInfo != null) { +// p.takeExit(tParam, dist, getSpeakableExitName(next, exitInfo, true)); +// } else { +// p.turn(tParam, dist, getSpeakableStreetName(currentSegment, next, true)); +// } suppressDest = true; } else if (next.getTurnType().isRoundAbout()) { p.roundAbout(dist, next.getTurnType().getTurnAngle(), next.getTurnType().getExitOut(), getSpeakableStreetName(currentSegment, next, true)); @@ -782,13 +782,13 @@ public class VoiceRouter { String tParam = getTurnType(next.getTurnType()); ExitInfo exitInfo = next.getExitInfo(); boolean isplay = true; - String lang = player.getLanguage(); if (tParam != null) { - if (exitInfo != null) { - p.takeExit(tParam, getSpeakableExitName(next, exitInfo, !suppressDest)); - } else { - p.turn(tParam, getSpeakableStreetName(currentSegment, next, !suppressDest)); - } + p.turn(tParam, getSpeakableStreetName(currentSegment, next, !suppressDest)); +// if (exitInfo != null) { +// p.takeExit(tParam, getSpeakableExitName(next, exitInfo, !suppressDest)); +// } else { +// p.turn(tParam, getSpeakableStreetName(currentSegment, next, !suppressDest)); +// } } else if (next.getTurnType().isRoundAbout()) { p.roundAbout(next.getTurnType().getTurnAngle(), next.getTurnType().getExitOut(), getSpeakableStreetName(currentSegment, next, !suppressDest)); } else if (next.getTurnType().getValue() == TurnType.TU || next.getTurnType().getValue() == TurnType.TRU) { diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java index 2752dc3dc3..7f9bac6381 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java @@ -913,13 +913,13 @@ public class MapInfoWidgetsFactory { public static class TopTextView { private final RoutingHelper routingHelper; private final MapActivity map; - private View topBar; - private TextView addressText; - private TextView addressTextShadow; - private TextView exitRefText; - private ImageView shieldIcon; - private ImageView turnIcon; - private OsmAndLocationProvider locationProvider; + private final View topBar; + private final TextView addressText; + private final TextView addressTextShadow; + private final TextView exitRefText; + private final ImageView shieldIcon; + private final ImageView turnIcon; + private final OsmAndLocationProvider locationProvider; private WaypointHelper waypointHelper; private OsmandSettings settings; private View waypointInfoBar; @@ -927,9 +927,12 @@ public class MapInfoWidgetsFactory { private TurnDrawable turnDrawable; private boolean showMarker; private int shadowRad; + RouteCalculationResult.NextDirectionInfo calc1; + private static final Log LOG = PlatformUtil.getLog(TopTextView.class); public TopTextView(OsmandApplication app, MapActivity map) { + turnDrawable = new NextTurnInfoWidget.TurnDrawable(map, true); topBar = map.findViewById(R.id.map_top_bar); addressText = (TextView) map.findViewById(R.id.map_address_text); addressTextShadow = (TextView) map.findViewById(R.id.map_address_text_shadow); @@ -943,7 +946,7 @@ public class MapInfoWidgetsFactory { settings = app.getSettings(); waypointHelper = app.getWaypointHelper(); updateVisibility(false); - turnDrawable = new NextTurnInfoWidget.TurnDrawable(map, true); + calc1 = new RouteCalculationResult.NextDirectionInfo(); } public boolean updateVisibility(boolean visible) { @@ -979,13 +982,15 @@ public class MapInfoWidgetsFactory { boolean showMarker = this.showMarker; boolean showExitInfo = false; boolean showShield = false; + boolean imminentTurn = false; ExitInfo exitInfo = null; RouteDataObject object = null; if (routingHelper != null && routingHelper.isRouteCalculated() && !routingHelper.isDeviatedFromRoute()) { if (routingHelper.isFollowingMode()) { if (settings.SHOW_STREET_NAME.get()) { - text = routingHelper.getCurrentName(type); + RouteCalculationResult.NextDirectionInfo nextDirInfo = routingHelper.getNextRouteDirectionInfo(calc1, true); + text = routingHelper.getCurrentName(type, nextDirInfo); if (text == null) { text = ""; } else { @@ -995,10 +1000,15 @@ public class MapInfoWidgetsFactory { turnDrawable.setColor(R.color.nav_arrow); } } - RouteCalculationResult.NextDirectionInfo nextDirInfo = routingHelper.getNextRouteDirectionInfo( - new RouteCalculationResult.NextDirectionInfo(), true); + RouteDirectionInfo directionInfo = nextDirInfo.directionInfo; + if (nextDirInfo.imminent >= 0) { + imminentTurn = true; + } else { + imminentTurn = false; + } + if (directionInfo != null && directionInfo.getExitInfo() != null) { exitInfo = directionInfo.getExitInfo(); showExitInfo = true; @@ -1072,19 +1082,15 @@ public class MapInfoWidgetsFactory { AndroidUiHelper.updateVisibility(addressTextShadow, shadowRad > 0); boolean update = turnDrawable.setTurnType(type[0]) || showMarker != this.showMarker; this.showMarker = showMarker; - if (showShield) { - if (setRoadShield(shieldIcon, object)) { - AndroidUiHelper.updateVisibility(shieldIcon, true); - } else { - AndroidUiHelper.updateVisibility(shieldIcon, false); - } + if (showShield && setRoadShield(shieldIcon, object)) { + AndroidUiHelper.updateVisibility(shieldIcon, true); } else { AndroidUiHelper.updateVisibility(shieldIcon, false); } if (showExitInfo) { String exitRef = exitInfo.getRef(); - if (!Algorithms.isEmpty(exitRef)) { + if (!Algorithms.isEmpty(exitRef) && imminentTurn) { exitRefText.setText(exitRef); AndroidUiHelper.updateVisibility(exitRefText, true); } else { @@ -1095,6 +1101,7 @@ public class MapInfoWidgetsFactory { } if (update) { if (type[0] != null) { + turnIcon.invalidateDrawable(turnDrawable); turnIcon.setImageDrawable(turnDrawable); AndroidUiHelper.updateVisibility(turnIcon, true); } else if (showMarker) {