use of net.osmand.osm.MapPoiTypes in project Osmand by osmandapp.
the class OsmAndFormatter method getAmenityDescriptionContent.
public static String getAmenityDescriptionContent(OsmandApplication ctx, Amenity amenity, boolean shortDescription) {
StringBuilder d = new StringBuilder();
if (amenity.getType().isWiki()) {
return "";
}
MapPoiTypes poiTypes = ctx.getPoiTypes();
for (Entry<String, String> e : amenity.getAdditionalInfo().entrySet()) {
String key = e.getKey();
String vl = e.getValue();
if (key.startsWith("name:")) {
continue;
} else if (vl.length() >= 150) {
if (shortDescription) {
continue;
}
} else if (Amenity.OPENING_HOURS.equals(key)) {
d.append(ctx.getString(R.string.opening_hours) + ": ");
} else if (Amenity.PHONE.equals(key)) {
d.append(ctx.getString(R.string.phone) + ": ");
} else if (Amenity.WEBSITE.equals(key)) {
d.append(ctx.getString(R.string.website) + ": ");
} else {
AbstractPoiType pt = poiTypes.getAnyPoiAdditionalTypeByKey(e.getKey());
if (pt != null) {
if (pt instanceof PoiType && !((PoiType) pt).isText()) {
vl = pt.getTranslation();
} else {
vl = pt.getTranslation() + ": " + amenity.unzipContent(e.getValue());
}
} else {
vl = Algorithms.capitalizeFirstLetterAndLowercase(e.getKey()) + ": " + amenity.unzipContent(e.getValue());
}
}
d.append(vl).append('\n');
}
return d.toString().trim();
}
use of net.osmand.osm.MapPoiTypes in project Osmand by osmandapp.
the class PoiTypeDialogFragment method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
MapPoiTypes poiTypes = ((OsmandApplication) getActivity().getApplication()).getPoiTypes();
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
final List<PoiCategory> categories = new ArrayList<PoiCategory>();
ArrayList<String> vals = new ArrayList<>();
for (PoiCategory category : poiTypes.getCategories(false)) {
if (!category.isNotEditableOsm()) {
vals.add(category.getTranslation());
categories.add(category);
}
}
builder.setItems(vals.toArray(new String[vals.size()]), new Dialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
PoiCategory aType = categories.get(which);
onItemSelectListener.select(aType);
dismiss();
}
});
return builder.create();
}
use of net.osmand.osm.MapPoiTypes in project Osmand by osmandapp.
the class PoiFiltersHelper method getTopDefinedPoiFilters.
public List<PoiUIFilter> getTopDefinedPoiFilters() {
if (cacheTopStandardFilters == null) {
List<PoiUIFilter> top = new ArrayList<PoiUIFilter>();
// user defined
top.addAll(getUserDefinedPoiFilters());
if (getLocalWikiPOIFilter() != null) {
top.add(getLocalWikiPOIFilter());
}
// default
MapPoiTypes poiTypes = application.getPoiTypes();
for (PoiFilter t : poiTypes.getTopVisibleFilters()) {
PoiUIFilter f = new PoiUIFilter(t, application, "");
top.add(f);
}
Collections.sort(top);
cacheTopStandardFilters = top;
}
List<PoiUIFilter> result = new ArrayList<PoiUIFilter>();
result.addAll(cacheTopStandardFilters);
result.add(getShowAllPOIFilter());
return result;
}
use of net.osmand.osm.MapPoiTypes in project Osmand by osmandapp.
the class AdvancedEditPoiFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_edit_poi_advanced, container, false);
deleteDrawable = getPaintedContentIcon(R.drawable.ic_action_remove_dark, getActivity().getResources().getColor(R.color.dash_search_icon_dark));
nameTextView = (TextView) view.findViewById(R.id.nameTextView);
amenityTagTextView = (TextView) view.findViewById(R.id.amenityTagTextView);
amenityTextView = (TextView) view.findViewById(R.id.amenityTextView);
LinearLayout editTagsLineaLayout = (LinearLayout) view.findViewById(R.id.editTagsList);
final MapPoiTypes mapPoiTypes = getMyApplication().getPoiTypes();
mAdapter = new TagAdapterLinearLayoutHack(editTagsLineaLayout, getData());
// It is possible to not restart initialization every time, and probably move initialization to appInit
Map<String, PoiType> translatedTypes = getData().getAllTranslatedSubTypes();
HashSet<String> tagKeys = new HashSet<>();
HashSet<String> valueKeys = new HashSet<>();
for (AbstractPoiType abstractPoiType : translatedTypes.values()) {
addPoiToStringSet(abstractPoiType, tagKeys, valueKeys);
}
addPoiToStringSet(mapPoiTypes.getOtherMapCategory(), tagKeys, valueKeys);
mAdapter.setTagData(tagKeys.toArray(new String[tagKeys.size()]));
mAdapter.setValueData(valueKeys.toArray(new String[valueKeys.size()]));
Button addTagButton = (Button) view.findViewById(R.id.addTagButton);
addTagButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mAdapter.addTagView("", "");
}
});
return view;
}
use of net.osmand.osm.MapPoiTypes in project Osmand by osmandapp.
the class PoiSubTypeDialogFragment method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
MapPoiTypes poiTypes = ((OsmandApplication) getActivity().getApplication()).getPoiTypes();
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
final PoiCategory a = poiTypes.getPoiCategoryByName((String) getArguments().getSerializable(KEY_POI_CATEGORY));
Set<String> strings = new TreeSet<>();
if (a == poiTypes.getOtherPoiCategory()) {
for (PoiCategory category : poiTypes.getCategories(false)) {
if (!category.isNotEditableOsm()) {
addCategory(category, strings);
}
}
} else {
addCategory(a, strings);
}
final String[] subCats = strings.toArray(new String[strings.size()]);
builder.setItems(subCats, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
onItemSelectListener.select(subCats[which]);
dismiss();
}
});
return builder.create();
}
Aggregations