Search in sources :

Example 6 with OsmNotesPoint

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

the class OsmEditingPlugin method registerMapContextMenuActions.

@Override
public void registerMapContextMenuActions(@NonNull final MapActivity mapActivity, final double latitude, final double longitude, ContextMenuAdapter adapter, final Object selectedObj, boolean configureMenu) {
    ContextMenuAdapter.ItemClickListener listener = (adptr, resId, pos, isChecked, viewCoordinates) -> {
        if (resId == R.string.context_menu_item_create_poi) {
            // getPoiActions(mapActivity).showCreateDialog(latitude, longitude);
            EditPoiDialogFragment editPoiDialogFragment = EditPoiDialogFragment.createAddPoiInstance(latitude, longitude, mapActivity.getMyApplication());
            editPoiDialogFragment.show(mapActivity.getSupportFragmentManager(), EditPoiDialogFragment.TAG);
        } else if (resId == R.string.context_menu_item_open_note) {
            openOsmNote(mapActivity, latitude, longitude, "", false);
        } else if (resId == R.string.context_menu_item_modify_note) {
            modifyOsmNote(mapActivity, (OsmNotesPoint) selectedObj);
        } else if (resId == R.string.poi_context_menu_modify) {
            if (selectedObj instanceof TransportStop && ((TransportStop) selectedObj).getAmenity() != null) {
                EditPoiDialogFragment.showEditInstance(((TransportStop) selectedObj).getAmenity(), mapActivity);
            } else if (selectedObj instanceof MapObject) {
                EditPoiDialogFragment.showEditInstance((MapObject) selectedObj, mapActivity);
            }
        } else if (resId == R.string.poi_context_menu_modify_osm_change) {
            final Entity entity = ((OpenstreetmapPoint) selectedObj).getEntity();
            EditPoiDialogFragment.createInstance(entity, false).show(mapActivity.getSupportFragmentManager(), EditPoiDialogFragment.TAG);
        }
        return true;
    };
    boolean isEditable = false;
    if (selectedObj instanceof Amenity || (selectedObj instanceof TransportStop && ((TransportStop) selectedObj).getAmenity() != null)) {
        Amenity amenity;
        if (selectedObj instanceof Amenity) {
            amenity = (Amenity) selectedObj;
        } else {
            amenity = ((TransportStop) selectedObj).getAmenity();
        }
        final PoiType poiType = amenity.getType().getPoiTypeByKeyName(amenity.getSubType());
        isEditable = !amenity.getType().isWiki() && poiType != null && !poiType.isNotEditableOsm();
    } else if (selectedObj instanceof MapObject) {
        Long objectId = ((MapObject) selectedObj).getId();
        isEditable = objectId != null && objectId > 0 && (objectId % 2 == MapObject.AMENITY_ID_RIGHT_SHIFT || (objectId >> MapObject.NON_AMENITY_ID_RIGHT_SHIFT) < Integer.MAX_VALUE);
    }
    if (isEditable) {
        adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.poi_context_menu_modify, mapActivity).setId(MAP_CONTEXT_MENU_CREATE_POI).setIcon(R.drawable.ic_action_edit_dark).setOrder(MODIFY_POI_ITEM_ORDER).setListener(listener).createItem());
    } else if (selectedObj instanceof OpenstreetmapPoint && ((OpenstreetmapPoint) selectedObj).getAction() != Action.DELETE) {
        adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.poi_context_menu_modify_osm_change, mapActivity).setId(MAP_CONTEXT_MENU_CREATE_POI).setIcon(R.drawable.ic_action_edit_dark).setOrder(MODIFY_OSM_CHANGE_ITEM_ORDER).setListener(listener).createItem());
    } else {
        adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.context_menu_item_create_poi, mapActivity).setId(MAP_CONTEXT_MENU_CREATE_POI).setIcon(R.drawable.ic_action_plus_dark).setOrder(CREATE_POI_ITEM_ORDER).setListener(listener).createItem());
    }
    if (selectedObj instanceof OsmNotesPoint) {
        adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.context_menu_item_modify_note, mapActivity).setId(MAP_CONTEXT_MENU_OPEN_OSM_NOTE).setIcon(R.drawable.ic_action_edit_dark).setOrder(MODIFY_OSM_NOTE_ITEM_ORDER).setListener(listener).createItem());
    } else {
        adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.context_menu_item_open_note, mapActivity).setId(MAP_CONTEXT_MENU_OPEN_OSM_NOTE).setIcon(R.drawable.ic_action_osm_note_add).setOrder(OPEN_OSM_NOTE_ITEM_ORDER).setListener(listener).createItem());
    }
}
Also used : OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) SendGpxBottomSheetFragment(net.osmand.plus.plugins.osmedit.dialogs.SendGpxBottomSheetFragment) NonNull(androidx.annotation.NonNull) R(net.osmand.plus.R) AddOSMBugAction(net.osmand.plus.plugins.osmedit.quickactions.AddOSMBugAction) INVALID_ID(net.osmand.plus.ContextMenuItem.INVALID_ID) OsmBugsDbHelper(net.osmand.plus.plugins.osmedit.helpers.OsmBugsDbHelper) Drawable(android.graphics.drawable.Drawable) ContextMenuAdapter.makeDeleteAction(net.osmand.plus.ContextMenuAdapter.makeDeleteAction) Fragment(androidx.fragment.app.Fragment) View(android.view.View) Amenity(net.osmand.data.Amenity) LoginBottomSheetFragment(net.osmand.plus.measurementtool.LoginBottomSheetFragment) DashFragmentData(net.osmand.plus.dashboard.tools.DashFragmentData) OsmBugsRemoteUtil(net.osmand.plus.plugins.osmedit.helpers.OsmBugsRemoteUtil) OsmandApplication(net.osmand.plus.OsmandApplication) OsmandPlugin(net.osmand.plus.plugins.OsmandPlugin) StringRes(androidx.annotation.StringRes) List(java.util.List) Nullable(androidx.annotation.Nullable) DashboardType(net.osmand.plus.dashboard.DashboardOnMap.DashboardType) ContextMenuAdapter(net.osmand.plus.ContextMenuAdapter) OsmBugsLocalUtil(net.osmand.plus.plugins.osmedit.helpers.OsmBugsLocalUtil) MAP_CONTEXT_MENU_CREATE_POI(net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_CREATE_POI) TabActivity(net.osmand.plus.activities.TabActivity) Typeface(android.graphics.Typeface) Context(android.content.Context) OSM_NOTES(net.osmand.aidlapi.OsmAndCustomizationConstants.OSM_NOTES) MapObject(net.osmand.data.MapObject) GpxInfo(net.osmand.plus.myplaces.ui.AvailableGPXFragment.GpxInfo) MAP_CONTEXT_MENU_OPEN_OSM_NOTE(net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_OPEN_OSM_NOTE) PLUGIN_OSMAND_EDITING(net.osmand.aidlapi.OsmAndCustomizationConstants.PLUGIN_OSMAND_EDITING) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) CommonPreference(net.osmand.plus.settings.backend.preferences.CommonPreference) AddPOIAction(net.osmand.plus.plugins.osmedit.quickactions.AddPOIAction) Intent(android.content.Intent) OsmandPreference(net.osmand.plus.settings.backend.preferences.OsmandPreference) FragmentActivity(androidx.fragment.app.FragmentActivity) ArrayList(java.util.ArrayList) RenderingRuleProperty(net.osmand.render.RenderingRuleProperty) PoiType(net.osmand.osm.PoiType) OsmEditsFragment(net.osmand.plus.plugins.osmedit.fragments.OsmEditsFragment) OpenstreetmapLocalUtil(net.osmand.plus.plugins.osmedit.helpers.OpenstreetmapLocalUtil) SettingsScreenType(net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType) OSM_EDITS(net.osmand.aidlapi.OsmAndCustomizationConstants.OSM_EDITS) AvailableGPXFragment(net.osmand.plus.myplaces.ui.AvailableGPXFragment) DashOsmEditsFragment(net.osmand.plus.plugins.osmedit.fragments.DashOsmEditsFragment) PlatformUtil(net.osmand.PlatformUtil) Algorithms(net.osmand.util.Algorithms) AndroidUtils(net.osmand.plus.utils.AndroidUtils) Entity(net.osmand.osm.edit.Entity) Iterator(java.util.Iterator) ItemBuilder(net.osmand.plus.ContextMenuItem.ItemBuilder) SpannableString(android.text.SpannableString) EditPoiDialogFragment(net.osmand.plus.plugins.osmedit.dialogs.EditPoiDialogFragment) StyleSpan(android.text.style.StyleSpan) TextUtils(android.text.TextUtils) POI_TYPE_TAG(net.osmand.osm.edit.Entity.POI_TYPE_TAG) TransportStop(net.osmand.data.TransportStop) ArrayAdapter(android.widget.ArrayAdapter) OpenstreetmapsDbHelper(net.osmand.plus.plugins.osmedit.helpers.OpenstreetmapsDbHelper) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) ShowHideOSMBugAction(net.osmand.plus.plugins.osmedit.quickactions.ShowHideOSMBugAction) Action(net.osmand.plus.plugins.osmedit.data.OsmPoint.Action) OPEN_STREET_MAP(net.osmand.aidlapi.OsmAndCustomizationConstants.OPEN_STREET_MAP) ContextMenuItem(net.osmand.plus.ContextMenuItem) FavoritesActivity(net.osmand.plus.myplaces.ui.FavoritesActivity) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) ConfigureMapMenu(net.osmand.plus.dialogs.ConfigureMapMenu) Log(org.apache.commons.logging.Log) OpenstreetmapRemoteUtil(net.osmand.plus.plugins.osmedit.helpers.OpenstreetmapRemoteUtil) QuickActionType(net.osmand.plus.quickaction.QuickActionType) MapActivity(net.osmand.plus.activities.MapActivity) Entity(net.osmand.osm.edit.Entity) Amenity(net.osmand.data.Amenity) ContextMenuItem(net.osmand.plus.ContextMenuItem) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) PoiType(net.osmand.osm.PoiType) EditPoiDialogFragment(net.osmand.plus.plugins.osmedit.dialogs.EditPoiDialogFragment) ContextMenuAdapter(net.osmand.plus.ContextMenuAdapter) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) ItemBuilder(net.osmand.plus.ContextMenuItem.ItemBuilder) TransportStop(net.osmand.data.TransportStop) MapObject(net.osmand.data.MapObject) ItemBuilder(net.osmand.plus.ContextMenuItem.ItemBuilder)

Example 7 with OsmNotesPoint

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

the class OsmEditsLayer method getObjectName.

@Override
public PointDescription getObjectName(Object o) {
    if (o instanceof OsmPoint) {
        OsmPoint point = (OsmPoint) o;
        String name = "";
        String type = "";
        if (point.getGroup() == OsmPoint.Group.POI) {
            name = ((OpenstreetmapPoint) point).getName();
            type = PointDescription.POINT_TYPE_OSM_NOTE;
        } else if (point.getGroup() == OsmPoint.Group.BUG) {
            name = ((OsmNotesPoint) point).getText();
            type = PointDescription.POINT_TYPE_OSM_BUG;
        }
        return new PointDescription(type, name);
    }
    return null;
}
Also used : OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) PointDescription(net.osmand.data.PointDescription)

Example 8 with OsmNotesPoint

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

the class OsmEditsLayer method applyNewObjectPosition.

@Override
public void applyNewObjectPosition(@NonNull Object o, @NonNull LatLon position, @Nullable ApplyMovedObjectCallback callback) {
    if (o instanceof OsmPoint) {
        if (o instanceof OpenstreetmapPoint) {
            OpenstreetmapPoint objectInMotion = (OpenstreetmapPoint) o;
            Entity entity = objectInMotion.getEntity();
            entity.setLatitude(position.getLatitude());
            entity.setLongitude(position.getLongitude());
            new SaveOsmChangeAsyncTask(mOsmChangeUtil, objectInMotion, callback).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else if (o instanceof OsmNotesPoint) {
            OsmNotesPoint objectInMotion = (OsmNotesPoint) o;
            objectInMotion.setLatitude(position.getLatitude());
            objectInMotion.setLongitude(position.getLongitude());
            new SaveOsmNoteAsyncTask(objectInMotion.getText(), ctx, callback, plugin, mOsmBugsUtil).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, objectInMotion);
        }
    }
}
Also used : SaveOsmNoteAsyncTask(net.osmand.plus.plugins.osmedit.asynctasks.SaveOsmNoteAsyncTask) Entity(net.osmand.osm.edit.Entity) OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) SaveOsmChangeAsyncTask(net.osmand.plus.plugins.osmedit.asynctasks.SaveOsmChangeAsyncTask)

Example 9 with OsmNotesPoint

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

the class HandleOsmNoteAsyncTask method doInBackground.

@Override
protected OsmBugResult doInBackground(Void... params) {
    if (bug != null) {
        OsmNotesPoint point = new OsmNotesPoint();
        point.setId(bug.getId());
        point.setLatitude(bug.getLatitude());
        point.setLongitude(bug.getLongitude());
        return osmbugsUtil.commit(point, text, action);
    } else if (point != null) {
        osmbugsUtil = local;
        return osmbugsUtil.modify(point, text);
    }
    return null;
}
Also used : OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint)

Example 10 with OsmNotesPoint

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

the class OsmEditsFragment method showOnMap.

private void showOnMap(OsmPoint osmPoint, int itemPosition) {
    selectedItemPosition = itemPosition;
    boolean isOsmPoint = osmPoint instanceof OpenstreetmapPoint;
    String type = osmPoint.getGroup() == Group.POI ? PointDescription.POINT_TYPE_POI : PointDescription.POINT_TYPE_OSM_BUG;
    String name = (isOsmPoint ? ((OpenstreetmapPoint) osmPoint).getName() : ((OsmNotesPoint) osmPoint).getText());
    FavoritesActivity.showOnMap(requireActivity(), this, osmPoint.getLatitude(), osmPoint.getLongitude(), 15, new PointDescription(type, name), true, osmPoint);
}
Also used : OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) PointDescription(net.osmand.data.PointDescription)

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