Fix osmo group
This commit is contained in:
parent
524743cf4a
commit
d478d14a73
9 changed files with 82 additions and 33 deletions
|
@ -6,6 +6,7 @@ import java.util.Map;
|
|||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
|
||||
public class Amenity extends MapObject {
|
||||
|
@ -14,6 +15,7 @@ public class Amenity extends MapObject {
|
|||
public static final String PHONE = "phone";
|
||||
public static final String DESCRIPTION = "description";
|
||||
public static final String OPENING_HOURS = "opening_hours";
|
||||
public static final String CONTENT = "content";
|
||||
|
||||
private static final long serialVersionUID = 132083949926339552L;
|
||||
private String subType;
|
||||
|
@ -118,8 +120,57 @@ public class Amenity extends MapObject {
|
|||
setAdditionalInfo(PHONE, phone);
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return getAdditionalInfo(DESCRIPTION);
|
||||
public String getName(String lang) {
|
||||
if (lang != null) {
|
||||
String translateName;
|
||||
if (lang.equals("en")) {
|
||||
translateName = getEnName();
|
||||
} else {
|
||||
translateName = getAdditionalInfo("name:" + lang);
|
||||
}
|
||||
if (!Algorithms.isEmpty(translateName)) {
|
||||
return translateName;
|
||||
}
|
||||
}
|
||||
if (!Algorithms.isEmpty(getName())) {
|
||||
return getName();
|
||||
}
|
||||
for (String nm : additionalInfo.keySet()) {
|
||||
if (nm.startsWith("name:")) {
|
||||
return getAdditionalInfo(nm);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
public String getContentLang(String tag, String lang) {
|
||||
if (lang != null) {
|
||||
String translateName = getAdditionalInfo(tag + ":" + lang);
|
||||
if (!Algorithms.isEmpty(translateName)) {
|
||||
return translateName;
|
||||
}
|
||||
}
|
||||
String plainName = getAdditionalInfo(tag);
|
||||
if (!Algorithms.isEmpty(plainName)) {
|
||||
return plainName;
|
||||
}
|
||||
String enName = getAdditionalInfo(tag + ":en");
|
||||
if (!Algorithms.isEmpty(enName)) {
|
||||
return enName;
|
||||
}
|
||||
for (String nm : additionalInfo.keySet()) {
|
||||
if (nm.startsWith(tag + ":")) {
|
||||
return getAdditionalInfo(nm);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getDescription(String lang) {
|
||||
String info = getContentLang(DESCRIPTION, lang);
|
||||
if(!Algorithms.isEmpty(info)) {
|
||||
return info;
|
||||
}
|
||||
return getContentLang(CONTENT, lang);
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
|
|
|
@ -160,7 +160,7 @@ public class OsmAndFormatter {
|
|||
return "";
|
||||
}
|
||||
|
||||
public static String getPoiStringWithoutType(Amenity amenity, boolean en) {
|
||||
public static String getPoiStringWithoutType(Amenity amenity, String locale) {
|
||||
PoiCategory pc = amenity.getType();
|
||||
PoiType pt = pc.getPoiTypeByKeyName(amenity.getSubType());
|
||||
String nm = amenity.getSubType();
|
||||
|
@ -169,7 +169,7 @@ public class OsmAndFormatter {
|
|||
} else if(nm != null){
|
||||
nm = Algorithms.capitalizeFirstLetterAndLowercase(nm.replace('_', ' '));
|
||||
}
|
||||
String n = amenity.getName(en);
|
||||
String n = amenity.getName(locale);
|
||||
if (n.indexOf(nm) != -1) {
|
||||
// type is contained in name e.g.
|
||||
// n = "Bakery the Corner"
|
||||
|
|
|
@ -176,7 +176,7 @@ public class GeoIntentActivity extends OsmandListActivity {
|
|||
private PointDescription getString(MapObject o) {
|
||||
if (o instanceof Amenity) {
|
||||
return new PointDescription(PointDescription.POINT_TYPE_POI,
|
||||
OsmAndFormatter.getPoiStringWithoutType((Amenity) o, false));
|
||||
OsmAndFormatter.getPoiStringWithoutType((Amenity) o, ((OsmandApplication) getApplication()).getSettings().MAP_PREFERRED_LOCALE.get()));
|
||||
}
|
||||
if (o instanceof Street) {
|
||||
return new PointDescription(PointDescription.POINT_TYPE_ADDRESS, ((Street) o).getCity().getName() + " " + o.getName());
|
||||
|
|
|
@ -541,7 +541,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
final Amenity amenity = ((AmenityAdapter) getListAdapter()).getItem(position);
|
||||
final OsmandSettings settings = app.getSettings();
|
||||
String poiSimpleFormat = OsmAndFormatter.getPoiStringWithoutType(amenity,
|
||||
settings.usingEnglishNames());
|
||||
app.getSettings().MAP_PREFERRED_LOCALE.get());
|
||||
PointDescription name = new PointDescription(PointDescription.POINT_TYPE_POI, poiSimpleFormat);
|
||||
int z = Math.max(16, settings.getLastKnownMapZoom());
|
||||
final PopupMenu optionsMenu = new PopupMenu(this, view);
|
||||
|
@ -566,7 +566,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
// Create dialog
|
||||
Builder bs = new AlertDialog.Builder(view.getContext());
|
||||
bs.setTitle(OsmAndFormatter.getPoiStringWithoutType(amenity,
|
||||
settings.usingEnglishNames()));
|
||||
app.getSettings().MAP_PREFERRED_LOCALE.get()));
|
||||
bs.setMessage(spannable);
|
||||
AlertDialog dialog = bs.show();
|
||||
|
||||
|
@ -583,7 +583,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
item.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
showPOIDetails(amenity, settings.usingEnglishNames());
|
||||
showPOIDetails(amenity, app.getSettings().MAP_PREFERRED_LOCALE.get());
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
@ -804,7 +804,7 @@ 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().usingEnglishNames());
|
||||
String poiType = OsmAndFormatter.getPoiStringWithoutType(amenity, app.getSettings().MAP_PREFERRED_LOCALE.get());
|
||||
label.setText(poiType);
|
||||
distanceText.setText(distance);
|
||||
return (row);
|
||||
|
@ -852,9 +852,9 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
}
|
||||
}
|
||||
|
||||
private void showPOIDetails(final Amenity amenity, boolean en) {
|
||||
private void showPOIDetails(final Amenity amenity, String lang) {
|
||||
AlertDialog.Builder b = new AlertDialog.Builder(SearchPOIActivity.this);
|
||||
b.setTitle(OsmAndFormatter.getPoiStringWithoutType(amenity, en));
|
||||
b.setTitle(OsmAndFormatter.getPoiStringWithoutType(amenity, lang));
|
||||
b.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
|
|
|
@ -774,7 +774,7 @@ public class WaypointHelper {
|
|||
@Override
|
||||
public PointDescription getPointDescription(Context ctx) {
|
||||
return new PointDescription(PointDescription.POINT_TYPE_POI,
|
||||
OsmAndFormatter.getPoiStringWithoutType(a, app.getSettings().usingEnglishNames()));
|
||||
OsmAndFormatter.getPoiStringWithoutType(a, app.getSettings().MAP_PREFERRED_LOCALE.get()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -180,7 +180,7 @@ public class EditingPOIDialogProvider implements DialogProvider {
|
|||
private void prepareDeleteDialog(Dialog dlg, Bundle args) {
|
||||
Amenity a = (Amenity) args.getSerializable(KEY_AMENITY);
|
||||
dlg.setTitle(MessageFormat.format(this.activity.getResources().getString(R.string.poi_remove_confirm_template),
|
||||
OsmAndFormatter.getPoiStringWithoutType(a, settings.usingEnglishNames())));
|
||||
OsmAndFormatter.getPoiStringWithoutType(a, settings.MAP_PREFERRED_LOCALE.get())));
|
||||
}
|
||||
|
||||
private Dialog createDeleteDialog(final Bundle args) {
|
||||
|
|
|
@ -1078,22 +1078,21 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
|||
createMenuItem(oldMenu, SETTINGS_ID, R.string.shared_string_settings, R.drawable.ic_action_settings,
|
||||
MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||
boolean portrait = AndroidUiHelper.isOrientationPortrait(this);
|
||||
if (selectedObject == null) {
|
||||
if (portrait) {
|
||||
menu = getClearToolbar(true).getMenu();
|
||||
} else {
|
||||
getClearToolbar(false);
|
||||
}
|
||||
createMenuItem(menu, CONNECT_TO, R.string.osmo_connect,
|
||||
0, 0,/*R.drawable.ic_action_marker_light,*/
|
||||
createMenuItem(menu, CONNECT_TO, R.string.osmo_connect, 0, 0,/* R.drawable.ic_action_marker_light, */
|
||||
MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||
// createMenuItem(menu, SHARE_SESSION, R.string.osmo_share_session,
|
||||
// R.drawable.ic_action_gshare_dark,
|
||||
// MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||
createMenuItem(menu, CREATE_GROUP, R.string.osmo_create_group,
|
||||
0, 0,
|
||||
// R.drawable.ic_group_add,
|
||||
// createMenuItem(menu, SHARE_SESSION, R.string.osmo_share_session,
|
||||
// R.drawable.ic_action_gshare_dark,
|
||||
// MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||
createMenuItem(menu, CREATE_GROUP, R.string.osmo_create_group, 0, 0,
|
||||
// R.drawable.ic_group_add,
|
||||
MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||
|
||||
}
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
|
|
|
@ -295,13 +295,12 @@ public class PoiLegacyFilter implements SearchPoiTypeFilter {
|
|||
final CollatorStringMatcher sm =
|
||||
nmFilter.length() > 0 ?
|
||||
new CollatorStringMatcher(nmFilter.toString().trim(), StringMatcherMode.CHECK_CONTAINS) : null;
|
||||
final boolean en = app.getSettings().usingEnglishNames();
|
||||
return new AmenityNameFilter() {
|
||||
|
||||
@Override
|
||||
public boolean accept(Amenity a) {
|
||||
if (sm != null) {
|
||||
String lower = OsmAndFormatter.getPoiStringWithoutType(a, en);
|
||||
String lower = OsmAndFormatter.getPoiStringWithoutType(a, app.getSettings().MAP_PREFERRED_LOCALE.get());
|
||||
if (!sm.matches(lower)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -159,7 +159,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
|||
|
||||
private StringBuilder buildPoiInformation(StringBuilder res, Amenity n) {
|
||||
String format = OsmAndFormatter.getPoiStringWithoutType(n,
|
||||
view.getSettings().usingEnglishNames());
|
||||
view.getSettings().MAP_PREFERRED_LOCALE.get());
|
||||
res.append(" " + format + "\n" + OsmAndFormatter.getAmenityDescriptionContent(view.getApplication(), n, true));
|
||||
return res;
|
||||
}
|
||||
|
@ -310,9 +310,9 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
|||
|
||||
private void showDescriptionDialog(Amenity a) {
|
||||
Builder bs = new AlertDialog.Builder(view.getContext());
|
||||
bs.setTitle(OsmAndFormatter.getPoiStringWithoutType(a, view.getSettings().usingEnglishNames()));
|
||||
bs.setTitle(OsmAndFormatter.getPoiStringWithoutType(a, view.getSettings().MAP_PREFERRED_LOCALE.get()));
|
||||
if (a.getType().isWiki()) {
|
||||
bs.setMessage(a.getDescription());
|
||||
bs.setMessage(a.getDescription(view.getSettings().MAP_PREFERRED_LOCALE.get()));
|
||||
} else {
|
||||
bs.setMessage(OsmAndFormatter.getAmenityDescriptionContent(view.getApplication(), a, false));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue