commit
ef62639d37
10 changed files with 239 additions and 57 deletions
BIN
OsmAnd/res/drawable-hdpi/ic_signpost.png
Normal file
BIN
OsmAnd/res/drawable-hdpi/ic_signpost.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 398 B |
BIN
OsmAnd/res/drawable-large/ic_signpost.png
Normal file
BIN
OsmAnd/res/drawable-large/ic_signpost.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 460 B |
BIN
OsmAnd/res/drawable-mdpi/ic_signpost.png
Normal file
BIN
OsmAnd/res/drawable-mdpi/ic_signpost.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 314 B |
BIN
OsmAnd/res/drawable-xhdpi/ic_signpost.png
Normal file
BIN
OsmAnd/res/drawable-xhdpi/ic_signpost.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 440 B |
BIN
OsmAnd/res/drawable-xxhdpi/ic_signpost.png
Normal file
BIN
OsmAnd/res/drawable-xxhdpi/ic_signpost.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 704 B |
|
@ -24,6 +24,7 @@
|
||||||
<ListView android:id="@android:id/list"
|
<ListView android:id="@android:id/list"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
|
android:choiceMode="singleChoice"
|
||||||
style="@style/OsmandListView"/>
|
style="@style/OsmandListView"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
<string name="mark_as_visited">Mark as visited</string>
|
<string name="mark_as_visited">Mark as visited</string>
|
||||||
<string name="mark_as_not_visited">Mark as not-visited</string>
|
<string name="mark_as_not_visited">Mark as not-visited</string>
|
||||||
<string name="mark_as_current">Navigate to</string>
|
<string name="mark_as_current">Navigate to</string>
|
||||||
|
<string name="navigate_to_next">Navigate to next point</string>
|
||||||
<string name="map_widget_route_points">Route points</string>
|
<string name="map_widget_route_points">Route points</string>
|
||||||
<string name="route_points_activity">Route Points</string>
|
<string name="route_points_activity">Route Points</string>
|
||||||
<string name="navigate_dialog">Navigate dialog</string>
|
<string name="navigate_dialog">Navigate dialog</string>
|
||||||
|
|
|
@ -132,6 +132,7 @@ public class RoutePointsActivity extends OsmandListActivity {
|
||||||
super.onListItemClick(l, v, position, id);
|
super.onListItemClick(l, v, position, id);
|
||||||
RoutePoint rp = adapter.getItem(position);
|
RoutePoint rp = adapter.getItem(position);
|
||||||
getSherlock().startActionMode(getPointActionModeCallback(rp));
|
getSherlock().startActionMode(getPointActionModeCallback(rp));
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PointItemAdapter extends ArrayAdapter<RoutePoint> {
|
private class PointItemAdapter extends ArrayAdapter<RoutePoint> {
|
||||||
|
@ -262,6 +263,7 @@ public class RoutePointsActivity extends OsmandListActivity {
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyActionMode(ActionMode actionMode) {
|
public void onDestroyActionMode(ActionMode actionMode) {
|
||||||
selectedItem = null;
|
selectedItem = null;
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,135 @@
|
||||||
|
package net.osmand.plus.routepointsnavigation;
|
||||||
|
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.PointF;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.data.RotatedTileBox;
|
||||||
|
import net.osmand.plus.ContextMenuAdapter;
|
||||||
|
import net.osmand.plus.GPXUtilities;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.views.ContextMenuLayer;
|
||||||
|
import net.osmand.plus.views.OsmandMapLayer;
|
||||||
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Barsik on 20.06.2014.
|
||||||
|
*/
|
||||||
|
public class RoutePointsLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider {
|
||||||
|
|
||||||
|
private final RoutePointsPlugin plugin;
|
||||||
|
private final MapActivity map;
|
||||||
|
|
||||||
|
public RoutePointsLayer(MapActivity map, RoutePointsPlugin plugin){
|
||||||
|
this.map = map;
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LatLon getObjectLocation(Object o) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getObjectDescription(Object o) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getObjectName(Object o) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initLayer(OsmandMapTileView view) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroyLayer() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean drawInScreenPixels() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void populateObjectContextMenu(Object o, ContextMenuAdapter adapter) {
|
||||||
|
if (o instanceof GPXUtilities.WptPt && plugin.getCurrentRoute() != null){
|
||||||
|
final GPXUtilities.WptPt point = (GPXUtilities.WptPt) o;
|
||||||
|
ContextMenuAdapter.OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() {
|
||||||
|
@Override
|
||||||
|
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||||
|
if (itemId == R.string.mark_as_not_visited){
|
||||||
|
plugin.getCurrentRoute().markPoint(point,false);
|
||||||
|
saveGPXAsync();
|
||||||
|
} else if (itemId == R.string.mark_as_visited) {
|
||||||
|
plugin.getCurrentRoute().markPoint(point, true);
|
||||||
|
saveGPXAsync();
|
||||||
|
} else if (itemId == R.string.mark_as_current){
|
||||||
|
plugin.getCurrentRoute().markPoint(point, false);
|
||||||
|
plugin.getCurrentRoute().navigateToPoint(point);
|
||||||
|
saveGPXAsync();
|
||||||
|
} else if (itemId == R.string.navigate_to_next){
|
||||||
|
plugin.getCurrentRoute().naviateToNextPoint();
|
||||||
|
saveGPXAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (plugin.getCurrentRoute().getPointStatus(point)){
|
||||||
|
adapter.item(R.string.mark_as_not_visited).icons(
|
||||||
|
R.drawable.ic_action_gremove_dark, R.drawable.ic_action_gremove_light).listen(listener).reg();
|
||||||
|
} else {
|
||||||
|
adapter.item(R.string.mark_as_visited).icons(
|
||||||
|
R.drawable.ic_action_ok_dark, R.drawable.ic_action_ok_light).listen(listener).reg();
|
||||||
|
}
|
||||||
|
|
||||||
|
RoutePointsPlugin.RoutePoint routePoint = plugin.getCurrentRoute().getRoutePointFromWpt(point);
|
||||||
|
if (routePoint.isNextNavigate) {
|
||||||
|
adapter.item(R.string.navigate_to_next).icons(
|
||||||
|
R.drawable.ic_action_gnext_dark, R.drawable.ic_action_gnext_light).listen(listener).reg();
|
||||||
|
} else {
|
||||||
|
adapter.item(R.string.mark_as_current).icons(
|
||||||
|
R.drawable.ic_action_signpost_dark, R.drawable.ic_action_signpost_light).listen(listener).reg();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void saveGPXAsync() {
|
||||||
|
new AsyncTask<RoutePointsPlugin.SelectedRouteGpxFile, Void, Void>() {
|
||||||
|
protected void onPreExecute() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Void doInBackground(RoutePointsPlugin.SelectedRouteGpxFile... params) {
|
||||||
|
if(plugin.getCurrentRoute() != null) {
|
||||||
|
plugin.getCurrentRoute().saveFile();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onPostExecute(Void result) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}.execute(plugin.getCurrentRoute());
|
||||||
|
}
|
||||||
|
}
|
|
@ -42,6 +42,8 @@ public class RoutePointsPlugin extends OsmandPlugin {
|
||||||
private TextInfoWidget routeStepsControl;
|
private TextInfoWidget routeStepsControl;
|
||||||
private SelectedRouteGpxFile currentRoute;
|
private SelectedRouteGpxFile currentRoute;
|
||||||
|
|
||||||
|
private RoutePointsLayer routePointsLayer;
|
||||||
|
|
||||||
public RoutePointsPlugin(OsmandApplication app) {
|
public RoutePointsPlugin(OsmandApplication app) {
|
||||||
ApplicationMode.regWidget("route_steps", ApplicationMode.CAR, ApplicationMode.DEFAULT);
|
ApplicationMode.regWidget("route_steps", ApplicationMode.CAR, ApplicationMode.DEFAULT);
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
@ -97,7 +99,7 @@ public class RoutePointsPlugin extends OsmandPlugin {
|
||||||
if (mapInfoLayer != null) {
|
if (mapInfoLayer != null) {
|
||||||
routeStepsControl = createRouteStepsInfoControl(activity, mapInfoLayer.getPaintSubText(), mapInfoLayer.getPaintSubText());
|
routeStepsControl = createRouteStepsInfoControl(activity, mapInfoLayer.getPaintSubText(), mapInfoLayer.getPaintSubText());
|
||||||
mapInfoLayer.getMapInfoControls().registerSideWidget(routeStepsControl,
|
mapInfoLayer.getMapInfoControls().registerSideWidget(routeStepsControl,
|
||||||
R.drawable.widget_target, R.string.map_widget_route_points, "route_steps", false, 8);
|
R.drawable.ic_signpost, R.string.map_widget_route_points, "route_steps", false, 8);
|
||||||
mapInfoLayer.recreateControls();
|
mapInfoLayer.recreateControls();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,11 +107,22 @@ public class RoutePointsPlugin extends OsmandPlugin {
|
||||||
@Override
|
@Override
|
||||||
public void registerLayers(MapActivity activity) {
|
public void registerLayers(MapActivity activity) {
|
||||||
super.registerLayers(activity);
|
super.registerLayers(activity);
|
||||||
|
|
||||||
|
if (routePointsLayer != null) {
|
||||||
|
activity.getMapView().removeLayer(routePointsLayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
routePointsLayer = new RoutePointsLayer(activity, this);
|
||||||
|
activity.getMapView().addLayer(routePointsLayer, 5.5f);
|
||||||
registerWidget(activity);
|
registerWidget(activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
|
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
|
||||||
|
if (routePointsLayer == null){
|
||||||
|
registerLayers(activity);
|
||||||
|
}
|
||||||
|
|
||||||
if (routeStepsControl == null) {
|
if (routeStepsControl == null) {
|
||||||
registerWidget(activity);
|
registerWidget(activity);
|
||||||
}
|
}
|
||||||
|
@ -143,7 +156,7 @@ public class RoutePointsPlugin extends OsmandPlugin {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
routeStepsControl.setText(null, null);
|
routeStepsControl.setText(null, null);
|
||||||
routeStepsControl.setImageDrawable(map.getResources().getDrawable(R.drawable.widget_target));
|
routeStepsControl.setImageDrawable(map.getResources().getDrawable(R.drawable.ic_signpost));
|
||||||
return routeStepsControl;
|
return routeStepsControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,6 +178,7 @@ public class RoutePointsPlugin extends OsmandPlugin {
|
||||||
public boolean isNextNavigate() {
|
public boolean isNextNavigate() {
|
||||||
return isNextNavigate;
|
return isNextNavigate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isVisited() {
|
public boolean isVisited() {
|
||||||
return visitedTime != 0;
|
return visitedTime != 0;
|
||||||
}
|
}
|
||||||
|
@ -358,6 +372,35 @@ public class RoutePointsPlugin extends OsmandPlugin {
|
||||||
sortPoints();
|
sortPoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getPointStatus(WptPt p) {
|
||||||
|
RoutePoint point = getRoutePointFromWpt(p);
|
||||||
|
return point != null && (point.isVisited());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void markPoint(WptPt point, boolean visited) {
|
||||||
|
RoutePoint routePoint = getRoutePointFromWpt(point);
|
||||||
|
if (routePoint != null) {
|
||||||
|
markPoint(routePoint, visited);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void navigateToPoint(WptPt point) {
|
||||||
|
RoutePoint routePoint = getRoutePointFromWpt(point);
|
||||||
|
if (routePoint != null) {
|
||||||
|
navigateToPoint(routePoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoutePoint getRoutePointFromWpt(WptPt point) {
|
||||||
|
if (currentPoints != null) {
|
||||||
|
for (RoutePoint find : currentPoints) {
|
||||||
|
WptPt itemToFind = find.getWpt();
|
||||||
|
if (itemToFind.equals(point)) {
|
||||||
|
return find;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue