Search in sources :

Example 31 with MapActivity

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;
}
Also used : Button(android.widget.Button) RecyclerView(android.support.v7.widget.RecyclerView) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) MapActivity(net.osmand.plus.activities.MapActivity) Nullable(android.support.annotation.Nullable)

Example 32 with MapActivity

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);
}
Also used : Action(net.osmand.plus.osmedit.OsmPoint.Action) Node(net.osmand.osm.edit.Node) PoiType(net.osmand.osm.PoiType) LatLon(net.osmand.data.LatLon) ImageButton(android.widget.ImageButton) Button(android.widget.Button) List(java.util.List) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) MapActivity(net.osmand.plus.activities.MapActivity)

Example 33 with MapActivity

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();
    }
}
Also used : MapActivity(net.osmand.plus.activities.MapActivity)

Example 34 with MapActivity

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();
    }
}
Also used : ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) RecyclerView(android.support.v7.widget.RecyclerView) MapActivity(net.osmand.plus.activities.MapActivity)

Example 35 with MapActivity

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));
    }
}
Also used : MapActivity(net.osmand.plus.activities.MapActivity)

Aggregations

MapActivity (net.osmand.plus.activities.MapActivity)85 View (android.view.View)39 ImageView (android.widget.ImageView)28 TextView (android.widget.TextView)28 RecyclerView (android.support.v7.widget.RecyclerView)15 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)14 AlertDialog (android.support.v7.app.AlertDialog)12 Nullable (android.support.annotation.Nullable)11 DialogInterface (android.content.DialogInterface)10 AdapterView (android.widget.AdapterView)9 LatLon (net.osmand.data.LatLon)9 OsmandApplication (net.osmand.plus.OsmandApplication)9 Bundle (android.os.Bundle)7 Button (android.widget.Button)7 EditText (android.widget.EditText)7 ImageButton (android.widget.ImageButton)7 FavouritePoint (net.osmand.data.FavouritePoint)7 Fragment (android.support.v4.app.Fragment)6 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)6 ViewTreeObserver (android.view.ViewTreeObserver)6