Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-09-27 23:08:11 +02:00
commit 84034beb2f
2 changed files with 16 additions and 11 deletions

View file

@ -249,14 +249,16 @@ public class NavigationService extends Service implements LocationListener {
@Override @Override
public void onTaskRemoved(Intent rootIntent) { public void onTaskRemoved(Intent rootIntent) {
if (((OsmandApplication) getApplication()).getNavigationService() != null && OsmandApplication app = ((OsmandApplication) getApplication());
((OsmandApplication) getApplication()).getSettings().DISABLE_RECORDING_ONCE_APP_KILLED.get()) { if (app.getNavigationService() != null &&
app.getSettings().DISABLE_RECORDING_ONCE_APP_KILLED.get()) {
OsMoPlugin plugin = OsmandPlugin.getEnabledPlugin(OsMoPlugin.class); OsMoPlugin plugin = OsmandPlugin.getEnabledPlugin(OsMoPlugin.class);
if (plugin != null) { if (plugin != null) {
if (plugin.getTracker().isEnabledTracker()) { if (plugin.getTracker().isEnabledTracker()) {
plugin.getTracker().disableTracker(); plugin.getTracker().disableTracker();
} }
} }
app.getNotificationHelper().removeServiceNotificationCompletely();
NavigationService.this.stopSelf(); NavigationService.this.stopSelf();
} }
} }

View file

@ -118,28 +118,31 @@ public class NotificationHelper {
.setContentTitle(Version.getAppName(app)).setContentText(notificationText).setSmallIcon(icon) .setContentTitle(Version.getAppName(app)).setContentText(notificationText).setSmallIcon(icon)
.setContentIntent(contentPendingIntent).setOngoing(service != null); .setContentIntent(contentPendingIntent).setOngoing(service != null);
if (monitoringPlugin != null) { if (monitoringPlugin != null) {
if(service != null && (service.getUsedBy() & NavigationService.USED_BY_GPX) != 0) { Intent saveIntent = new Intent(OSMAND_SAVE_GPX_SERVICE_ACTION);
PendingIntent savePendingIntent = PendingIntent.getBroadcast(app, 0, saveIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
if(service != null && service.getUsedBy() == NavigationService.USED_BY_GPX) {
Intent stopIntent = new Intent(OSMAND_STOP_GPX_SERVICE_ACTION); Intent stopIntent = new Intent(OSMAND_STOP_GPX_SERVICE_ACTION);
PendingIntent stopPendingIntent = PendingIntent.getBroadcast(app, 0, stopIntent, PendingIntent stopPendingIntent = PendingIntent.getBroadcast(app, 0, stopIntent,
PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent.FLAG_UPDATE_CURRENT);
notificationBuilder.addAction(R.drawable.ic_action_rec_stop, notificationBuilder.addAction(R.drawable.ic_action_rec_stop,
app.getString(R.string.shared_string_control_stop), stopPendingIntent); app.getString(R.string.shared_string_control_stop), stopPendingIntent);
} else { notificationBuilder.addAction(R.drawable.ic_action_save, app.getString(R.string.shared_string_save),
savePendingIntent);
} else if(service == null) {
Intent startIntent = new Intent(OSMAND_START_GPX_SERVICE_ACTION); Intent startIntent = new Intent(OSMAND_START_GPX_SERVICE_ACTION);
PendingIntent startPendingIntent = PendingIntent.getBroadcast(app, 0, startIntent, PendingIntent startPendingIntent = PendingIntent.getBroadcast(app, 0, startIntent,
PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent.FLAG_UPDATE_CURRENT);
notificationBuilder.addAction(R.drawable.ic_action_rec_start, notificationBuilder.addAction(R.drawable.ic_action_rec_start,
app.getString(R.string.shared_string_control_start), startPendingIntent); app.getString(R.string.shared_string_control_start), startPendingIntent);
}
Intent saveIntent = new Intent(OSMAND_SAVE_GPX_SERVICE_ACTION);
PendingIntent savePendingIntent = PendingIntent.getBroadcast(app, 0, saveIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
notificationBuilder.addAction(R.drawable.ic_action_save, app.getString(R.string.shared_string_save), notificationBuilder.addAction(R.drawable.ic_action_save, app.getString(R.string.shared_string_save),
savePendingIntent); savePendingIntent);
} }
}
return notificationBuilder; return notificationBuilder;
} }