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);
}
}
}
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));
}
};
}
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);
}
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);
}
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();
}
Aggregations