From b0afbeb6786cbe725dc842b014b5a7d6129c79f4 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 19 Jun 2014 15:05:32 +0200 Subject: [PATCH] update route points activity --- OsmAnd/res/values/colors.xml | 1 + .../RoutePointsActivity.java | 14 +++++++++++++- .../routepointsnavigation/RoutePointsPlugin.java | 15 +++++++++++++++ OsmAnd/src/net/osmand/plus/views/GPXLayer.java | 16 +++++++++++++--- 4 files changed, 42 insertions(+), 4 deletions(-) diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml index 26db37c054..1a7ce30d08 100644 --- a/OsmAnd/res/values/colors.xml +++ b/OsmAnd/res/values/colors.xml @@ -1,5 +1,6 @@ + #cd2c33 #c79c00 #32CD32 #EE3232 diff --git a/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsActivity.java b/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsActivity.java index 3243a10072..658fccd744 100644 --- a/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsActivity.java +++ b/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsActivity.java @@ -6,6 +6,7 @@ import java.util.List; import net.osmand.CallbackWithObject; import net.osmand.data.LatLon; import net.osmand.plus.GPXUtilities; +import net.osmand.plus.GPXUtilities.GPXFile; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; @@ -71,7 +72,10 @@ public class RoutePointsActivity extends OsmandListActivity { GpxUiHelper.selectGPXFile(this, false, false, new CallbackWithObject() { @Override public boolean processResult(GPXUtilities.GPXFile[] result) { - plugin.setCurrentRoute(result[0]); + final GPXFile gpx = result[0]; + app.getSelectedGpxHelper().clearAllGpxFileToShow(); + app.getSelectedGpxHelper().setGpxFileToDisplay(gpx); + plugin.setCurrentRoute(gpx); SelectedRouteGpxFile sgpx = plugin.getCurrentRoute(); sgpx.naviateToNextPoint(); prepareView(); @@ -79,6 +83,14 @@ public class RoutePointsActivity extends OsmandListActivity { } }); } + + @Override + protected void onResume() { + super.onResume(); + if(plugin.getCurrentRoute() != null) { + plugin.getCurrentRoute().updateCurrentTargetPoint(); + } + } private void prepareView() { diff --git a/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsPlugin.java b/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsPlugin.java index 58585b6220..8bb33e5dc7 100644 --- a/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsPlugin.java @@ -332,6 +332,21 @@ public class RoutePointsPlugin extends OsmandPlugin { sortPoints(); app.getTargetPointsHelper().navigateToPoint(rp.getPoint(), true, -1, rp.getName()); } + + public void updateCurrentTargetPoint() { + TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper(); + String locName = targetPointsHelper.getPointNavigateDescription(); + for(int i = 0; i < currentPoints.size(); i++) { + RoutePoint rtp = currentPoints.get(i); + rtp.isNextNavigate = rtp.visitedTime == 0 && locName != null && locName.equals(rtp.getName()); + if(rtp.isNextNavigate) { + locName = null; + } + + } + sortPoints(); + } } + } diff --git a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java index d9baa01b6d..8830f51553 100644 --- a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java @@ -97,7 +97,8 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex List selectedGPXFiles = selectedGpxHelper.getSelectedGPXFiles(); int clr = getColor(settings); cache.clear(); - int pointColor = view.getResources().getColor(R.color.gpx_track); + int defPointColor = view.getResources().getColor(R.color.gpx_color_point); + int visitedColor = view.getContext().getResources().getColor(R.color.color_ok); if (!selectedGPXFiles.isEmpty()) { for (SelectedGpxFile g : selectedGPXFiles) { List> points = g.getPointsToDisplay(); @@ -111,9 +112,18 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex final QuadRect latLonBounds = tileBox.getLatLonBounds(); for (SelectedGpxFile g : selectedGPXFiles) { List pts = g.getGpxFile().points; - int fcolor = g.getColor() == 0 ? pointColor : g.getColor(); - FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(view.getContext(), fcolor); + if(pts.isEmpty() & !g.getGpxFile().routes.isEmpty()) { + pts = g.getGpxFile().routes.get(0).points; + } + int fcolor = g.getColor() == 0 ? defPointColor : g.getColor(); + for (WptPt o : pts) { + int pointColor = o.getColor(fcolor); + String visited = o.getExtensionsToRead().get("VISITED_KEY"); + if(visited != null && !visited.equals("0")) { + pointColor = visitedColor; + } + FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(view.getContext(), pointColor); if (o.lat >= latLonBounds.bottom && o.lat <= latLonBounds.top && o.lon >= latLonBounds.left && o.lon <= latLonBounds.right) { cache.add(o);