Fix #2490
This commit is contained in:
parent
c23d4b7c5b
commit
884caf3739
2 changed files with 27 additions and 16 deletions
|
@ -30,7 +30,7 @@ public class RasterMapMenu {
|
||||||
private static void createLayersItems(final ContextMenuAdapter contextMenuAdapter,
|
private static void createLayersItems(final ContextMenuAdapter contextMenuAdapter,
|
||||||
final MapActivity mapActivity,
|
final MapActivity mapActivity,
|
||||||
final OsmandRasterMapsPlugin.RasterMapType type) {
|
final OsmandRasterMapsPlugin.RasterMapType type) {
|
||||||
OsmandApplication app = mapActivity.getMyApplication();
|
final OsmandApplication app = mapActivity.getMyApplication();
|
||||||
final OsmandSettings settings = app.getSettings();
|
final OsmandSettings settings = app.getSettings();
|
||||||
final OsmandRasterMapsPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class);
|
final OsmandRasterMapsPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class);
|
||||||
assert plugin != null;
|
assert plugin != null;
|
||||||
|
@ -86,20 +86,25 @@ public class RasterMapMenu {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter,
|
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter,
|
||||||
int itemId, int pos, boolean isChecked) {
|
final int itemId, final int pos, final boolean isChecked) {
|
||||||
if (itemId == toggleActionStringId) {
|
if (itemId == toggleActionStringId) {
|
||||||
if (isChecked) {
|
app.runInUIThread(new Runnable() {
|
||||||
mapLayers.getMapControlsLayer().showTransparencyBar(mapTransparencyPreference);
|
@Override
|
||||||
} else {
|
public void run() {
|
||||||
mapLayers.getMapControlsLayer().hideTransparencyBar(mapTransparencyPreference);
|
if (isChecked) {
|
||||||
}
|
mapLayers.getMapControlsLayer().showTransparencyBar(mapTransparencyPreference);
|
||||||
mapLayers.getMapControlsLayer().setTransparencyBarEnabled(isChecked);
|
} else {
|
||||||
plugin.toggleUnderlayState(mapActivity, type, onMapSelectedCallback);
|
mapLayers.getMapControlsLayer().hideTransparencyBar(mapTransparencyPreference);
|
||||||
if (type == OsmandRasterMapsPlugin.RasterMapType.UNDERLAY && !isChecked) {
|
}
|
||||||
hidePolygonsPref.set(false);
|
mapLayers.getMapControlsLayer().setTransparencyBarEnabled(isChecked);
|
||||||
mapActivity.getDashboard().refreshContent(true);
|
plugin.toggleUnderlayState(mapActivity, type, onMapSelectedCallback);
|
||||||
}
|
if (type == OsmandRasterMapsPlugin.RasterMapType.UNDERLAY) {
|
||||||
refreshMapComplete(mapActivity);
|
hidePolygonsPref.set(isChecked);
|
||||||
|
mapActivity.getDashboard().refreshContent(true);
|
||||||
|
}
|
||||||
|
refreshMapComplete(mapActivity);
|
||||||
|
}
|
||||||
|
});
|
||||||
} else if (itemId == R.string.show_polygons) {
|
} else if (itemId == R.string.show_polygons) {
|
||||||
hidePolygonsPref.set(!isChecked);
|
hidePolygonsPref.set(!isChecked);
|
||||||
refreshMapComplete(mapActivity);
|
refreshMapComplete(mapActivity);
|
||||||
|
@ -149,7 +154,7 @@ public class RasterMapMenu {
|
||||||
.setTitleId(R.string.show_polygons, mapActivity)
|
.setTitleId(R.string.show_polygons, mapActivity)
|
||||||
.hideDivider(true)
|
.hideDivider(true)
|
||||||
.setListener(l)
|
.setListener(l)
|
||||||
.setSelected(hidePolygonsPref.get()).createItem());
|
.setSelected(!hidePolygonsPref.get()).createItem());
|
||||||
}
|
}
|
||||||
Boolean transparencySwitchState = settings.SHOW_LAYER_TRANSPARENCY_SEEKBAR.get()
|
Boolean transparencySwitchState = settings.SHOW_LAYER_TRANSPARENCY_SEEKBAR.get()
|
||||||
&& mapLayers.getMapControlsLayer().isTransparencyBarInitialized();
|
&& mapLayers.getMapControlsLayer().isTransparencyBarInitialized();
|
||||||
|
@ -161,7 +166,7 @@ public class RasterMapMenu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void refreshMapComplete(final MapActivity activity) {
|
public static void refreshMapComplete(final MapActivity activity) {
|
||||||
activity.getMyApplication().getResourceManager().getRenderer().clearCache();
|
activity.getMyApplication().getResourceManager().getRenderer().clearCache();
|
||||||
activity.updateMapSettings();
|
activity.updateMapSettings();
|
||||||
GPXLayer gpx = activity.getMapView().getLayerByClass(GPXLayer.class);
|
GPXLayer gpx = activity.getMapView().getLayerByClass(GPXLayer.class);
|
||||||
|
|
|
@ -34,6 +34,7 @@ import net.osmand.plus.activities.DownloadTilesDialog;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.MapActivityLayers;
|
import net.osmand.plus.activities.MapActivityLayers;
|
||||||
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
|
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
|
||||||
|
import net.osmand.plus.dialogs.RasterMapMenu;
|
||||||
import net.osmand.plus.views.MapTileLayer;
|
import net.osmand.plus.views.MapTileLayer;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -288,6 +289,11 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
item.setColorRes(hasUnderlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
item.setColorRes(hasUnderlayDescription ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
||||||
|
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
|
|
||||||
|
final OsmandSettings.CommonPreference<Boolean> hidePolygonsPref =
|
||||||
|
mapActivity.getMyApplication().getSettings().getCustomRenderBooleanProperty("noPolygons");
|
||||||
|
hidePolygonsPref.set(hasUnderlayDescription);
|
||||||
|
RasterMapMenu.refreshMapComplete(mapActivity);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue