Finalized overlay and underlay layers.
This commit is contained in:
parent
440ee3cefa
commit
b9fdd6271c
3 changed files with 27 additions and 4 deletions
|
@ -1135,6 +1135,10 @@ public class OsmandSettings {
|
|||
public final CommonPreference<Boolean> SHOW_LAYER_TRANSPARENCY_SEEKBAR =
|
||||
new BooleanPreference("show_layer_transparency_seekbar", false).makeGlobal();
|
||||
|
||||
public final CommonPreference<String> MAP_OVERLAY_PREVIOUS = new StringPreference("map_overlay_previous", null).makeGlobal().cache();
|
||||
|
||||
public final CommonPreference<String> MAP_UNDERLAY_PREVIOUS = new StringPreference("map_underlay_previous", null).makeGlobal().cache();
|
||||
|
||||
public CommonPreference<String> PREVIOUS_INSTALLED_VERSION = new StringPreference("previous_installed_version", "").makeGlobal();
|
||||
|
||||
public final OsmandPreference<Boolean> SHOULD_SHOW_FREE_VERSION_BANNER = new BooleanPreference("should_show_free_version_banner", false).makeGlobal().cache();
|
||||
|
|
|
@ -35,16 +35,19 @@ public class RasterMapMenu {
|
|||
assert plugin != null;
|
||||
final OsmandSettings.CommonPreference<Integer> mapTransparencyPreference;
|
||||
final OsmandSettings.CommonPreference<String> mapTypePreference;
|
||||
final OsmandSettings.CommonPreference<String> exMapTypePreference;
|
||||
@StringRes final int mapTypeString;
|
||||
@StringRes final int mapTypeStringTransparency;
|
||||
if (type == OsmandRasterMapsPlugin.RasterMapType.OVERLAY) {
|
||||
mapTransparencyPreference = settings.MAP_OVERLAY_TRANSPARENCY;
|
||||
mapTypePreference = settings.MAP_OVERLAY;
|
||||
exMapTypePreference = settings.MAP_OVERLAY_PREVIOUS;
|
||||
mapTypeString = R.string.map_overlay;
|
||||
mapTypeStringTransparency = R.string.overlay_transparency;
|
||||
} else if (type == OsmandRasterMapsPlugin.RasterMapType.UNDERLAY) {
|
||||
mapTransparencyPreference = settings.MAP_TRANSPARENCY;
|
||||
mapTypePreference = settings.MAP_UNDERLAY;
|
||||
exMapTypePreference = settings.MAP_UNDERLAY_PREVIOUS;
|
||||
mapTypeString = R.string.map_underlay;
|
||||
mapTypeStringTransparency = R.string.map_transparency;
|
||||
} else {
|
||||
|
@ -71,7 +74,7 @@ public class RasterMapMenu {
|
|||
if (itemId == mapTypeString) {
|
||||
if (selected) {
|
||||
plugin.selectMapOverlayLayer(mapActivity.getMapView(), mapTypePreference,
|
||||
mapActivity, onMapSelectedCallback);
|
||||
exMapTypePreference, true, mapActivity, onMapSelectedCallback);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -149,10 +149,20 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
|
||||
public void selectMapOverlayLayer(@NonNull final OsmandMapTileView mapView,
|
||||
@NonNull final CommonPreference<String> mapPref,
|
||||
@NonNull final CommonPreference<String> exMapPref,
|
||||
boolean force,
|
||||
@NonNull final MapActivity activity,
|
||||
@Nullable final OnMapSelectedCallback callback) {
|
||||
final OsmandSettings settings = app.getSettings();
|
||||
final MapActivityLayers layers = activity.getMapLayers();
|
||||
if (!force && exMapPref.get() != null) {
|
||||
mapPref.set(exMapPref.get());
|
||||
if (callback != null) {
|
||||
callback.onMapSelected();
|
||||
}
|
||||
updateMapLayers(mapView, mapPref, layers);
|
||||
return;
|
||||
}
|
||||
final OsmandSettings settings = app.getSettings();
|
||||
Map<String, String> entriesMap = settings.getTileSourceEntries();
|
||||
final ArrayList<String> keys = new ArrayList<>(entriesMap.keySet());
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
|
@ -176,12 +186,13 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
if (object == null) {
|
||||
if (count == 1) {
|
||||
mapPref.set(template.getName());
|
||||
exMapPref.set(template.getName());
|
||||
if (callback != null) {
|
||||
callback.onMapSelected();
|
||||
}
|
||||
updateMapLayers(mapView, mapPref, layers);
|
||||
} else {
|
||||
selectMapOverlayLayer(mapView, mapPref, activity, null);
|
||||
selectMapOverlayLayer(mapView, mapPref, exMapPref, false, activity, null);
|
||||
}
|
||||
} else {
|
||||
count++;
|
||||
|
@ -197,6 +208,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
});
|
||||
} else {
|
||||
mapPref.set(keys.get(which));
|
||||
exMapPref.set(keys.get(which));
|
||||
if (callback != null) {
|
||||
callback.onMapSelected();
|
||||
}
|
||||
|
@ -449,12 +461,16 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
@Nullable OnMapSelectedCallback callback) {
|
||||
OsmandMapTileView mapView = mapActivity.getMapView();
|
||||
CommonPreference<String> mapTypePreference;
|
||||
CommonPreference<String> exMapTypePreference;
|
||||
ITileSource map;
|
||||
if (type == RasterMapType.OVERLAY) {
|
||||
mapTypePreference = settings.MAP_OVERLAY;
|
||||
exMapTypePreference = settings.MAP_OVERLAY_PREVIOUS;
|
||||
map = overlayLayer.getMap();
|
||||
} else {
|
||||
// Underlay expected
|
||||
mapTypePreference = settings.MAP_UNDERLAY;
|
||||
exMapTypePreference = settings.MAP_OVERLAY_PREVIOUS;
|
||||
map = underlayLayer.getMap();
|
||||
}
|
||||
|
||||
|
@ -466,7 +482,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
MapActivityLayers mapLayers = mapActivity.getMapLayers();
|
||||
updateMapLayers(mapView, null, mapLayers);
|
||||
} else {
|
||||
selectMapOverlayLayer(mapView, mapTypePreference, mapActivity, callback);
|
||||
selectMapOverlayLayer(mapView, mapTypePreference, exMapTypePreference, false, mapActivity, callback);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue