From c93854eb43461a697f1fb7e1d4f284336594147e Mon Sep 17 00:00:00 2001 From: Chumva Date: Mon, 2 Dec 2019 12:44:23 +0200 Subject: [PATCH] Revert fix #7789 because plugins became global --- OsmAnd/src/net/osmand/plus/AppInitializer.java | 3 ++- OsmAnd/src/net/osmand/plus/OsmandPlugin.java | 15 --------------- .../net/osmand/plus/activities/MapActivity.java | 1 - .../plus/activities/SavingTrackHelper.java | 16 ++++++++++------ .../plus/monitoring/LiveMonitoringHelper.java | 5 ++++- .../plus/notifications/ErrorNotification.java | 2 +- .../plus/notifications/GpxNotification.java | 8 ++++---- 7 files changed, 21 insertions(+), 29 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index b9e70643ce..da84471693 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -38,6 +38,7 @@ import net.osmand.plus.inapp.InAppPurchaseHelper; import net.osmand.plus.liveupdates.LiveUpdatesHelper; import net.osmand.plus.mapmarkers.MapMarkersDbHelper; import net.osmand.plus.monitoring.LiveMonitoringHelper; +import net.osmand.plus.monitoring.OsmandMonitoringPlugin; import net.osmand.plus.poi.PoiFiltersHelper; import net.osmand.plus.render.MapRenderRepositories; import net.osmand.plus.render.NativeOsmandLibrary; @@ -768,7 +769,7 @@ public class AppInitializer implements IProgress { app.savingTrackHelper.loadGpxFromDatabase(); } } - if (app.savingTrackHelper.getIsRecording()) { + if(app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get() && OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null){ int interval = app.getSettings().SAVE_GLOBAL_TRACK_INTERVAL.get(); app.startNavigationService(NavigationService.USED_BY_GPX, app.navigationServiceGpsInterval(interval)); } diff --git a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java index 2de54cf09d..a5c4004aff 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java +++ b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java @@ -208,21 +208,6 @@ public abstract class OsmandPlugin { } } - public static void updateActivatedPlugins(OsmandApplication app) { - Set enabledPlugins = app.getSettings().getEnabledPlugins(); - for (OsmandPlugin plugin : OsmandPlugin.getMarketPlugins()) { - updateMarketPlugin(app, enabledPlugins, plugin); - } - for (OsmandPlugin plugin : allPlugins) { - if (enabledPlugins.contains(plugin.getId())) { - initPlugin(app, plugin); - } else if (plugin.isActive()) { - plugin.setActive(false); - plugin.disable(app); - } - } - } - private static void initPlugin(OsmandApplication app, OsmandPlugin plugin) { try { if (plugin.init(app, null)) { diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 120c8dbc40..41c0d8fae8 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -1516,7 +1516,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven }); getMapView().refreshMap(true); applyScreenOrientation(); - getMyApplication().getNotificationHelper().refreshNotifications(); } public void updateMapSettings() { diff --git a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java index 78ad9d58d9..4e8f2dadc0 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java @@ -5,20 +5,22 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.text.format.DateFormat; +import net.osmand.PlatformUtil; +import net.osmand.data.LatLon; +import net.osmand.plus.GPXDatabase.GpxDataItem; import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.GPXTrackAnalysis; import net.osmand.GPXUtilities.Track; import net.osmand.GPXUtilities.TrkSegment; import net.osmand.GPXUtilities.WptPt; -import net.osmand.PlatformUtil; -import net.osmand.data.LatLon; -import net.osmand.plus.GPXDatabase.GpxDataItem; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandSettings; import net.osmand.plus.Version; +import net.osmand.plus.monitoring.OsmandMonitoringPlugin; import net.osmand.plus.notifications.OsmandNotification.NotificationType; import net.osmand.util.MapUtils; @@ -426,7 +428,8 @@ public class SavingTrackHelper extends SQLiteOpenHelper { heading = NO_HEADING; } boolean record = false; - if (location != null && OsmAndLocationProvider.isNotSimulatedLocation(location)) { + if (location != null && OsmAndLocationProvider.isNotSimulatedLocation(location) + && OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null) { if (settings.SAVE_TRACK_TO_GPX.get() && locationTime - lastTimeUpdated > settings.SAVE_TRACK_INTERVAL.get() && ctx.getRoutingHelper().isFollowingMode()) { @@ -667,8 +670,9 @@ public class SavingTrackHelper extends SQLiteOpenHelper { } public boolean getIsRecording() { - return ctx.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get() || - (ctx.getSettings().SAVE_TRACK_TO_GPX.get() && ctx.getRoutingHelper().isFollowingMode()); + return OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null + && ctx.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get() + || (ctx.getSettings().SAVE_TRACK_TO_GPX.get() && ctx.getRoutingHelper().isFollowingMode()); } public float getDistance() { diff --git a/OsmAnd/src/net/osmand/plus/monitoring/LiveMonitoringHelper.java b/OsmAnd/src/net/osmand/plus/monitoring/LiveMonitoringHelper.java index 4d73b90105..c3f9649a28 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/LiveMonitoringHelper.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/LiveMonitoringHelper.java @@ -7,6 +7,7 @@ import net.osmand.PlatformUtil; import net.osmand.data.LatLon; import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandSettings; import net.osmand.util.MapUtils; @@ -46,7 +47,9 @@ public class LiveMonitoringHelper { public void updateLocation(net.osmand.Location location) { boolean record = false; long locationTime = System.currentTimeMillis(); - if (location != null && isLiveMonitoringEnabled() && OsmAndLocationProvider.isNotSimulatedLocation(location)) { + if (location != null && isLiveMonitoringEnabled() + && OsmAndLocationProvider.isNotSimulatedLocation(location) + && OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null) { if (locationTime - lastTimeUpdated > settings.LIVE_MONITORING_INTERVAL.get()) { record = true; } diff --git a/OsmAnd/src/net/osmand/plus/notifications/ErrorNotification.java b/OsmAnd/src/net/osmand/plus/notifications/ErrorNotification.java index 3ea07aa690..af9a3841c9 100644 --- a/OsmAnd/src/net/osmand/plus/notifications/ErrorNotification.java +++ b/OsmAnd/src/net/osmand/plus/notifications/ErrorNotification.java @@ -62,7 +62,7 @@ public class ErrorNotification extends OsmandNotification { boolean planning = routingHelper.isRoutePlanningMode(); boolean pause = routingHelper.isPauseNavigation(); - boolean gpxEnabled = app.getSavingTrackHelper().getIsRecording() || OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null; + boolean gpxEnabled = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null; String usedBy = service != null ? "" + service.getUsedBy() : "X"; notificationText = "Info: " + (following ? "1" : "") + (planning ? "2" : "") + (pause ? "3" : "") + (gpxEnabled ? "4" : "") + "-" + usedBy + ". " diff --git a/OsmAnd/src/net/osmand/plus/notifications/GpxNotification.java b/OsmAnd/src/net/osmand/plus/notifications/GpxNotification.java index f0defc9be8..c56b92027b 100644 --- a/OsmAnd/src/net/osmand/plus/notifications/GpxNotification.java +++ b/OsmAnd/src/net/osmand/plus/notifications/GpxNotification.java @@ -40,7 +40,7 @@ public class GpxNotification extends OsmandNotification { @Override public void onReceive(Context context, Intent intent) { - final OsmandMonitoringPlugin plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class); + final OsmandMonitoringPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class); if (plugin != null) { plugin.saveCurrentTrack(); if (!app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get()) { @@ -54,7 +54,7 @@ public class GpxNotification extends OsmandNotification { @Override public void onReceive(Context context, Intent intent) { - final OsmandMonitoringPlugin plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class); + final OsmandMonitoringPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class); if (plugin != null) { plugin.startGPXMonitoring(null); plugin.updateControl(); @@ -66,7 +66,7 @@ public class GpxNotification extends OsmandNotification { @Override public void onReceive(Context context, Intent intent) { - final OsmandMonitoringPlugin plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class); + final OsmandMonitoringPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class); if (plugin != null) { plugin.stopRecording(); plugin.updateControl(); @@ -95,7 +95,7 @@ public class GpxNotification extends OsmandNotification { @Override public boolean isEnabled() { - return app.getSavingTrackHelper().getIsRecording() || OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null; + return OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null; } @Override