Fix discrepencies
This commit is contained in:
parent
8e960d43a8
commit
c826afb0d1
3 changed files with 44 additions and 59 deletions
|
@ -117,14 +117,13 @@ public class RasterMapMenu {
|
|||
hidePolygonsPref.set(!isChecked);
|
||||
refreshMapComplete(mapActivity);
|
||||
} else if (itemId == R.string.show_transparency_seekbar) {
|
||||
settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.set(
|
||||
isChecked ? currentMapTypeSeekbarMode : LayerTransparencySeekbarMode.OFF);
|
||||
if (isChecked) {
|
||||
mapLayers.getMapControlsLayer().showTransparencyBar(mapTransparencyPreference);
|
||||
} else {
|
||||
mapLayers.getMapControlsLayer().hideTransparencyBar(mapTransparencyPreference);
|
||||
settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.set(currentMapTypeSeekbarMode);
|
||||
mapLayers.getMapControlsLayer().showTransparencyBar(mapTransparencyPreference, true);
|
||||
} else // if(settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.get() == currentMapTypeSeekbarMode)
|
||||
{
|
||||
mapLayers.getMapControlsLayer().hideTransparencyBar();
|
||||
}
|
||||
mapLayers.getMapControlsLayer().setTransparencyBarEnabled(isChecked);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -144,6 +144,13 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
mapView.removeLayer(underlayLayer);
|
||||
underlayLayer.setMap(null);
|
||||
}
|
||||
if(settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.get() == LayerTransparencySeekbarMode.UNDERLAY &&
|
||||
underlayLayer.getMap() != null) {
|
||||
layers.getMapControlsLayer().showTransparencyBar(settings.MAP_UNDERLAY, true);
|
||||
} else if(settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.get() == LayerTransparencySeekbarMode.OVERLAY &&
|
||||
overlayLayer.getMap() != null) {
|
||||
layers.getMapControlsLayer().showTransparencyBar(settings.MAP_OVERLAY_TRANSPARENCY, true);
|
||||
}
|
||||
layers.updateMapSource(mapView, settingsToWarnAboutMap);
|
||||
}
|
||||
|
||||
|
@ -565,54 +572,43 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
@NonNull RasterMapType type,
|
||||
@Nullable OnMapSelectedCallback callback) {
|
||||
OsmandMapTileView mapView = mapActivity.getMapView();
|
||||
CommonPreference<String> mapTypePreference;
|
||||
CommonPreference<String> exMapTypePreference;
|
||||
OsmandSettings.CommonPreference<Integer> mapTransparencyPreference;
|
||||
ITileSource map;
|
||||
|
||||
boolean isMapSelected;
|
||||
MapTileLayer layer;
|
||||
if (type == RasterMapType.OVERLAY) {
|
||||
mapTransparencyPreference = settings.MAP_OVERLAY_TRANSPARENCY;
|
||||
mapTypePreference = settings.MAP_OVERLAY;
|
||||
exMapTypePreference = settings.MAP_OVERLAY_PREVIOUS;
|
||||
map = overlayLayer.getMap();
|
||||
layer = overlayLayer;
|
||||
} else {
|
||||
// Underlay expected
|
||||
mapTransparencyPreference = settings.MAP_TRANSPARENCY;
|
||||
mapTypePreference = settings.MAP_UNDERLAY;
|
||||
exMapTypePreference = settings.MAP_UNDERLAY_PREVIOUS;
|
||||
map = underlayLayer.getMap();
|
||||
layer = underlayLayer;
|
||||
}
|
||||
|
||||
MapActivityLayers mapLayers = mapActivity.getMapLayers();
|
||||
ITileSource map = layer.getMap();
|
||||
final OsmandSettings.LayerTransparencySeekbarMode currentMapTypeSeekbarMode =
|
||||
OsmandRasterMapsPlugin.RasterMapType.OVERLAY ?
|
||||
OsmandSettings.LayerTransparencySeekbarMode.OVERLAY : OsmandSettings.LayerTransparencySeekbarMode.UNDERLAY;
|
||||
if (map != null) {
|
||||
isMapSelected = false;
|
||||
mapTypePreference.set(null);
|
||||
if (callback != null) {
|
||||
callback.onMapSelected(false);
|
||||
}
|
||||
updateMapLayers(mapView, null, mapLayers);
|
||||
} else {
|
||||
isMapSelected = !Algorithms.isEmpty(exMapTypePreference.get()); // we can also later extra check if prev map was not empty
|
||||
selectMapOverlayLayer(mapView, mapTypePreference, exMapTypePreference, false, mapActivity, callback);
|
||||
}
|
||||
|
||||
final OsmandSettings.LayerTransparencySeekbarMode currentMapTypeSeekbarMode =
|
||||
OsmandRasterMapsPlugin.RasterMapType.OVERLAY ?
|
||||
OsmandSettings.LayerTransparencySeekbarMode.OVERLAY : OsmandSettings.LayerTransparencySeekbarMode.UNDERLAY;
|
||||
boolean isSeekBarVisible = RasterMapMenu.isSeekbarVisible(app, type);
|
||||
boolean showSeekbar = isMapSelected && isSeekBarVisible ;
|
||||
boolean hideSeekbar = !isMapSelected && isSeekBarVisible &&
|
||||
seekbarModePref.get() == currentMapTypeSeekbarMode;
|
||||
MapActivityLayers mapLayers = mapActivity.getMapLayers();
|
||||
CommonPreference<LayerTransparencySeekbarMode> seekbarModePref = settings.LAYER_TRANSPARENCY_SEEKBAR_MODE;
|
||||
if (showSeekbar) {
|
||||
mapLayers.getMapControlsLayer().showTransparencyBar(mapTransparencyPreference);
|
||||
mapActivity.getMapLayers().getMapControlsLayer().setTransparencyBarEnabled(true);
|
||||
if (seekbarModePref.get() == LayerTransparencySeekbarMode.UNDEFINED) {
|
||||
seekbarModePref.set(currentMapTypeSeekbarMode);
|
||||
// hide seekbar
|
||||
if(currentMapTypeSeekbarMode == settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.get()) {
|
||||
settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.set(LayerTransparencySeekbarMode.UNDEFINED);
|
||||
mapLayers.getMapControlsLayer().hideTransparencyBar();
|
||||
}
|
||||
} else if(){
|
||||
mapLayers.getMapControlsLayer().hideTransparencyBar(mapTransparencyPreference);
|
||||
mapLayers.getMapControlsLayer().setTransparencyBarEnabled(false);
|
||||
} else {
|
||||
settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.set(currentMapTypeSeekbarMode);
|
||||
|
||||
selectMapOverlayLayer(mapView, mapTypePreference, exMapTypePreference, false, mapActivity, callback);
|
||||
showSeekbar = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -928,41 +928,31 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
LayerTransparencySeekbarMode seekbarMode = settings.LAYER_TRANSPARENCY_SEEKBAR_MODE.get();
|
||||
if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) != null) {
|
||||
if (seekbarMode == LayerTransparencySeekbarMode.OVERLAY && settings.MAP_OVERLAY.get() != null) {
|
||||
showTransparencyBar(settings.MAP_OVERLAY_TRANSPARENCY);
|
||||
setTransparencyBarEnabled(true);
|
||||
showTransparencyBar(settings.MAP_OVERLAY_TRANSPARENCY, true);
|
||||
} else if (seekbarMode == LayerTransparencySeekbarMode.UNDERLAY && settings.MAP_UNDERLAY.get() != null) {
|
||||
showTransparencyBar(settings.MAP_TRANSPARENCY);
|
||||
setTransparencyBarEnabled(true);
|
||||
showTransparencyBar(settings.MAP_TRANSPARENCY, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void showTransparencyBar(CommonPreference<Integer> transparenPreference) {
|
||||
public void showTransparencyBar(CommonPreference<Integer> transparenPreference,
|
||||
boolean isTransparencyBarEnabled) {
|
||||
this.isTransparencyBarEnabled = isTransparencyBarEnabled;
|
||||
if (MapControlsLayer.transparencySetting != transparenPreference) {
|
||||
MapControlsLayer.transparencySetting = transparenPreference;
|
||||
if (isTransparencyBarEnabled) {
|
||||
transparencyBarLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
}
|
||||
if (transparenPreference != null && isTransparencyBarEnabled) {
|
||||
transparencyBarLayout.setVisibility(View.VISIBLE);
|
||||
transparencyBar.setProgress(transparenPreference.get());
|
||||
}
|
||||
}
|
||||
|
||||
public void hideTransparencyBar(CommonPreference<Integer> transparentPreference) {
|
||||
if (transparencySetting == transparentPreference) {
|
||||
} else {
|
||||
transparencyBarLayout.setVisibility(View.GONE);
|
||||
transparencySetting = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setTransparencyBarEnabled(boolean isTransparencyBarEnabled) {
|
||||
this.isTransparencyBarEnabled = isTransparencyBarEnabled;
|
||||
if (transparencySetting != null) {
|
||||
if (isTransparencyBarEnabled) {
|
||||
transparencyBarLayout.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
transparencyBarLayout.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
public void hideTransparencyBar() {
|
||||
transparencyBarLayout.setVisibility(View.GONE);
|
||||
transparencySetting = null;
|
||||
}
|
||||
|
||||
private class MapHudButton {
|
||||
|
|
Loading…
Reference in a new issue