From d38407e11abd63df39cb23869503715b05ae2507 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sun, 23 Sep 2012 18:07:14 +0200 Subject: [PATCH] Enable background service in navigation mode --- OsmAnd/res/drawable-hdpi/monitoring.png | Bin 0 -> 1918 bytes OsmAnd/res/drawable-large/monitoring.png | Bin 0 -> 1918 bytes OsmAnd/res/values/strings.xml | 1 + .../net/osmand/plus/NavigationService.java | 60 ++++++++++++------ .../net/osmand/plus/OsmandApplication.java | 2 +- .../osmand/plus/activities/MapActivity.java | 24 ++++++- .../plus/activities/MapActivityActions.java | 52 +++------------ .../osmand/plus/routing/RoutingHelper.java | 56 ++++++++++------ 8 files changed, 105 insertions(+), 90 deletions(-) create mode 100644 OsmAnd/res/drawable-hdpi/monitoring.png create mode 100644 OsmAnd/res/drawable-large/monitoring.png diff --git a/OsmAnd/res/drawable-hdpi/monitoring.png b/OsmAnd/res/drawable-hdpi/monitoring.png new file mode 100644 index 0000000000000000000000000000000000000000..cbc5e15c90d702962ec8aa6fda1b5d3706798096 GIT binary patch literal 1918 zcmV-^2Z8vBP)dv`oiKP)LWY}jcZio^*JpsoJ~KlER3jXoA= zi@$k1xE1&(aOV?Y2+4g<~auF#+q!f`%L^9S%{Fa;(aQEcyjk_=1eF;R?$!sLq7T^^K zK%uG!S(e=!4u_u?MX?t`C@&Kbksj%FBs`_m)OG!)s;Zxxruo6$CqUJaSS5QS1bT3} zh#cs`&Kj)A5rhPrh9&7Sc3LN-3Rm;ColPF#-w% z5h+Kb(I4;MzyI*7ufF=SEX!L}Rps;f9DtM(%jJ@jlM|N9S13)Fl73rI(x$n*SGp63VdzB?X|6-Y701mNz{G!4_~ zl%{ELcT|x#3kp@m-PO#7gTdf1&+~m?KpSVh%f8hLn-J(13qX-&*{Ern zay%aEcsx!qMr)eJrH@)#OROy*ay~k7Ri!LT+?|wCAtEJEbb6Ext+0&+6v*6N=kqzQ zUcK_kWMXG$XHwU-uYhY2uIxUS|ARKLZ{51Z?(S|{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YDV;aG$z5X_`cUe=WpJ@EI*#P1XXm%v{EaSHr9%lKK9Qxzs6=!*OGpXV9yNkGk2n}!ooT^?ldAfb32Q4DklK)TyuHf&QRDExAO$;~_;jFtpKgz90S59AU zBW}%P8v@=d&a#ZbU|?C6#qL<>(#o|+R{d|K4EMoc;30&hs;fs#)ztJeG=*V)DL?p(@ z>FKGsyQh?lEn14(5a>ymyT`h&r&U$WX0zFHG#c%N5b}2kLU(7eSj3Z)lQf-9r*&P= zfF)a!*opv9#~6Q^PNzTo^wUqzo2H>G%Nbl;0^XAQ>D2hW>Ek$JG(_PyVvRGBsc(GV~S5?)&Qc5pq-w*Tz zHX^aND|Tk!+Q-RqRn>y*+fGyC4%k7=v)GulJk zM!nHZ37j`~X`2nZz=4Py0y|w}b}Irv?d~&oe*^qVTS6_kc)@Wczq}6txOl~sccY+f zhxgZ;Hf8&GiXGS`?K^>ni+2MXfoDU7tI{`L18w|-m9c40^L$J0fF>?nW-IV)sPMWu z%GFNtR=d#3Sl$1(0^fsqACceq{x*59`sb5;k{gu&0X{XV8bKu8X#fBK07*qoM6N<$ Ef) + No route Remove target point Target point %1$s Waypoint %1$s diff --git a/OsmAnd/src/net/osmand/plus/NavigationService.java b/OsmAnd/src/net/osmand/plus/NavigationService.java index 789162eb99..b0487187c3 100644 --- a/OsmAnd/src/net/osmand/plus/NavigationService.java +++ b/OsmAnd/src/net/osmand/plus/NavigationService.java @@ -35,6 +35,7 @@ public class NavigationService extends Service implements LocationListener { } private final static int NOTIFICATION_SERVICE_ID = 1; public final static String OSMAND_STOP_SERVICE_ACTION = "OSMAND_STOP_SERVICE_ACTION"; //$NON-NLS-1$ + public final static String NAVIGATION_START_SERVICE_PARAM = "NAVIGATION_START_SERVICE_PARAM"; private static final int LOST_LOCATION_MSG_ID = 10; private static final long LOST_LOCATION_CHECK_DELAY = 20000; @@ -55,6 +56,7 @@ public class NavigationService extends Service implements LocationListener { private PendingIntent pendingIntent; private BroadcastReceiver broadcastReceiver; private LiveMonitoringHelper liveMonitoringHelper; + private boolean startedForNavigation; @Override public IBinder onBind(Intent intent) { @@ -85,14 +87,20 @@ public class NavigationService extends Service implements LocationListener { return serviceOffProvider; } + public boolean startedForNavigation(){ + return startedForNavigation; + } @Override - public void onCreate() { - super.onCreate(); - // initializing variables - setForeground(true); + public int onStartCommand(Intent intent, int flags, int startId) { handler = new Handler(); settings = ((OsmandApplication) getApplication()).getSettings(); - serviceOffInterval = settings.SERVICE_OFF_INTERVAL.get(); + + startedForNavigation = intent.getBooleanExtra(NAVIGATION_START_SERVICE_PARAM, false); + if (startedForNavigation) { + serviceOffInterval = 0; + } else { + serviceOffInterval = settings.SERVICE_OFF_INTERVAL.get(); + } // use only gps provider serviceOffProvider = LocationManager.GPS_PROVIDER; serviceError = serviceOffInterval / 5; @@ -122,23 +130,33 @@ public class NavigationService extends Service implements LocationListener { } // registering icon at top level - broadcastReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - NavigationService.this.stopSelf(); - } + // Leave icon visible even for navigation for proper testing +// if (!startedForNavigation) { + broadcastReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + NavigationService.this.stopSelf(); + } - }; - registerReceiver(broadcastReceiver, new IntentFilter(OSMAND_STOP_SERVICE_ACTION)); - Intent notificationIntent = new Intent(OSMAND_STOP_SERVICE_ACTION); - Notification notification = new Notification(R.drawable.bgs_icon, "", //$NON-NLS-1$ - System.currentTimeMillis()); - notification.flags = Notification.FLAG_NO_CLEAR; - notification.setLatestEventInfo(this, Version.getAppName(this), - getString(R.string.service_stop_background_service), PendingIntent.getBroadcast(this, 0, notificationIntent, - PendingIntent.FLAG_UPDATE_CURRENT)); - NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); - mNotificationManager.notify(NOTIFICATION_SERVICE_ID, notification); + }; + registerReceiver(broadcastReceiver, new IntentFilter(OSMAND_STOP_SERVICE_ACTION)); + Intent notificationIntent = new Intent(OSMAND_STOP_SERVICE_ACTION); + Notification notification = new Notification(R.drawable.bgs_icon, "", //$NON-NLS-1$ + System.currentTimeMillis()); + notification.flags = Notification.FLAG_NO_CLEAR; + notification.setLatestEventInfo(this, Version.getAppName(this), getString(R.string.service_stop_background_service), + PendingIntent.getBroadcast(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT)); + NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); + mNotificationManager.notify(NOTIFICATION_SERVICE_ID, notification); +// } + return START_REDELIVER_INTENT; + } + + @Override + public void onCreate() { + super.onCreate(); + // initializing variables + setForeground(true); } private boolean isContinuous(){ diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index bcb106dbf2..9516ea6c57 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -86,7 +86,7 @@ public class OsmandApplication extends Application { long timeToStart = System.currentTimeMillis(); osmandSettings = createOsmandSettingsInstance(); - routingHelper = new RoutingHelper(osmandSettings, this, player); + routingHelper = new RoutingHelper(this, player); manager = new ResourceManager(this); daynightHelper = new DayNightHelper(this); bidforfix = new BidForFixHelper("osmand.net", getString(R.string.default_buttons_support), getString(R.string.default_buttons_cancel)); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 7ccb55efb4..a5b5a6f121 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -426,9 +426,7 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe if (endPoint == null) { notRestoreRoutingMode(); } else { - routingHelper.setFollowingMode(true); - routingHelper.setFinalAndCurrentLocation(endPoint, intermediates, startPoint, gpxRoute); - getMyApplication().showDialogInitializingCommandPlayer(MapActivity.this); + followRoute(settings.getApplicationMode(), endPoint, intermediates, startPoint, gpxRoute); } } }; @@ -944,6 +942,26 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe settings.getIntermediatePoints(), getLastKnownLocation(), routingHelper.getCurrentGPXRoute()); } } + + public void followRoute(ApplicationMode appMode, LatLon finalLocation, List intermediatePoints, Location currentLocation, GPXRouteParams gpxRoute){ + // change global settings + // Do not overwrite PREV_APPLICATION_MODE if already navigating + if (!routingHelper.isFollowingMode()) { + settings.PREV_APPLICATION_MODE.set(settings.APPLICATION_MODE.get()); + } + boolean changed = settings.APPLICATION_MODE.set(appMode); + if (changed) { + updateApplicationModeSettings(); + } + getMapView().refreshMap(changed); + settings.FOLLOW_THE_ROUTE.set(true); + if(gpxRoute == null) { + settings.FOLLOW_THE_GPX_ROUTE.set(null); + } + routingHelper.setFollowingMode(true); + routingHelper.setFinalAndCurrentLocation(finalLocation, intermediatePoints, currentLocation, gpxRoute); + getMyApplication().showDialogInitializingCommandPlayer(MapActivity.this); + } public void navigateToPoint(LatLon point, boolean updateRoute, int intermediate){ if(point != null){ diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 45a3710cfb..72700eaeaa 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -469,10 +469,6 @@ public class MapActivityActions implements DialogProvider { return; } ApplicationMode mode = getAppMode(buttons, settings); - // Do not overwrite PREV_APPLICATION_MODE if already navigating - if (!routingHelper.isFollowingMode()) { - settings.PREV_APPLICATION_MODE.set(settings.APPLICATION_MODE.get()); - } routingHelper.setAppMode(mode); settings.FOLLOW_THE_ROUTE.set(false); settings.FOLLOW_THE_GPX_ROUTE.set(null); @@ -502,24 +498,9 @@ public class MapActivityActions implements DialogProvider { AccessibleToast.makeText(mapActivity, R.string.route_updated_loc_found, Toast.LENGTH_LONG).show(); } ApplicationMode mode = getAppMode(buttons, settings); - // change global settings - // Do not overwrite PREV_APPLICATION_MODE if already navigating - if (!routingHelper.isFollowingMode()) { - settings.PREV_APPLICATION_MODE.set(settings.APPLICATION_MODE.get()); - } - boolean changed = settings.APPLICATION_MODE.set(mode); - if (changed) { - mapActivity.updateApplicationModeSettings(); - mapActivity.getMapView().refreshMap(true); - } - routingHelper.setAppMode(mode); - settings.FOLLOW_THE_ROUTE.set(true); - settings.FOLLOW_THE_GPX_ROUTE.set(null); - routingHelper.setFollowingMode(true); - routingHelper.setFinalAndCurrentLocation(mapActivity.getPointToNavigate(), mapActivity.getIntermediatePoints(), - current, null); dialog.dismiss(); - getMyApplication().showDialogInitializingCommandPlayer(mapActivity); + mapActivity.followRoute(mode, mapActivity.getPointToNavigate(), mapActivity.getIntermediatePoints(), + current, null); } }; @@ -533,15 +514,12 @@ public class MapActivityActions implements DialogProvider { builder.setView(view); builder.setTitle(R.string.get_directions); + builder.setPositiveButton(R.string.follow, followCall); + builder.setNeutralButton(R.string.only_show, onlyShowCall); if (gpxRouteEnabled) { - builder.setPositiveButton(R.string.follow, followCall); - builder.setNeutralButton(R.string.gpx_navigation, useGpxNavigation); - builder.setNegativeButton(R.string.only_show, onlyShowCall); + builder.setNegativeButton(R.string.gpx_navigation, useGpxNavigation); } else { - // view.findViewById(R.id.TextView).setVisibility(View.GONE); - builder.setPositiveButton(R.string.follow, followCall); - builder.setNeutralButton(R.string.only_show, onlyShowCall); - builder.setNegativeButton(R.string.default_buttons_cancel, null); + builder.setNegativeButton(R.string.no_route, null); } builder.show(); } @@ -553,7 +531,6 @@ public class MapActivityActions implements DialogProvider { public void navigateUsingGPX(final ApplicationMode appMode) { final LatLon endForRouting = mapActivity.getPointToNavigate(); final MapActivityLayers mapLayers = mapActivity.getMapLayers(); - final RoutingHelper routingHelper = mapActivity.getRoutingHelper(); mapLayers.selectGPXFileLayer(new CallbackWithObject() { @Override @@ -597,23 +574,10 @@ public class MapActivityActions implements DialogProvider { mapLayers.getNavigationLayer().setPointToNavigate(point, new ArrayList()); } } - // change global settings - // Do not overwrite PREV_APPLICATION_MODE if already navigating - if (!routingHelper.isFollowingMode()) { - settings.PREV_APPLICATION_MODE.set(settings.APPLICATION_MODE.get()); - } - boolean changed = settings.APPLICATION_MODE.set(appMode); - if (changed) { - mapActivity.updateApplicationModeSettings(); - } - mapActivity.getMapView().refreshMap(changed); if(endPoint != null){ - settings.FOLLOW_THE_ROUTE.set(true); - settings.FOLLOW_THE_GPX_ROUTE.set(result.path); - routingHelper.setFollowingMode(true); - routingHelper.setFinalAndCurrentLocation(endPoint, + mapActivity.followRoute(appMode, endPoint, new ArrayList(), startForRouting, gpxRoute); - getMyApplication().showDialogInitializingCommandPlayer(mapActivity); + settings.FOLLOW_THE_GPX_ROUTE.set(result.path); } } }); diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index f88182933d..0d0a9b1452 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -10,6 +10,8 @@ import net.osmand.OsmAndFormatter; import net.osmand.access.AccessibleToast; import net.osmand.osm.LatLon; import net.osmand.osm.MapUtils; +import net.osmand.plus.NavigationService; +import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.OsmandSettings.MetricsConstants; @@ -21,6 +23,7 @@ import net.osmand.plus.voice.CommandPlayer; import net.osmand.router.Interruptable; import net.osmand.router.RouteSegmentResult; import android.content.Context; +import android.content.Intent; import android.location.Location; import android.os.Handler; import android.widget.Toast; @@ -40,7 +43,7 @@ public class RoutingHelper { private List listeners = new ArrayList(); - private Context context; + private OsmandApplication app; private boolean isFollowingMode = false; @@ -74,9 +77,8 @@ public class RoutingHelper { } - public RoutingHelper(OsmandSettings settings, Context context, CommandPlayer player){ - this.settings = settings; - this.context = context; + public RoutingHelper(OsmandApplication context, CommandPlayer player){ + this.app = context; voiceRouter = new VoiceRouter(this, player); uiHandler = new Handler(); } @@ -84,11 +86,22 @@ public class RoutingHelper { public boolean isFollowingMode() { return isFollowingMode; } - - public void setFollowingMode(boolean isFollowingMode) { - this.isFollowingMode = isFollowingMode; - } + public void setFollowingMode(boolean follow) { + isFollowingMode = follow; + Intent serviceIntent = new Intent(app, NavigationService.class); + if(follow) { + if(app.getNavigationService() == null) { + serviceIntent.putExtra(NavigationService.NAVIGATION_START_SERVICE_PARAM, true); + app.startService(serviceIntent); + } + } else { + if(app.getNavigationService() != null && app.getNavigationService().startedForNavigation()) { + app.stopService(serviceIntent); + } + } + } + public synchronized void setFinalAndCurrentLocation(LatLon finalLocation, List intermediatePoints, Location currentLocation, GPXRouteParams gpxRoute){ @@ -121,7 +134,7 @@ public class RoutingHelper { settings.FOLLOW_THE_GPX_ROUTE.set(null); // clear last fixed location this.lastProjection = null; - this.isFollowingMode = false; + setFollowingMode(false); } } @@ -340,7 +353,7 @@ public class RoutingHelper { // 2. check if intermediate found if(route.getIntermediatePointsToPass() > 0 && route.getDistanceToNextIntermediate(lastFixedLocation) < posTolerance) { - showMessage(context.getString(R.string.arrived_at_intermediate_point)); + showMessage(app.getString(R.string.arrived_at_intermediate_point)); voiceRouter.arrivedIntermediatePoint(); route.passIntermediatePoint(); int toDel = settings.getIntermediatePoints().size() - route.getIntermediatePointsToPass(); @@ -356,7 +369,7 @@ public class RoutingHelper { // 3. check if destination found Location lastPoint = routeNodes.get(routeNodes.size() - 1); if (currentRoute > routeNodes.size() - 3 && currentLocation.distanceTo(lastPoint) < posTolerance * 1.2) { - showMessage(context.getString(R.string.arrived_at_destination)); + showMessage(app.getString(R.string.arrived_at_destination)); voiceRouter.arrivedDestinationPoint(); clearCurrentRoute(null, null); return true; @@ -478,7 +491,7 @@ public class RoutingHelper { int dist = getLeftDistance(); int hours = getLeftTime() / (60 * 60); int minutes = (getLeftTime() / 60) % 60; - return context.getString(R.string.route_general_information, OsmAndFormatter.getFormattedDistance(dist, context), + return app.getString(R.string.route_general_information, OsmAndFormatter.getFormattedDistance(dist, app), hours, minutes); } @@ -588,7 +601,7 @@ public class RoutingHelper { public void run() { boolean leftSide = settings.LEFT_SIDE_NAVIGATION.get(); boolean fastRoute = settings.FAST_ROUTE_MODE.get(); - RouteCalculationResult res = provider.calculateRouteImpl(start, end, intermediates, mode, service, context, gpxRoute, previousRoute, fastRoute, + RouteCalculationResult res = provider.calculateRouteImpl(start, end, intermediates, mode, service, app, gpxRoute, previousRoute, fastRoute, leftSide, this); if (interrupted) { currentRunningJob = null; @@ -606,16 +619,16 @@ public class RoutingHelper { } if (res.isCalculated()) { - showMessage(context.getString(R.string.new_route_calculated_dist) - + ": " + OsmAndFormatter.getFormattedDistance(res.getWholeDistance(), context)); //$NON-NLS-1$ + showMessage(app.getString(R.string.new_route_calculated_dist) + + ": " + OsmAndFormatter.getFormattedDistance(res.getWholeDistance(), app)); //$NON-NLS-1$ } else if (service != RouteService.OSMAND && !settings.isInternetConnectionAvailable()) { - showMessage(context.getString(R.string.error_calculating_route) - + ":\n" + context.getString(R.string.internet_connection_required_for_online_route), Toast.LENGTH_LONG); //$NON-NLS-1$ + showMessage(app.getString(R.string.error_calculating_route) + + ":\n" + app.getString(R.string.internet_connection_required_for_online_route), Toast.LENGTH_LONG); //$NON-NLS-1$ } else { if (res.getErrorMessage() != null) { - showMessage(context.getString(R.string.error_calculating_route) + ":\n" + res.getErrorMessage(), Toast.LENGTH_LONG); //$NON-NLS-1$ + showMessage(app.getString(R.string.error_calculating_route) + ":\n" + res.getErrorMessage(), Toast.LENGTH_LONG); //$NON-NLS-1$ } else { - showMessage(context.getString(R.string.empty_route_calculated), Toast.LENGTH_LONG); + showMessage(app.getString(R.string.empty_route_calculated), Toast.LENGTH_LONG); } } lastTimeEvaluatedRoute = System.currentTimeMillis(); @@ -647,7 +660,7 @@ public class RoutingHelper { uiHandler.post(new Runnable() { @Override public void run() { - AccessibleToast.makeText(context, msg, length).show(); + AccessibleToast.makeText(app, msg, length).show(); } }); } @@ -662,7 +675,7 @@ public class RoutingHelper { } protected Context getContext() { - return context; + return app; } @@ -670,4 +683,5 @@ public class RoutingHelper { return provider.createOsmandRouterGPX(route); } + }