diff --git a/OsmAnd/src/net/osmand/plus/NotificationHelper.java b/OsmAnd/src/net/osmand/plus/NotificationHelper.java index 639d7fe99e..1d6a5a7f46 100644 --- a/OsmAnd/src/net/osmand/plus/NotificationHelper.java +++ b/OsmAnd/src/net/osmand/plus/NotificationHelper.java @@ -19,7 +19,6 @@ public class NotificationHelper { private NavigationNotification navigationNotification; private GpxNotification gpxNotification; - private OsMoNotification osMoNotification; private GpsWakeUpNotification gpsWakeUpNotification; private List all = new ArrayList<>(); @@ -31,11 +30,9 @@ public class NotificationHelper { private void init() { navigationNotification = new NavigationNotification(app); gpxNotification = new GpxNotification(app); - osMoNotification = new OsMoNotification(app); gpsWakeUpNotification = new GpsWakeUpNotification(app); all.add(navigationNotification); all.add(gpxNotification); - all.add(osMoNotification); all.add(gpsWakeUpNotification); } diff --git a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java index ef0677fbc9..03f299a57a 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java +++ b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java @@ -105,7 +105,7 @@ public abstract class OsmandPlugin { Set enabledPlugins = settings.getEnabledPlugins(); allPlugins.add(new OsmandRasterMapsPlugin(app)); allPlugins.add(new OsmandMonitoringPlugin(app)); - allPlugins.add(new OsMoPlugin(app)); + // allPlugins.add(new OsMoPlugin(app)); checkMarketPlugin(app, new SRTMPlugin(app), true, SRTM_PLUGIN_COMPONENT_PAID, SRTM_PLUGIN_COMPONENT); // ? questionable - definitely not market plugin diff --git a/OsmAnd/src/net/osmand/plus/notifications/OsMoNotification.java b/OsmAnd/src/net/osmand/plus/notifications/OsMoNotification.java deleted file mode 100644 index 0b93bda9b1..0000000000 --- a/OsmAnd/src/net/osmand/plus/notifications/OsMoNotification.java +++ /dev/null @@ -1,181 +0,0 @@ -package net.osmand.plus.notifications; - -import android.app.PendingIntent; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.support.v4.app.NotificationCompat; -import android.support.v4.app.NotificationCompat.Builder; - -import net.osmand.plus.NavigationService; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.OsmandPlugin; -import net.osmand.plus.R; -import net.osmand.plus.osmo.OsMoPlugin; - -import static net.osmand.plus.NavigationService.USED_BY_LIVE; - -public class OsMoNotification extends OsmandNotification { - - public final static String OSMAND_START_OSMO_SERVICE_ACTION = "OSMAND_START_OSMO_SERVICE_ACTION"; - public final static String OSMAND_STOP_OSMO_SERVICE_ACTION = "OSMAND_STOP_OSMO_SERVICE_ACTION"; - public final static String OSMAND_START_SHARE_LOCATION_ACTION = "OSMAND_START_SHARE_LOCATION_ACTION"; - public final static String OSMAND_STOP_SHARE_LOCATION_ACTION = "OSMAND_STOP_SHARE_LOCATION_ACTION"; - public final static String GROUP_NAME = "OSMO"; - - public OsMoNotification(OsmandApplication app) { - super(app, GROUP_NAME); - } - - @Override - public void init() { - app.registerReceiver(new BroadcastReceiver() { - - @Override - public void onReceive(Context context, Intent intent) { - OsMoPlugin osMoPlugin = OsmandPlugin.getEnabledPlugin(OsMoPlugin.class); - if (osMoPlugin != null) { - osMoPlugin.getService().connect(true); - osMoPlugin.refreshMap(); - } - } - }, new IntentFilter(OSMAND_START_OSMO_SERVICE_ACTION)); - - app.registerReceiver(new BroadcastReceiver() { - - @Override - public void onReceive(Context context, Intent intent) { - OsMoPlugin osMoPlugin = OsmandPlugin.getEnabledPlugin(OsMoPlugin.class); - if (osMoPlugin != null) { - osMoPlugin.getTracker().disableTracker(); - osMoPlugin.getService().disconnect(); - if (app.getNavigationService() != null) { - app.getNavigationService().stopIfNeeded(app, NavigationService.USED_BY_LIVE); - } - osMoPlugin.refreshMap(); - } - } - }, new IntentFilter(OSMAND_STOP_OSMO_SERVICE_ACTION)); - - app.registerReceiver(new BroadcastReceiver() { - - @Override - public void onReceive(Context context, Intent intent) { - OsMoPlugin osMoPlugin = OsmandPlugin.getEnabledPlugin(OsMoPlugin.class); - if (osMoPlugin != null) { - osMoPlugin.getService().connect(true); - if (osMoPlugin.getTracker() != null) { - osMoPlugin.getTracker().enableTracker(); - } - app.startNavigationService(NavigationService.USED_BY_LIVE, 0); - } - } - }, new IntentFilter(OSMAND_START_SHARE_LOCATION_ACTION)); - - app.registerReceiver(new BroadcastReceiver() { - - @Override - public void onReceive(Context context, Intent intent) { - OsMoPlugin osMoPlugin = OsmandPlugin.getEnabledPlugin(OsMoPlugin.class); - if (osMoPlugin != null) { - if (osMoPlugin.getTracker() != null) { - osMoPlugin.getTracker().disableTracker(); - } - if (app.getNavigationService() != null) { - app.getNavigationService() - .stopIfNeeded(app, NavigationService.USED_BY_LIVE); - } - } - } - }, new IntentFilter(OSMAND_STOP_SHARE_LOCATION_ACTION)); - } - - @Override - public NotificationType getType() { - return NotificationType.OSMO; - } - - @Override - public int getPriority() { - return NotificationCompat.PRIORITY_DEFAULT; - } - - @Override - public boolean isActive() { - NavigationService service = app.getNavigationService(); - return isEnabled() - && service != null - && (service.getUsedBy() & USED_BY_LIVE) != 0; - } - - @Override - public boolean isEnabled() { - OsMoPlugin osMoPlugin = OsmandPlugin.getEnabledPlugin(OsMoPlugin.class); - return osMoPlugin != null && osMoPlugin.getService().isEnabled(); - } - - @Override - public Builder buildNotification(boolean wearable) { - OsMoPlugin osMoPlugin = OsmandPlugin.getEnabledPlugin(OsMoPlugin.class); - if (osMoPlugin == null) { - return null; - } - - boolean shareLocation = osMoPlugin.getTracker() != null && osMoPlugin.getTracker().isEnabledTracker(); - String notificationTitle; - String notificationText; - color = 0; - icon = R.drawable.ic_osmo_dark; - color = app.getResources().getColor(R.color.osmand_orange); - notificationTitle = app.getString(R.string.osmo_service_running); - notificationText = app.getString(R.string.osmo_share_my_location) + ": " + (shareLocation ? app.getString(R.string.shared_string_yes) : app.getString(R.string.shared_string_no)).toLowerCase(); - - final Builder notificationBuilder = createBuilder(wearable) - .setContentTitle(notificationTitle) - .setContentText(notificationText); - - if (osMoPlugin.getService().isEnabled()) { - Intent stopServiceIntent = new Intent(OSMAND_STOP_OSMO_SERVICE_ACTION); - PendingIntent stopServicePendingIntent = PendingIntent.getBroadcast(app, 0, stopServiceIntent, - PendingIntent.FLAG_UPDATE_CURRENT); - notificationBuilder.addAction(R.drawable.ic_action_rec_stop, - app.getString(R.string.shared_string_control_stop), stopServicePendingIntent); - - if (osMoPlugin.getTracker() != null) { - if (osMoPlugin.getTracker().isEnabledTracker()) { - Intent stopShareLocatiponIntent = new Intent(OSMAND_STOP_SHARE_LOCATION_ACTION); - PendingIntent stopShareLocatiponIntentPendingIntent = PendingIntent.getBroadcast(app, 0, stopShareLocatiponIntent, - PendingIntent.FLAG_UPDATE_CURRENT); - notificationBuilder.addAction(R.drawable.ic_action_marker_dark, - app.getString(R.string.osmo_pause_location), stopShareLocatiponIntentPendingIntent); - } else { - Intent startShareLocationIntent = new Intent(OSMAND_START_SHARE_LOCATION_ACTION); - PendingIntent startShareLocationPendingIntent = PendingIntent.getBroadcast(app, 0, startShareLocationIntent, - PendingIntent.FLAG_UPDATE_CURRENT); - notificationBuilder.addAction(R.drawable.ic_action_marker_dark, - app.getString(R.string.osmo_share_location), startShareLocationPendingIntent); - } - } - } else { - Intent startServiceIntent = new Intent(OSMAND_START_OSMO_SERVICE_ACTION); - PendingIntent startServicePendingIntent = PendingIntent.getBroadcast(app, 0, startServiceIntent, - PendingIntent.FLAG_UPDATE_CURRENT); - notificationBuilder.addAction(R.drawable.ic_play_dark, - app.getString(R.string.shared_string_control_start), startServicePendingIntent); - } - - return notificationBuilder; - } - - - @Override - public int getOsmandNotificationId() { - return OSMO_NOTIFICATION_SERVICE_ID; - } - - @Override - public int getOsmandWearableNotificationId() { - return WEAR_OSMO_NOTIFICATION_SERVICE_ID; - } -}