Search in sources :

Example 6 with MapPoiTypes

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();
}
Also used : AbstractPoiType(net.osmand.osm.AbstractPoiType) PoiType(net.osmand.osm.PoiType) AbstractPoiType(net.osmand.osm.AbstractPoiType) MapPoiTypes(net.osmand.osm.MapPoiTypes)

Example 7 with MapPoiTypes

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();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) OsmandApplication(net.osmand.plus.OsmandApplication) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) MapPoiTypes(net.osmand.osm.MapPoiTypes) PoiCategory(net.osmand.osm.PoiCategory) AlertDialog(android.support.v7.app.AlertDialog) Dialog(android.app.Dialog) NonNull(android.support.annotation.NonNull)

Example 8 with MapPoiTypes

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;
}
Also used : PoiFilter(net.osmand.osm.PoiFilter) ArrayList(java.util.ArrayList) MapPoiTypes(net.osmand.osm.MapPoiTypes)

Example 9 with MapPoiTypes

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;
}
Also used : AbstractPoiType(net.osmand.osm.AbstractPoiType) PoiType(net.osmand.osm.PoiType) AbstractPoiType(net.osmand.osm.AbstractPoiType) View(android.view.View) AutoCompleteTextView(android.widget.AutoCompleteTextView) TextView(android.widget.TextView) MapPoiTypes(net.osmand.osm.MapPoiTypes) ImageButton(android.widget.ImageButton) Button(android.widget.Button) LinearLayout(android.widget.LinearLayout) HashSet(java.util.HashSet) Nullable(android.support.annotation.Nullable)

Example 10 with MapPoiTypes

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();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) OsmandApplication(net.osmand.plus.OsmandApplication) DialogInterface(android.content.DialogInterface) MapPoiTypes(net.osmand.osm.MapPoiTypes) PoiCategory(net.osmand.osm.PoiCategory) TreeSet(java.util.TreeSet) NonNull(android.support.annotation.NonNull)

Aggregations

MapPoiTypes (net.osmand.osm.MapPoiTypes)17 AbstractPoiType (net.osmand.osm.AbstractPoiType)11 PoiType (net.osmand.osm.PoiType)10 OsmandApplication (net.osmand.plus.OsmandApplication)7 PoiCategory (net.osmand.osm.PoiCategory)6 ArrayList (java.util.ArrayList)5 Drawable (android.graphics.drawable.Drawable)3 NonNull (android.support.annotation.NonNull)3 View (android.view.View)3 TextView (android.widget.TextView)3 List (java.util.List)3 Map (java.util.Map)3 Amenity (net.osmand.data.Amenity)3 DialogInterface (android.content.DialogInterface)2 AlertDialog (android.support.v7.app.AlertDialog)2 AutoCompleteTextView (android.widget.AutoCompleteTextView)2 Button (android.widget.Button)2 ImageButton (android.widget.ImageButton)2 LinearLayout (android.widget.LinearLayout)2 File (java.io.File)2