Update map layers
This commit is contained in:
parent
80fdca2e91
commit
9b0920786b
14 changed files with 312 additions and 259 deletions
|
@ -8,6 +8,9 @@
|
|||
If you are making/correcting english translations make sure :
|
||||
1. All your modified/created strings are in the top of the file (to make easier find what's translated).
|
||||
-->
|
||||
<string name="map_online_plugin_is_not_installed">Enable online maps plugin to select different map sources</string>
|
||||
<string name="map_online_data">Online maps</string>
|
||||
<string name="map_online_data_descr">Use online maps (download and save them on sdcard)</string>
|
||||
<string name="online_map_settings">Online Map</string>
|
||||
<string name="online_map_settings_descr">Configure online or cached tile map sources</string>
|
||||
<string name="map_settings">- Map Settings</string>
|
||||
|
@ -442,8 +445,6 @@
|
|||
<string name="default_none">None</string>
|
||||
<string name="map_overlay">Overlay map</string>
|
||||
<string name="map_overlay_descr">Choose overlay map</string>
|
||||
<string name="map_vector_data">Offline vector maps</string>
|
||||
<string name="map_vector_data_descr">Use downloaded vector maps</string>
|
||||
<string name="tile_source_already_installed">Map is already installed, settings will be updated</string>
|
||||
<string name="select_tile_source_to_install">Select (tile) maps to install or update</string>
|
||||
<string name="internet_not_available">Internet connection required for operation is not available</string>
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
package net.osmand.plus;
|
||||
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
|
||||
public class ContextMenuAdapter {
|
||||
|
||||
public interface OnContextMenuClick {
|
||||
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked);
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog);
|
||||
}
|
||||
|
||||
private final Context ctx;
|
||||
|
|
|
@ -58,22 +58,6 @@ public abstract class OsmandPlugin {
|
|||
installedPlugins.add(new OsmandDevelopmentPlugin(app));
|
||||
|
||||
Set<String> enabledPlugins = settings.getEnabledPlugins();
|
||||
// update special plugin state
|
||||
if (!enabledPlugins.contains(rasterMapsPlugin.getId())) {
|
||||
if (settings.MAP_VECTOR_DATA.get()) {
|
||||
if(settings.MAP_OVERLAY.get() != null) {
|
||||
settings.MAP_OVERLAY.set(null);
|
||||
}
|
||||
if(settings.MAP_UNDERLAY.get() != null) {
|
||||
settings.MAP_UNDERLAY.set(null);
|
||||
}
|
||||
} else {
|
||||
settings.enablePlugin(rasterMapsPlugin.getId(), true);
|
||||
enabledPlugins = settings.getEnabledPlugins();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (OsmandPlugin plugin : installedPlugins) {
|
||||
if (enabledPlugins.contains(plugin.getId())) {
|
||||
try {
|
||||
|
@ -101,10 +85,7 @@ public abstract class OsmandPlugin {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* ????
|
||||
*/
|
||||
public void updateLayers(OsmandMapTileView mapView) {};
|
||||
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {};
|
||||
|
||||
public abstract void registerLayers(MapActivity activity);
|
||||
|
||||
|
@ -122,13 +103,13 @@ public abstract class OsmandPlugin {
|
|||
|
||||
public void settingsActivityUpdate(final SettingsActivity activity){}
|
||||
|
||||
public void registerLayerContextMenuActions(OsmandMapTileView mapView, ContextMenuAdapter adapter) {}
|
||||
public void registerLayerContextMenuActions(OsmandMapTileView mapView, ContextMenuAdapter adapter, MapActivity mapActivity) {}
|
||||
|
||||
public void registerMapContextMenuActions(MapActivity mapActivity, double latitude, double longitude, ContextMenuAdapter adapter, Object selectedObj) {}
|
||||
|
||||
public static void refreshLayers(OsmandMapTileView mapView) {
|
||||
public static void refreshLayers(OsmandMapTileView mapView, MapActivity activity) {
|
||||
for (OsmandPlugin plugin : activePlugins) {
|
||||
plugin.updateLayers(mapView);
|
||||
plugin.updateLayers(mapView, activity);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,9 +187,9 @@ public abstract class OsmandPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
public static void registerLayerContextMenu(OsmandMapTileView mapView, ContextMenuAdapter adapter) {
|
||||
public static void registerLayerContextMenu(OsmandMapTileView mapView, ContextMenuAdapter adapter, MapActivity mapActivity) {
|
||||
for (OsmandPlugin plugin : activePlugins) {
|
||||
plugin.registerLayerContextMenuActions(mapView, adapter);
|
||||
plugin.registerLayerContextMenuActions(mapView, adapter, mapActivity);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -684,24 +684,24 @@ public class OsmandSettings {
|
|||
}
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final CommonPreference<Boolean> MAP_VECTOR_DATA = new BooleanPreference("map_vector_data",
|
||||
true, false);
|
||||
public final CommonPreference<Boolean> MAP_ONLINE_DATA = new BooleanPreference("map_online_data",
|
||||
false, true);
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final CommonPreference<String> MAP_OVERLAY = new StringPreference("map_overlay",
|
||||
null, false);
|
||||
null, true);
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final CommonPreference<String> MAP_UNDERLAY = new StringPreference("map_underlay",
|
||||
null, false);
|
||||
null, true);
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final CommonPreference<Integer> MAP_OVERLAY_TRANSPARENCY = new IntPreference("overlay_transparency",
|
||||
200, false);
|
||||
200, true);
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final CommonPreference<Integer> MAP_TRANSPARENCY = new IntPreference("map_transparency",
|
||||
255, false);
|
||||
255, true);
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final CommonPreference<String> MAP_TILE_SOURCES = new StringPreference("map_tile_sources",
|
||||
|
|
|
@ -620,11 +620,6 @@ public class DownloadIndexActivity extends OsmandExpandableListActivity {
|
|||
if (vectorMapsToReindex) {
|
||||
ResourceManager manager = getMyApplication().getResourceManager();
|
||||
List<String> warnings = manager.indexingMaps(progress);
|
||||
if (warnings.isEmpty() && !settings.MAP_VECTOR_DATA.get()) {
|
||||
warnings.add(getString(R.string.binary_map_download_success));
|
||||
// Is it proper way to switch every tome to vector data?
|
||||
settings.MAP_VECTOR_DATA.set(true);
|
||||
}
|
||||
if (!warnings.isEmpty()) {
|
||||
return warnings.get(0);
|
||||
}
|
||||
|
|
|
@ -164,16 +164,6 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
|||
startProgressDialog = new ProgressDialog(this);
|
||||
startProgressDialog.setCancelable(true);
|
||||
((OsmandApplication) getApplication()).checkApplicationIsBeingInitialized(this, startProgressDialog);
|
||||
// Do some action on close
|
||||
startProgressDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
OsmandApplication app = ((OsmandApplication) getApplication());
|
||||
if (settings.MAP_VECTOR_DATA.get() && app.getResourceManager().getRenderer().isEmpty()) {
|
||||
AccessibleToast.makeText(MapActivity.this, getString(R.string.no_vector_map_loaded), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
parseLaunchIntentLocation();
|
||||
|
||||
mapView = (OsmandMapTileView) findViewById(R.id.MapView);
|
||||
|
@ -183,7 +173,14 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
|||
showAndHideMapPosition();
|
||||
return MapActivity.this.onTrackballEvent(e);
|
||||
}
|
||||
});
|
||||
|
||||
// Do some action on close
|
||||
startProgressDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
mapView.refreshMap();
|
||||
}
|
||||
});
|
||||
|
||||
getMyApplication().getResourceManager().getMapTileDownloader().addDownloaderCallback(new IMapDownloaderCallback(){
|
||||
|
@ -260,7 +257,6 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
|||
setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
||||
}
|
||||
|
||||
mapLayers.updateMapSource(mapView, null);
|
||||
updateApplicationModeSettings();
|
||||
|
||||
mapLayers.getPoiMapLayer().setFilter(settings.getPoiFilterForMap((OsmandApplication) getApplication()));
|
||||
|
@ -1001,7 +997,7 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
|||
registerUnregisterSensor(getLastKnownLocation());
|
||||
mapLayers.getMapInfoLayer().applyTheme();
|
||||
mapLayers.updateLayers(mapView);
|
||||
mapLayers.updateMapSource(mapView, settings.MAP_TILE_SOURCES);
|
||||
|
||||
getMyApplication().getDaynightHelper().setDayNightMode(settings.DAYNIGHT_MODE.get());
|
||||
}
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
return b.create();
|
||||
}
|
||||
|
||||
protected void addWaypoint(final double latitude, final double longitude){
|
||||
public void addWaypoint(final double latitude, final double longitude){
|
||||
String name = mapActivity.getMapLayers().getContextMenuLayer().getSelectedObjectName();
|
||||
enhance(dialogBundle,latitude,longitude, name);
|
||||
mapActivity.showDialog(DIALOG_ADD_WAYPOINT);
|
||||
|
@ -234,59 +234,14 @@ public class MapActivityActions implements DialogProvider {
|
|||
return builder.create();
|
||||
}
|
||||
|
||||
protected void reloadTile(final int zoom, final double latitude, final double longitude){
|
||||
public void reloadTile(final int zoom, final double latitude, final double longitude){
|
||||
enhance(dialogBundle,latitude,longitude,zoom);
|
||||
mapActivity.showDialog(DIALOG_RELOAD_TITLE);
|
||||
}
|
||||
|
||||
|
||||
private Dialog createReloadTitleDialog(final Bundle args) {
|
||||
Builder builder = new AccessibleAlertBuilder(mapActivity);
|
||||
builder.setMessage(R.string.context_menu_item_update_map_confirm);
|
||||
builder.setNegativeButton(R.string.default_buttons_cancel, null);
|
||||
final OsmandMapTileView mapView = mapActivity.getMapView();
|
||||
builder.setPositiveButton(R.string.context_menu_item_update_map, new DialogInterface.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
int zoom = args.getInt(KEY_ZOOM);
|
||||
BaseMapLayer mainLayer = mapView.getMainLayer();
|
||||
if(!(mainLayer instanceof MapTileLayer) || !((MapTileLayer) mainLayer).isVisible()){
|
||||
AccessibleToast.makeText(mapActivity, R.string.maps_could_not_be_downloaded, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
final ITileSource mapSource = ((MapTileLayer) mainLayer).getMap();
|
||||
if(mapSource == null || !mapSource.couldBeDownloadedFromInternet()){
|
||||
AccessibleToast.makeText(mapActivity, R.string.maps_could_not_be_downloaded, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
Rect pixRect = new Rect(0, 0, mapView.getWidth(), mapView.getHeight());
|
||||
RectF tilesRect = new RectF();
|
||||
mapView.calculateTileRectangle(pixRect, mapView.getCenterPointX(), mapView.getCenterPointY(),
|
||||
mapView.getXTile(), mapView.getYTile(), tilesRect);
|
||||
int left = (int) FloatMath.floor(tilesRect.left);
|
||||
int top = (int) FloatMath.floor(tilesRect.top);
|
||||
int width = (int) (FloatMath.ceil(tilesRect.right) - left);
|
||||
int height = (int) (FloatMath.ceil(tilesRect.bottom) - top);
|
||||
for (int i = 0; i <width; i++) {
|
||||
for (int j = 0; j< height; j++) {
|
||||
((OsmandApplication)mapActivity.getApplication()).getResourceManager().
|
||||
clearTileImageForMap(null, mapSource, i + left, j + top, zoom);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mapView.refreshMap();
|
||||
}
|
||||
});
|
||||
builder.setNeutralButton(R.string.context_menu_item_update_poi, new DialogInterface.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
updatePoiDb(args.getInt(KEY_ZOOM), args.getDouble(KEY_LATITUDE), args.getDouble(KEY_LONGITUDE));
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
protected String getString(int res){
|
||||
return mapActivity.getString(res);
|
||||
}
|
||||
|
@ -726,13 +681,8 @@ public class MapActivityActions implements DialogProvider {
|
|||
adapter.registerItem(R.string.context_menu_item_search);
|
||||
adapter.registerItem(R.string.context_menu_item_add_favorite);
|
||||
adapter.registerItem(R.string.context_menu_item_share_location);
|
||||
adapter.registerItem(R.string.context_menu_item_add_waypoint);
|
||||
OsmandPlugin.registerMapContextMenu(mapActivity, latitude, longitude, adapter, selectedObj);
|
||||
|
||||
if (mapView.getMainLayer() instanceof MapTileLayer) {
|
||||
adapter.registerItem(R.string.context_menu_item_update_map);
|
||||
adapter.registerItem(R.string.context_menu_item_download_map);
|
||||
}
|
||||
OsmandPlugin.registerMapContextMenu(mapActivity, latitude, longitude, adapter, selectedObj);
|
||||
|
||||
builder.setItems(adapter.getItemNames(), new DialogInterface.OnClickListener() {
|
||||
|
||||
|
@ -741,7 +691,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
int standardId = adapter.getItemId(which );
|
||||
OnContextMenuClick click = adapter.getClickAdapter(which);
|
||||
if(click != null) {
|
||||
click.onContextMenuClick(standardId, which, false);
|
||||
click.onContextMenuClick(standardId, which, false, dialog);
|
||||
} else if (standardId == R.string.context_menu_item_navigate_point) {
|
||||
mapActivity.navigateToPoint(new LatLon(latitude, longitude));
|
||||
} else if (standardId == R.string.context_menu_item_show_route) {
|
||||
|
@ -756,19 +706,61 @@ public class MapActivityActions implements DialogProvider {
|
|||
addFavouritePoint(latitude, longitude);
|
||||
} else if (standardId == R.string.context_menu_item_share_location) {
|
||||
shareLocation(latitude, longitude, mapView.getZoom());
|
||||
} else if (standardId == R.string.context_menu_item_add_waypoint) {
|
||||
addWaypoint(latitude, longitude);
|
||||
} else if (standardId == R.string.context_menu_item_update_map) {
|
||||
reloadTile(mapView.getZoom(), latitude, longitude);
|
||||
} else if (standardId == R.string.context_menu_item_download_map) {
|
||||
DownloadTilesDialog dlg = new DownloadTilesDialog(mapActivity, (OsmandApplication) mapActivity.getApplication(), mapView);
|
||||
dlg.openDialog();
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.create().show();
|
||||
}
|
||||
|
||||
private Dialog createReloadTitleDialog(final Bundle args) {
|
||||
Builder builder = new AccessibleAlertBuilder(mapActivity);
|
||||
builder.setMessage(R.string.context_menu_item_update_map_confirm);
|
||||
builder.setNegativeButton(R.string.default_buttons_cancel, null);
|
||||
final OsmandMapTileView mapView = mapActivity.getMapView();
|
||||
builder.setPositiveButton(R.string.context_menu_item_update_map, new DialogInterface.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
int zoom = args.getInt(KEY_ZOOM);
|
||||
BaseMapLayer mainLayer = mapView.getMainLayer();
|
||||
if(!(mainLayer instanceof MapTileLayer) || !((MapTileLayer) mainLayer).isVisible()){
|
||||
AccessibleToast.makeText(mapActivity, R.string.maps_could_not_be_downloaded, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
final ITileSource mapSource = ((MapTileLayer) mainLayer).getMap();
|
||||
if(mapSource == null || !mapSource.couldBeDownloadedFromInternet()){
|
||||
AccessibleToast.makeText(mapActivity, R.string.maps_could_not_be_downloaded, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
Rect pixRect = new Rect(0, 0, mapView.getWidth(), mapView.getHeight());
|
||||
RectF tilesRect = new RectF();
|
||||
mapView.calculateTileRectangle(pixRect, mapView.getCenterPointX(), mapView.getCenterPointY(),
|
||||
mapView.getXTile(), mapView.getYTile(), tilesRect);
|
||||
int left = (int) FloatMath.floor(tilesRect.left);
|
||||
int top = (int) FloatMath.floor(tilesRect.top);
|
||||
int width = (int) (FloatMath.ceil(tilesRect.right) - left);
|
||||
int height = (int) (FloatMath.ceil(tilesRect.bottom) - top);
|
||||
for (int i = 0; i <width; i++) {
|
||||
for (int j = 0; j< height; j++) {
|
||||
((OsmandApplication)mapActivity.getApplication()).getResourceManager().
|
||||
clearTileImageForMap(null, mapSource, i + left, j + top, zoom);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mapView.refreshMap();
|
||||
}
|
||||
});
|
||||
builder.setNeutralButton(R.string.context_menu_item_update_poi, new DialogInterface.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
updatePoiDb(args.getInt(KEY_ZOOM), args.getDouble(KEY_LATITUDE), args.getDouble(KEY_LONGITUDE));
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(int id) {
|
||||
Bundle args = dialogBundle;
|
||||
|
|
|
@ -10,7 +10,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.osmand.Algoritms;
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
|
@ -32,10 +31,9 @@ import net.osmand.plus.PoiFiltersHelper;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.ResourceManager;
|
||||
import net.osmand.plus.SQLiteTileSource;
|
||||
import net.osmand.plus.render.MapRenderRepositories;
|
||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||
import net.osmand.plus.render.MapVectorLayer;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.views.BaseMapLayer;
|
||||
import net.osmand.plus.views.ContextMenuLayer;
|
||||
import net.osmand.plus.views.FavoritesLayer;
|
||||
import net.osmand.plus.views.GPXLayer;
|
||||
|
@ -81,8 +79,6 @@ public class MapActivityLayers {
|
|||
// the order of layer should be preserved ! when you are inserting new layer
|
||||
private MapTileLayer mapTileLayer;
|
||||
private MapVectorLayer mapVectorLayer;
|
||||
private MapTileLayer overlayLayer;
|
||||
private MapTileLayer underlayLayer;
|
||||
private GPXLayer gpxLayer;
|
||||
private RouteLayer routeLayer;
|
||||
private POIMapLayer poiMapLayer;
|
||||
|
@ -109,9 +105,7 @@ public class MapActivityLayers {
|
|||
|
||||
RoutingHelper routingHelper = ((OsmandApplication) getApplication()).getRoutingHelper();
|
||||
|
||||
underlayLayer = new MapTileLayer(false);
|
||||
// mapView.addLayer(underlayLayer, -0.5f);
|
||||
|
||||
mapTileLayer = new MapTileLayer(true);
|
||||
mapView.addLayer(mapTileLayer, 0.0f);
|
||||
mapView.setMainLayer(mapTileLayer);
|
||||
|
@ -120,7 +114,6 @@ public class MapActivityLayers {
|
|||
mapVectorLayer = new MapVectorLayer(mapTileLayer);
|
||||
mapView.addLayer(mapVectorLayer, 0.5f);
|
||||
|
||||
overlayLayer = new MapTileLayer(false);
|
||||
// mapView.addLayer(overlayLayer, 0.7f);
|
||||
|
||||
// 0.9 gpx layer
|
||||
|
@ -167,6 +160,7 @@ public class MapActivityLayers {
|
|||
|
||||
public void updateLayers(OsmandMapTileView mapView){
|
||||
OsmandSettings settings = getApplication().getSettings();
|
||||
updateMapSource(mapView, settings.MAP_TILE_SOURCES);
|
||||
if(mapView.getLayers().contains(transportStopsLayer) != settings.SHOW_TRANSPORT_OVER_MAP.get()){
|
||||
if(settings.SHOW_TRANSPORT_OVER_MAP.get()){
|
||||
mapView.addLayer(transportStopsLayer, 5);
|
||||
|
@ -191,7 +185,7 @@ public class MapActivityLayers {
|
|||
mapView.removeLayer(favoritesLayer);
|
||||
}
|
||||
}
|
||||
OsmandPlugin.refreshLayers(mapView);
|
||||
OsmandPlugin.refreshLayers(mapView, activity);
|
||||
updateGPXLayer();
|
||||
}
|
||||
|
||||
|
@ -199,30 +193,20 @@ public class MapActivityLayers {
|
|||
OsmandSettings settings = getApplication().getSettings();
|
||||
|
||||
// update transparency
|
||||
overlayLayer.setAlpha(settings.MAP_OVERLAY_TRANSPARENCY.get());
|
||||
int mapTransparency = settings.MAP_UNDERLAY.get() == null ? 255 : settings.MAP_TRANSPARENCY.get();
|
||||
mapTileLayer.setAlpha(mapTransparency);
|
||||
mapVectorLayer.setAlpha(mapTransparency);
|
||||
|
||||
// update overlay layer
|
||||
updateLayer(mapView, settings, overlayLayer, settings.MAP_OVERLAY, 0.7f, settings.MAP_OVERLAY == settingsToWarnAboutMap);
|
||||
updateLayer(mapView, settings, underlayLayer, settings.MAP_UNDERLAY, -0.5f, settings.MAP_UNDERLAY == settingsToWarnAboutMap);
|
||||
|
||||
boolean vectorData = settings.MAP_VECTOR_DATA.get();
|
||||
OsmandApplication app = ((OsmandApplication)getApplication());
|
||||
ResourceManager rm = app.getResourceManager();
|
||||
if(vectorData && !app.isApplicationInitializing()){
|
||||
if(rm.getRenderer().isEmpty()){
|
||||
AccessibleToast.makeText(activity, activity.getString(R.string.no_vector_map_loaded), Toast.LENGTH_LONG).show();
|
||||
vectorData = false;
|
||||
}
|
||||
}
|
||||
ITileSource newSource = settings.getMapTileSource(settings.MAP_TILE_SOURCES == settingsToWarnAboutMap);
|
||||
ITileSource oldMap = mapTileLayer.getMap();
|
||||
if (newSource != oldMap) {
|
||||
if (oldMap instanceof SQLiteTileSource) {
|
||||
((SQLiteTileSource) oldMap).closeDB();
|
||||
}
|
||||
mapTileLayer.setMap(newSource);
|
||||
}
|
||||
|
||||
boolean vectorData = !settings.MAP_ONLINE_DATA.get();
|
||||
mapTileLayer.setVisible(!vectorData);
|
||||
mapVectorLayer.setVisible(vectorData);
|
||||
if(vectorData){
|
||||
|
@ -232,24 +216,10 @@ public class MapActivityLayers {
|
|||
}
|
||||
}
|
||||
|
||||
private void updateLayer(OsmandMapTileView mapView, OsmandSettings settings,
|
||||
MapTileLayer layer, CommonPreference<String> preference, float layerOrder, boolean warnWhenSelected) {
|
||||
ITileSource overlay = settings.getTileSourceByName(preference.get(), warnWhenSelected);
|
||||
if(!Algoritms.objectEquals(overlay, layer.getMap())){
|
||||
if(overlay == null){
|
||||
mapView.removeLayer(layer);
|
||||
} else {
|
||||
mapView.addLayer(layer, layerOrder);
|
||||
}
|
||||
layer.setMap(overlay);
|
||||
mapView.refreshMap();
|
||||
}
|
||||
}
|
||||
|
||||
public void openLayerSelectionDialog(final OsmandMapTileView mapView){
|
||||
final OsmandSettings settings = getApplication().getSettings();
|
||||
final ContextMenuAdapter adapter = new ContextMenuAdapter(activity);
|
||||
adapter.registerSelectedItem(R.string.layer_map, -1, R.drawable.list_activities_map_src);
|
||||
adapter.registerSelectedItem(R.string.layer_poi, settings.SHOW_POI_OVER_MAP.get() ? 1 : 0,
|
||||
R.drawable.list_activities_poi);
|
||||
adapter.registerSelectedItem(R.string.layer_poi_label, settings.SHOW_POI_LABEL.get() ? 1 : 0,
|
||||
|
@ -270,12 +240,7 @@ public class MapActivityLayers {
|
|||
}
|
||||
|
||||
|
||||
adapter.registerSelectedItem(R.string.layer_overlay, overlayLayer.getMap() != null ? 1 : 0,
|
||||
R.drawable.list_activities_overlay_map);
|
||||
adapter.registerSelectedItem(R.string.layer_underlay, underlayLayer.getMap() != null ? 1 : 0,
|
||||
R.drawable.list_activities_underlay_map);
|
||||
|
||||
OsmandPlugin.registerLayerContextMenu(mapView, adapter);
|
||||
OsmandPlugin.registerLayerContextMenu(mapView, adapter, activity);
|
||||
|
||||
|
||||
final OnMultiChoiceClickListener listener = new DialogInterface.OnMultiChoiceClickListener() {
|
||||
|
@ -284,10 +249,7 @@ public class MapActivityLayers {
|
|||
int itemId = adapter.getItemId(item);
|
||||
OnContextMenuClick clck = adapter.getClickAdapter(item);
|
||||
if(clck != null) {
|
||||
clck.onContextMenuClick(itemId, item, isChecked);
|
||||
} else if (itemId == R.string.layer_map) {
|
||||
dialog.dismiss();
|
||||
selectMapLayer(mapView);
|
||||
clck.onContextMenuClick(itemId, item, isChecked, dialog);
|
||||
} else if(itemId == R.string.layer_poi){
|
||||
if(isChecked){
|
||||
selectPOIFilterLayer(mapView);
|
||||
|
@ -311,24 +273,6 @@ public class MapActivityLayers {
|
|||
transportInfoLayer.setVisible(isChecked);
|
||||
} else if(itemId == R.string.layer_transport){
|
||||
settings.SHOW_TRANSPORT_OVER_MAP.set(isChecked);
|
||||
} else if(itemId == R.string.layer_overlay){
|
||||
if(overlayLayer.getMap() != null){
|
||||
settings.MAP_OVERLAY.set(null);
|
||||
updateMapSource(mapView, null);
|
||||
} else {
|
||||
dialog.dismiss();
|
||||
selectMapOverlayLayer(mapView, settings.MAP_OVERLAY, settings.MAP_OVERLAY_TRANSPARENCY,
|
||||
overlayLayer);
|
||||
}
|
||||
} else if(itemId == R.string.layer_underlay){
|
||||
if(underlayLayer.getMap() != null){
|
||||
settings.MAP_UNDERLAY.set(null);
|
||||
updateMapSource(mapView, null);
|
||||
} else {
|
||||
dialog.dismiss();
|
||||
selectMapOverlayLayer(mapView, settings.MAP_UNDERLAY,settings.MAP_TRANSPARENCY,
|
||||
mapTileLayer, mapVectorLayer);
|
||||
}
|
||||
}
|
||||
updateLayers(mapView);
|
||||
mapView.refreshMap();
|
||||
|
@ -561,10 +505,15 @@ public class MapActivityLayers {
|
|||
}
|
||||
|
||||
public void selectMapLayer(final OsmandMapTileView mapView){
|
||||
if(OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) == null) {
|
||||
AccessibleToast.makeText(activity, R.string.map_online_plugin_is_not_installed, Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
final OsmandSettings settings = getApplication().getSettings();
|
||||
|
||||
final LinkedHashMap<String, String> entriesMap = new LinkedHashMap<String, String>();
|
||||
|
||||
|
||||
final String layerOsmVector = "LAYER_OSM_VECTOR";
|
||||
final String layerInstallMore = "LAYER_INSTALL_MORE";
|
||||
|
||||
|
@ -579,7 +528,7 @@ public class MapActivityLayers {
|
|||
String selectedTileSourceKey = settings.MAP_TILE_SOURCES.get();
|
||||
|
||||
int selectedItem = -1;
|
||||
if (settings.MAP_VECTOR_DATA.get()) {
|
||||
if (!settings.MAP_ONLINE_DATA.get()) {
|
||||
selectedItem = 0;
|
||||
} else {
|
||||
|
||||
|
@ -608,13 +557,7 @@ public class MapActivityLayers {
|
|||
public void onClick(DialogInterface dialog, int which) {
|
||||
String layerKey = entriesMapList.get(which).getKey();
|
||||
if (layerKey.equals(layerOsmVector)) {
|
||||
MapRenderRepositories r = ((OsmandApplication) getApplication()).getResourceManager().getRenderer();
|
||||
if (r.isEmpty()) {
|
||||
AccessibleToast.makeText(activity, getString(R.string.no_vector_map_loaded), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
} else {
|
||||
settings.MAP_VECTOR_DATA.set(true);
|
||||
}
|
||||
settings.MAP_ONLINE_DATA.set(false);
|
||||
updateMapSource(mapView, null);
|
||||
} else if (layerKey.equals(layerInstallMore)) {
|
||||
SettingsActivity.installMapLayers(activity, new ResultMatcher<TileSourceTemplate>() {
|
||||
|
@ -625,7 +568,7 @@ public class MapActivityLayers {
|
|||
if(object == null){
|
||||
if(count == 1){
|
||||
settings.MAP_TILE_SOURCES.set(template.getName());
|
||||
settings.MAP_VECTOR_DATA.set(false);
|
||||
settings.MAP_ONLINE_DATA.set(true);
|
||||
updateMapSource(mapView, settings.MAP_TILE_SOURCES);
|
||||
} else {
|
||||
selectMapLayer(mapView);
|
||||
|
@ -644,7 +587,7 @@ public class MapActivityLayers {
|
|||
});
|
||||
} else {
|
||||
settings.MAP_TILE_SOURCES.set(layerKey);
|
||||
settings.MAP_VECTOR_DATA.set(false);
|
||||
settings.MAP_ONLINE_DATA.set(true);
|
||||
updateMapSource(mapView, settings.MAP_TILE_SOURCES);
|
||||
}
|
||||
|
||||
|
@ -655,62 +598,6 @@ public class MapActivityLayers {
|
|||
builder.show();
|
||||
}
|
||||
|
||||
private void selectMapOverlayLayer(final OsmandMapTileView mapView,
|
||||
final CommonPreference<String> mapPref, final CommonPreference<Integer> transparencyPref,
|
||||
final BaseMapLayer... transparencyToChange){
|
||||
final OsmandSettings settings = getApplication().getSettings();
|
||||
Map<String, String> entriesMap = settings.getTileSourceEntries();
|
||||
final ArrayList<String> keys = new ArrayList<String>(entriesMap.keySet());
|
||||
Builder builder = new AlertDialog.Builder(activity);
|
||||
final String[] items = new String[entriesMap.size() + 1];
|
||||
int i = 0;
|
||||
for(String it : entriesMap.values()){
|
||||
items[i++] = it;
|
||||
}
|
||||
|
||||
items[i] = getString(R.string.install_more);
|
||||
builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (which == items.length - 1){
|
||||
SettingsActivity.installMapLayers(activity, new ResultMatcher<TileSourceTemplate>() {
|
||||
TileSourceTemplate template = null;
|
||||
int count = 0;
|
||||
@Override
|
||||
public boolean publish(TileSourceTemplate object) {
|
||||
if(object == null){
|
||||
if(count == 1){
|
||||
mapPref.set(template.getName());
|
||||
mapControlsLayer.showAndHideTransparencyBar(transparencyPref, transparencyToChange);
|
||||
updateMapSource(mapView, mapPref);
|
||||
} else {
|
||||
selectMapOverlayLayer(mapView, mapPref, transparencyPref, transparencyToChange);
|
||||
}
|
||||
} else {
|
||||
count ++;
|
||||
template = object;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mapPref.set(keys.get(which));
|
||||
mapControlsLayer.showAndHideTransparencyBar(transparencyPref, transparencyToChange);
|
||||
updateMapSource(mapView, mapPref);
|
||||
}
|
||||
|
||||
dialog.dismiss();
|
||||
}
|
||||
|
||||
});
|
||||
builder.show();
|
||||
}
|
||||
|
||||
|
||||
private String getString(int resId) {
|
||||
return activity.getString(resId);
|
||||
|
@ -739,6 +626,18 @@ public class MapActivityLayers {
|
|||
return mapInfoLayer;
|
||||
}
|
||||
|
||||
public MapControlsLayer getMapControlsLayer() {
|
||||
return mapControlsLayer;
|
||||
}
|
||||
|
||||
public MapTileLayer getMapTileLayer() {
|
||||
return mapTileLayer;
|
||||
}
|
||||
|
||||
public MapVectorLayer getMapVectorLayer() {
|
||||
return mapVectorLayer;
|
||||
}
|
||||
|
||||
public POIMapLayer getPoiMapLayer() {
|
||||
return poiMapLayer;
|
||||
}
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
package net.osmand.plus.monitoring;
|
||||
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.ProgressDialogImplementation;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.activities.ApplicationMode;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SavingTrackHelper;
|
||||
import net.osmand.plus.activities.SettingsActivity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.preference.Preference;
|
||||
import android.preference.Preference.OnPreferenceClickListener;
|
||||
import android.preference.PreferenceCategory;
|
||||
|
@ -49,6 +52,20 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
public void registerLayers(MapActivity activity) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerMapContextMenuActions(final MapActivity mapActivity, final double latitude, final double longitude, ContextMenuAdapter adapter,
|
||||
Object selectedObj) {
|
||||
OnContextMenuClick listener = new OnContextMenuClick() {
|
||||
@Override
|
||||
public void onContextMenuClick(int resId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (resId == R.string.context_menu_item_add_waypoint) {
|
||||
mapActivity.getMapActions().addWaypoint(latitude, longitude);
|
||||
}
|
||||
}
|
||||
};
|
||||
adapter.registerItem(R.string.context_menu_item_add_waypoint, 0, listener, -1);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void settingsActivityCreate(final SettingsActivity activity, PreferenceScreen screen) {
|
||||
|
|
|
@ -457,7 +457,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
|||
OnContextMenuClick listener = new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (itemId == R.string.osb_comment_menu_item) {
|
||||
commentBug(bug);
|
||||
} else if (itemId == R.string.osb_close_menu_item) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.osmand.plus.osmedit;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.EditTextPreference;
|
||||
|
@ -43,7 +44,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
private EditingPOIActivity poiActions;
|
||||
|
||||
@Override
|
||||
public void updateLayers(OsmandMapTileView mapView){
|
||||
public void updateLayers(OsmandMapTileView mapView, MapActivity activity){
|
||||
if(mapView.getLayers().contains(osmBugsLayer) != settings.SHOW_OSM_BUGS.get()){
|
||||
if(settings.SHOW_OSM_BUGS.get()){
|
||||
mapView.addLayer(osmBugsLayer, 2);
|
||||
|
@ -108,7 +109,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
OnContextMenuClick alist = new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public void onContextMenuClick(int resId, int pos, boolean isChecked) {
|
||||
public void onContextMenuClick(int resId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (resId == R.string.poi_context_menu_delete) {
|
||||
getPoiActions().showDeleteDialog(a);
|
||||
} else if (resId == R.string.poi_context_menu_modify) {
|
||||
|
@ -122,7 +123,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
OnContextMenuClick listener = new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public void onContextMenuClick(int resId, int pos, boolean isChecked) {
|
||||
public void onContextMenuClick(int resId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (resId == R.string.context_menu_item_create_poi) {
|
||||
poiActions.showCreateDialog(latitude, longitude);
|
||||
} else if (resId == R.string.context_menu_item_open_bug) {
|
||||
|
@ -135,12 +136,12 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void registerLayerContextMenuActions(OsmandMapTileView mapView, ContextMenuAdapter adapter) {
|
||||
public void registerLayerContextMenuActions(OsmandMapTileView mapView, ContextMenuAdapter adapter, MapActivity mapActivity) {
|
||||
adapter.registerSelectedItem(R.string.layer_osm_bugs, settings.SHOW_OSM_BUGS.get() ? 1 : 0, R.drawable.list_activities_osm_bugs,
|
||||
new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (itemId == R.string.layer_osm_bugs) {
|
||||
settings.SHOW_OSM_BUGS.set(isChecked);
|
||||
}
|
||||
|
|
|
@ -1,16 +1,30 @@
|
|||
package net.osmand.plus.rastermaps;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import net.osmand.Algoritms;
|
||||
import net.osmand.ResultMatcher;
|
||||
import net.osmand.map.ITileSource;
|
||||
import net.osmand.map.TileSourceManager.TileSourceTemplate;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.OsmandSettings.CommonPreference;
|
||||
import net.osmand.plus.activities.DownloadTilesDialog;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.MapActivityLayers;
|
||||
import net.osmand.plus.activities.SettingsActivity;
|
||||
import net.osmand.plus.views.BaseMapLayer;
|
||||
import net.osmand.plus.views.MapTileLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.SeekBarPreference;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.content.DialogInterface;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
|
@ -27,6 +41,9 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
private ListPreference overlayPreference;
|
||||
private ListPreference underlayPreference;
|
||||
|
||||
private MapTileLayer overlayLayer;
|
||||
private MapTileLayer underlayLayer;
|
||||
|
||||
public OsmandRasterMapsPlugin(OsmandApplication app) {
|
||||
this.app = app;
|
||||
}
|
||||
|
@ -51,6 +68,154 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
}
|
||||
@Override
|
||||
public void registerLayers(MapActivity activity) {
|
||||
underlayLayer = new MapTileLayer(false);
|
||||
// mapView.addLayer(underlayLayer, -0.5f);
|
||||
overlayLayer = new MapTileLayer(false);
|
||||
// mapView.addLayer(overlayLayer, 0.7f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
|
||||
updateMapLayers(mapView, null, activity.getMapLayers());
|
||||
}
|
||||
|
||||
|
||||
public void updateMapLayers(OsmandMapTileView mapView, CommonPreference<String> settingsToWarnAboutMap,
|
||||
final MapActivityLayers layers) {
|
||||
overlayLayer.setAlpha(settings.MAP_OVERLAY_TRANSPARENCY.get());
|
||||
updateLayer(mapView, settings, overlayLayer, settings.MAP_OVERLAY, 0.7f, settings.MAP_OVERLAY == settingsToWarnAboutMap);
|
||||
updateLayer(mapView, settings, underlayLayer, settings.MAP_UNDERLAY, -0.5f, settings.MAP_UNDERLAY == settingsToWarnAboutMap);
|
||||
layers.updateMapSource(mapView, settingsToWarnAboutMap);
|
||||
}
|
||||
|
||||
public void updateLayer(OsmandMapTileView mapView, OsmandSettings settings,
|
||||
MapTileLayer layer, CommonPreference<String> preference, float layerOrder, boolean warnWhenSelected) {
|
||||
ITileSource overlay = settings.getTileSourceByName(preference.get(), warnWhenSelected);
|
||||
if(!Algoritms.objectEquals(overlay, layer.getMap())){
|
||||
if(overlay == null){
|
||||
mapView.removeLayer(layer);
|
||||
} else {
|
||||
mapView.addLayer(layer, layerOrder);
|
||||
}
|
||||
layer.setMap(overlay);
|
||||
mapView.refreshMap();
|
||||
}
|
||||
}
|
||||
|
||||
public void selectMapOverlayLayer(final OsmandMapTileView mapView,
|
||||
final CommonPreference<String> mapPref, final CommonPreference<Integer> transparencyPref,
|
||||
final MapActivity activity,
|
||||
final BaseMapLayer... transparencyToChange){
|
||||
final OsmandSettings settings = app.getSettings();
|
||||
final MapActivityLayers layers = activity.getMapLayers();
|
||||
Map<String, String> entriesMap = settings.getTileSourceEntries();
|
||||
final ArrayList<String> keys = new ArrayList<String>(entriesMap.keySet());
|
||||
Builder builder = new AlertDialog.Builder(activity);
|
||||
final String[] items = new String[entriesMap.size() + 1];
|
||||
int i = 0;
|
||||
for(String it : entriesMap.values()){
|
||||
items[i++] = it;
|
||||
}
|
||||
|
||||
items[i] = app.getString(R.string.install_more);
|
||||
builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (which == items.length - 1){
|
||||
SettingsActivity.installMapLayers(activity, new ResultMatcher<TileSourceTemplate>() {
|
||||
TileSourceTemplate template = null;
|
||||
int count = 0;
|
||||
@Override
|
||||
public boolean publish(TileSourceTemplate object) {
|
||||
if(object == null){
|
||||
if(count == 1){
|
||||
mapPref.set(template.getName());
|
||||
layers.getMapControlsLayer().showAndHideTransparencyBar(transparencyPref, transparencyToChange);
|
||||
updateMapLayers(mapView, mapPref, layers);
|
||||
} else {
|
||||
selectMapOverlayLayer(mapView, mapPref, transparencyPref, activity, transparencyToChange);
|
||||
}
|
||||
} else {
|
||||
count ++;
|
||||
template = object;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mapPref.set(keys.get(which));
|
||||
layers.getMapControlsLayer().showAndHideTransparencyBar(transparencyPref, transparencyToChange);
|
||||
updateMapLayers(mapView, mapPref, layers);
|
||||
}
|
||||
dialog.dismiss();
|
||||
}
|
||||
|
||||
});
|
||||
builder.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerLayerContextMenuActions(final OsmandMapTileView mapView, ContextMenuAdapter adapter, final MapActivity mapActivity) {
|
||||
final MapActivityLayers layers = mapActivity.getMapLayers();
|
||||
OnContextMenuClick listener = new OnContextMenuClick() {
|
||||
@Override
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (itemId == R.string.layer_map) {
|
||||
dialog.dismiss();
|
||||
layers.selectMapLayer(mapView);
|
||||
} else if(itemId == R.string.layer_overlay){
|
||||
if(overlayLayer.getMap() != null){
|
||||
settings.MAP_OVERLAY.set(null);
|
||||
updateMapLayers(mapView, null, layers);
|
||||
} else {
|
||||
dialog.dismiss();
|
||||
selectMapOverlayLayer(mapView, settings.MAP_OVERLAY, settings.MAP_OVERLAY_TRANSPARENCY, mapActivity,
|
||||
overlayLayer);
|
||||
}
|
||||
} else if(itemId == R.string.layer_underlay){
|
||||
if(underlayLayer.getMap() != null){
|
||||
settings.MAP_UNDERLAY.set(null);
|
||||
updateMapLayers(mapView, null, layers);
|
||||
} else {
|
||||
dialog.dismiss();
|
||||
selectMapOverlayLayer(mapView, settings.MAP_UNDERLAY,settings.MAP_TRANSPARENCY,
|
||||
mapActivity, layers.getMapTileLayer(), layers.getMapVectorLayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
adapter.registerSelectedItem(R.string.layer_map, -1, R.drawable.list_activities_map_src, listener, 0);
|
||||
adapter.registerSelectedItem(R.string.layer_overlay, overlayLayer.getMap() != null ? 1 : 0,
|
||||
R.drawable.list_activities_overlay_map, listener, -1);
|
||||
adapter.registerSelectedItem(R.string.layer_underlay, underlayLayer.getMap() != null ? 1 : 0,
|
||||
R.drawable.list_activities_underlay_map, listener, -1);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void registerMapContextMenuActions(final MapActivity mapActivity, final double latitude, final double longitude, ContextMenuAdapter adapter,
|
||||
Object selectedObj) {
|
||||
final OsmandMapTileView mapView = mapActivity.getMapView();
|
||||
if (mapView.getMainLayer() instanceof MapTileLayer) {
|
||||
OnContextMenuClick listener = new OnContextMenuClick() {
|
||||
@Override
|
||||
public void onContextMenuClick(int resId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (resId == R.string.context_menu_item_update_map) {
|
||||
mapActivity.getMapActions().reloadTile(mapView.getZoom(), latitude, longitude);
|
||||
} else if (resId == R.string.context_menu_item_download_map) {
|
||||
DownloadTilesDialog dlg = new DownloadTilesDialog(mapActivity, (OsmandApplication) mapActivity.getApplication(), mapView);
|
||||
dlg.openDialog();
|
||||
}
|
||||
}
|
||||
};
|
||||
adapter.registerItem(R.string.context_menu_item_update_map, 0, listener, -1);
|
||||
adapter.registerItem(R.string.context_menu_item_download_map, 0, listener, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -76,7 +241,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
cat.setTitle(R.string.pref_raster_map);
|
||||
grp.addPreference(cat);
|
||||
|
||||
CheckBoxPreference mapVectorData = activity.createCheckBoxPreference(settings.MAP_VECTOR_DATA,
|
||||
CheckBoxPreference mapVectorData = activity.createCheckBoxPreference(settings.MAP_ONLINE_DATA,
|
||||
R.string.map_vector_data, R.string.map_vector_data_descr);
|
||||
// final OnPreferenceChangeListener parent = mapVectorData.getOnPreferenceChangeListener();
|
||||
// MapRenderRepositories r = app.getResourceManager().getRenderer();
|
||||
|
|
|
@ -110,7 +110,8 @@ public class MapVectorLayer extends BaseMapLayer {
|
|||
}
|
||||
|
||||
|
||||
private void drawRenderedMap(Canvas canvas, Bitmap bmp, RotatedTileBox bmpLoc) {
|
||||
private boolean drawRenderedMap(Canvas canvas, Bitmap bmp, RotatedTileBox bmpLoc) {
|
||||
boolean shown = false;
|
||||
if (bmp != null && bmpLoc != null) {
|
||||
float rot = bmpLoc.getRotate();
|
||||
float mult = (float) MapUtils.getPowZoom(view.getZoom() - bmpLoc.getZoom());
|
||||
|
@ -131,9 +132,11 @@ public class MapVectorLayer extends BaseMapLayer {
|
|||
* view.getTileSize());
|
||||
if(!bmp.isRecycled()){
|
||||
canvas.drawBitmap(bmp, null, destImage, paintImg);
|
||||
shown = true;
|
||||
}
|
||||
canvas.rotate(rot, view.getCenterPointX(), view.getCenterPointY());
|
||||
}
|
||||
return shown;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import net.osmand.plus.render.RenderingIcons;
|
|||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
|
@ -302,7 +303,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
|||
final Amenity a = (Amenity) o;
|
||||
OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() {
|
||||
@Override
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked) {
|
||||
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (itemId == R.string.poi_context_menu_call) {
|
||||
try {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
|
|
Loading…
Reference in a new issue