Merge branch 'master' of ssh://github.com/osmandapp/Osmand into osm_edits_fix

This commit is contained in:
PavelRatushnyi 2017-10-14 15:36:47 +03:00
commit 7a28118033
6 changed files with 60 additions and 26 deletions

View file

@ -78,6 +78,10 @@ public class MenuBuilder {
private CardsRowBuilder onlinePhotoCardsRow; private CardsRowBuilder onlinePhotoCardsRow;
private List<AbstractCard> onlinePhotoCards; private List<AbstractCard> onlinePhotoCards;
private String preferredMapLang;
private String preferredMapAppLang;
private boolean transliterateNames;
public class PlainMenuItem { public class PlainMenuItem {
private int iconId; private int iconId;
private String text; private String text;
@ -185,6 +189,25 @@ public class MenuBuilder {
this.mapActivity = mapActivity; this.mapActivity = mapActivity;
this.app = mapActivity.getMyApplication(); this.app = mapActivity.getMyApplication();
this.plainMenuItems = new LinkedList<>(); this.plainMenuItems = new LinkedList<>();
preferredMapLang = app.getSettings().MAP_PREFERRED_LOCALE.get();
preferredMapAppLang = preferredMapLang;
if (Algorithms.isEmpty(preferredMapAppLang)) {
preferredMapAppLang = app.getLanguage();
}
transliterateNames = app.getSettings().MAP_TRANSLITERATE_NAMES.get();
}
public String getPreferredMapLang() {
return preferredMapLang;
}
public String getPreferredMapAppLang() {
return preferredMapAppLang;
}
public boolean isTransliterateNames() {
return transliterateNames;
} }
public MapActivity getMapActivity() { public MapActivity getMapActivity() {
@ -661,7 +684,7 @@ public class MenuBuilder {
wikiButton.setPadding(dpToPx(14f), 0, dpToPx(14f), 0); wikiButton.setPadding(dpToPx(14f), 0, dpToPx(14f), 0);
wikiButton.setTextColor(app.getResources() wikiButton.setTextColor(app.getResources()
.getColor(light ? R.color.color_dialog_buttons_light : R.color.color_dialog_buttons_dark)); .getColor(light ? R.color.color_dialog_buttons_light : R.color.color_dialog_buttons_dark));
wikiButton.setText(wiki.getName()); wikiButton.setText(wiki.getName(preferredMapAppLang, transliterateNames));
wikiButton.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); wikiButton.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
wikiButton.setSingleLine(true); wikiButton.setSingleLine(true);
@ -683,10 +706,6 @@ public class MenuBuilder {
protected boolean processNearstWiki() { protected boolean processNearstWiki() {
if (showNearestWiki && latLon != null) { if (showNearestWiki && latLon != null) {
String preferredLang = app.getSettings().MAP_PREFERRED_LOCALE.get();
if (Algorithms.isEmpty(preferredLang)) {
preferredLang = app.getLanguage();
}
QuadRect rect = MapUtils.calculateLatLonBbox( QuadRect rect = MapUtils.calculateLatLonBbox(
latLon.getLatitude(), latLon.getLongitude(), 250); latLon.getLatitude(), latLon.getLongitude(), 250);
nearestWiki = app.getResourceManager().searchAmenities( nearestWiki = app.getResourceManager().searchAmenities(
@ -711,16 +730,14 @@ public class MenuBuilder {
} }
}); });
Long id = objectId; Long id = objectId;
if (id != 0) { List<Amenity> wikiList = new ArrayList<>();
List<Amenity> wikiList = new ArrayList<>(); for (Amenity wiki : nearestWiki) {
for (Amenity wiki : nearestWiki) { String lng = wiki.getContentLanguage("content", preferredMapAppLang, "en");
String lng = wiki.getContentLanguage("content", preferredLang, "en"); if (wiki.getId().equals(id) || (!lng.equals("en") && !lng.equals(preferredMapAppLang))) {
if (wiki.getId().equals(id) || (!lng.equals("en") && !lng.equals(preferredLang))) { wikiList.add(wiki);
wikiList.add(wiki);
}
} }
nearestWiki.removeAll(wikiList);
} }
nearestWiki.removeAll(wikiList);
return true; return true;
} }
return false; return false;

View file

@ -119,6 +119,18 @@ public abstract class MenuController extends BaseMenuController {
this.builder.setLight(isLight()); this.builder.setLight(isLight());
} }
public String getPreferredMapLang() {
return builder.getPreferredMapLang();
}
public String getPreferredMapAppLang() {
return builder.getPreferredMapAppLang();
}
public boolean isTransliterateNames() {
return builder.isTransliterateNames();
}
public void setMapContextMenu(MapContextMenu mapContextMenu) { public void setMapContextMenu(MapContextMenu mapContextMenu) {
this.mapContextMenu = mapContextMenu; this.mapContextMenu = mapContextMenu;
builder.setMapContextMenu(mapContextMenu); builder.setMapContextMenu(mapContextMenu);

View file

@ -278,10 +278,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
public void buildInternal(View view) { public void buildInternal(View view) {
boolean hasWiki = false; boolean hasWiki = false;
MapPoiTypes poiTypes = app.getPoiTypes(); MapPoiTypes poiTypes = app.getPoiTypes();
String preferredLang = app.getSettings().MAP_PREFERRED_LOCALE.get(); String preferredLang = getPreferredMapAppLang();
if (Algorithms.isEmpty(preferredLang)) {
preferredLang = app.getLanguage();
}
List<AmenityInfoRow> infoRows = new LinkedList<>(); List<AmenityInfoRow> infoRows = new LinkedList<>();
List<AmenityInfoRow> descriptions = new LinkedList<>(); List<AmenityInfoRow> descriptions = new LinkedList<>();

View file

@ -11,7 +11,6 @@ import net.osmand.data.TransportStop;
import net.osmand.osm.PoiCategory; import net.osmand.osm.PoiCategory;
import net.osmand.osm.PoiFilter; import net.osmand.osm.PoiFilter;
import net.osmand.osm.PoiType; import net.osmand.osm.PoiType;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.MapContextMenu;
@ -84,7 +83,7 @@ public class AmenityMenuController extends MenuController {
return getLeftIconId(amenity); return getLeftIconId(amenity);
} }
public static int getLeftIconId(Amenity amenity) { private static int getLeftIconId(Amenity amenity) {
String id = null; String id = null;
PoiType st = amenity.getType().getPoiTypeByKeyName(amenity.getSubType()); PoiType st = amenity.getType().getPoiTypeByKeyName(amenity.getSubType());
if (st != null) { if (st != null) {
@ -107,8 +106,9 @@ public class AmenityMenuController extends MenuController {
@Override @Override
public String getNameStr() { public String getNameStr() {
OsmandSettings settings = getMapActivity().getMyApplication().getSettings(); return amenity.getName(
return amenity.getName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get()); amenity.getType().isWiki() ? getPreferredMapAppLang() : getPreferredMapLang(),
isTransliterateNames());
} }
@Override @Override

View file

@ -62,7 +62,7 @@ public class RenderedObjectMenuController extends MenuController {
if (!Algorithms.isEmpty(renderedObject.getName()) && !isStartingWithRTLChar(renderedObject.getName())) { if (!Algorithms.isEmpty(renderedObject.getName()) && !isStartingWithRTLChar(renderedObject.getName())) {
return renderedObject.getName(); return renderedObject.getName();
} else if (renderedObject.getTags().size() > 0) { } else if (renderedObject.getTags().size() > 0) {
String lang = getMapActivity().getMyApplication().getSettings().MAP_PREFERRED_LOCALE.get().toLowerCase(); String lang = getPreferredMapLang().toLowerCase();
String name = ""; String name = "";
if (!Algorithms.isEmpty(lang)) { if (!Algorithms.isEmpty(lang)) {
name = renderedObject.getTags().get("name:" + lang); name = renderedObject.getTags().get("name:" + lang);

View file

@ -321,7 +321,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
app.getSettings().isLightContent() ? app.getSettings().isLightContent() ?
R.style.OsmandLightTheme : R.style.OsmandLightTheme :
R.style.OsmandDarkTheme); R.style.OsmandDarkTheme);
final String title = Algorithms.isEmpty(lang) ? a.getName() : a.getName(lang); final String title = Algorithms.isEmpty(preferredLang) ? a.getName() : a.getName(preferredLang);
LinearLayout ll = new LinearLayout(ctx); LinearLayout ll = new LinearLayout(ctx);
ll.setOrientation(LinearLayout.VERTICAL); ll.setOrientation(LinearLayout.VERTICAL);
@ -519,9 +519,17 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
@Override @Override
public PointDescription getObjectName(Object o) { public PointDescription getObjectName(Object o) {
if (o instanceof Amenity) { if (o instanceof Amenity) {
return new PointDescription(PointDescription.POINT_TYPE_POI, ((Amenity) o).getName( Amenity a = (Amenity) o;
view.getSettings().MAP_PREFERRED_LOCALE.get(), String preferredMapLang = app.getSettings().MAP_PREFERRED_LOCALE.get();
view.getSettings().MAP_TRANSLITERATE_NAMES.get())); String preferredMapAppLang = preferredMapLang;
if (Algorithms.isEmpty(preferredMapAppLang)) {
preferredMapAppLang = app.getLanguage();
}
boolean transliterateNames = app.getSettings().MAP_TRANSLITERATE_NAMES.get();
return new PointDescription(PointDescription.POINT_TYPE_POI, a.getName(
a.getType().isWiki() ? preferredMapAppLang : preferredMapLang,
transliterateNames));
} }
return null; return null;
} }