diff --git a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java index ee2fdee108..29bdc36de1 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java +++ b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java @@ -86,6 +86,7 @@ public abstract class OsmandPlugin { if(Version.isRouteNavPluginInlined(app)) { RoutePointsPlugin routePointsPlugin = new RoutePointsPlugin(app); installedPlugins.add(routePointsPlugin); + enablePlugin(app, routePointsPlugin, true); } installPlugin(OSMODROID_PLUGIN_COMPONENT, OsMoDroidPlugin.ID, app, new OsMoDroidPlugin(app)); @@ -137,7 +138,7 @@ public abstract class OsmandPlugin { public void mapActivityDestroy(MapActivity activity) { } - public void destinationReached() { } + public boolean destinationReached() { return true; } public void settingsActivityCreate(SettingsActivity activity, PreferenceScreen screen) {} @@ -240,10 +241,14 @@ public abstract class OsmandPlugin { } } - public static void onDestinationReached() { + public static boolean onDestinationReached() { + boolean b = true; for (OsmandPlugin plugin : activePlugins) { - plugin.destinationReached(); + if(!plugin.destinationReached()){ + b = false; + } } + return b; } diff --git a/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsPlugin.java b/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsPlugin.java index 77a40a4d7b..1c2b646300 100644 --- a/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsPlugin.java @@ -62,10 +62,14 @@ public class RoutePointsPlugin extends OsmandPlugin { @Override - public void destinationReached() { + public boolean destinationReached() { if(currentRoute != null) { - currentRoute.naviateToNextPoint(); + boolean naviateToNextPoint = currentRoute.naviateToNextPoint(); + if(naviateToNextPoint) { + return false; + } } + return true; } @Override @@ -248,7 +252,7 @@ public class RoutePointsPlugin extends OsmandPlugin { sortPoints(); } - public void naviateToNextPoint() { + public boolean naviateToNextPoint() { if(!currentPoints.isEmpty()) { RoutePoint rp = currentPoints.get(0); if(rp.isNextNavigate) { @@ -259,11 +263,12 @@ public class RoutePointsPlugin extends OsmandPlugin { if(!first.isVisited()) { app.getTargetPointsHelper().navigateToPoint(first.getPoint(), true, -1, first.getName()); first.isNextNavigate = true; + return true; } else { app.getTargetPointsHelper().clearPointToNavigate(true); } - } + return false; } private void sortPoints() { diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index faff41c070..2e5212ae4e 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -434,16 +434,17 @@ public class RoutingHelper { if(isFollowingMode) { voiceRouter.arrivedDestinationPoint(description); } - clearCurrentRoute(null, null); - setRoutePlanningMode(false); - OsmandPlugin.onDestinationReached(); - app.runInUIThread(new Runnable() { - @Override - public void run() { - settings.APPLICATION_MODE.set(settings.DEFAULT_APPLICATION_MODE.get()); - } - }); - + if (OsmandPlugin.onDestinationReached()) { + clearCurrentRoute(null, null); + setRoutePlanningMode(false); + OsmandPlugin.onDestinationReached(); + app.runInUIThread(new Runnable() { + @Override + public void run() { + settings.APPLICATION_MODE.set(settings.DEFAULT_APPLICATION_MODE.get()); + } + }); + } // targets.clearPointToNavigate(false); return true; }