Update osmand application

This commit is contained in:
vshcherb 2013-11-24 19:45:00 +01:00
parent 8fe2a7df62
commit 99f2d38483
4 changed files with 47 additions and 40 deletions

View file

@ -7,6 +7,11 @@ import java.util.Map;
public class Amenity extends MapObject {
public static final String WEBSITE = "website";
public static final String PHONE = "phone";
public static final String DESCRIPTION = "description";
public static final String OPENING_HOURS = "opening_hours";
private static final long serialVersionUID = 132083949926339552L;
private String subType;
private AmenityType type;
@ -54,7 +59,7 @@ public class Amenity extends MapObject {
public void setAdditionalInfo(Map<String, String> additionalInfo) {
this.additionalInfo = additionalInfo;
openingHours = additionalInfo.get("opening_hours");
openingHours = additionalInfo.get(OPENING_HOURS);
}
@ -63,7 +68,7 @@ public class Amenity extends MapObject {
this.additionalInfo = new LinkedHashMap<String, String>();
}
this.additionalInfo.put(tag, value);
if("opening_hours".equals(tag)) {
if(OPENING_HOURS.equals(tag)) {
this.openingHours = value;
}
}
@ -75,31 +80,31 @@ public class Amenity extends MapObject {
}
public String getSite() {
return getAdditionalInfo("website");
return getAdditionalInfo(WEBSITE);
}
public void setSite(String site) {
setAdditionalInfo("website", site);
setAdditionalInfo(WEBSITE, site);
}
public String getPhone() {
return getAdditionalInfo("phone");
return getAdditionalInfo(PHONE);
}
public void setPhone(String phone) {
setAdditionalInfo("phone", phone);
setAdditionalInfo(PHONE, phone);
}
public String getDescription() {
return getAdditionalInfo("description");
return getAdditionalInfo(DESCRIPTION);
}
public void setDescription(String description) {
setAdditionalInfo("description", description);
setAdditionalInfo(DESCRIPTION, description);
}
public void setOpeningHours(String openingHours) {
setAdditionalInfo("opening_hours", openingHours);
setAdditionalInfo(OPENING_HOURS, openingHours);
}

View file

@ -2,6 +2,7 @@ package net.osmand.plus;
import java.lang.reflect.Field;
import java.text.MessageFormat;
import java.util.Map.Entry;
import net.osmand.data.Amenity;
import net.osmand.data.AmenityType;
@ -126,6 +127,8 @@ public class OsmAndFormatter {
return ctx.getString(R.string.city_type_village);
case SUBURB:
return ctx.getString(R.string.city_type_suburb);
default:
break;
}
return "";
}
@ -162,4 +165,26 @@ public class OsmAndFormatter {
}
return type + " " + n; //$NON-NLS-1$
}
public static String getAmenityDescriptionContent(ClientContext ctx, Amenity amenity) {
StringBuilder d = new StringBuilder();
for(Entry<String, String> e : amenity.getAdditionalInfo().entrySet()) {
String key = e.getKey();
if(Amenity.DESCRIPTION.equals(key)) {
} else if(Amenity.OPENING_HOURS.equals(key)) {
d.append(ctx.getString(R.string.opening_hours) + " : ");
} else if(Amenity.PHONE.equals(key)) {
d.append(ctx.getString(R.string.phone) + " : ");
} else if(Amenity.WEBSITE.equals(key)) {
if(amenity.getType() == AmenityType.OSMWIKI) {
continue;
}
d.append(ctx.getString(R.string.website) + " : ");
} else {
d.append(e.getKey() + " : ");
}
d.append(e.getValue()).append('\n');
}
return d.toString().trim();
}
}

View file

@ -555,7 +555,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
ActionItem poiDescription = new ActionItem();
poiDescription.setIcon(getResources().getDrawable(R.drawable.ic_action_note_light));
poiDescription.setTitle(getString(R.string.poi_context_menu_showdescription));
final StringBuilder d = getDescriptionContent(amenity);
final String d = getDescriptionContent(amenity);
poiDescription.setOnClickListener(new OnClickListener() {
@Override
@ -600,21 +600,8 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
}
private StringBuilder getDescriptionContent(final Amenity amenity) {
StringBuilder d = new StringBuilder();
if(amenity.getOpeningHours() != null) {
d.append(getString(R.string.opening_hours) + " : ").append(amenity.getOpeningHours()).append("\n");
}
if(amenity.getPhone() != null) {
d.append(getString(R.string.phone) + " : ").append(amenity.getPhone()).append("\n");
}
if(amenity.getSite() != null) {
d.append(getString(R.string.website) + " : ").append(amenity.getSite()).append("\n");
}
if(amenity.getDescription() != null) {
d.append(amenity.getDescription());
}
return d;
private String getDescriptionContent(final Amenity amenity) {
return OsmAndFormatter.getAmenityDescriptionContent(getMyApplication(), amenity);
}
@ -889,10 +876,10 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
String direction = navigationInfo.getDirectionString(amenity.getLocation(), heading);
if (direction != null)
attributes.add(direction);
if (amenity.getPhone() != null)
attributes.add(getString(R.string.phone) + " " + amenity.getPhone());
if (amenity.getOpeningHours() != null)
attributes.add(getString(R.string.opening_hours) + " " + amenity.getOpeningHours());
String[] as = OsmAndFormatter.getAmenityDescriptionContent(getMyApplication(), amenity).split("\n");
for(String s: as) {
attributes.add(s.replace(':', ' '));
}
attributes.add(getString(R.string.navigate_point_latitude) + " " + Double.toString(amenity.getLocation().getLatitude()));
attributes.add(getString(R.string.navigate_point_longitude) + " " + Double.toString(amenity.getLocation().getLongitude()));
b.setItems(attributes.toArray(new String[attributes.size()]),

View file

@ -8,7 +8,6 @@ import java.util.List;
import net.osmand.PlatformUtil;
import net.osmand.access.AccessibleToast;
import net.osmand.data.Amenity;
import net.osmand.data.AmenityType;
import net.osmand.data.LatLon;
import net.osmand.data.QuadRect;
import net.osmand.data.RotatedTileBox;
@ -111,16 +110,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
private StringBuilder buildPoiInformation(StringBuilder res, Amenity n) {
String format = OsmAndFormatter.getPoiSimpleFormat(n, view.getApplication(), view.getSettings().USE_ENGLISH_NAMES.get());
res.append(" " + format);
if (n.getOpeningHours() != null) {
res.append("\n").append(view.getContext().getString(R.string.opening_hours)).append(" : ").append(n.getOpeningHours()); //$NON-NLS-1$ //$NON-NLS-2$
}
if (n.getPhone() != null) {
res.append("\n").append(view.getContext().getString(R.string.phone)).append(" : ").append(n.getPhone()); //$NON-NLS-1$ //$NON-NLS-2$
}
if (n.getSite() != null && n.getType() != AmenityType.OSMWIKI) {
res.append("\n").append(view.getContext().getString(R.string.website)).append(" : ").append(n.getSite()); //$NON-NLS-1$ //$NON-NLS-2$
}
res.append(" " + format + "\n" + OsmAndFormatter.getAmenityDescriptionContent(view.getApplication(), n));
return res;
}