diff --git a/OsmAnd/res/layout/map_hud_bottom.xml b/OsmAnd/res/layout/map_hud_bottom.xml index bc91ccae1a..b5fbb27736 100644 --- a/OsmAnd/res/layout/map_hud_bottom.xml +++ b/OsmAnd/res/layout/map_hud_bottom.xml @@ -74,7 +74,9 @@ android:id="@+id/map_transparency_seekbar" android:layout_width="@dimen/map_trans_seek_size" android:layout_height="wrap_content" - android:layout_gravity="center"/> + android:layout_gravity="center" + android:paddingLeft="6dp" + android:paddingRight="6dp"/> adapter, View view, int itemId, int pos) { @@ -84,24 +85,28 @@ public class RasterMapMenu { @Override public boolean onContextMenuClick(final ArrayAdapter adapter, int itemId, int pos, boolean isChecked) { - MapActivityLayers mapLayers = mapActivity.getMapLayers(); if (itemId == toggleActionStringId) { if (isChecked) { mapLayers.getMapControlsLayer().showTransparencyBar(mapTransparencyPreference); } else { mapLayers.getMapControlsLayer().hideTransparencyBar(mapTransparencyPreference); } + mapLayers.getMapControlsLayer().setTransparencyBarEnabled(isChecked); plugin.toggleUnderlayState(mapActivity, type, onMapSelectedCallback); - if (type == OsmandRasterMapsPlugin.RasterMapType.UNDERLAY) { - hidePolygonsPref.set(isChecked); + if (type == OsmandRasterMapsPlugin.RasterMapType.UNDERLAY && !isChecked) { + hidePolygonsPref.set(false); mapActivity.getDashboard().refreshContent(true); } + refreshMapComplete(mapActivity); } else if (itemId == R.string.show_polygons) { hidePolygonsPref.set(!isChecked); refreshMapComplete(mapActivity); } else if (itemId == R.string.show_transparency_seekbar) { settings.SHOW_LAYER_TRANSPARENCY_SEEKBAR.set(isChecked); mapLayers.getMapControlsLayer().setTransparencyBarEnabled(isChecked); + if (isChecked) { + mapLayers.getMapControlsLayer().showTransparencyBar(mapTransparencyPreference); + } } return false; } @@ -131,8 +136,10 @@ public class RasterMapMenu { contextMenuAdapter.item(R.string.show_polygons).listen(l) .selected(hidePolygonsPref.get() ? 0 : 1).reg(); } + Boolean transparencySwitchState = settings.SHOW_LAYER_TRANSPARENCY_SEEKBAR.get() + && mapLayers.getMapControlsLayer().isTransparencyBarInitialized(); contextMenuAdapter.item(R.string.show_transparency_seekbar).listen(l) - .selected(settings.SHOW_LAYER_TRANSPARENCY_SEEKBAR.get() ? 1 : 0).reg(); + .selected(transparencySwitchState ? 1 : 0).reg(); } } diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java index 33a923016a..d9513fc8ef 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java @@ -439,8 +439,8 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { private static void updateTileSourceEditView(TileSourceTemplate ts, EditText name, final EditText urlToLoad, final EditText minZoom, final EditText maxZoom, EditText expire, final CheckBox elliptic) { - minZoom.setText(ts.getMinimumZoomSupported() + ""); - maxZoom.setText(ts.getMaximumZoomSupported() + ""); + minZoom.setText(String.valueOf(ts.getMinimumZoomSupported())); + maxZoom.setText(String.valueOf(ts.getMaximumZoomSupported())); name.setText(ts.getName()); expire.setText(ts.getExpirationTimeMinutes() < 0 ? "" : ts.getExpirationTimeMinutes() + ""); urlToLoad.setText(ts.getUrlTemplate() == null ? "" : @@ -470,7 +470,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { } else { // Underlay expected mapTypePreference = settings.MAP_UNDERLAY; - exMapTypePreference = settings.MAP_OVERLAY_PREVIOUS; + exMapTypePreference = settings.MAP_UNDERLAY_PREVIOUS; map = underlayLayer.getMap(); } diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index 3838dfd1fc..9270fd6a3b 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -637,11 +637,13 @@ public class MapControlsLayer extends OsmandMapLayer { } public void showTransparencyBar(CommonPreference transparenPreference) { - MapControlsLayer.settingsToTransparency = transparenPreference; - if (isTransparencyBarEnabled) { - transparencyBarLayout.setVisibility(View.VISIBLE); + if (MapControlsLayer.settingsToTransparency != transparenPreference) { + MapControlsLayer.settingsToTransparency = transparenPreference; + if (isTransparencyBarEnabled) { + transparencyBarLayout.setVisibility(View.VISIBLE); + } + transparencyBar.setProgress(transparenPreference.get()); } - transparencyBar.setProgress(transparenPreference.get()); } public void hideTransparencyBar(CommonPreference transparentPreference) { @@ -662,6 +664,10 @@ public class MapControlsLayer extends OsmandMapLayer { } } + public boolean isTransparencyBarInitialized() { + return settingsToTransparency != null; + } + private class MapHudButton { View iv; int bgDark;