Merge pull request #7784 from osmandapp/Fix_7779

Fix #7779
This commit is contained in:
max-klaus 2019-10-30 11:34:30 +03:00 committed by GitHub
commit 9e0e83e8db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 2 deletions

View file

@ -40,6 +40,7 @@ public interface OsmAndCustomizationConstants {
String RECORDING_LAYER = SHOW_ITEMS_ID_SCHEME + "recording_layer";
String MAPILLARY = SHOW_ITEMS_ID_SCHEME + "mapillary";
String OSM_NOTES = SHOW_ITEMS_ID_SCHEME + "osm_notes";
String OSM_EDITS = SHOW_ITEMS_ID_SCHEME + "osm_edits";
String OVERLAY_MAP = SHOW_ITEMS_ID_SCHEME + "overlay_map";
String UNDERLAY_MAP = SHOW_ITEMS_ID_SCHEME + "underlay_map";
String CONTOUR_LINES = SHOW_ITEMS_ID_SCHEME + "contour_lines";

View file

@ -11,6 +11,7 @@
Thx - Hardy
-->
<string name="layer_osm_edits">OSM Edits</string>
<string name="apply_preference_to_all_profiles">You can apply this change to all profiles or only to selected.</string>
<string name="shared_preference">Shared</string>
<string name="routing_attr_driving_style_prefer_unpaved_name">Prefer unpaved roads</string>

View file

@ -1707,6 +1707,7 @@ public class OsmandSettings {
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Boolean> SHOW_OSM_BUGS = new BooleanPreference("show_osm_bugs", false).makeGlobal();
public final OsmandPreference<Boolean> SHOW_OSM_EDITS = new BooleanPreference("show_osm_edits", true).makeProfile().cache();
public final CommonPreference<Boolean> SHOW_CLOSED_OSM_BUGS = new BooleanPreference("show_closed_osm_bugs", false).makeGlobal();
public final CommonPreference<Integer> SHOW_OSM_BUGS_MIN_ZOOM = new IntPreference("show_osm_bugs_min_zoom", 8).makeGlobal();

View file

@ -52,6 +52,7 @@ import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_M
import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_MODIFY_OSM_NOTE;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_MODIFY_POI;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_OPEN_OSM_NOTE;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.OSM_EDITS;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.OSM_NOTES;
@ -140,8 +141,12 @@ public class OsmEditingPlugin extends OsmandPlugin {
if (osmBugsLayer == null) {
registerLayers(activity);
}
if (!mapView.getLayers().contains(osmEditsLayer)) {
activity.getMapView().addLayer(osmEditsLayer, 3.5f);
if (mapView.getLayers().contains(osmEditsLayer) != settings.SHOW_OSM_EDITS.get()) {
if (settings.SHOW_OSM_EDITS.get()) {
mapView.addLayer(osmEditsLayer, 3.5f);
} else {
mapView.removeLayer(osmEditsLayer);
}
}
if (mapView.getLayers().contains(osmBugsLayer) != settings.SHOW_OSM_BUGS.get()) {
if (settings.SHOW_OSM_BUGS.get()) {
@ -338,6 +343,28 @@ public class OsmEditingPlugin extends OsmandPlugin {
})
.setPosition(16)
.createItem());
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setId(OSM_EDITS)
.setTitleId(R.string.layer_osm_edits, mapActivity)
.setSelected(settings.SHOW_OSM_EDITS.get())
.setIcon(R.drawable.ic_action_openstreetmap_logo)
.setColor(settings.SHOW_OSM_EDITS.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setListener(new ContextMenuAdapter.OnRowItemClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
if (itemId == R.string.layer_osm_edits) {
OsmandSettings.OsmandPreference<Boolean> showOsmEdits = settings.SHOW_OSM_EDITS;
showOsmEdits.set(isChecked);
adapter.getItem(pos).setColorRes(showOsmEdits.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
adapter.notifyDataSetChanged();
updateLayers(mapActivity.getMapView(), mapActivity);
}
return true;
}
})
.setPosition(17)
.createItem());
}
@Override