quick action add parking

This commit is contained in:
Rosty 2017-01-03 14:03:44 +02:00
parent bbb35bc385
commit 0187015cac
3 changed files with 55 additions and 1 deletions

View file

@ -2469,6 +2469,7 @@ If you need help with OsmAnd application, please contact our support team: suppo
<string name="quick_action_item_screen">Screen %d</string> <string name="quick_action_item_screen">Screen %d</string>
<string name="quick_action_add_marker">Add marker</string> <string name="quick_action_add_marker">Add marker</string>
<string name="quick_action_add_gpx">Add GPX waypoint</string> <string name="quick_action_add_gpx">Add GPX waypoint</string>
<string name="quick_action_add_parking">Add Parking place</string>
<string name="quick_action_new_action">Add action</string> <string name="quick_action_new_action">Add action</string>
<string name="quick_action_edit_action">Edit action</string> <string name="quick_action_edit_action">Edit action</string>
<string name="quick_action_add_favorite">Add favorite</string> <string name="quick_action_add_favorite">Add favorite</string>
@ -2483,6 +2484,7 @@ If you need help with OsmAnd application, please contact our support team: suppo
<string name="text_name">Name</string> <string name="text_name">Name</string>
<string name="quick_action_add_marker_discr">Tap on action will add marker to the specified location.</string> <string name="quick_action_add_marker_discr">Tap on action will add marker to the specified location.</string>
<string name="quick_action_add_gpx_discr">Tap on action will add GPX waypiont to the specified location.</string> <string name="quick_action_add_gpx_discr">Tap on action will add GPX waypiont to the specified location.</string>
<string name="quick_action_add_parking_discr">Tap on action will add Parking place to the specified location.</string>
<string name="quick_action_favorite_dialog">Show favorite dialog</string> <string name="quick_action_favorite_dialog">Show favorite dialog</string>
<string name="favorite_autofill_toast_text">" is saved to "</string> <string name="favorite_autofill_toast_text">" is saved to "</string>
<string name="favorite_empty_place_name">Place</string> <string name="favorite_empty_place_name">Place</string>

View file

@ -238,7 +238,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
* Method dialog for adding of a parking location. * Method dialog for adding of a parking location.
* It allows user to choose a type of parking (time-limited or time-unlimited). * 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 boolean wasEventPreviouslyAdded = isParkingEventAdded();
final View addParking = mapActivity.getLayoutInflater().inflate(R.layout.parking_set_type, null); final View addParking = mapActivity.getLayoutInflater().inflate(R.layout.parking_set_type, null);
final Dialog choose = new Dialog(mapActivity); final Dialog choose = new Dialog(mapActivity);

View file

@ -18,10 +18,12 @@ import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.GeocodingLookupService; import net.osmand.plus.GeocodingLookupService;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.editors.EditCategoryDialogFragment; import net.osmand.plus.mapcontextmenu.editors.EditCategoryDialogFragment;
import net.osmand.plus.mapcontextmenu.editors.SelectCategoryDialogFragment; import net.osmand.plus.mapcontextmenu.editors.SelectCategoryDialogFragment;
import net.osmand.plus.parkingpoint.ParkingPositionPlugin;
import net.osmand.plus.poi.PoiFiltersHelper; import net.osmand.plus.poi.PoiFiltersHelper;
import net.osmand.plus.widgets.AutoCompleteTextViewEx; import net.osmand.plus.widgets.AutoCompleteTextViewEx;
@ -67,6 +69,7 @@ public class QuickActionFactory {
quickActions.add(new MarkerAction()); quickActions.add(new MarkerAction());
quickActions.add(new FavoriteAction()); quickActions.add(new FavoriteAction());
quickActions.add(new GPXAction()); quickActions.add(new GPXAction());
quickActions.add(new ParkingAction());
quickActions.add(new QuickAction(0, R.string.quick_action_add_configure_map)); quickActions.add(new QuickAction(0, R.string.quick_action_add_configure_map));
quickActions.add(new ShowHideFavoritesAction()); quickActions.add(new ShowHideFavoritesAction());
@ -97,6 +100,9 @@ public class QuickActionFactory {
case GPXAction.TYPE: case GPXAction.TYPE:
return new GPXAction(); return new GPXAction();
case ParkingAction.TYPE:
return new ParkingAction();
default: default:
return new QuickAction(); return new QuickAction();
} }
@ -124,6 +130,9 @@ public class QuickActionFactory {
case GPXAction.TYPE: case GPXAction.TYPE:
return new GPXAction(quickAction); return new GPXAction(quickAction);
case ParkingAction.TYPE:
return new ParkingAction(quickAction);
default: default:
return quickAction; return quickAction;
} }
@ -514,4 +523,47 @@ public class QuickActionFactory {
parent.addView(view); 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);
}
}
} }