Search in sources :

Example 26 with OsmNotesPoint

use of net.osmand.plus.plugins.osmedit.data.OsmNotesPoint 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 27 with OsmNotesPoint

use of net.osmand.plus.plugins.osmedit.data.OsmNotesPoint 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 28 with OsmNotesPoint

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

the class OsmBugsLayer method createBugDialog.

private void createBugDialog(@NonNull MapActivity mapActivity, final boolean offline, String text, int titleTextId, int posButtonTextId, final Action action, final OpenStreetNote bug, OsmNotesPoint point) {
    if (mapActivity.isFinishing()) {
        return;
    }
    if (offline) {
        mapActivity.getContextMenu().close();
        BugBottomSheetDialog.showInstance(mapActivity.getSupportFragmentManager(), getOsmBugsUtil(bug), local, text, titleTextId, posButtonTextId, action, bug, point, getHandleBugListener(mapActivity));
    } else {
        OsmNotesPoint notesPoint = new OsmNotesPoint();
        notesPoint.setAction(action);
        notesPoint.setId(bug.getId());
        notesPoint.setLatitude(bug.getLatitude());
        notesPoint.setLongitude(bug.getLongitude());
        SendOsmNoteBottomSheetFragment.showInstance(mapActivity.getSupportFragmentManager(), new OsmPoint[] { notesPoint });
    }
}
Also used : OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint)

Example 29 with OsmNotesPoint

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

the class SaveOsmNoteAsyncTask method doInBackground.

@Override
protected OsmNotesPoint doInBackground(OsmNotesPoint... params) {
    OsmNotesPoint mOsmNotesPoint = params[0];
    Action action = mOsmNotesPoint.getAction();
    plugin.getDBBug().deleteAllBugModifications(mOsmNotesPoint);
    OsmBugsUtil.OsmBugResult result = mOsmbugsUtil.commit(mOsmNotesPoint, mText, action);
    return result == null ? null : result.local;
}
Also used : OsmBugsUtil(net.osmand.plus.plugins.osmedit.helpers.OsmBugsUtil) Action(net.osmand.plus.plugins.osmedit.data.OsmPoint.Action) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint)

Aggregations

OsmNotesPoint (net.osmand.plus.plugins.osmedit.data.OsmNotesPoint)29 OpenstreetmapPoint (net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint)16 OsmPoint (net.osmand.plus.plugins.osmedit.data.OsmPoint)13 ArrayList (java.util.ArrayList)7 View (android.view.View)5 File (java.io.File)5 HistoryEntry (net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry)5 MapMarkersGroup (net.osmand.plus.mapmarkers.MapMarkersGroup)5 FavoriteGroup (net.osmand.plus.myplaces.FavoriteGroup)5 ITileSource (net.osmand.map.ITileSource)4 AvoidRoadInfo (net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo)4 OnlineRoutingEngine (net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine)4 OsmEditingPlugin (net.osmand.plus.plugins.osmedit.OsmEditingPlugin)4 PoiUIFilter (net.osmand.plus.poi.PoiUIFilter)4 QuickAction (net.osmand.plus.quickaction.QuickAction)4 TextView (android.widget.TextView)3 Entity (net.osmand.osm.edit.Entity)3 LinearLayout (android.widget.LinearLayout)2 NonNull (androidx.annotation.NonNull)2 FragmentActivity (androidx.fragment.app.FragmentActivity)2