Merge pull request #11502 from osmandapp/Fix_11423

Fix #11423 Wikipedia labels on the map shown on few languages
This commit is contained in:
Vitaliy 2021-04-22 18:50:59 +03:00 committed by GitHub
commit e6be5dcab5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -357,19 +357,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
@Override
public PointDescription getObjectName(Object o) {
if (o instanceof Amenity) {
Amenity amenity = (Amenity) o;
String preferredLang = app.getSettings().MAP_PREFERRED_LOCALE.get();
boolean transliterateNames = app.getSettings().MAP_TRANSLITERATE_NAMES.get();
if (amenity.getType().isWiki()) {
if (Algorithms.isEmpty(preferredLang)) {
preferredLang = app.getLanguage();
}
preferredLang = OsmandPlugin.onGetMapObjectsLocale(amenity, preferredLang);
}
return new PointDescription(PointDescription.POINT_TYPE_POI,
amenity.getName(preferredLang, transliterateNames));
return new PointDescription(PointDescription.POINT_TYPE_POI, getAmenityName((Amenity) o));
}
return null;
}
@ -431,8 +419,20 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
@Override
public String getText(Amenity o) {
return o.getName(view.getSettings().MAP_PREFERRED_LOCALE.get(),
view.getSettings().MAP_TRANSLITERATE_NAMES.get());
return getAmenityName(o);
}
private String getAmenityName(Amenity amenity) {
String locale = app.getSettings().MAP_PREFERRED_LOCALE.get();
if (amenity.getType().isWiki()) {
if (Algorithms.isEmpty(locale)) {
locale = app.getLanguage();
}
locale = OsmandPlugin.onGetMapObjectsLocale(amenity, locale);
}
return amenity.getName(locale, app.getSettings().MAP_TRANSLITERATE_NAMES.get());
}
@Override