Fixing bugs overlay and underlay layers.

This commit is contained in:
GaidamakUA 2016-02-24 15:44:22 +02:00
parent aa9cf8d4a8
commit 338c418a40
4 changed files with 27 additions and 12 deletions

View file

@ -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"/>
<ImageButton
android:id="@+id/map_transparency_hide"

View file

@ -68,6 +68,7 @@ public class RasterMapMenu {
mapActivity.getDashboard().refreshContent(true);
}
};
final MapActivityLayers mapLayers = mapActivity.getMapLayers();
ContextMenuAdapter.OnRowItemClick l = new ContextMenuAdapter.OnRowItemClick() {
@Override
public boolean onRowItemClick(ArrayAdapter<?> 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();
}
}

View file

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

View file

@ -637,11 +637,13 @@ public class MapControlsLayer extends OsmandMapLayer {
}
public void showTransparencyBar(CommonPreference<Integer> 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<Integer> transparentPreference) {
@ -662,6 +664,10 @@ public class MapControlsLayer extends OsmandMapLayer {
}
}
public boolean isTransparencyBarInitialized() {
return settingsToTransparency != null;
}
private class MapHudButton {
View iv;
int bgDark;