From 0187015cac7e078c519910e6760ca2919807e0e2 Mon Sep 17 00:00:00 2001 From: Rosty Date: Tue, 3 Jan 2017 14:03:44 +0200 Subject: [PATCH] quick action add parking --- OsmAnd/res/values/strings.xml | 2 + .../parkingpoint/ParkingPositionPlugin.java | 2 +- .../plus/quickaction/QuickActionFactory.java | 52 +++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 2fa6d0a0cb..3fbdd012f8 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -2469,6 +2469,7 @@ If you need help with OsmAnd application, please contact our support team: suppo Screen %d Add marker Add GPX waypoint + Add Parking place Add action Edit action Add favorite @@ -2483,6 +2484,7 @@ If you need help with OsmAnd application, please contact our support team: suppo Name Tap on action will add marker to the specified location. Tap on action will add GPX waypiont to the specified location. + Tap on action will add Parking place to the specified location. Show favorite dialog " is saved to " Place diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java index 2baa5e8a99..4086133fc9 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingPositionPlugin.java @@ -238,7 +238,7 @@ public class ParkingPositionPlugin extends OsmandPlugin { * Method dialog for adding of a parking location. * It allows user to choose a type of parking (time-limited or time-unlimited). */ - private void showAddParkingDialog(final MapActivity mapActivity, final double latitude, final double longitude) { + public void showAddParkingDialog(final MapActivity mapActivity, final double latitude, final double longitude) { final boolean wasEventPreviouslyAdded = isParkingEventAdded(); final View addParking = mapActivity.getLayoutInflater().inflate(R.layout.parking_set_type, null); final Dialog choose = new Dialog(mapActivity); diff --git a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionFactory.java b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionFactory.java index d6b42f200f..76926b364f 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionFactory.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionFactory.java @@ -18,10 +18,12 @@ import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.GeocodingLookupService; +import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.mapcontextmenu.editors.EditCategoryDialogFragment; import net.osmand.plus.mapcontextmenu.editors.SelectCategoryDialogFragment; +import net.osmand.plus.parkingpoint.ParkingPositionPlugin; import net.osmand.plus.poi.PoiFiltersHelper; import net.osmand.plus.widgets.AutoCompleteTextViewEx; @@ -67,6 +69,7 @@ public class QuickActionFactory { quickActions.add(new MarkerAction()); quickActions.add(new FavoriteAction()); quickActions.add(new GPXAction()); + quickActions.add(new ParkingAction()); quickActions.add(new QuickAction(0, R.string.quick_action_add_configure_map)); quickActions.add(new ShowHideFavoritesAction()); @@ -97,6 +100,9 @@ public class QuickActionFactory { case GPXAction.TYPE: return new GPXAction(); + case ParkingAction.TYPE: + return new ParkingAction(); + default: return new QuickAction(); } @@ -124,6 +130,9 @@ public class QuickActionFactory { case GPXAction.TYPE: return new GPXAction(quickAction); + case ParkingAction.TYPE: + return new ParkingAction(quickAction); + default: return quickAction; } @@ -514,4 +523,47 @@ public class QuickActionFactory { parent.addView(view); } } + + public static class ParkingAction extends QuickAction { + + public static final int TYPE = 7; + + private ParkingAction() { + id = System.currentTimeMillis(); + type = TYPE; + nameRes = R.string.quick_action_add_parking; + iconRes = R.drawable.ic_action_parking_dark; + } + + public ParkingAction(QuickAction quickAction) { + super(quickAction); + } + + @Override + public void execute(MapActivity activity) { + + ParkingPositionPlugin plugin = OsmandPlugin.getEnabledPlugin(ParkingPositionPlugin.class); + + if (plugin != null){ + + LatLon latLon = activity.getMapView() + .getCurrentRotatedTileBox() + .getCenterLatLon(); + + plugin.showAddParkingDialog(activity, latLon.getLatitude(), latLon.getLongitude()); + } + } + + @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_parking_discr); + + parent.addView(view); + } + } }