add poi action (need to be more specified)

This commit is contained in:
Korusn Oleksandr 2017-01-03 16:37:50 +02:00
parent 6d8779e65a
commit 96b5a9a8b3
2 changed files with 60 additions and 5 deletions

View file

@ -2468,6 +2468,7 @@ If you need help with OsmAnd application, please contact our support team: suppo
<string name="quick_action_item_action">Action %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_poi">Add POI</string>
<string name="quick_action_take_audio_note">Take audio note</string>
<string name="quick_action_take_video_note">Take video note</string>
<string name="quick_action_take_photo_note">Take photo note</string>
@ -2493,6 +2494,7 @@ If you need help with OsmAnd application, please contact our support team: suppo
<string name="quick_action_take_video_note_discr">Tap on action will add video note to the specified location.</string>
<string name="quick_action_take_photo_note_discr">Tap on action will add photo note to the specified location.</string>
<string name="quick_action_add_osm_bug_discr">Tap on action will add OSM bug note to the specified location.</string>
<string name="quick_action_add_poi_discr">Tap on action will add POI to the specified location.</string>
<string name="quick_action_navigation_voice_discr">Tap on action will disable or enable voice during navigation.</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>

View file

@ -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);
}
}
}