use of net.osmand.plus.activities.MapActivity in project Osmand by osmandapp.
the class AddQuickActionDialog method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
List<QuickAction> active = ((MapActivity) getActivity()).getMapLayers().getQuickActionRegistry().getQuickActions();
View root = inflater.inflate(R.layout.quick_action_add_dialog, container, false);
Adapter adapter = new Adapter(QuickActionFactory.produceTypeActionsListWithHeaders(active));
RecyclerView recyclerView = (RecyclerView) root.findViewById(R.id.recycler_view);
Button btnDismiss = (Button) root.findViewById(R.id.btnDismiss);
btnDismiss.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
}
});
recyclerView.setAdapter(adapter);
return root;
}
use of net.osmand.plus.activities.MapActivity in project Osmand by osmandapp.
the class EditPoiDialogFragment method save.
private void save() {
Node original = editPoiData.getEntity();
final boolean offlineEdit = mOpenstreetmapUtil instanceof OpenstreetmapLocalUtil;
Node node = new Node(original.getLatitude(), original.getLongitude(), original.getId());
Action action = node.getId() < 0 ? Action.CREATE : Action.MODIFY;
for (Map.Entry<String, String> tag : editPoiData.getTagValues().entrySet()) {
if (!Algorithms.isEmpty(tag.getKey()) && !Algorithms.isEmpty(tag.getValue()) && !tag.getKey().equals(EditPoiData.POI_TYPE_TAG)) {
node.putTagNoLC(tag.getKey(), tag.getValue());
}
}
String poiTypeTag = editPoiData.getTagValues().get(EditPoiData.POI_TYPE_TAG);
String comment = "";
if (poiTypeTag != null) {
final PoiType poiType = editPoiData.getAllTranslatedSubTypes().get(poiTypeTag.trim().toLowerCase());
if (poiType != null) {
node.putTagNoLC(poiType.getOsmTag(), poiType.getOsmValue());
node.removeTag(EditPoiData.REMOVE_TAG_PREFIX + poiType.getOsmTag());
if (poiType.getOsmTag2() != null) {
node.putTagNoLC(poiType.getOsmTag2(), poiType.getOsmValue2());
node.removeTag(EditPoiData.REMOVE_TAG_PREFIX + poiType.getOsmTag2());
}
} else if (!Algorithms.isEmpty(poiTypeTag)) {
node.putTagNoLC(editPoiData.getPoiCategory().getDefaultTag(), poiTypeTag);
}
if (offlineEdit && !Algorithms.isEmpty(poiTypeTag)) {
node.putTagNoLC(EditPoiData.POI_TYPE_TAG, poiTypeTag);
}
String actionString = action == Action.CREATE ? getString(R.string.default_changeset_add) : getString(R.string.default_changeset_edit);
comment = actionString + " " + poiTypeTag;
}
commitNode(action, node, mOpenstreetmapUtil.getEntityInfo(node.getId()), comment, false, new CallbackWithObject<Node>() {
@Override
public boolean processResult(Node result) {
if (result != null) {
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
if (plugin != null && offlineEdit) {
List<OpenstreetmapPoint> points = plugin.getDBPOI().getOpenstreetmapPoints();
if (getActivity() instanceof MapActivity && points.size() > 0) {
OsmPoint point = points.get(points.size() - 1);
MapActivity mapActivity = (MapActivity) getActivity();
mapActivity.getContextMenu().showOrUpdate(new LatLon(point.getLatitude(), point.getLongitude()), plugin.getOsmEditsLayer(mapActivity).getObjectName(point), point);
}
}
if (getActivity() instanceof MapActivity) {
((MapActivity) getActivity()).getMapView().refreshMap(true);
}
dismiss();
} else {
OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
mOpenstreetmapUtil = plugin.getPoiModificationLocalUtil();
Button saveButton = (Button) view.findViewById(R.id.saveButton);
saveButton.setText(mOpenstreetmapUtil instanceof OpenstreetmapRemoteUtil ? R.string.shared_string_upload : R.string.shared_string_save);
}
return false;
}
}, getActivity(), mOpenstreetmapUtil, action == Action.MODIFY ? editPoiData.getChangedTags() : null);
}
use of net.osmand.plus.activities.MapActivity in project Osmand by osmandapp.
the class MeasurementToolFragment method cancelMovePointMode.
private void cancelMovePointMode() {
switchMovePointMode(false);
exitMovePointMode(true);
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
mapActivity.refreshMap();
}
}
use of net.osmand.plus.activities.MapActivity in project Osmand by osmandapp.
the class MeasurementToolFragment method exitMeasurementMode.
private void exitMeasurementMode() {
MapActivity mapActivity = getMapActivity();
MeasurementToolLayer measurementLayer = getMeasurementLayer();
if (mapActivity != null && measurementLayer != null) {
if (toolBarController != null) {
mapActivity.hideTopToolbar(toolBarController);
}
measurementLayer.setInMeasurementMode(false);
mapActivity.enableDrawer();
mark(View.VISIBLE, R.id.map_left_widgets_panel, R.id.map_right_widgets_panel, R.id.map_center_info, R.id.map_route_info_button, R.id.map_menu_button, R.id.map_compass_button, R.id.map_layers_button, R.id.map_search_button, R.id.map_quick_actions_button);
View collapseButton = mapActivity.findViewById(R.id.map_collapse_button);
if (collapseButton != null && wasCollapseButtonVisible) {
collapseButton.setVisibility(View.VISIBLE);
}
mapActivity.refreshMap();
}
}
use of net.osmand.plus.activities.MapActivity in project Osmand by osmandapp.
the class MeasurementToolFragment method switchAddPointBeforeAfterMode.
private void switchAddPointBeforeAfterMode(boolean enable) {
if (enable) {
toolBarController.setBackBtnIconIds(R.drawable.ic_action_mode_back, R.drawable.ic_action_mode_back);
} else {
toolBarController.setBackBtnIconIds(R.drawable.ic_action_remove_dark, R.drawable.ic_action_remove_dark);
}
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
mapActivity.showTopToolbar(toolBarController);
}
markGeneralComponents(enable ? View.GONE : View.VISIBLE);
mark(enable ? View.VISIBLE : View.GONE, R.id.add_point_before_after_text, R.id.add_point_before_after_controls);
if (!enable) {
mainIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_ruler));
}
}
Aggregations