Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
50b1a11bc5
3 changed files with 64 additions and 31 deletions
|
@ -38,7 +38,6 @@ public class NavigationService extends Service implements LocationListener {
|
||||||
// global id don't conflict with others
|
// global id don't conflict with others
|
||||||
private final static int NOTIFICATION_SERVICE_ID = 5;
|
private final static int NOTIFICATION_SERVICE_ID = 5;
|
||||||
public final static String OSMAND_STOP_SERVICE_ACTION = "OSMAND_STOP_SERVICE_ACTION"; //$NON-NLS-1$
|
public final static String OSMAND_STOP_SERVICE_ACTION = "OSMAND_STOP_SERVICE_ACTION"; //$NON-NLS-1$
|
||||||
public final static String OSMAND_SAVE_SERVICE_ACTION = "OSMAND_SAVE_SERVICE_ACTION";
|
|
||||||
public static int USED_BY_NAVIGATION = 1;
|
public static int USED_BY_NAVIGATION = 1;
|
||||||
public static int USED_BY_GPX = 2;
|
public static int USED_BY_GPX = 2;
|
||||||
public static int USED_BY_LIVE = 4;
|
public static int USED_BY_LIVE = 4;
|
||||||
|
@ -176,26 +175,23 @@ public class NavigationService extends Service implements LocationListener {
|
||||||
if (settings.SAVE_GLOBAL_TRACK_TO_GPX.get()) {
|
if (settings.SAVE_GLOBAL_TRACK_TO_GPX.get()) {
|
||||||
settings.SAVE_GLOBAL_TRACK_TO_GPX.set(false);
|
settings.SAVE_GLOBAL_TRACK_TO_GPX.set(false);
|
||||||
}
|
}
|
||||||
OsMoPlugin plugin = OsmandPlugin.getEnabledPlugin(OsMoPlugin.class);
|
OsMoPlugin osmoPlugin = OsmandPlugin.getEnabledPlugin(OsMoPlugin.class);
|
||||||
if (plugin != null) {
|
if (osmoPlugin != null) {
|
||||||
if (plugin.getTracker().isEnabledTracker()) {
|
if (osmoPlugin.getTracker().isEnabledTracker()) {
|
||||||
plugin.getTracker().disableTracker();
|
osmoPlugin.getTracker().disableTracker();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
OsmandMonitoringPlugin monitoringPlugin =
|
||||||
|
OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class);
|
||||||
|
if (monitoringPlugin != null) {
|
||||||
|
monitoringPlugin.stopRecording();
|
||||||
|
}
|
||||||
NavigationService.this.stopSelf();
|
NavigationService.this.stopSelf();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
registerReceiver(broadcastReceiver, new IntentFilter(OSMAND_STOP_SERVICE_ACTION));
|
registerReceiver(broadcastReceiver, new IntentFilter(OSMAND_STOP_SERVICE_ACTION));
|
||||||
saveBroadcastReceiver = new BroadcastReceiver() {
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
final OsmandMonitoringPlugin plugin = OsmandPlugin
|
|
||||||
.getEnabledPlugin(OsmandMonitoringPlugin.class);
|
|
||||||
plugin.saveCurrentTrack();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
registerReceiver(saveBroadcastReceiver, new IntentFilter(OSMAND_SAVE_SERVICE_ACTION));
|
|
||||||
|
|
||||||
//Show currently active wake-up interval
|
//Show currently active wake-up interval
|
||||||
int soi = settings.SERVICE_OFF_INTERVAL.get();
|
int soi = settings.SERVICE_OFF_INTERVAL.get();
|
||||||
|
@ -215,14 +211,6 @@ public class NavigationService extends Service implements LocationListener {
|
||||||
// notification.flags = Notification.FLAG_NO_CLEAR;
|
// notification.flags = Notification.FLAG_NO_CLEAR;
|
||||||
// startForeground(NOTIFICATION_SERVICE_ID, notification);
|
// startForeground(NOTIFICATION_SERVICE_ID, notification);
|
||||||
|
|
||||||
String stop = getResources().getString(R.string.shared_string_control_stop);
|
|
||||||
Intent stopIntent = new Intent(OSMAND_STOP_SERVICE_ACTION);
|
|
||||||
PendingIntent stopPendingIntent = PendingIntent.getBroadcast(this, 0, stopIntent,
|
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT);
|
|
||||||
String pause = getResources().getString(R.string.shared_string_save);
|
|
||||||
Intent saveIntent = new Intent(OSMAND_SAVE_SERVICE_ACTION);
|
|
||||||
PendingIntent savePendingIntent = PendingIntent.getBroadcast(this, 0, saveIntent,
|
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT);
|
|
||||||
Intent contentIntent = new Intent(this, MapActivity.class);
|
Intent contentIntent = new Intent(this, MapActivity.class);
|
||||||
PendingIntent contentPendingIntent = PendingIntent.getActivity(this, 0, contentIntent,
|
PendingIntent contentPendingIntent = PendingIntent.getActivity(this, 0, contentIntent,
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT);
|
PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
|
|
@ -3,9 +3,15 @@ package net.osmand.plus.monitoring;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.AlertDialog.Builder;
|
import android.app.AlertDialog.Builder;
|
||||||
|
import android.app.NotificationManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.DialogInterface.OnClickListener;
|
import android.content.DialogInterface.OnClickListener;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
|
import android.support.v4.app.NotificationCompat;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
@ -45,6 +51,8 @@ import gnu.trove.list.array.TIntArrayList;
|
||||||
|
|
||||||
public class OsmandMonitoringPlugin extends OsmandPlugin {
|
public class OsmandMonitoringPlugin extends OsmandPlugin {
|
||||||
private static final String ID = "osmand.monitoring";
|
private static final String ID = "osmand.monitoring";
|
||||||
|
private static final int notificationId = ID.hashCode();
|
||||||
|
public final static String OSMAND_SAVE_SERVICE_ACTION = "OSMAND_SAVE_SERVICE_ACTION";
|
||||||
private OsmandSettings settings;
|
private OsmandSettings settings;
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private TextInfoWidget monitoringControl;
|
private TextInfoWidget monitoringControl;
|
||||||
|
@ -329,6 +337,10 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
||||||
public void stopRecording(){
|
public void stopRecording(){
|
||||||
settings.SAVE_GLOBAL_TRACK_TO_GPX.set(false);
|
settings.SAVE_GLOBAL_TRACK_TO_GPX.set(false);
|
||||||
if (app.getNavigationService() != null) {
|
if (app.getNavigationService() != null) {
|
||||||
|
NotificationManager mNotificationManager =
|
||||||
|
(NotificationManager) app.getNavigationService()
|
||||||
|
.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
mNotificationManager.cancel(notificationId);
|
||||||
app.getNavigationService().stopIfNeeded(app, NavigationService.USED_BY_GPX);
|
app.getNavigationService().stopIfNeeded(app, NavigationService.USED_BY_GPX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -368,6 +380,38 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String stop = map.getResources().getString(R.string.shared_string_control_stop);
|
||||||
|
Intent stopIntent = new Intent(NavigationService.OSMAND_STOP_SERVICE_ACTION);
|
||||||
|
PendingIntent stopPendingIntent = PendingIntent.getBroadcast(map, 0, stopIntent,
|
||||||
|
PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
String save = map.getResources().getString(R.string.shared_string_save);
|
||||||
|
Intent saveIntent = new Intent(OSMAND_SAVE_SERVICE_ACTION);
|
||||||
|
PendingIntent savePendingIntent = PendingIntent.getBroadcast(map, 0, saveIntent,
|
||||||
|
PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
|
||||||
|
BroadcastReceiver saveBroadcastReceiver = new BroadcastReceiver() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
final OsmandMonitoringPlugin plugin = OsmandPlugin
|
||||||
|
.getEnabledPlugin(OsmandMonitoringPlugin.class);
|
||||||
|
if (plugin != null) {
|
||||||
|
plugin.saveCurrentTrack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
map.registerReceiver(saveBroadcastReceiver, new IntentFilter(OSMAND_SAVE_SERVICE_ACTION));
|
||||||
|
|
||||||
|
final NotificationCompat.Builder notificationBuilder =
|
||||||
|
new android.support.v7.app.NotificationCompat.Builder(map)
|
||||||
|
.setContentTitle(map.getResources().getString(R.string.map_widget_monitoring))
|
||||||
|
.setSmallIcon(R.drawable.ic_action_polygom_dark)
|
||||||
|
// .setLargeIcon(Helpers.getBitmap(R.drawable.mirakel, getBaseContext()))
|
||||||
|
.setOngoing(true)
|
||||||
|
.addAction(R.drawable.ic_action_rec_stop, stop, stopPendingIntent)
|
||||||
|
.addAction(R.drawable.ic_action_save, save, savePendingIntent);
|
||||||
|
NotificationManager mNotificationManager =
|
||||||
|
(NotificationManager) map.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
mNotificationManager.notify(notificationId, notificationBuilder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showIntervalChooseDialog(final Context uiCtx, final String patternMsg,
|
public static void showIntervalChooseDialog(final Context uiCtx, final String patternMsg,
|
||||||
|
|
|
@ -1,14 +1,6 @@
|
||||||
package net.osmand.plus.monitoring;
|
package net.osmand.plus.monitoring;
|
||||||
|
|
||||||
|
|
||||||
import android.view.Window;
|
|
||||||
import net.osmand.plus.NavigationService;
|
|
||||||
import net.osmand.plus.OsmAndTaskManager.OsmAndTaskRunnable;
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
|
||||||
import net.osmand.plus.OsmandSettings;
|
|
||||||
import net.osmand.plus.R;
|
|
||||||
import net.osmand.plus.activities.SavingTrackHelper;
|
|
||||||
import net.osmand.plus.activities.SettingsBaseActivity;
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -21,6 +13,15 @@ import android.preference.Preference.OnPreferenceChangeListener;
|
||||||
import android.preference.Preference.OnPreferenceClickListener;
|
import android.preference.Preference.OnPreferenceClickListener;
|
||||||
import android.preference.PreferenceCategory;
|
import android.preference.PreferenceCategory;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
|
import android.view.Window;
|
||||||
|
|
||||||
|
import net.osmand.plus.NavigationService;
|
||||||
|
import net.osmand.plus.OsmAndTaskManager.OsmAndTaskRunnable;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.SavingTrackHelper;
|
||||||
|
import net.osmand.plus.activities.SettingsBaseActivity;
|
||||||
|
|
||||||
|
|
||||||
public class SettingsMonitoringActivity extends SettingsBaseActivity {
|
public class SettingsMonitoringActivity extends SettingsBaseActivity {
|
||||||
|
|
Loading…
Reference in a new issue