Merge branch 'r3.7'
This commit is contained in:
commit
f79d06d133
3 changed files with 98 additions and 128 deletions
|
@ -203,8 +203,7 @@ public class MapPoiTypes {
|
|||
|
||||
public Map<String, PoiType> getAllTranslatedNames(boolean skipNonEditable) {
|
||||
Map<String, PoiType> translation = new HashMap<String, PoiType>();
|
||||
for (int i = 0; i < categories.size(); i++) {
|
||||
PoiCategory pc = categories.get(i);
|
||||
for (PoiCategory pc : categories) {
|
||||
if (skipNonEditable && pc.isNotEditableOsm()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -298,12 +297,18 @@ public class MapPoiTypes {
|
|||
if (!lastCategory.getKeyName().equals("Other")) {
|
||||
lastCategory.setTopVisible(true);
|
||||
}
|
||||
categories.add(lastCategory);
|
||||
addCategory(lastCategory);
|
||||
return lastCategory;
|
||||
}
|
||||
return otherCategory;
|
||||
}
|
||||
|
||||
private void addCategory(PoiCategory category) {
|
||||
List<PoiCategory> copy = new ArrayList<>(categories);
|
||||
copy.add(category);
|
||||
categories = copy;
|
||||
}
|
||||
|
||||
public PoiTranslator getPoiTranslator() {
|
||||
return poiTranslator;
|
||||
}
|
||||
|
@ -348,7 +353,7 @@ public class MapPoiTypes {
|
|||
final Map<String, PoiType> allTypes = new LinkedHashMap<String, PoiType>();
|
||||
final Map<String, List<PoiType>> categoryPoiAdditionalMap = new LinkedHashMap<String, List<PoiType>>();
|
||||
final Map<AbstractPoiType, Set<String>> abstractTypeAdditionalCategories = new LinkedHashMap<AbstractPoiType, Set<String>>();
|
||||
this.categories.clear();
|
||||
List<PoiCategory> categoriesList = new ArrayList<>();
|
||||
try {
|
||||
XmlPullParser parser = PlatformUtil.newXMLPullParser();
|
||||
int tok;
|
||||
|
@ -364,7 +369,7 @@ public class MapPoiTypes {
|
|||
if (tok == XmlPullParser.START_TAG) {
|
||||
String name = parser.getName();
|
||||
if (name.equals("poi_category")) {
|
||||
lastCategory = new PoiCategory(this, parser.getAttributeValue("", "name"), categories.size());
|
||||
lastCategory = new PoiCategory(this, parser.getAttributeValue("", "name"), categoriesList.size());
|
||||
lastCategory.setTopVisible(Boolean.parseBoolean(parser.getAttributeValue("", "top")));
|
||||
lastCategory.setNotEditableOsm("true".equals(parser.getAttributeValue("", "no_edit")));
|
||||
lastCategory.setDefaultTag(parser.getAttributeValue("", "default_tag"));
|
||||
|
@ -375,7 +380,7 @@ public class MapPoiTypes {
|
|||
lastCategory.addExcludedPoiAdditionalCategories(parser.getAttributeValue("", "excluded_poi_additional_category").split(","));
|
||||
lastCategoryPoiAdditionalsCategories.removeAll(lastCategory.getExcludedPoiAdditionalCategories());
|
||||
}
|
||||
categories.add(lastCategory);
|
||||
categoriesList.add(lastCategory);
|
||||
} else if (name.equals("poi_filter")) {
|
||||
PoiFilter tp = new PoiFilter(this, lastCategory, parser.getAttributeValue("", "name"));
|
||||
tp.setTopVisible(Boolean.parseBoolean(parser.getAttributeValue("", "top")));
|
||||
|
@ -477,6 +482,7 @@ public class MapPoiTypes {
|
|||
}
|
||||
}
|
||||
}
|
||||
categories = categoriesList;
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
log.error("Unexpected error", e); //$NON-NLS-1$
|
||||
|
|
|
@ -915,9 +915,6 @@ public class RoutingHelper {
|
|||
|
||||
|
||||
public static String formatStreetName(String name, String ref, String destination, String towards) {
|
||||
//Hardy, 2016-08-05:
|
||||
//Now returns: (ref) + ((" ")+name) + ((" ")+"toward "+dest) or ""
|
||||
|
||||
String formattedStreetName = "";
|
||||
if (ref != null && ref.length() > 0) {
|
||||
formattedStreetName = ref;
|
||||
|
@ -938,56 +935,78 @@ public class RoutingHelper {
|
|||
|
||||
}
|
||||
|
||||
// protected boolean isDistanceLess(float currentSpeed, double dist, double etalon, float defSpeed){
|
||||
// if(dist < etalon || ((dist / currentSpeed) < (etalon / defSpeed))){
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
|
||||
public synchronized String getCurrentName(TurnType[] next, NextDirectionInfo n){
|
||||
public static class CurrentStreetName {
|
||||
public String text;
|
||||
public TurnType turnType;
|
||||
public boolean showMarker; // turn type has priority over showMarker
|
||||
public RouteDataObject shieldObject;
|
||||
public String exitRef;
|
||||
}
|
||||
|
||||
public synchronized CurrentStreetName getCurrentName(NextDirectionInfo n){
|
||||
CurrentStreetName streetName = new CurrentStreetName();
|
||||
Location l = lastFixedLocation;
|
||||
float speed = 0;
|
||||
if(l != null && l.hasSpeed()) {
|
||||
if (l != null && l.hasSpeed()) {
|
||||
speed = l.getSpeed();
|
||||
}
|
||||
if(next != null && n.directionInfo != null) {
|
||||
next[0] = n.directionInfo.getTurnType();
|
||||
}
|
||||
if(n.distanceTo > 0 && n.directionInfo != null && !n.directionInfo.getTurnType().isSkipToSpeak() &&
|
||||
boolean isSet = false;
|
||||
// 1. turn is imminent
|
||||
if (n.distanceTo > 0 && n.directionInfo != null && !n.directionInfo.getTurnType().isSkipToSpeak() &&
|
||||
voiceRouter.isDistanceLess(speed, n.distanceTo, voiceRouter.PREPARE_DISTANCE * 0.75f)) {
|
||||
String nm = n.directionInfo.getStreetName();
|
||||
String rf = n.directionInfo.getRef();
|
||||
String dn = n.directionInfo.getDestinationName();
|
||||
|
||||
return formatStreetName(nm, null, dn, "»");
|
||||
}
|
||||
RouteSegmentResult rs = getCurrentSegmentResult();
|
||||
if(rs != null) {
|
||||
String name = getRouteSegmentStreetName(rs);
|
||||
if (!Algorithms.isEmpty(name)) {
|
||||
return name;
|
||||
isSet = !(Algorithms.isEmpty(nm) && Algorithms.isEmpty(rf) && Algorithms.isEmpty(dn));
|
||||
streetName.text = formatStreetName(nm, null, dn, "»");
|
||||
streetName.turnType = n.directionInfo.getTurnType();
|
||||
streetName.shieldObject = n.directionInfo.getRouteDataObject();
|
||||
if (streetName.turnType == null) {
|
||||
streetName.turnType = TurnType.valueOf(TurnType.C, false);
|
||||
}
|
||||
}
|
||||
rs = getNextStreetSegmentResult();
|
||||
if(rs != null) {
|
||||
String name = getRouteSegmentStreetName(rs);
|
||||
if (!Algorithms.isEmpty(name)) {
|
||||
if(next != null) {
|
||||
next[0] = TurnType.valueOf(TurnType.C, false);
|
||||
if (n.directionInfo.getExitInfo() != null) {
|
||||
streetName.exitRef = n.directionInfo.getExitInfo().getRef();
|
||||
if (!Algorithms.isEmpty(n.directionInfo.getExitInfo().getExitStreetName())) {
|
||||
streetName.text = n.directionInfo.getExitInfo().getExitStreetName();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
// 2. display current road street name
|
||||
if (!isSet) {
|
||||
RouteSegmentResult rs = getCurrentSegmentResult();
|
||||
if (rs != null) {
|
||||
streetName.text = getRouteSegmentStreetName(rs, false);
|
||||
if (Algorithms.isEmpty(streetName.text)) {
|
||||
isSet = !Algorithms.isEmpty(getRouteSegmentStreetName(rs, true));
|
||||
} else {
|
||||
isSet = true;
|
||||
}
|
||||
streetName.showMarker = true;
|
||||
streetName.shieldObject = rs.getObject();
|
||||
}
|
||||
}
|
||||
// 3. display next road street name if this one empty
|
||||
if (!isSet) {
|
||||
RouteSegmentResult rs = getNextStreetSegmentResult();
|
||||
if (rs != null) {
|
||||
streetName.text = getRouteSegmentStreetName(rs, false);
|
||||
streetName.turnType = TurnType.valueOf(TurnType.C, false);
|
||||
streetName.shieldObject = rs.getObject();
|
||||
}
|
||||
}
|
||||
if (streetName.turnType == null) {
|
||||
streetName.showMarker = true;
|
||||
}
|
||||
return streetName;
|
||||
}
|
||||
|
||||
private String getRouteSegmentStreetName(RouteSegmentResult rs) {
|
||||
private String getRouteSegmentStreetName(RouteSegmentResult rs, boolean includeRef) {
|
||||
String nm = rs.getObject().getName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get());
|
||||
// String rf = rs.getObject().getRef(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rs.isForwardDirection());
|
||||
String rf = rs.getObject().getRef(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rs.isForwardDirection());
|
||||
String dn = rs.getObject().getDestinationName(settings.MAP_PREFERRED_LOCALE.get(),
|
||||
settings.MAP_TRANSLITERATE_NAMES.get(), rs.isForwardDirection());
|
||||
return formatStreetName(nm, null, dn, "»");
|
||||
return formatStreetName(nm, includeRef ? rf : null, dn, "»");
|
||||
}
|
||||
|
||||
public RouteSegmentResult getCurrentSegmentResult() {
|
||||
|
|
|
@ -931,11 +931,11 @@ public class MapInfoWidgetsFactory {
|
|||
private View waypointInfoBar;
|
||||
private LocationPointWrapper lastPoint;
|
||||
private TurnDrawable turnDrawable;
|
||||
private boolean showMarker;
|
||||
private int shadowRad;
|
||||
RouteCalculationResult.NextDirectionInfo calc1;
|
||||
|
||||
private static final Log LOG = PlatformUtil.getLog(TopTextView.class);
|
||||
private boolean showMarker;
|
||||
|
||||
public TopTextView(OsmandApplication app, MapActivity map) {
|
||||
turnDrawable = new NextTurnInfoWidget.TurnDrawable(map, true);
|
||||
|
@ -981,138 +981,80 @@ public class MapInfoWidgetsFactory {
|
|||
}
|
||||
|
||||
|
||||
public boolean updateInfo(DrawSettings d) {
|
||||
String text = null;
|
||||
TurnType[] type = new TurnType[1];
|
||||
boolean showNextTurn = false;
|
||||
boolean showMarker = this.showMarker;
|
||||
boolean showExitInfo = false;
|
||||
boolean showShield = false;
|
||||
boolean imminentTurn = false;
|
||||
ExitInfo exitInfo = null;
|
||||
RouteDataObject object = null;
|
||||
|
||||
public boolean updateInfo(DrawSettings d) {
|
||||
RoutingHelper.CurrentStreetName streetName = null;
|
||||
boolean showClosestWaypointFirstInAddress = true;
|
||||
if (routingHelper != null && routingHelper.isRouteCalculated() && !routingHelper.isDeviatedFromRoute()) {
|
||||
if (routingHelper.isFollowingMode()) {
|
||||
if (settings.SHOW_STREET_NAME.get()) {
|
||||
RouteCalculationResult.NextDirectionInfo nextDirInfo = routingHelper.getNextRouteDirectionInfo(calc1, true);
|
||||
text = routingHelper.getCurrentName(type, nextDirInfo);
|
||||
if (text == null) {
|
||||
text = "";
|
||||
} else {
|
||||
if (type[0] == null) {
|
||||
showMarker = true;
|
||||
} else {
|
||||
turnDrawable.setColor(R.color.nav_arrow);
|
||||
}
|
||||
}
|
||||
|
||||
RouteDirectionInfo directionInfo = nextDirInfo.directionInfo;
|
||||
|
||||
if (nextDirInfo.imminent >= 0) {
|
||||
imminentTurn = true;
|
||||
} else {
|
||||
imminentTurn = false;
|
||||
}
|
||||
|
||||
if (directionInfo != null && directionInfo.getExitInfo() != null) {
|
||||
exitInfo = directionInfo.getExitInfo();
|
||||
showExitInfo = true;
|
||||
} else {
|
||||
showExitInfo = false;
|
||||
}
|
||||
|
||||
if (showExitInfo) {
|
||||
if(!Algorithms.isEmpty(exitInfo.getExitStreetName())) {
|
||||
text = exitInfo.getExitStreetName();
|
||||
}
|
||||
}
|
||||
|
||||
if (directionInfo != null && directionInfo.getRouteDataObject() != null) {
|
||||
object = directionInfo.getRouteDataObject();
|
||||
showShield = true;
|
||||
}
|
||||
streetName = routingHelper.getCurrentName(nextDirInfo);
|
||||
turnDrawable.setColor(R.color.nav_arrow);
|
||||
}
|
||||
} else {
|
||||
int di = MapRouteInfoMenu.getDirectionInfo();
|
||||
if (di >= 0 && map.getMapRouteInfoMenu().isVisible() &&
|
||||
di < routingHelper.getRouteDirections().size()) {
|
||||
showNextTurn = true;
|
||||
if (di >= 0 && map.getMapRouteInfoMenu().isVisible() && di < routingHelper.getRouteDirections().size()) {
|
||||
showClosestWaypointFirstInAddress = false;
|
||||
RouteDirectionInfo next = routingHelper.getRouteDirections().get(di);
|
||||
type[0] = next.getTurnType();
|
||||
streetName = routingHelper.getCurrentName(routingHelper.getNextRouteDirectionInfo(calc1, true));
|
||||
turnDrawable.setColor(R.color.nav_arrow_distant);
|
||||
text = RoutingHelper.formatStreetName(next.getStreetName(), null, next.getDestinationName(), "»");
|
||||
if (text == null) {
|
||||
text = "";
|
||||
}
|
||||
} else {
|
||||
text = null;
|
||||
}
|
||||
}
|
||||
} else if (map.getMapViewTrackingUtilities().isMapLinkedToLocation() &&
|
||||
settings.SHOW_STREET_NAME.get()) {
|
||||
streetName = new RoutingHelper.CurrentStreetName();
|
||||
RouteDataObject rt = locationProvider.getLastKnownRouteSegment();
|
||||
if (rt != null) {
|
||||
Location lastKnownLocation = locationProvider.getLastKnownLocation();
|
||||
text = RoutingHelper.formatStreetName(
|
||||
streetName.text = RoutingHelper.formatStreetName(
|
||||
rt.getName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get()),
|
||||
rt.getRef(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rt.bearingVsRouteDirection(lastKnownLocation)),
|
||||
rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rt.bearingVsRouteDirection(lastKnownLocation)),
|
||||
"»");
|
||||
}
|
||||
if (text == null) {
|
||||
text = "";
|
||||
} else {
|
||||
Location lastKnownLocation = locationProvider.getLastKnownLocation();
|
||||
if (!Algorithms.isEmpty(text) && lastKnownLocation != null) {
|
||||
double dist =
|
||||
CurrentPositionHelper.getOrthogonalDistance(rt, lastKnownLocation);
|
||||
if (!Algorithms.isEmpty(streetName.text) && lastKnownLocation != null) {
|
||||
double dist = CurrentPositionHelper.getOrthogonalDistance(rt, lastKnownLocation);
|
||||
if (dist < 50) {
|
||||
showMarker = true;
|
||||
streetName.showMarker = true;
|
||||
} else {
|
||||
text = map.getResources().getString(R.string.shared_string_near) + " " + text;
|
||||
streetName.text = map.getResources().getString(R.string.shared_string_near) + " " + streetName.text;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (map.isTopToolbarActive() || !map.getContextMenu().shouldShowTopControls() || MapRouteInfoMenu.chooseRoutesVisible || MapRouteInfoMenu.waypointsVisible) {
|
||||
updateVisibility(false);
|
||||
} else if (!showNextTurn && updateWaypoint()) {
|
||||
} else if (!showClosestWaypointFirstInAddress && updateWaypoint()) {
|
||||
updateVisibility(true);
|
||||
AndroidUiHelper.updateVisibility(addressText, false);
|
||||
AndroidUiHelper.updateVisibility(addressTextShadow, false);
|
||||
} else if (text == null) {
|
||||
} else if (streetName == null) {
|
||||
updateVisibility(false);
|
||||
} else {
|
||||
updateVisibility(true);
|
||||
AndroidUiHelper.updateVisibility(waypointInfoBar, false);
|
||||
AndroidUiHelper.updateVisibility(addressText, true);
|
||||
AndroidUiHelper.updateVisibility(addressTextShadow, shadowRad > 0);
|
||||
boolean update = turnDrawable.setTurnType(type[0]) || showMarker != this.showMarker;
|
||||
this.showMarker = showMarker;
|
||||
if (showShield && setRoadShield(shieldIcon, object)) {
|
||||
|
||||
if (streetName.shieldObject != null && setRoadShield(shieldIcon, streetName.shieldObject)) {
|
||||
AndroidUiHelper.updateVisibility(shieldIcon, true);
|
||||
} else {
|
||||
AndroidUiHelper.updateVisibility(shieldIcon, false);
|
||||
}
|
||||
|
||||
if (showExitInfo) {
|
||||
String exitRef = exitInfo.getRef();
|
||||
if (!Algorithms.isEmpty(exitRef) && imminentTurn) {
|
||||
exitRefText.setText(exitRef);
|
||||
AndroidUiHelper.updateVisibility(exitRefText, true);
|
||||
} else {
|
||||
AndroidUiHelper.updateVisibility(exitRefText, false);
|
||||
}
|
||||
if (!Algorithms.isEmpty(streetName.exitRef) ) {
|
||||
exitRefText.setText(streetName.exitRef);
|
||||
AndroidUiHelper.updateVisibility(exitRefText, true);
|
||||
} else {
|
||||
AndroidUiHelper.updateVisibility(exitRefText, false);
|
||||
}
|
||||
if (update) {
|
||||
if (type[0] != null) {
|
||||
if (turnDrawable.setTurnType(streetName.turnType) || streetName.showMarker != this.showMarker) {
|
||||
this.showMarker = streetName.showMarker;
|
||||
if (streetName.turnType != null) {
|
||||
turnIcon.invalidateDrawable(turnDrawable);
|
||||
turnIcon.setImageDrawable(turnDrawable);
|
||||
AndroidUiHelper.updateVisibility(turnIcon, true);
|
||||
} else if (showMarker) {
|
||||
} else if (streetName.showMarker) {
|
||||
Drawable marker = map.getMyApplication().getUIUtilities().getIcon(R.drawable.ic_action_start_navigation, R.color.color_myloc_distance);
|
||||
turnIcon.setImageDrawable(marker);
|
||||
AndroidUiHelper.updateVisibility(turnIcon, true);
|
||||
|
@ -1120,9 +1062,12 @@ public class MapInfoWidgetsFactory {
|
|||
AndroidUiHelper.updateVisibility(turnIcon, false);
|
||||
}
|
||||
}
|
||||
if (!text.equals(addressText.getText().toString())) {
|
||||
addressTextShadow.setText(text);
|
||||
addressText.setText(text);
|
||||
if(streetName.text == null || streetName.text.isEmpty()) {
|
||||
addressTextShadow.setText("");
|
||||
addressText.setText("");
|
||||
} else if (!streetName.text.equals(addressText.getText().toString())) {
|
||||
addressTextShadow.setText(streetName.text);
|
||||
addressText.setText(streetName.text );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue