diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 11bbb51601..2a396430ff 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -2468,6 +2468,7 @@ If you need help with OsmAnd application, please contact our support team: suppo Action %d Screen %d Add marker + Add POI Take audio note Take video note Take photo note @@ -2493,6 +2494,7 @@ If you need help with OsmAnd application, please contact our support team: suppo Tap on action will add video note to the specified location. Tap on action will add photo note to the specified location. Tap on action will add OSM bug note to the specified location. + Tap on action will add POI to the specified location. Tap on action will disable or enable voice during navigation. Tap on action will add Parking place to the specified location. Show favorite dialog diff --git a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionFactory.java b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionFactory.java index 5ea5c80f1d..5342aa1569 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionFactory.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionFactory.java @@ -24,6 +24,7 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.audionotes.AudioVideoNotesPlugin; import net.osmand.plus.mapcontextmenu.editors.EditCategoryDialogFragment; import net.osmand.plus.mapcontextmenu.editors.SelectCategoryDialogFragment; +import net.osmand.plus.osmedit.EditPoiDialogFragment; import net.osmand.plus.osmedit.OsmEditingPlugin; import net.osmand.plus.parkingpoint.ParkingPositionPlugin; import net.osmand.plus.poi.PoiFiltersHelper; @@ -88,16 +89,17 @@ public class QuickActionFactory { quickActions.add(new TakeVideoNoteAction()); } + if (OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class) != null) { + + quickActions.add(new AddPOIAction()); + quickActions.add(new AddOSMBugAction()); + } + if (OsmandPlugin.getEnabledPlugin(ParkingPositionPlugin.class) != null) { quickActions.add(new ParkingAction()); } - if (OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class) != null) { - - quickActions.add(new AddOSMBugAction()); - } - quickActions.add(new QuickAction(0, R.string.quick_action_add_configure_map)); quickActions.add(new ShowHideFavoritesAction()); quickActions.add(new ShowHidePoiAction()); @@ -148,6 +150,9 @@ public class QuickActionFactory { case AddOSMBugAction.TYPE: return new AddOSMBugAction(); + case AddPOIAction.TYPE: + return new AddPOIAction(); + default: return new QuickAction(); } @@ -193,6 +198,9 @@ public class QuickActionFactory { case AddOSMBugAction.TYPE: return new AddOSMBugAction(quickAction); + case AddPOIAction.TYPE: + return new AddPOIAction(quickAction); + default: return quickAction; } @@ -818,4 +826,49 @@ public class QuickActionFactory { parent.addView(view); } } + + + public static class AddPOIAction extends QuickAction { + public static final int TYPE = 13; + + protected AddPOIAction() { + id = System.currentTimeMillis(); + type = TYPE; + nameRes = R.string.quick_action_add_poi; + iconRes = R.drawable.ic_action_gabout_dark; + } + + public AddPOIAction(QuickAction quickAction) { + super(quickAction); + } + + @Override + public void execute(MapActivity activity) { + + LatLon latLon = activity.getMapView() + .getCurrentRotatedTileBox() + .getCenterLatLon(); + + OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); + if (plugin != null) { + EditPoiDialogFragment editPoiDialogFragment = + EditPoiDialogFragment.createAddPoiInstance(latLon.getLatitude(), latLon.getLongitude(), + activity.getMyApplication()); + editPoiDialogFragment.show(activity.getSupportFragmentManager(), + EditPoiDialogFragment.TAG); + } + } + + @Override + public void drawUI(ViewGroup parent, MapActivity activity) { + + View view = LayoutInflater.from(parent.getContext()) + .inflate(R.layout.quick_action_with_text, parent, false); + + ((TextView) view.findViewById(R.id.text)).setText( + R.string.quick_action_add_poi_discr); + + parent.addView(view); + } + } }