Fix poi description
This commit is contained in:
parent
380f0e08e5
commit
63417876f3
4 changed files with 24 additions and 22 deletions
|
@ -68,6 +68,11 @@ public class Amenity extends MapObject {
|
|||
return null;
|
||||
}
|
||||
String str = additionalInfo.get(key);
|
||||
str = unzipContent(str);
|
||||
return str;
|
||||
}
|
||||
|
||||
public String unzipContent(String str) {
|
||||
if (str != null) {
|
||||
if (str.startsWith(" gz ")) {
|
||||
try {
|
||||
|
@ -164,9 +169,6 @@ public class Amenity extends MapObject {
|
|||
return lang;
|
||||
}
|
||||
}
|
||||
if (!Algorithms.isEmpty(getName())) {
|
||||
return "";
|
||||
}
|
||||
for (String nm : getAdditionalInfo().keySet()) {
|
||||
if (nm.startsWith("name:")) {
|
||||
return nm.substring("name:".length());
|
||||
|
@ -187,7 +189,7 @@ public class Amenity extends MapObject {
|
|||
return translateName;
|
||||
}
|
||||
}
|
||||
if (!Algorithms.isEmpty(getName())) {
|
||||
if(!Algorithms.isEmpty(getName())) {
|
||||
return getName();
|
||||
}
|
||||
for (String nm : getAdditionalInfo().keySet()) {
|
||||
|
@ -198,17 +200,13 @@ public class Amenity extends MapObject {
|
|||
return "";
|
||||
}
|
||||
|
||||
public List<String> getNames(String defName) {
|
||||
public List<String> getNames(String tag) {
|
||||
List<String> l = new ArrayList<String>();
|
||||
if (!Algorithms.isEmpty(getName())) {
|
||||
l.add(defName);
|
||||
}
|
||||
for (String nm : getAdditionalInfo().keySet()) {
|
||||
if (nm.startsWith("name:")) {
|
||||
l.add(nm.substring("name:".length()));
|
||||
if (nm.startsWith(tag+":")) {
|
||||
l.add(nm.substring(tag.length() +1));
|
||||
}
|
||||
}
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
|
|
|
@ -185,6 +185,9 @@ public class OsmAndFormatter {
|
|||
|
||||
public static String getAmenityDescriptionContent(Context ctx, Amenity amenity, boolean shortDescription) {
|
||||
StringBuilder d = new StringBuilder();
|
||||
if(amenity.getType().isWiki()) {
|
||||
return "";
|
||||
}
|
||||
for(Entry<String, String> e : amenity.getAdditionalInfo().entrySet()) {
|
||||
String key = e.getKey();
|
||||
String vl = e.getValue();
|
||||
|
@ -199,9 +202,7 @@ public class OsmAndFormatter {
|
|||
} else if(Amenity.PHONE.equals(key)) {
|
||||
d.append(ctx.getString(R.string.phone) + ": ");
|
||||
} else if(Amenity.WEBSITE.equals(key)) {
|
||||
if(amenity.getType().isWiki()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
d.append(ctx.getString(R.string.website) + ": ");
|
||||
} else {
|
||||
PoiCategory pc = amenity.getType();
|
||||
|
@ -211,7 +212,7 @@ public class OsmAndFormatter {
|
|||
} else {
|
||||
vl = Algorithms.capitalizeFirstLetterAndLowercase(e.getKey());
|
||||
}
|
||||
vl += ": " + e.getValue();
|
||||
vl += ": " + amenity.unzipContent(e.getValue());
|
||||
}
|
||||
d.append(vl).append('\n');
|
||||
}
|
||||
|
|
|
@ -554,7 +554,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
DirectionsDialogs.createDirectionsActionsPopUpMenu(optionsMenu, amenity.getLocation(), amenity, name, z, this,
|
||||
true);
|
||||
final String d = OsmAndFormatter.getAmenityDescriptionContent(getMyApplication(), amenity, false);
|
||||
if (d.toString().trim().length() > 0) {
|
||||
if (d.toString().trim().length() > 0 || amenity.getType().isWiki()) {
|
||||
MenuItem item = optionsMenu
|
||||
.getMenu()
|
||||
.add(R.string.poi_context_menu_showdescription)
|
||||
|
|
|
@ -3,6 +3,8 @@ package net.osmand.plus.views;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.ResultMatcher;
|
||||
|
@ -321,7 +323,8 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
|||
return true;
|
||||
}
|
||||
};
|
||||
if (OsmAndFormatter.getAmenityDescriptionContent(view.getApplication(), a, false).length() > 0) {
|
||||
if (OsmAndFormatter.getAmenityDescriptionContent(view.getApplication(), a, false).length() > 0 ||
|
||||
a.getType().isWiki()) {
|
||||
adapter.item(R.string.poi_context_menu_showdescription)
|
||||
.iconColor(R.drawable.ic_action_note_dark).listen(listener).reg();
|
||||
}
|
||||
|
@ -387,10 +390,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
|||
|
||||
String lng = a.getNameSelected(lang);
|
||||
if(Algorithms.isEmpty(lng)) {
|
||||
// Second choice to display wiki article in if it does not exist in the OsmAnd locale is EN
|
||||
lng = a.getNameSelected("en");
|
||||
// If POI has no "en" name, "" is returned. Unfortunatley no easy way then to determine what the corresponding article language is.
|
||||
// "" is also returned if no name can be found at all
|
||||
lng = "en";
|
||||
}
|
||||
|
||||
final String langSelected = lng;
|
||||
|
@ -464,7 +464,10 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
|||
protected static void showPopupLangMenu(final Context ctx, Toolbar tb,
|
||||
final OsmandApplication app, final Amenity a, final Dialog dialog) {
|
||||
final PopupMenu optionsMenu = new PopupMenu(ctx, tb, Gravity.RIGHT);
|
||||
List<String> names = a.getNames("");
|
||||
Set<String> names = new TreeSet<String>();
|
||||
names.addAll(a.getNames("content"));
|
||||
names.addAll(a.getNames("description"));
|
||||
|
||||
for (final String n : names) {
|
||||
String vn = FileNameTranslationHelper.getVoiceName(ctx, n);
|
||||
MenuItem item = optionsMenu.getMenu().add(vn);
|
||||
|
|
Loading…
Reference in a new issue