Merge pull request #8223 from osmandapp/exit_and_shield_widget
Exit and shield widget
This commit is contained in:
commit
1d4944b09e
4 changed files with 44 additions and 37 deletions
|
@ -317,7 +317,7 @@ public class TextRenderer {
|
||||||
float coef = rc.getDensityValue(rc.screenDensityRatio * rc.textScale);
|
float coef = rc.getDensityValue(rc.screenDensityRatio * rc.textScale);
|
||||||
Bitmap ico = RenderingIcons.getIcon(context, sr, true);
|
Bitmap ico = RenderingIcons.getIcon(context, sr, true);
|
||||||
if (ico != null) {
|
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;
|
float top = text.centerY - ico.getHeight() / 2 * coef - paintText.descent() * 1.5f;
|
||||||
if(rc.screenDensityRatio != 1f){
|
if(rc.screenDensityRatio != 1f){
|
||||||
RectF rf = new RectF(left, top, left + ico.getWidth() * coef,
|
RectF rf = new RectF(left, top, left + ico.getWidth() * coef,
|
||||||
|
|
|
@ -834,21 +834,21 @@ public class RoutingHelper {
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public synchronized String getCurrentName(TurnType[] next){
|
public synchronized String getCurrentName(TurnType[] next, NextDirectionInfo n){
|
||||||
NextDirectionInfo n = getNextRouteDirectionInfo(new NextDirectionInfo(), true);
|
|
||||||
Location l = lastFixedLocation;
|
Location l = lastFixedLocation;
|
||||||
float speed = 0;
|
float speed = 0;
|
||||||
if(l != null && l.hasSpeed()) {
|
if(l != null && l.hasSpeed()) {
|
||||||
speed = l.getSpeed();
|
speed = l.getSpeed();
|
||||||
}
|
}
|
||||||
|
if(next != null) {
|
||||||
|
next[0] = n.directionInfo.getTurnType();
|
||||||
|
}
|
||||||
if(n.distanceTo > 0 && n.directionInfo != null && !n.directionInfo.getTurnType().isSkipToSpeak() &&
|
if(n.distanceTo > 0 && n.directionInfo != null && !n.directionInfo.getTurnType().isSkipToSpeak() &&
|
||||||
voiceRouter.isDistanceLess(speed, n.distanceTo, voiceRouter.PREPARE_DISTANCE * 0.75f, 0f)) {
|
voiceRouter.isDistanceLess(speed, n.distanceTo, voiceRouter.PREPARE_DISTANCE * 0.75f, 0f)) {
|
||||||
String nm = n.directionInfo.getStreetName();
|
String nm = n.directionInfo.getStreetName();
|
||||||
// String rf = n.directionInfo.getRef();
|
String rf = n.directionInfo.getRef();
|
||||||
String dn = n.directionInfo.getDestinationName();
|
String dn = n.directionInfo.getDestinationName();
|
||||||
if(next != null) {
|
|
||||||
next[0] = n.directionInfo.getTurnType();
|
|
||||||
}
|
|
||||||
return formatStreetName(nm, null, dn, "»");
|
return formatStreetName(nm, null, dn, "»");
|
||||||
}
|
}
|
||||||
RouteSegmentResult rs = getCurrentSegmentResult();
|
RouteSegmentResult rs = getCurrentSegmentResult();
|
||||||
|
|
|
@ -708,13 +708,13 @@ public class VoiceRouter {
|
||||||
String tParam = getTurnType(next.getTurnType());
|
String tParam = getTurnType(next.getTurnType());
|
||||||
boolean isPlay = true;
|
boolean isPlay = true;
|
||||||
ExitInfo exitInfo = next.getExitInfo();
|
ExitInfo exitInfo = next.getExitInfo();
|
||||||
String lang = player.getLanguage();
|
|
||||||
if (tParam != null) {
|
if (tParam != null) {
|
||||||
if (exitInfo != null) {
|
p.turn(tParam, dist, getSpeakableStreetName(currentSegment, next, true));
|
||||||
p.takeExit(tParam, dist, getSpeakableExitName(next, exitInfo, true));
|
// if (exitInfo != null) {
|
||||||
} else {
|
// p.takeExit(tParam, dist, getSpeakableExitName(next, exitInfo, true));
|
||||||
p.turn(tParam, dist, getSpeakableStreetName(currentSegment, next, true));
|
// } else {
|
||||||
}
|
// p.turn(tParam, dist, getSpeakableStreetName(currentSegment, next, true));
|
||||||
|
// }
|
||||||
suppressDest = true;
|
suppressDest = true;
|
||||||
} else if (next.getTurnType().isRoundAbout()) {
|
} else if (next.getTurnType().isRoundAbout()) {
|
||||||
p.roundAbout(dist, next.getTurnType().getTurnAngle(), next.getTurnType().getExitOut(), getSpeakableStreetName(currentSegment, next, true));
|
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());
|
String tParam = getTurnType(next.getTurnType());
|
||||||
ExitInfo exitInfo = next.getExitInfo();
|
ExitInfo exitInfo = next.getExitInfo();
|
||||||
boolean isplay = true;
|
boolean isplay = true;
|
||||||
String lang = player.getLanguage();
|
|
||||||
if (tParam != null) {
|
if (tParam != null) {
|
||||||
if (exitInfo != null) {
|
p.turn(tParam, getSpeakableStreetName(currentSegment, next, !suppressDest));
|
||||||
p.takeExit(tParam, getSpeakableExitName(next, exitInfo, !suppressDest));
|
// if (exitInfo != null) {
|
||||||
} else {
|
// p.takeExit(tParam, getSpeakableExitName(next, exitInfo, !suppressDest));
|
||||||
p.turn(tParam, getSpeakableStreetName(currentSegment, next, !suppressDest));
|
// } else {
|
||||||
}
|
// p.turn(tParam, getSpeakableStreetName(currentSegment, next, !suppressDest));
|
||||||
|
// }
|
||||||
} else if (next.getTurnType().isRoundAbout()) {
|
} else if (next.getTurnType().isRoundAbout()) {
|
||||||
p.roundAbout(next.getTurnType().getTurnAngle(), next.getTurnType().getExitOut(), getSpeakableStreetName(currentSegment, next, !suppressDest));
|
p.roundAbout(next.getTurnType().getTurnAngle(), next.getTurnType().getExitOut(), getSpeakableStreetName(currentSegment, next, !suppressDest));
|
||||||
} else if (next.getTurnType().getValue() == TurnType.TU || next.getTurnType().getValue() == TurnType.TRU) {
|
} else if (next.getTurnType().getValue() == TurnType.TU || next.getTurnType().getValue() == TurnType.TRU) {
|
||||||
|
|
|
@ -913,13 +913,13 @@ public class MapInfoWidgetsFactory {
|
||||||
public static class TopTextView {
|
public static class TopTextView {
|
||||||
private final RoutingHelper routingHelper;
|
private final RoutingHelper routingHelper;
|
||||||
private final MapActivity map;
|
private final MapActivity map;
|
||||||
private View topBar;
|
private final View topBar;
|
||||||
private TextView addressText;
|
private final TextView addressText;
|
||||||
private TextView addressTextShadow;
|
private final TextView addressTextShadow;
|
||||||
private TextView exitRefText;
|
private final TextView exitRefText;
|
||||||
private ImageView shieldIcon;
|
private final ImageView shieldIcon;
|
||||||
private ImageView turnIcon;
|
private final ImageView turnIcon;
|
||||||
private OsmAndLocationProvider locationProvider;
|
private final OsmAndLocationProvider locationProvider;
|
||||||
private WaypointHelper waypointHelper;
|
private WaypointHelper waypointHelper;
|
||||||
private OsmandSettings settings;
|
private OsmandSettings settings;
|
||||||
private View waypointInfoBar;
|
private View waypointInfoBar;
|
||||||
|
@ -927,9 +927,12 @@ public class MapInfoWidgetsFactory {
|
||||||
private TurnDrawable turnDrawable;
|
private TurnDrawable turnDrawable;
|
||||||
private boolean showMarker;
|
private boolean showMarker;
|
||||||
private int shadowRad;
|
private int shadowRad;
|
||||||
|
RouteCalculationResult.NextDirectionInfo calc1;
|
||||||
|
|
||||||
private static final Log LOG = PlatformUtil.getLog(TopTextView.class);
|
private static final Log LOG = PlatformUtil.getLog(TopTextView.class);
|
||||||
|
|
||||||
public TopTextView(OsmandApplication app, MapActivity map) {
|
public TopTextView(OsmandApplication app, MapActivity map) {
|
||||||
|
turnDrawable = new NextTurnInfoWidget.TurnDrawable(map, true);
|
||||||
topBar = map.findViewById(R.id.map_top_bar);
|
topBar = map.findViewById(R.id.map_top_bar);
|
||||||
addressText = (TextView) map.findViewById(R.id.map_address_text);
|
addressText = (TextView) map.findViewById(R.id.map_address_text);
|
||||||
addressTextShadow = (TextView) map.findViewById(R.id.map_address_text_shadow);
|
addressTextShadow = (TextView) map.findViewById(R.id.map_address_text_shadow);
|
||||||
|
@ -943,7 +946,7 @@ public class MapInfoWidgetsFactory {
|
||||||
settings = app.getSettings();
|
settings = app.getSettings();
|
||||||
waypointHelper = app.getWaypointHelper();
|
waypointHelper = app.getWaypointHelper();
|
||||||
updateVisibility(false);
|
updateVisibility(false);
|
||||||
turnDrawable = new NextTurnInfoWidget.TurnDrawable(map, true);
|
calc1 = new RouteCalculationResult.NextDirectionInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateVisibility(boolean visible) {
|
public boolean updateVisibility(boolean visible) {
|
||||||
|
@ -979,13 +982,15 @@ public class MapInfoWidgetsFactory {
|
||||||
boolean showMarker = this.showMarker;
|
boolean showMarker = this.showMarker;
|
||||||
boolean showExitInfo = false;
|
boolean showExitInfo = false;
|
||||||
boolean showShield = false;
|
boolean showShield = false;
|
||||||
|
boolean imminentTurn = false;
|
||||||
ExitInfo exitInfo = null;
|
ExitInfo exitInfo = null;
|
||||||
RouteDataObject object = null;
|
RouteDataObject object = null;
|
||||||
|
|
||||||
if (routingHelper != null && routingHelper.isRouteCalculated() && !routingHelper.isDeviatedFromRoute()) {
|
if (routingHelper != null && routingHelper.isRouteCalculated() && !routingHelper.isDeviatedFromRoute()) {
|
||||||
if (routingHelper.isFollowingMode()) {
|
if (routingHelper.isFollowingMode()) {
|
||||||
if (settings.SHOW_STREET_NAME.get()) {
|
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) {
|
if (text == null) {
|
||||||
text = "";
|
text = "";
|
||||||
} else {
|
} else {
|
||||||
|
@ -995,10 +1000,15 @@ public class MapInfoWidgetsFactory {
|
||||||
turnDrawable.setColor(R.color.nav_arrow);
|
turnDrawable.setColor(R.color.nav_arrow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RouteCalculationResult.NextDirectionInfo nextDirInfo = routingHelper.getNextRouteDirectionInfo(
|
|
||||||
new RouteCalculationResult.NextDirectionInfo(), true);
|
|
||||||
RouteDirectionInfo directionInfo = nextDirInfo.directionInfo;
|
RouteDirectionInfo directionInfo = nextDirInfo.directionInfo;
|
||||||
|
|
||||||
|
if (nextDirInfo.imminent >= 0) {
|
||||||
|
imminentTurn = true;
|
||||||
|
} else {
|
||||||
|
imminentTurn = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (directionInfo != null && directionInfo.getExitInfo() != null) {
|
if (directionInfo != null && directionInfo.getExitInfo() != null) {
|
||||||
exitInfo = directionInfo.getExitInfo();
|
exitInfo = directionInfo.getExitInfo();
|
||||||
showExitInfo = true;
|
showExitInfo = true;
|
||||||
|
@ -1072,19 +1082,15 @@ public class MapInfoWidgetsFactory {
|
||||||
AndroidUiHelper.updateVisibility(addressTextShadow, shadowRad > 0);
|
AndroidUiHelper.updateVisibility(addressTextShadow, shadowRad > 0);
|
||||||
boolean update = turnDrawable.setTurnType(type[0]) || showMarker != this.showMarker;
|
boolean update = turnDrawable.setTurnType(type[0]) || showMarker != this.showMarker;
|
||||||
this.showMarker = showMarker;
|
this.showMarker = showMarker;
|
||||||
if (showShield) {
|
if (showShield && setRoadShield(shieldIcon, object)) {
|
||||||
if (setRoadShield(shieldIcon, object)) {
|
AndroidUiHelper.updateVisibility(shieldIcon, true);
|
||||||
AndroidUiHelper.updateVisibility(shieldIcon, true);
|
|
||||||
} else {
|
|
||||||
AndroidUiHelper.updateVisibility(shieldIcon, false);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
AndroidUiHelper.updateVisibility(shieldIcon, false);
|
AndroidUiHelper.updateVisibility(shieldIcon, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showExitInfo) {
|
if (showExitInfo) {
|
||||||
String exitRef = exitInfo.getRef();
|
String exitRef = exitInfo.getRef();
|
||||||
if (!Algorithms.isEmpty(exitRef)) {
|
if (!Algorithms.isEmpty(exitRef) && imminentTurn) {
|
||||||
exitRefText.setText(exitRef);
|
exitRefText.setText(exitRef);
|
||||||
AndroidUiHelper.updateVisibility(exitRefText, true);
|
AndroidUiHelper.updateVisibility(exitRefText, true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1095,6 +1101,7 @@ public class MapInfoWidgetsFactory {
|
||||||
}
|
}
|
||||||
if (update) {
|
if (update) {
|
||||||
if (type[0] != null) {
|
if (type[0] != null) {
|
||||||
|
turnIcon.invalidateDrawable(turnDrawable);
|
||||||
turnIcon.setImageDrawable(turnDrawable);
|
turnIcon.setImageDrawable(turnDrawable);
|
||||||
AndroidUiHelper.updateVisibility(turnIcon, true);
|
AndroidUiHelper.updateVisibility(turnIcon, true);
|
||||||
} else if (showMarker) {
|
} else if (showMarker) {
|
||||||
|
|
Loading…
Reference in a new issue