quick action add GPX first look

This commit is contained in:
Rosty 2017-01-03 12:41:23 +02:00
parent 3126ebabea
commit efd2d53dc3
2 changed files with 56 additions and 0 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_gpx">Add GPX waypoint</string>
<string name="quick_action_new_action">Add action</string>
<string name="quick_action_edit_action">Edit action</string>
<string name="quick_action_add_favorite">Add favorite</string>
@ -2482,6 +2483,7 @@ If you need help with OsmAnd application, please contact our support team: suppo
<string name="quick_action_name_hint">Action 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_gpx_discr">Tap on action will add GPX waypiont to the specified location.</string>
<string name="quick_action_favorite_dialog">Show favorite dialog</string>
<string name="favorite_autofill_toast_text">" is saved to "</string>
<string name="favorite_empty_place_name">Place</string>

View file

@ -54,6 +54,7 @@ public class QuickActionFactory {
quickActions.add(new FavoriteAction());
quickActions.add(new ShowHideFavoritesAction());
quickActions.add(new ShowHidePoiAction());
quickActions.add(new GPXAction());
return quickActions;
}
@ -77,6 +78,9 @@ public class QuickActionFactory {
case ShowHidePoiAction.TYPE:
return new ShowHidePoiAction();
case GPXAction.TYPE:
return new GPXAction();
default:
return new QuickAction();
}
@ -101,6 +105,9 @@ public class QuickActionFactory {
case ShowHidePoiAction.TYPE:
return new ShowHidePoiAction(quickAction);
case GPXAction.TYPE:
return new GPXAction(quickAction);
default:
return quickAction;
}
@ -390,6 +397,8 @@ public class QuickActionFactory {
activity.getMyApplication().getSettings().SHOW_FAVORITES.set(
!activity.getMyApplication().getSettings().SHOW_FAVORITES.get());
activity.getMapLayers().updateLayers(activity.getMapView());
}
@Override
@ -430,6 +439,8 @@ public class QuickActionFactory {
pf.loadSelectedPoiFilters();
} else pf.hidePoiFilters();
activity.getMapLayers().updateLayers(activity.getMapView());
}
@Override
@ -444,4 +455,47 @@ public class QuickActionFactory {
parent.addView(view);
}
}
public static class GPXAction extends QuickAction {
public static final int TYPE = 6;
private GPXAction() {
id = System.currentTimeMillis();
type = TYPE;
nameRes = R.string.quick_action_add_gpx;
iconRes = R.drawable.ic_action_flag_dark;
}
public GPXAction(QuickAction quickAction) {
super(quickAction);
}
@Override
public void execute(MapActivity activity) {
LatLon latLon = activity.getMapView()
.getCurrentRotatedTileBox()
.getCenterLatLon();
PointDescription pointDescription = new PointDescription(
latLon.getLatitude(),
latLon.getLongitude());
activity.getContextMenu().init(latLon, pointDescription, null);
activity.getContextMenu().addWptPt();
}
@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_gpx_discr);
parent.addView(view);
}
}
}