Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-10-11 15:21:04 +02:00
commit 0add2f340e
8 changed files with 29 additions and 53 deletions

View file

@ -239,7 +239,7 @@ public class OsmAndFormatter {
return "";
}
public static String getPoiStringWithoutType(Amenity amenity, String locale) {
public static String getPoiStringWithoutType(Amenity amenity, String locale, boolean transliterate) {
PoiCategory pc = amenity.getType();
PoiType pt = pc.getPoiTypeByKeyName(amenity.getSubType());
String nm = amenity.getSubType();
@ -248,7 +248,7 @@ public class OsmAndFormatter {
} else if(nm != null){
nm = Algorithms.capitalizeFirstLetterAndLowercase(nm.replace('_', ' '));
}
String n = amenity.getName(locale);
String n = amenity.getName(locale, transliterate);
if (n.indexOf(nm) != -1) {
// type is contained in name e.g.
// n = "Bakery the Corner"

View file

@ -179,8 +179,9 @@ public class GeoIntentActivity extends OsmandListActivity {
private PointDescription getString(MapObject o) {
if (o instanceof Amenity) {
OsmandSettings settings = ((OsmandApplication) getApplication()).getSettings();
return new PointDescription(PointDescription.POINT_TYPE_POI,
OsmAndFormatter.getPoiStringWithoutType((Amenity) o, ((OsmandApplication) getApplication()).getSettings().MAP_PREFERRED_LOCALE.get()));
OsmAndFormatter.getPoiStringWithoutType((Amenity) o, settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get()));
}
if (o instanceof Street) {
return new PointDescription(PointDescription.POINT_TYPE_ADDRESS, ((Street) o).getCity().getName() + " " + o.getName());

View file

@ -587,7 +587,8 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
final Amenity amenity = ((AmenityAdapter) getListAdapter()).getItem(position);
final OsmandSettings settings = app.getSettings();
String poiSimpleFormat = OsmAndFormatter.getPoiStringWithoutType(amenity,
app.getSettings().MAP_PREFERRED_LOCALE.get());
app.getSettings().MAP_PREFERRED_LOCALE.get(),
app.getSettings().MAP_TRANSLITERATE_NAMES.get());
PointDescription name = new PointDescription(PointDescription.POINT_TYPE_POI, poiSimpleFormat);
int z = Math.max(16, settings.getLastKnownMapZoom());
@ -818,7 +819,9 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
if (mes != null) {
distance = " " + OsmAndFormatter.getFormattedDistance((int) mes[0], getMyApplication()) + " "; //$NON-NLS-1$
}
String poiType = OsmAndFormatter.getPoiStringWithoutType(amenity, app.getSettings().MAP_PREFERRED_LOCALE.get());
String poiType = OsmAndFormatter.getPoiStringWithoutType(amenity,
app.getSettings().MAP_PREFERRED_LOCALE.get(),
app.getSettings().MAP_TRANSLITERATE_NAMES.get());
label.setText(poiType);
distanceText.setText(distance);
ViewCompat.setAccessibilityDelegate(row, accessibilityAssistant);
@ -867,35 +870,6 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
}
}
private void showPOIDetails(final Amenity amenity, String lang) {
AlertDialog.Builder b = new AlertDialog.Builder(SearchPOIActivity.this);
b.setTitle(OsmAndFormatter.getPoiStringWithoutType(amenity, lang));
b.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
List<String> attributes = new ArrayList<String>();
String direction = navigationInfo.getDirectionString(amenity.getLocation(), heading);
if (direction != null) {
attributes.add(direction);
}
String[] as = OsmAndFormatter.getAmenityDescriptionContent(getMyApplication(), amenity, false).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()]), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
b.show();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {

View file

@ -829,7 +829,8 @@ public class WaypointHelper {
@Override
public PointDescription getPointDescription(Context ctx) {
return new PointDescription(PointDescription.POINT_TYPE_POI,
OsmAndFormatter.getPoiStringWithoutType(a, app.getSettings().MAP_PREFERRED_LOCALE.get()));
OsmAndFormatter.getPoiStringWithoutType(a, app.getSettings().MAP_PREFERRED_LOCALE.get(),
app.getSettings().MAP_TRANSLITERATE_NAMES.get()));
}
@Override

View file

@ -320,7 +320,8 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
@Override
public boolean accept(Amenity a) {
if (sm != null) {
String lower = OsmAndFormatter.getPoiStringWithoutType(a, app.getSettings().MAP_PREFERRED_LOCALE.get());
String lower = OsmAndFormatter.getPoiStringWithoutType(a,
app.getSettings().MAP_PREFERRED_LOCALE.get(), app.getSettings().MAP_TRANSLITERATE_NAMES.get());
if (!sm.matches(lower)) {
return false;
}

View file

@ -161,22 +161,23 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
if (searchResult.location != null) {
OsmandApplication app = getMyApplication();
String lang = searchResult.requiredSearchPhrase.getSettings().getLang();
boolean transliterate = searchResult.requiredSearchPhrase.getSettings().isTransliterate();
PointDescription pointDescription = null;
Object object = searchResult.object;
switch (searchResult.objectType) {
case POI:
String poiSimpleFormat = OsmAndFormatter.getPoiStringWithoutType((Amenity) object, lang);
String poiSimpleFormat = OsmAndFormatter.getPoiStringWithoutType((Amenity) object, lang, transliterate);
pointDescription = new PointDescription(PointDescription.POINT_TYPE_POI, poiSimpleFormat);
break;
case RECENT_OBJ:
HistoryEntry entry = (HistoryEntry) object;
pointDescription = entry.getName();
if (pointDescription.isPoi()) {
Amenity amenity = findAmenity(entry.getName().getName(), entry.getLat(), entry.getLon(), lang);
Amenity amenity = findAmenity(entry.getName().getName(), entry.getLat(), entry.getLon(), lang, transliterate);
if (amenity != null) {
object = amenity;
pointDescription = new PointDescription(PointDescription.POINT_TYPE_POI,
OsmAndFormatter.getPoiStringWithoutType(amenity, lang));
OsmAndFormatter.getPoiStringWithoutType(amenity, lang, transliterate));
}
} else if (pointDescription.isFavorite()) {
LatLon entryLatLon = new LatLon(entry.getLat(), entry.getLon());
@ -239,7 +240,7 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
}
}
private Amenity findAmenity(String name, double lat, double lon, String lang) {
private Amenity findAmenity(String name, double lat, double lon, String lang, boolean transliterate) {
OsmandApplication app = getMyApplication();
QuadRect rect = MapUtils.calculateLatLonBbox(lat, lon, 15);
List<Amenity> amenities = app.getResourceManager().searchAmenities(
@ -257,13 +258,13 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
MapPoiTypes types = app.getPoiTypes();
for (Amenity amenity : amenities) {
String poiSimpleFormat = OsmAndFormatter.getPoiStringWithoutType(amenity, lang);
String poiSimpleFormat = OsmAndFormatter.getPoiStringWithoutType(amenity, lang, transliterate);
if (poiSimpleFormat.equals(name)) {
return amenity;
}
}
for (Amenity amenity : amenities) {
String amenityName = amenity.getName(lang, true);
String amenityName = amenity.getName(lang, transliterate);
if (Algorithms.isEmpty(amenityName)) {
AbstractPoiType st = types.getAnyPoiTypeByKey(amenity.getSubType());
if (st != null) {

View file

@ -174,13 +174,6 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
}
}
private StringBuilder buildPoiInformation(StringBuilder res, Amenity n) {
String format = OsmAndFormatter.getPoiStringWithoutType(n,
view.getSettings().MAP_PREFERRED_LOCALE.get());
res.append(" ").append(format).append("\n").append(
OsmAndFormatter.getAmenityDescriptionContent(view.getApplication(), n, true));
return res;
}
@Override
public void initLayer(OsmandMapTileView view) {
@ -482,7 +475,8 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
public PointDescription getObjectName(Object o) {
if (o instanceof Amenity) {
return new PointDescription(PointDescription.POINT_TYPE_POI, ((Amenity) o).getName(
view.getSettings().MAP_PREFERRED_LOCALE.get()));
view.getSettings().MAP_PREFERRED_LOCALE.get(),
view.getSettings().MAP_TRANSLITERATE_NAMES.get()));
}
return null;
}
@ -529,7 +523,8 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
@Override
public String getText(Amenity o) {
return o.getName(view.getSettings().MAP_PREFERRED_LOCALE.get());
return o.getName(view.getSettings().MAP_PREFERRED_LOCALE.get(),
view.getSettings().MAP_TRANSLITERATE_NAMES.get());
}
@Override

View file

@ -580,8 +580,11 @@ public class MapInfoWidgetsFactory {
settings.SHOW_STREET_NAME.get()) {
RouteDataObject rt = locationProvider.getLastKnownRouteSegment();
if (rt != null) {
text = RoutingHelper.formatStreetName(rt.getName(settings.MAP_PREFERRED_LOCALE.get()),
rt.getRef(rt.bearingVsRouteDirection(locationProvider.getLastKnownLocation())), rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), rt.bearingVsRouteDirection(locationProvider.getLastKnownLocation())), "»");
text = RoutingHelper.formatStreetName(
rt.getName(settings.MAP_PREFERRED_LOCALE.get()),
rt.getRef(rt.bearingVsRouteDirection(locationProvider.getLastKnownLocation())),
rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), rt.bearingVsRouteDirection(locationProvider.getLastKnownLocation())),
"»");
}
if (text == null) {
text = "";