Added mapillary setting to configure map
This commit is contained in:
parent
e0f1d3697e
commit
6a02e772c2
6 changed files with 170 additions and 2 deletions
|
@ -425,6 +425,9 @@ public class TileSourceManager {
|
||||||
return new TileSourceTemplate("CycleMap", "http://b.tile.opencyclemap.org/cycle/{0}/{1}/{2}.png", ".png", 16, 1, 256, 32, 18000); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
|
return new TileSourceTemplate("CycleMap", "http://b.tile.opencyclemap.org/cycle/{0}/{1}/{2}.png", ".png", 16, 1, 256, 32, 18000); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TileSourceTemplate getMapillarySource() {
|
||||||
|
return new TileSourceTemplate("Mapillary (raster tiles)", "https://d6a1v2w10ny40.cloudfront.net/v0.1/{0}/{1}/{2}.png", ".png", 17, 0, 256, 16, 32000);
|
||||||
|
}
|
||||||
|
|
||||||
public static List<TileSourceTemplate> downloadTileSourceTemplates(String versionAsUrl) {
|
public static List<TileSourceTemplate> downloadTileSourceTemplates(String versionAsUrl) {
|
||||||
final List<TileSourceTemplate> templates = new ArrayList<TileSourceTemplate>();
|
final List<TileSourceTemplate> templates = new ArrayList<TileSourceTemplate>();
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||||
-->
|
-->
|
||||||
|
<string name="mapillary">Mapillary</string>
|
||||||
<string name="private_access_routing_req">Your destination is located in the area with a private access. Do you want to allow access to the private roads for this trip?</string>
|
<string name="private_access_routing_req">Your destination is located in the area with a private access. Do you want to allow access to the private roads for this trip?</string>
|
||||||
<string name="restart_search">Restart search</string>
|
<string name="restart_search">Restart search</string>
|
||||||
<string name="increase_search_radius">Increase search radius</string>
|
<string name="increase_search_radius">Increase search radius</string>
|
||||||
|
|
|
@ -19,6 +19,7 @@ import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
||||||
import net.osmand.plus.dashboard.tools.DashFragmentData;
|
import net.osmand.plus.dashboard.tools.DashFragmentData;
|
||||||
import net.osmand.plus.development.OsmandDevelopmentPlugin;
|
import net.osmand.plus.development.OsmandDevelopmentPlugin;
|
||||||
import net.osmand.plus.distancecalculator.DistanceCalculatorPlugin;
|
import net.osmand.plus.distancecalculator.DistanceCalculatorPlugin;
|
||||||
|
import net.osmand.plus.mapillary.MapillaryPlugin;
|
||||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||||
import net.osmand.plus.myplaces.FavoritesActivity;
|
import net.osmand.plus.myplaces.FavoritesActivity;
|
||||||
import net.osmand.plus.openseamapsplugin.NauticalMapsPlugin;
|
import net.osmand.plus.openseamapsplugin.NauticalMapsPlugin;
|
||||||
|
@ -55,6 +56,10 @@ public abstract class OsmandPlugin {
|
||||||
|
|
||||||
public abstract int getAssetResourceName();
|
public abstract int getAssetResourceName();
|
||||||
|
|
||||||
|
public boolean isStationary() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
public int getLogoResourceId() {
|
public int getLogoResourceId() {
|
||||||
return R.drawable.ic_extension_dark;
|
return R.drawable.ic_extension_dark;
|
||||||
|
@ -78,7 +83,7 @@ public abstract class OsmandPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isActive() {
|
public boolean isActive() {
|
||||||
return active;
|
return active || isStationary();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean needsInstallation() {
|
public boolean needsInstallation() {
|
||||||
|
@ -103,6 +108,7 @@ public abstract class OsmandPlugin {
|
||||||
public static void initPlugins(OsmandApplication app) {
|
public static void initPlugins(OsmandApplication app) {
|
||||||
OsmandSettings settings = app.getSettings();
|
OsmandSettings settings = app.getSettings();
|
||||||
Set<String> enabledPlugins = settings.getEnabledPlugins();
|
Set<String> enabledPlugins = settings.getEnabledPlugins();
|
||||||
|
allPlugins.add(new MapillaryPlugin(app));
|
||||||
allPlugins.add(new OsmandRasterMapsPlugin(app));
|
allPlugins.add(new OsmandRasterMapsPlugin(app));
|
||||||
allPlugins.add(new OsmandMonitoringPlugin(app));
|
allPlugins.add(new OsmandMonitoringPlugin(app));
|
||||||
// allPlugins.add(new OsMoPlugin(app));
|
// allPlugins.add(new OsMoPlugin(app));
|
||||||
|
@ -278,6 +284,16 @@ public abstract class OsmandPlugin {
|
||||||
return allPlugins;
|
return allPlugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<OsmandPlugin> getAdjustablePlugins() {
|
||||||
|
List<OsmandPlugin> res = new ArrayList<>();
|
||||||
|
for (OsmandPlugin plugin : allPlugins) {
|
||||||
|
if (!plugin.isStationary()) {
|
||||||
|
res.add(plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
public static List<OsmandPlugin> getEnabledPlugins() {
|
public static List<OsmandPlugin> getEnabledPlugins() {
|
||||||
ArrayList<OsmandPlugin> lst = new ArrayList<OsmandPlugin>(allPlugins.size());
|
ArrayList<OsmandPlugin> lst = new ArrayList<OsmandPlugin>(allPlugins.size());
|
||||||
for (OsmandPlugin p : allPlugins) {
|
for (OsmandPlugin p : allPlugins) {
|
||||||
|
|
|
@ -892,6 +892,8 @@ public class OsmandSettings {
|
||||||
|
|
||||||
public final OsmandPreference<Boolean> SHOW_POI_LABEL = new BooleanPreference("show_poi_label", false).makeGlobal();
|
public final OsmandPreference<Boolean> SHOW_POI_LABEL = new BooleanPreference("show_poi_label", false).makeGlobal();
|
||||||
|
|
||||||
|
public final OsmandPreference<Boolean> SHOW_MAPILLARY = new BooleanPreference("show_mapillary", false).makeGlobal();
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
public final OsmandPreference<String> PREFERRED_LOCALE = new StringPreference("preferred_locale", "").makeGlobal();
|
public final OsmandPreference<String> PREFERRED_LOCALE = new StringPreference("preferred_locale", "").makeGlobal();
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class PluginsActivity extends OsmandListActivity {
|
||||||
protected class PluginsListAdapter extends ArrayAdapter<OsmandPlugin> {
|
protected class PluginsListAdapter extends ArrayAdapter<OsmandPlugin> {
|
||||||
public PluginsListAdapter() {
|
public PluginsListAdapter() {
|
||||||
super(PluginsActivity.this, R.layout.plugins_list_item,
|
super(PluginsActivity.this, R.layout.plugins_list_item,
|
||||||
OsmandPlugin.getAvailablePlugins());
|
OsmandPlugin.getAdjustablePlugins());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
146
OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java
Normal file
146
OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java
Normal file
|
@ -0,0 +1,146 @@
|
||||||
|
package net.osmand.plus.mapillary;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
|
||||||
|
import net.osmand.map.ITileSource;
|
||||||
|
import net.osmand.map.TileSourceManager;
|
||||||
|
import net.osmand.plus.ContextMenuAdapter;
|
||||||
|
import net.osmand.plus.ContextMenuItem;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.OsmandPlugin;
|
||||||
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.activities.MapActivityLayers;
|
||||||
|
import net.osmand.plus.views.MapTileLayer;
|
||||||
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
public class MapillaryPlugin extends OsmandPlugin {
|
||||||
|
public static final String ID = "osmand.mapillary";
|
||||||
|
private OsmandSettings settings;
|
||||||
|
private OsmandApplication app;
|
||||||
|
|
||||||
|
private MapTileLayer rasterLayer;
|
||||||
|
|
||||||
|
public MapillaryPlugin(OsmandApplication app) {
|
||||||
|
this.app = app;
|
||||||
|
settings = app.getSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLogoResourceId() {
|
||||||
|
return R.drawable.ic_action_mapillary;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAssetResourceName() {
|
||||||
|
return R.drawable.online_maps;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getId() {
|
||||||
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() {
|
||||||
|
return app.getString(R.string.mapillary);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return app.getString(R.string.mapillary);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isStationary() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerLayers(MapActivity activity) {
|
||||||
|
createLayers();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createLayers() {
|
||||||
|
rasterLayer = new MapTileLayer(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
|
||||||
|
updateMapLayers(mapView, activity.getMapLayers());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateMapLayers(OsmandMapTileView mapView, final MapActivityLayers layers) {
|
||||||
|
if (rasterLayer == null) {
|
||||||
|
createLayers();
|
||||||
|
}
|
||||||
|
if (isActive()) {
|
||||||
|
updateLayer(mapView, rasterLayer, 0.6f);
|
||||||
|
} else {
|
||||||
|
mapView.removeLayer(rasterLayer);
|
||||||
|
rasterLayer.setMap(null);
|
||||||
|
}
|
||||||
|
layers.updateMapSource(mapView, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateLayer(OsmandMapTileView mapView, MapTileLayer layer, float layerOrder) {
|
||||||
|
ITileSource mapillarySource = null;
|
||||||
|
if (settings.SHOW_MAPILLARY.get()) {
|
||||||
|
mapillarySource = TileSourceManager.getMapillarySource();
|
||||||
|
}
|
||||||
|
if (!Algorithms.objectEquals(mapillarySource, layer.getMap())) {
|
||||||
|
if (mapillarySource == null) {
|
||||||
|
mapView.removeLayer(layer);
|
||||||
|
} else if (mapView.getMapRenderer() == null) {
|
||||||
|
mapView.addLayer(layer, layerOrder);
|
||||||
|
}
|
||||||
|
layer.setMap(mapillarySource);
|
||||||
|
mapView.refreshMap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends Activity> getSettingsActivity() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerLayerContextMenuActions(final OsmandMapTileView mapView,
|
||||||
|
ContextMenuAdapter adapter,
|
||||||
|
final MapActivity mapActivity) {
|
||||||
|
ContextMenuAdapter.ItemClickListener listener = new ContextMenuAdapter.OnRowItemClick() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter, int itemId, final int pos, boolean isChecked) {
|
||||||
|
final OsmandSettings settings = mapActivity.getMyApplication().getSettings();
|
||||||
|
if (itemId == R.string.mapillary) {
|
||||||
|
OsmandMapTileView mapView = mapActivity.getMapView();
|
||||||
|
MapActivityLayers mapLayers = mapActivity.getMapLayers();
|
||||||
|
settings.SHOW_MAPILLARY.set(!settings.SHOW_MAPILLARY.get());
|
||||||
|
updateMapLayers(mapView, mapLayers);
|
||||||
|
ContextMenuItem item = adapter.getItem(pos);
|
||||||
|
if (item != null) {
|
||||||
|
item.setSelected(settings.SHOW_MAPILLARY.get());
|
||||||
|
item.setColorRes(settings.SHOW_MAPILLARY.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (rasterLayer.getMap() == null) {
|
||||||
|
settings.SHOW_MAPILLARY.set(false);
|
||||||
|
}
|
||||||
|
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.mapillary, mapActivity)
|
||||||
|
.setSelected(settings.SHOW_MAPILLARY.get())
|
||||||
|
.setColor(settings.SHOW_MAPILLARY.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
|
||||||
|
.setIcon(R.drawable.ic_action_mapillary)
|
||||||
|
.setListener(listener)
|
||||||
|
.setPosition(11)
|
||||||
|
.createItem());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue