Search in sources :

Example 21 with OsmPoint

use of net.osmand.plus.plugins.osmedit.data.OsmPoint in project Osmand by osmandapp.

the class DashOsmEditsFragment method getOsmPoints.

private void getOsmPoints(ArrayList<OsmPoint> dataPoints) {
    List<OpenstreetmapPoint> l1 = plugin.getDBPOI().getOpenstreetmapPoints();
    List<OsmNotesPoint> l2 = plugin.getDBBug().getOsmbugsPoints();
    if (l1.isEmpty()) {
        int i = 0;
        for (OsmPoint point : l2) {
            if (i > 2) {
                break;
            }
            dataPoints.add(point);
            i++;
        }
    } else if (l2.isEmpty()) {
        int i = 0;
        for (OsmPoint point : l1) {
            if (i > 2) {
                break;
            }
            dataPoints.add(point);
            i++;
        }
    } else {
        dataPoints.add(l1.get(0));
        dataPoints.add(l2.get(0));
        if (l1.size() > 1) {
            dataPoints.add(l1.get(1));
        } else if (l2.size() > 1) {
            dataPoints.add(l2.get(1));
        }
    }
}
Also used : OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint)

Example 22 with OsmPoint

use of net.osmand.plus.plugins.osmedit.data.OsmPoint in project Osmand by osmandapp.

the class DashOsmEditsFragment method setupEditings.

private void setupEditings() {
    View mainView = getView();
    assert mainView != null;
    if (plugin == null) {
        mainView.setVisibility(View.GONE);
        return;
    }
    ArrayList<OsmPoint> dataPoints = new ArrayList<>();
    getOsmPoints(dataPoints);
    if (dataPoints.size() == 0) {
        mainView.setVisibility(View.GONE);
        return;
    } else {
        mainView.setVisibility(View.VISIBLE);
        DashboardOnMap.handleNumberOfRows(dataPoints, getMyApplication().getSettings(), ROW_NUMBER_TAG);
    }
    LinearLayout osmLayout = (LinearLayout) mainView.findViewById(R.id.items);
    osmLayout.removeAllViews();
    for (final OsmPoint point : dataPoints) {
        LayoutInflater inflater = getActivity().getLayoutInflater();
        View view = inflater.inflate(R.layout.note, null, false);
        OsmEditsFragment.getOsmEditView(view, point, getMyApplication());
        ImageButton send = (ImageButton) view.findViewById(R.id.play);
        send.setImageDrawable(getMyApplication().getUIUtilities().getThemedIcon(R.drawable.ic_action_export));
        send.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (point.getGroup() == OsmPoint.Group.POI) {
                    selectedPoint = point;
                    if (getMyApplication().getOsmOAuthHelper().isLogged()) {
                        SendPoiBottomSheetFragment.showInstance(getChildFragmentManager(), new OsmPoint[] { point });
                    } else {
                        LoginBottomSheetFragment.showInstance(getActivity().getSupportFragmentManager(), DashOsmEditsFragment.this);
                    }
                } else {
                    SendOsmNoteBottomSheetFragment.showInstance(getChildFragmentManager(), new OsmPoint[] { point });
                }
            }
        });
        view.findViewById(R.id.options).setVisibility(View.GONE);
        view.findViewById(R.id.divider).setVisibility(View.VISIBLE);
        view.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                boolean poi = point.getGroup() == OsmPoint.Group.POI;
                String name = poi ? ((OpenstreetmapPoint) point).getName() : ((OsmNotesPoint) point).getText();
                getMyApplication().getSettings().setMapLocationToShow(point.getLatitude(), point.getLongitude(), 15, new PointDescription(poi ? PointDescription.POINT_TYPE_POI : PointDescription.POINT_TYPE_OSM_BUG, name), true, // $NON-NLS-1$
                point);
                MapActivity.launchMapActivityMoveToTop(getActivity());
            }
        });
        osmLayout.addView(view);
    }
}
Also used : OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) ArrayList(java.util.ArrayList) View(android.view.View) TextView(android.widget.TextView) ImageButton(android.widget.ImageButton) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) LayoutInflater(android.view.LayoutInflater) PointDescription(net.osmand.data.PointDescription) LinearLayout(android.widget.LinearLayout)

Example 23 with OsmPoint

use of net.osmand.plus.plugins.osmedit.data.OsmPoint in project Osmand by osmandapp.

the class OsmEditsAdapter method getIcon.

private Drawable getIcon(OsmPoint point) {
    if (point.getGroup() == OsmPoint.Group.POI) {
        OpenstreetmapPoint osmPoint = (OpenstreetmapPoint) point;
        int iconResId = 0;
        String poiTranslation = osmPoint.getEntity().getTag(Entity.POI_TYPE_TAG);
        if (poiTranslation != null) {
            Map<String, PoiType> poiTypeMap = app.getPoiTypes().getAllTranslatedNames(false);
            PoiType poiType = poiTypeMap.get(poiTranslation.toLowerCase());
            if (poiType != null) {
                String id = null;
                if (RenderingIcons.containsBigIcon(poiType.getIconKeyName())) {
                    id = poiType.getIconKeyName();
                } else if (RenderingIcons.containsBigIcon(poiType.getOsmTag() + "_" + poiType.getOsmValue())) {
                    id = poiType.getOsmTag() + "_" + poiType.getOsmValue();
                }
                if (id != null) {
                    iconResId = RenderingIcons.getBigIconResourceId(id);
                }
            }
        }
        if (iconResId == 0) {
            iconResId = R.drawable.ic_action_info_dark;
        }
        int colorResId = R.color.color_distance;
        if (point.getAction() == OsmPoint.Action.CREATE) {
            colorResId = R.color.color_osm_edit_create;
        } else if (point.getAction() == OsmPoint.Action.MODIFY) {
            colorResId = R.color.color_osm_edit_modify;
        } else if (point.getAction() == OsmPoint.Action.DELETE) {
            colorResId = R.color.color_osm_edit_delete;
        } else if (point.getAction() == OsmPoint.Action.REOPEN) {
            colorResId = R.color.color_osm_edit_modify;
        }
        return app.getUIUtilities().getIcon(iconResId, colorResId);
    } else if (point.getGroup() == OsmPoint.Group.BUG) {
        return app.getUIUtilities().getIcon(R.drawable.ic_action_osm_note_add, R.color.color_distance);
    }
    return null;
}
Also used : OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) PoiType(net.osmand.osm.PoiType) OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint)

Example 24 with OsmPoint

use of net.osmand.plus.plugins.osmedit.data.OsmPoint in project Osmand by osmandapp.

the class OsmEditsAdapter method getView.

@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
    boolean nightMode = !app.getSettings().isLightContent();
    Context themedCtx = UiUtilities.getThemedContext(getContext(), nightMode);
    if (portrait) {
        if (convertView == null) {
            if (position == 0) {
                convertView = LayoutInflater.from(themedCtx).inflate(R.layout.list_item_header, parent, false);
                HeaderViewHolder holder = new HeaderViewHolder(convertView);
                convertView.setTag(holder);
            } else {
                convertView = LayoutInflater.from(themedCtx).inflate(R.layout.note_list_item, parent, false);
                OsmEditViewHolder holder = new OsmEditViewHolder(convertView);
                convertView.setTag(holder);
            }
        }
        if (position == 0) {
            bindHeaderViewHolder((HeaderViewHolder) convertView.getTag());
        } else {
            final Object item = getItem(position);
            if (item instanceof OsmPoint) {
                final OsmEditViewHolder holder = (OsmEditViewHolder) convertView.getTag();
                bindOsmEditViewHolder(holder, (OsmPoint) item, position);
            }
        }
        return convertView;
    } else {
        int margin = app.getResources().getDimensionPixelSize(R.dimen.content_padding);
        int sideMargin = app.getResources().getDisplayMetrics().widthPixels / 10;
        FrameLayout fl = new FrameLayout(themedCtx);
        LinearLayout ll = new LinearLayout(themedCtx);
        ll.setOrientation(LinearLayout.VERTICAL);
        ll.setBackgroundResource(app.getSettings().isLightContent() ? R.drawable.bg_card_light : R.drawable.bg_card_dark);
        fl.addView(ll);
        ((FrameLayout.LayoutParams) ll.getLayoutParams()).setMargins(sideMargin, margin, sideMargin, margin);
        HeaderViewHolder headerViewHolder = new HeaderViewHolder(LayoutInflater.from(themedCtx).inflate(R.layout.list_item_header, parent, false));
        bindHeaderViewHolder(headerViewHolder);
        ll.addView(headerViewHolder.mainView);
        for (int i = 0; i < items.size(); i++) {
            Object item = getItem(i);
            if (item instanceof OsmPoint) {
                OsmEditViewHolder viewHolder = new OsmEditViewHolder(LayoutInflater.from(themedCtx).inflate(R.layout.note_list_item, parent, false));
                bindOsmEditViewHolder(viewHolder, (OsmPoint) item, i);
                ll.addView(viewHolder.mainView);
            }
        }
        return fl;
    }
}
Also used : Context(android.content.Context) OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) FrameLayout(android.widget.FrameLayout) OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) LinearLayout(android.widget.LinearLayout) NonNull(androidx.annotation.NonNull)

Example 25 with OsmPoint

use of net.osmand.plus.plugins.osmedit.data.OsmPoint in project Osmand by osmandapp.

the class OsmEditsLayer method getOsmEditsFromPoint.

public void getOsmEditsFromPoint(PointF point, RotatedTileBox tileBox, List<? super OsmPoint> am) {
    int ex = (int) point.x;
    int ey = (int) point.y;
    int compare = getScaledTouchRadius(app, getRadiusPoi(tileBox));
    int radius = compare * 3 / 2;
    compare = getFromPoint(tileBox, am, ex, ey, compare, radius, plugin.getDBBug().getOsmbugsPoints());
    getFromPoint(tileBox, am, ex, ey, compare, radius, plugin.getDBPOI().getOpenstreetmapPoints());
}
Also used : OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint)

Aggregations

OsmPoint (net.osmand.plus.plugins.osmedit.data.OsmPoint)29 OpenstreetmapPoint (net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint)21 OsmNotesPoint (net.osmand.plus.plugins.osmedit.data.OsmNotesPoint)15 PoiType (net.osmand.osm.PoiType)6 Map (java.util.Map)5 Entity (net.osmand.osm.edit.Entity)5 View (android.view.View)4 LinearLayout (android.widget.LinearLayout)4 LatLon (net.osmand.data.LatLon)4 TextView (android.widget.TextView)3 FragmentActivity (androidx.fragment.app.FragmentActivity)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 MapActivity (net.osmand.plus.activities.MapActivity)3 SimpleBottomSheetItem (net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem)3 ProgressDialogFragment (net.osmand.plus.dialogs.ProgressDialogFragment)3 OsmEditingPlugin (net.osmand.plus.plugins.osmedit.OsmEditingPlugin)3 ContextThemeWrapper (android.view.ContextThemeWrapper)2 CompoundButton (android.widget.CompoundButton)2 ImageButton (android.widget.ImageButton)2