Revert fix #7789 because plugins became global

This commit is contained in:
Chumva 2019-12-02 12:44:23 +02:00
parent 4b702b6ea0
commit c93854eb43
7 changed files with 21 additions and 29 deletions

View file

@ -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));
}

View file

@ -208,21 +208,6 @@ public abstract class OsmandPlugin {
}
}
public static void updateActivatedPlugins(OsmandApplication app) {
Set<String> 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)) {

View file

@ -1516,7 +1516,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
});
getMapView().refreshMap(true);
applyScreenOrientation();
getMyApplication().getNotificationHelper().refreshNotifications();
}
public void updateMapSettings() {

View file

@ -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() {

View file

@ -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;
}

View file

@ -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 + ". "

View file

@ -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