This commit is contained in:
parent
a063401389
commit
7a504b796e
1 changed files with 41 additions and 5 deletions
|
@ -23,6 +23,8 @@ import net.osmand.util.Algorithms;
|
|||
import net.osmand.util.OpeningHoursParser;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class AmenityMenuBuilder extends MenuBuilder {
|
||||
|
@ -141,6 +143,12 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
public void buildInternal(View view) {
|
||||
boolean hasWiki = false;
|
||||
MapPoiTypes poiTypes = app.getPoiTypes();
|
||||
String preferredLang = app.getSettings().MAP_PREFERRED_LOCALE.get();
|
||||
if (Algorithms.isEmpty(preferredLang)) {
|
||||
preferredLang = app.getLanguage();
|
||||
}
|
||||
List<AmenityDescription> descriptions = new LinkedList<>();
|
||||
|
||||
for (Map.Entry<String, String> e : amenity.getAdditionalInfo().entrySet()) {
|
||||
int iconId;
|
||||
Drawable icon = null;
|
||||
|
@ -156,10 +164,6 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
if (amenity.getType().isWiki()) {
|
||||
if (!hasWiki) {
|
||||
iconId = R.drawable.ic_action_note_dark;
|
||||
String preferredLang = app.getSettings().MAP_PREFERRED_LOCALE.get();
|
||||
if (Algorithms.isEmpty(preferredLang)) {
|
||||
preferredLang = app.getLanguage();
|
||||
}
|
||||
String lng = amenity.getContentSelected("content", preferredLang, "en");
|
||||
if (Algorithms.isEmpty(lng)) {
|
||||
lng = "en";
|
||||
|
@ -224,11 +228,43 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
if (icon != null) {
|
||||
if (isText && iconId == R.drawable.ic_action_note_dark) {
|
||||
descriptions.add(new AmenityDescription(key, textPrefix, vl));
|
||||
} else if (icon != null) {
|
||||
buildRow(view, icon, vl, textPrefix, textColor, isWiki, isText, needLinks);
|
||||
} else {
|
||||
buildRow(view, iconId, vl, textPrefix, textColor, isWiki, isText, needLinks);
|
||||
}
|
||||
}
|
||||
|
||||
String langSuffix = ":" + preferredLang;
|
||||
AmenityDescription descInPrefLang = null;
|
||||
for (AmenityDescription desc : descriptions) {
|
||||
if (desc.key.length() > langSuffix.length()
|
||||
&& desc.key.substring(desc.key.length() - langSuffix.length(), desc.key.length()).equals(langSuffix)) {
|
||||
descInPrefLang = desc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (descInPrefLang != null) {
|
||||
descriptions.remove(descInPrefLang);
|
||||
descriptions.add(0, descInPrefLang);
|
||||
}
|
||||
|
||||
for (AmenityDescription desc : descriptions) {
|
||||
buildRow(view, R.drawable.ic_action_note_dark, desc.text, desc.textPrefix, 0, false, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
private static class AmenityDescription {
|
||||
private String key;
|
||||
private String textPrefix;
|
||||
private String text;
|
||||
|
||||
public AmenityDescription(String key, String textPrefix, String text) {
|
||||
this.key = key;
|
||||
this.textPrefix = textPrefix;
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue