diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index c1830d5db3..d5844c4bb1 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -1336,6 +1336,8 @@ public class OsmandSettings { MAP_MARKERS_MODE.setModeDefaultValue(ApplicationMode.PEDESTRIAN, MapMarkersMode.TOOLBAR); } + public final OsmandPreference SHOW_MAP_MARKERS = new BooleanPreference("show_map_markers", true).makeGlobal(); + public final CommonPreference NOTES_SORT_BY_MODE = new EnumIntPreference<>("notes_sort_by_mode", NotesSortByMode.BY_DATE, NotesSortByMode.values()); public final OsmandPreference ANIMATE_MY_LOCATION = new BooleanPreference("animate_my_location", true).makeGlobal().cache(); diff --git a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java index eb8b08b0b5..c2d0b876e0 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java @@ -33,7 +33,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.TimeZone; public class SavingTrackHelper extends SQLiteOpenHelper { @@ -584,6 +583,8 @@ public class SavingTrackHelper extends SQLiteOpenHelper { if (db != null) { db.execSQL(script, objects); } + } catch (RuntimeException e) { + log.error(e.getMessage(), e); } finally { if (db != null) { db.close(); diff --git a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java index 1e90dc436f..19a42bfd83 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/ConfigureMapMenu.java @@ -186,6 +186,8 @@ public class ConfigureMapMenu { } else { showGpxSelectionDialog(adapter, adapter.getItem(pos)); } + } else if (itemId == R.string.map_markers) { + settings.SHOW_MAP_MARKERS.set(isChecked); } else if (itemId == R.string.layer_map) { if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) == null) { Intent intent = new Intent(ma, PluginActivity.class); @@ -464,6 +466,15 @@ public class ConfigureMapMenu { .setIcon(R.drawable.ic_action_polygom_dark) .setSecondaryIcon(R.drawable.ic_action_additional_option) .setListener(l).createItem()); + + selected = settings.SHOW_MAP_MARKERS.get(); + adapter.addItem(new ContextMenuItem.ItemBuilder() + .setTitleId(R.string.map_markers, activity) + .setSelected(selected) + .setColor(selected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) + .setIcon(R.drawable.ic_action_flag_dark) + .setListener(l).createItem()); + adapter.addItem(new ContextMenuItem.ItemBuilder() .setTitleId(R.string.layer_map, activity) .setIcon(R.drawable.ic_world_globe_dark) diff --git a/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java b/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java index e4e55cce48..bf6e2d2574 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapMarkersLayer.java @@ -233,6 +233,11 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi @Override public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings nightMode) { + OsmandSettings settings = map.getMyApplication().getSettings(); + if (!settings.SHOW_MAP_MARKERS.get()) { + return; + } + Location myLoc; if (useFingerLocation && fingerLocation != null) { myLoc = new Location(""); @@ -243,7 +248,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi } MapMarkersHelper markersHelper = map.getMyApplication().getMapMarkersHelper(); List activeMapMarkers = markersHelper.getMapMarkers(); - int displayedWidgets = map.getMyApplication().getSettings().DISPLAYED_MARKERS_WIDGETS_COUNT.get(); + int displayedWidgets = settings.DISPLAYED_MARKERS_WIDGETS_COUNT.get(); if (route != null && route.points.size() > 0) { planRouteAttrs.updatePaints(view, nightMode, tileBox); @@ -252,7 +257,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi route.drawRenderers(view.getZoom(), defaultAppMode ? planRouteAttrs.paint : planRouteAttrs.paint2, canvas, tileBox); } - if (map.getMyApplication().getSettings().SHOW_LINES_TO_FIRST_MARKERS.get() && myLoc != null) { + if (settings.SHOW_LINES_TO_FIRST_MARKERS.get() && myLoc != null) { textAttrs.paint.setTextSize(textSize); textAttrs.paint2.setTextSize(textSize); @@ -262,7 +267,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi textPaint.set(textAttrs.paint); - boolean drawMarkerName = map.getMyApplication().getSettings().DISPLAYED_MARKERS_WIDGETS_COUNT.get() == 1; + boolean drawMarkerName = settings.DISPLAYED_MARKERS_WIDGETS_COUNT.get() == 1; int locX; int locY; @@ -325,7 +330,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi widgetsFactory.updateInfo(useFingerLocation ? fingerLocation : null, tileBox.getZoom()); OsmandSettings settings = map.getMyApplication().getSettings(); - if (tileBox.getZoom() < 3) { + if (tileBox.getZoom() < 3 || !settings.SHOW_MAP_MARKERS.get()) { return; } @@ -499,8 +504,12 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi @Override public boolean runExclusiveAction(Object o, boolean unknownLocation) { - if (unknownLocation || o == null || !(o instanceof MapMarker) - || !map.getMyApplication().getSettings().SELECT_MARKER_ON_SINGLE_TAP.get()) { + OsmandSettings settings = map.getMyApplication().getSettings(); + if (unknownLocation + || o == null + || !(o instanceof MapMarker) + || !settings.SELECT_MARKER_ON_SINGLE_TAP.get() + || !settings.SHOW_MAP_MARKERS.get()) { return false; } final MapMarkersHelper helper = map.getMyApplication().getMapMarkersHelper(); @@ -520,7 +529,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi @Override public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List o, boolean unknownLocation) { - if (tileBox.getZoom() < 3) { + if (tileBox.getZoom() < 3 || !map.getMyApplication().getSettings().SHOW_MAP_MARKERS.get()) { return; } amenities.clear();