Search in sources :

Example 6 with OsmPoint

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

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

the class OsmEditsFragment method createOsmEditOptionsFragmentListener.

private OsmEditOptionsFragmentListener createOsmEditOptionsFragmentListener() {
    return new OsmEditOptionsFragmentListener() {

        @Override
        public void onUploadClick(OsmPoint osmPoint) {
            uploadItems(new OsmPoint[] { getPointAfterModify(osmPoint) });
        }

        @Override
        public void onShowOnMapClick(OsmPoint osmPoint) {
            OsmandSettings settings = getMyApplication().getSettings();
            settings.setMapLocationToShow(osmPoint.getLatitude(), osmPoint.getLongitude(), settings.getLastKnownMapZoom());
            MapActivity.launchMapActivityMoveToTop(getActivity());
        }

        @Override
        public void onModifyOsmChangeClick(OsmPoint osmPoint) {
            OpenstreetmapPoint i = (OpenstreetmapPoint) getPointAfterModify(osmPoint);
            final Entity entity = i.getEntity();
            refreshId = entity.getId();
            EditPoiDialogFragment.createInstance(entity, false).show(getActivity().getSupportFragmentManager(), "edit_poi");
        }

        @Override
        public void onModifyOsmNoteClick(OsmPoint osmPoint) {
            showBugDialog((OsmNotesPoint) osmPoint);
        }

        @Override
        public void onDeleteClick(OsmPoint osmPoint) {
            ArrayList<OsmPoint> points = new ArrayList<>();
            points.add(osmPoint);
            deleteItems(new ArrayList<>(points));
        }
    };
}
Also used : Entity(net.osmand.osm.edit.Entity) OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) OsmEditOptionsFragmentListener(net.osmand.plus.plugins.osmedit.dialogs.OsmEditOptionsBottomSheetDialogFragment.OsmEditOptionsFragmentListener) ArrayList(java.util.ArrayList) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings)

Example 8 with OsmPoint

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

the class OsmEditsFragment method fetchData.

private void fetchData() {
    boolean portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
    osmEdits = new ArrayList<>();
    List<OpenstreetmapPoint> l1 = plugin.getDBPOI().getOpenstreetmapPoints();
    List<OsmNotesPoint> l2 = plugin.getDBBug().getOsmbugsPoints();
    osmEdits.addAll(l1);
    osmEdits.addAll(l2);
    ListView listView = getListView();
    listView.setDivider(null);
    listView.setEmptyView(emptyView);
    if (osmEdits.size() > 0 && footerView == null && portrait) {
        footerView = getActivity().getLayoutInflater().inflate(R.layout.list_shadow_footer, listView, false);
        listView.addFooterView(footerView);
    }
    List<Object> items = createItemsList();
    listAdapter = new OsmEditsAdapter(getMyApplication(), items);
    listAdapter.setSelectedOsmEdits(osmEditsSelected);
    listAdapter.setAdapterListener(new OsmEditsAdapter.OsmEditsAdapterListener() {

        @Override
        public void onHeaderCheckboxClick(boolean checked) {
            if (checked) {
                selectAll();
            } else {
                deselectAll();
            }
            updateSelectionTitle(actionMode);
        }

        @Override
        public void onItemSelect(OsmPoint point, boolean checked) {
            if (checked) {
                osmEditsSelected.add(point);
            } else {
                osmEditsSelected.remove(point);
            }
            updateSelectionMode(actionMode);
        }

        @Override
        public void onItemShowMap(OsmPoint point, int position) {
            showOnMap(point, position);
        }

        @Override
        public void onOptionsClick(OsmPoint note) {
            openPopUpMenu(note);
        }
    });
    listAdapter.setPortrait(portrait);
    listView.setAdapter(listAdapter);
}
Also used : OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) OsmEditsAdapter(net.osmand.plus.plugins.osmedit.OsmEditsAdapter) OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) ListView(android.widget.ListView)

Example 9 with OsmPoint

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

the class SendPoiBottomSheetFragment method createMenuItems.

@Override
public void createMenuItems(Bundle savedInstanceState) {
    OsmandApplication app = getMyApplication();
    plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
    if (app == null || plugin == null)
        return;
    poi = (OsmPoint[]) getArguments().getSerializable(OPENSTREETMAP_POINT);
    final boolean isNightMode = app.getDaynightHelper().isNightModeForMapControls();
    final View sendOsmPoiView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.send_poi_fragment, null);
    sendOsmPoiView.getViewTreeObserver().addOnGlobalLayoutListener(getShadowLayoutListener());
    closeChangeSet = sendOsmPoiView.findViewById(R.id.close_change_set_checkbox);
    messageEditText = sendOsmPoiView.findViewById(R.id.message_field);
    String defaultChangeSet = createDefaultChangeSet(app);
    messageEditText.setText(defaultChangeSet);
    messageEditText.setSelection(messageEditText.getText().length());
    final TextView accountName = sendOsmPoiView.findViewById(R.id.user_name);
    String userNameOAuth = plugin.OSM_USER_DISPLAY_NAME.get();
    String userNameOpenID = plugin.OSM_USER_NAME_OR_EMAIL.get();
    String userName = isLoginOAuth() ? userNameOAuth : userNameOpenID;
    accountName.setText(userName);
    final int paddingSmall = app.getResources().getDimensionPixelSize(R.dimen.content_padding_small);
    closeChangeSet.setChecked(true);
    setCloseChangeSet(isNightMode, paddingSmall);
    closeChangeSet.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            setCloseChangeSet(isNightMode, paddingSmall);
        }
    });
    LinearLayout account = sendOsmPoiView.findViewById(R.id.account_container);
    account.setOnClickListener(v -> {
        FragmentActivity activity = getActivity();
        if (activity != null) {
            showOpenStreetMapScreen(activity);
        }
        dismiss();
    });
    final SimpleBottomSheetItem titleItem = (SimpleBottomSheetItem) new SimpleBottomSheetItem.Builder().setCustomView(sendOsmPoiView).create();
    items.add(titleItem);
}
Also used : SimpleBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem) OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OsmandApplication(net.osmand.plus.OsmandApplication) View(android.view.View) TextView(android.widget.TextView) OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) OsmEditingPlugin(net.osmand.plus.plugins.osmedit.OsmEditingPlugin) FragmentActivity(androidx.fragment.app.FragmentActivity) ContextThemeWrapper(android.view.ContextThemeWrapper) TextView(android.widget.TextView) CompoundButton(android.widget.CompoundButton) LinearLayout(android.widget.LinearLayout)

Example 10 with OsmPoint

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

the class SendPoiBottomSheetFragment method onRightBottomButtonClick.

@Override
protected void onRightBottomButtonClick() {
    ProgressDialogPoiUploader progressDialogPoiUploader = null;
    Activity activity = getActivity();
    if (activity instanceof MapActivity) {
        progressDialogPoiUploader = new SimpleProgressDialogPoiUploader((MapActivity) activity);
    } else if (getParentFragment() instanceof ProgressDialogPoiUploader) {
        progressDialogPoiUploader = (ProgressDialogPoiUploader) getParentFragment();
    }
    if (progressDialogPoiUploader != null) {
        String comment = messageEditText.getText().toString();
        if (comment.length() > 0) {
            for (OsmPoint osmPoint : poi) {
                if (osmPoint.getGroup() == OsmPoint.Group.POI) {
                    ((OpenstreetmapPoint) osmPoint).setComment(comment);
                    break;
                }
            }
        }
        progressDialogPoiUploader.showProgressDialog(poi, closeChangeSet.isChecked(), false);
    }
    dismiss();
}
Also used : OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) FragmentActivity(androidx.fragment.app.FragmentActivity) Activity(android.app.Activity) MapActivity(net.osmand.plus.activities.MapActivity) MapActivity(net.osmand.plus.activities.MapActivity)

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