Fixed formatting
This commit is contained in:
parent
8e979c02b9
commit
64bc77eb1d
5 changed files with 189 additions and 184 deletions
|
@ -196,6 +196,7 @@
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<include layout="@layout/recording_note_fragment"/>
|
<include layout="@layout/recording_note_fragment"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/map_context_menu_layout"
|
android:id="@+id/map_context_menu_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -193,7 +193,7 @@ public class ContextMenuAdapter {
|
||||||
i.name = name;
|
i.name = name;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Item item(int resId) {
|
public Item item(int resId) {
|
||||||
Item i = new Item();
|
Item i = new Item();
|
||||||
|
@ -229,7 +229,7 @@ public class ContextMenuAdapter {
|
||||||
this.lightIcon = icon;
|
this.lightIcon = icon;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Item position(int pos) {
|
public Item position(int pos) {
|
||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
|
@ -293,7 +293,7 @@ public class ContextMenuAdapter {
|
||||||
cat = b;
|
cat = b;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item name(String name) {
|
public Item name(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
return this;
|
return this;
|
||||||
|
@ -351,6 +351,7 @@ public class ContextMenuAdapter {
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private boolean holoLight;
|
private boolean holoLight;
|
||||||
private int layoutId;
|
private int layoutId;
|
||||||
|
|
||||||
public ContextMenuArrayAdapter(Activity context, int resource, int textViewResourceId,
|
public ContextMenuArrayAdapter(Activity context, int resource, int textViewResourceId,
|
||||||
String[] objects, OsmandApplication app, boolean holoLight) {
|
String[] objects, OsmandApplication app, boolean holoLight) {
|
||||||
super(context, resource, textViewResourceId, objects);
|
super(context, resource, textViewResourceId, objects);
|
||||||
|
@ -445,7 +446,7 @@ public class ContextMenuAdapter {
|
||||||
|
|
||||||
if (convertView.findViewById(R.id.seekbar) != null) {
|
if (convertView.findViewById(R.id.seekbar) != null) {
|
||||||
SeekBar seekBar = (SeekBar) convertView.findViewById(R.id.seekbar);
|
SeekBar seekBar = (SeekBar) convertView.findViewById(R.id.seekbar);
|
||||||
if(progressList.get(position) != -1) {
|
if (progressList.get(position) != -1) {
|
||||||
seekBar.setProgress(getProgress(position));
|
seekBar.setProgress(getProgress(position));
|
||||||
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -55,14 +55,14 @@ import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object is responsible to maintain layers using by map activity
|
* Object is responsible to maintain layers using by map activity
|
||||||
*/
|
*/
|
||||||
public class MapActivityLayers {
|
public class MapActivityLayers {
|
||||||
|
|
||||||
private final MapActivity activity;
|
private final MapActivity activity;
|
||||||
|
|
||||||
// the order of layer should be preserved ! when you are inserting new layer
|
// the order of layer should be preserved ! when you are inserting new layer
|
||||||
private MapTileLayer mapTileLayer;
|
private MapTileLayer mapTileLayer;
|
||||||
private MapVectorLayer mapVectorLayer;
|
private MapVectorLayer mapVectorLayer;
|
||||||
private GPXLayer gpxLayer;
|
private GPXLayer gpxLayer;
|
||||||
private RouteLayer routeLayer;
|
private RouteLayer routeLayer;
|
||||||
|
@ -86,18 +86,18 @@ public class MapActivityLayers {
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
this.mapWidgetRegistry = new MapWidgetRegistry(activity.getMyApplication().getSettings());
|
this.mapWidgetRegistry = new MapWidgetRegistry(activity.getMyApplication().getSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapWidgetRegistry getMapWidgetRegistry() {
|
public MapWidgetRegistry getMapWidgetRegistry() {
|
||||||
return mapWidgetRegistry;
|
return mapWidgetRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OsmandApplication getApplication(){
|
public OsmandApplication getApplication() {
|
||||||
return (OsmandApplication) activity.getApplication();
|
return (OsmandApplication) activity.getApplication();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void createLayers(final OsmandMapTileView mapView){
|
public void createLayers(final OsmandMapTileView mapView) {
|
||||||
|
|
||||||
OsmandApplication app = (OsmandApplication) getApplication();
|
OsmandApplication app = (OsmandApplication) getApplication();
|
||||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
RoutingHelper routingHelper = app.getRoutingHelper();
|
||||||
// first create to make accessible
|
// first create to make accessible
|
||||||
|
@ -108,7 +108,7 @@ public class MapActivityLayers {
|
||||||
mapTileLayer = new MapTileLayer(true);
|
mapTileLayer = new MapTileLayer(true);
|
||||||
mapView.addLayer(mapTileLayer, 0.0f);
|
mapView.addLayer(mapTileLayer, 0.0f);
|
||||||
mapView.setMainLayer(mapTileLayer);
|
mapView.setMainLayer(mapTileLayer);
|
||||||
|
|
||||||
// 0.5 layer
|
// 0.5 layer
|
||||||
mapVectorLayer = new MapVectorLayer(mapTileLayer, false);
|
mapVectorLayer = new MapVectorLayer(mapTileLayer, false);
|
||||||
mapView.addLayer(mapVectorLayer, 0.5f);
|
mapView.addLayer(mapVectorLayer, 0.5f);
|
||||||
|
@ -119,11 +119,11 @@ public class MapActivityLayers {
|
||||||
// 0.9 gpx layer
|
// 0.9 gpx layer
|
||||||
gpxLayer = new GPXLayer();
|
gpxLayer = new GPXLayer();
|
||||||
mapView.addLayer(gpxLayer, 0.9f);
|
mapView.addLayer(gpxLayer, 0.9f);
|
||||||
|
|
||||||
// 1. route layer
|
// 1. route layer
|
||||||
routeLayer = new RouteLayer(routingHelper);
|
routeLayer = new RouteLayer(routingHelper);
|
||||||
mapView.addLayer(routeLayer, 1);
|
mapView.addLayer(routeLayer, 1);
|
||||||
|
|
||||||
// 2. osm bugs layer
|
// 2. osm bugs layer
|
||||||
// 3. poi layer
|
// 3. poi layer
|
||||||
poiMapLayer = new POIMapLayer(activity);
|
poiMapLayer = new POIMapLayer(activity);
|
||||||
|
@ -155,7 +155,7 @@ public class MapActivityLayers {
|
||||||
// 11. route info layer
|
// 11. route info layer
|
||||||
mapControlsLayer = new MapControlsLayer(activity);
|
mapControlsLayer = new MapControlsLayer(activity);
|
||||||
mapView.addLayer(mapControlsLayer, 11);
|
mapView.addLayer(mapControlsLayer, 11);
|
||||||
|
|
||||||
transparencyListener = new StateChangedListener<Integer>() {
|
transparencyListener = new StateChangedListener<Integer>() {
|
||||||
@Override
|
@Override
|
||||||
public void stateChanged(Integer change) {
|
public void stateChanged(Integer change) {
|
||||||
|
@ -165,18 +165,18 @@ public class MapActivityLayers {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
app.getSettings().MAP_TRANSPARENCY.addListener(transparencyListener);
|
app.getSettings().MAP_TRANSPARENCY.addListener(transparencyListener);
|
||||||
|
|
||||||
OsmandPlugin.createLayers(mapView, activity);
|
OsmandPlugin.createLayers(mapView, activity);
|
||||||
app.getAppCustomization().createLayers(mapView, activity);
|
app.getAppCustomization().createLayers(mapView, activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void updateLayers(OsmandMapTileView mapView){
|
public void updateLayers(OsmandMapTileView mapView) {
|
||||||
OsmandSettings settings = getApplication().getSettings();
|
OsmandSettings settings = getApplication().getSettings();
|
||||||
updateMapSource(mapView, settings.MAP_TILE_SOURCES);
|
updateMapSource(mapView, settings.MAP_TILE_SOURCES);
|
||||||
boolean showStops = settings.getCustomRenderBooleanProperty(OsmandSettings.TRANSPORT_STOPS_OVER_MAP).get();
|
boolean showStops = settings.getCustomRenderBooleanProperty(OsmandSettings.TRANSPORT_STOPS_OVER_MAP).get();
|
||||||
if(mapView.getLayers().contains(transportStopsLayer) != showStops){
|
if (mapView.getLayers().contains(transportStopsLayer) != showStops) {
|
||||||
if(showStops){
|
if (showStops) {
|
||||||
mapView.addLayer(transportStopsLayer, 5);
|
mapView.addLayer(transportStopsLayer, 5);
|
||||||
} else {
|
} else {
|
||||||
mapView.removeLayer(transportStopsLayer);
|
mapView.removeLayer(transportStopsLayer);
|
||||||
|
@ -184,15 +184,15 @@ public class MapActivityLayers {
|
||||||
}
|
}
|
||||||
OsmandPlugin.refreshLayers(mapView, activity);
|
OsmandPlugin.refreshLayers(mapView, activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMapSource(OsmandMapTileView mapView, CommonPreference<String> settingsToWarnAboutMap){
|
public void updateMapSource(OsmandMapTileView mapView, CommonPreference<String> settingsToWarnAboutMap) {
|
||||||
OsmandSettings settings = getApplication().getSettings();
|
OsmandSettings settings = getApplication().getSettings();
|
||||||
|
|
||||||
// update transparency
|
// update transparency
|
||||||
int mapTransparency = settings.MAP_UNDERLAY.get() == null ? 255 : settings.MAP_TRANSPARENCY.get();
|
int mapTransparency = settings.MAP_UNDERLAY.get() == null ? 255 : settings.MAP_TRANSPARENCY.get();
|
||||||
mapTileLayer.setAlpha(mapTransparency);
|
mapTileLayer.setAlpha(mapTransparency);
|
||||||
mapVectorLayer.setAlpha(mapTransparency);
|
mapVectorLayer.setAlpha(mapTransparency);
|
||||||
|
|
||||||
ITileSource newSource = settings.getMapTileSource(settings.MAP_TILE_SOURCES == settingsToWarnAboutMap);
|
ITileSource newSource = settings.getMapTileSource(settings.MAP_TILE_SOURCES == settingsToWarnAboutMap);
|
||||||
ITileSource oldMap = mapTileLayer.getMap();
|
ITileSource oldMap = mapTileLayer.getMap();
|
||||||
if (newSource != oldMap) {
|
if (newSource != oldMap) {
|
||||||
|
@ -201,18 +201,18 @@ public class MapActivityLayers {
|
||||||
}
|
}
|
||||||
mapTileLayer.setMap(newSource);
|
mapTileLayer.setMap(newSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean vectorData = !settings.MAP_ONLINE_DATA.get();
|
boolean vectorData = !settings.MAP_ONLINE_DATA.get();
|
||||||
mapTileLayer.setVisible(!vectorData);
|
mapTileLayer.setVisible(!vectorData);
|
||||||
mapVectorLayer.setVisible(vectorData);
|
mapVectorLayer.setVisible(vectorData);
|
||||||
if(vectorData){
|
if (vectorData) {
|
||||||
mapView.setMainLayer(mapVectorLayer);
|
mapView.setMainLayer(mapVectorLayer);
|
||||||
} else {
|
} else {
|
||||||
mapView.setMainLayer(mapTileLayer);
|
mapView.setMainLayer(mapTileLayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public AlertDialog showGPXFileLayer(List<String> files, final OsmandMapTileView mapView) {
|
public AlertDialog showGPXFileLayer(List<String> files, final OsmandMapTileView mapView) {
|
||||||
final OsmandSettings settings = getApplication().getSettings();
|
final OsmandSettings settings = getApplication().getSettings();
|
||||||
CallbackWithObject<GPXFile[]> callbackWithObject = new CallbackWithObject<GPXFile[]>() {
|
CallbackWithObject<GPXFile[]> callbackWithObject = new CallbackWithObject<GPXFile[]>() {
|
||||||
|
@ -253,7 +253,7 @@ public class MapActivityLayers {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public AlertDialog selectPOIFilterLayer(final OsmandMapTileView mapView, final PoiUIFilter[] selected){
|
public AlertDialog selectPOIFilterLayer(final OsmandMapTileView mapView, final PoiUIFilter[] selected) {
|
||||||
OsmandApplication app = (OsmandApplication) getApplication();
|
OsmandApplication app = (OsmandApplication) getApplication();
|
||||||
final PoiFiltersHelper poiFilters = app.getPoiFilters();
|
final PoiFiltersHelper poiFilters = app.getPoiFilters();
|
||||||
final ContextMenuAdapter adapter = new ContextMenuAdapter(activity);
|
final ContextMenuAdapter adapter = new ContextMenuAdapter(activity);
|
||||||
|
@ -263,15 +263,15 @@ public class MapActivityLayers {
|
||||||
for (PoiUIFilter f : poiFilters.getTopDefinedPoiFilters()) {
|
for (PoiUIFilter f : poiFilters.getTopDefinedPoiFilters()) {
|
||||||
addFilterToList(adapter, list, f);
|
addFilterToList(adapter, list, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||||
ListAdapter listAdapter = adapter.createListAdapter(activity, app.getSettings().isLightContent());
|
ListAdapter listAdapter = adapter.createListAdapter(activity, app.getSettings().isLightContent());
|
||||||
builder.setAdapter(listAdapter, new DialogInterface.OnClickListener(){
|
builder.setAdapter(listAdapter, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
PoiUIFilter pf = list.get(which);
|
PoiUIFilter pf = list.get(which);
|
||||||
String filterId = pf.getFilterId();
|
String filterId = pf.getFilterId();
|
||||||
if(filterId.equals(PoiUIFilter.CUSTOM_FILTER_ID)){
|
if (filterId.equals(PoiUIFilter.CUSTOM_FILTER_ID)) {
|
||||||
Intent search = new Intent(activity, SearchActivity.class);
|
Intent search = new Intent(activity, SearchActivity.class);
|
||||||
search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
activity.getMyApplication().getSettings().SEARCH_TAB.set(SearchActivity.POI_TAB_INDEX);
|
activity.getMyApplication().getSettings().SEARCH_TAB.set(SearchActivity.POI_TAB_INDEX);
|
||||||
|
@ -283,12 +283,12 @@ public class MapActivityLayers {
|
||||||
}
|
}
|
||||||
getApplication().getSettings().SELECTED_POI_FILTER_FOR_MAP.set(filterId);
|
getApplication().getSettings().SELECTED_POI_FILTER_FOR_MAP.set(filterId);
|
||||||
mapView.refreshMap();
|
mapView.refreshMap();
|
||||||
if(selected != null && selected.length > 0) {
|
if (selected != null && selected.length > 0) {
|
||||||
selected[0] = pf;
|
selected[0] = pf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||||
return builder.show();
|
return builder.show();
|
||||||
|
@ -305,36 +305,36 @@ public class MapActivityLayers {
|
||||||
it.reg();
|
it.reg();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectMapLayer(final OsmandMapTileView mapView){
|
public void selectMapLayer(final OsmandMapTileView mapView) {
|
||||||
if(OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) == null) {
|
if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) == null) {
|
||||||
AccessibleToast.makeText(activity, R.string.map_online_plugin_is_not_installed, Toast.LENGTH_LONG).show();
|
AccessibleToast.makeText(activity, R.string.map_online_plugin_is_not_installed, Toast.LENGTH_LONG).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final OsmandSettings settings = getApplication().getSettings();
|
final OsmandSettings settings = getApplication().getSettings();
|
||||||
|
|
||||||
final LinkedHashMap<String, String> entriesMap = new LinkedHashMap<String, String>();
|
final LinkedHashMap<String, String> entriesMap = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
|
|
||||||
final String layerOsmVector = "LAYER_OSM_VECTOR";
|
final String layerOsmVector = "LAYER_OSM_VECTOR";
|
||||||
final String layerInstallMore = "LAYER_INSTALL_MORE";
|
final String layerInstallMore = "LAYER_INSTALL_MORE";
|
||||||
final String layerEditInstall = "LAYER_EDIT";
|
final String layerEditInstall = "LAYER_EDIT";
|
||||||
|
|
||||||
entriesMap.put(layerOsmVector, getString(R.string.vector_data));
|
entriesMap.put(layerOsmVector, getString(R.string.vector_data));
|
||||||
entriesMap.putAll(settings.getTileSourceEntries());
|
entriesMap.putAll(settings.getTileSourceEntries());
|
||||||
entriesMap.put(layerInstallMore, getString(R.string.install_more));
|
entriesMap.put(layerInstallMore, getString(R.string.install_more));
|
||||||
entriesMap.put(layerEditInstall, getString(R.string.maps_define_edit));
|
entriesMap.put(layerEditInstall, getString(R.string.maps_define_edit));
|
||||||
|
|
||||||
final List<Entry<String, String>> entriesMapList = new ArrayList<Entry<String, String>>(entriesMap.entrySet());
|
final List<Entry<String, String>> entriesMapList = new ArrayList<Entry<String, String>>(entriesMap.entrySet());
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||||
|
|
||||||
String selectedTileSourceKey = settings.MAP_TILE_SOURCES.get();
|
String selectedTileSourceKey = settings.MAP_TILE_SOURCES.get();
|
||||||
|
|
||||||
int selectedItem = -1;
|
int selectedItem = -1;
|
||||||
if (!settings.MAP_ONLINE_DATA.get()) {
|
if (!settings.MAP_ONLINE_DATA.get()) {
|
||||||
selectedItem = 0;
|
selectedItem = 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Entry<String, String> selectedEntry = null;
|
Entry<String, String> selectedEntry = null;
|
||||||
for (Entry<String, String> entry : entriesMap.entrySet()) {
|
for (Entry<String, String> entry : entriesMap.entrySet()) {
|
||||||
if (entry.getKey().equals(selectedTileSourceKey)) {
|
if (entry.getKey().equals(selectedTileSourceKey)) {
|
||||||
|
@ -348,14 +348,14 @@ public class MapActivityLayers {
|
||||||
entriesMapList.add(0, selectedEntry);
|
entriesMapList.add(0, selectedEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final String[] items = new String[entriesMapList.size()];
|
final String[] items = new String[entriesMapList.size()];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Entry<String, String> entry : entriesMapList) {
|
for (Entry<String, String> entry : entriesMapList) {
|
||||||
items[i++] = entry.getValue();
|
items[i++] = entry.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.setSingleChoiceItems(items, selectedItem, new DialogInterface.OnClickListener(){
|
builder.setSingleChoiceItems(items, selectedItem, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
String layerKey = entriesMapList.get(which).getKey();
|
String layerKey = entriesMapList.get(which).getKey();
|
||||||
|
@ -377,16 +377,17 @@ public class MapActivityLayers {
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
} else if (layerKey.equals(layerInstallMore)) {
|
} else if (layerKey.equals(layerInstallMore)) {
|
||||||
OsmandRasterMapsPlugin.installMapLayers(activity, new ResultMatcher<TileSourceTemplate>() {
|
OsmandRasterMapsPlugin.installMapLayers(activity, new ResultMatcher<TileSourceTemplate>() {
|
||||||
TileSourceTemplate template = null;
|
TileSourceTemplate template = null;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean publish(TileSourceTemplate object) {
|
public boolean publish(TileSourceTemplate object) {
|
||||||
if(object == null){
|
if (object == null) {
|
||||||
if(count == 1){
|
if (count == 1) {
|
||||||
settings.MAP_TILE_SOURCES.set(template.getName());
|
settings.MAP_TILE_SOURCES.set(template.getName());
|
||||||
settings.MAP_ONLINE_DATA.set(true);
|
settings.MAP_ONLINE_DATA.set(true);
|
||||||
updateMapSource(mapView, settings.MAP_TILE_SOURCES);
|
updateMapSource(mapView, settings.MAP_TILE_SOURCES);
|
||||||
|
@ -394,12 +395,12 @@ public class MapActivityLayers {
|
||||||
selectMapLayer(mapView);
|
selectMapLayer(mapView);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
count ++;
|
count++;
|
||||||
template = object;
|
template = object;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -413,12 +414,12 @@ public class MapActivityLayers {
|
||||||
|
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
builder.show();
|
builder.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String getString(int resId) {
|
private String getString(int resId) {
|
||||||
return activity.getString(resId);
|
return activity.getString(resId);
|
||||||
}
|
}
|
||||||
|
@ -434,44 +435,44 @@ public class MapActivityLayers {
|
||||||
public GPXLayer getGpxLayer() {
|
public GPXLayer getGpxLayer() {
|
||||||
return gpxLayer;
|
return gpxLayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContextMenuLayer getContextMenuLayer() {
|
public ContextMenuLayer getContextMenuLayer() {
|
||||||
return contextMenuLayer;
|
return contextMenuLayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FavoritesLayer getFavoritesLayer() {
|
public FavoritesLayer getFavoritesLayer() {
|
||||||
return favoritesLayer;
|
return favoritesLayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapTextLayer getMapTextLayer() {
|
public MapTextLayer getMapTextLayer() {
|
||||||
return mapTextLayer;
|
return mapTextLayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PointLocationLayer getLocationLayer() {
|
public PointLocationLayer getLocationLayer() {
|
||||||
return locationLayer;
|
return locationLayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapInfoLayer getMapInfoLayer() {
|
public MapInfoLayer getMapInfoLayer() {
|
||||||
return mapInfoLayer;
|
return mapInfoLayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapControlsLayer getMapControlsLayer() {
|
public MapControlsLayer getMapControlsLayer() {
|
||||||
return mapControlsLayer;
|
return mapControlsLayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public MapTileLayer getMapTileLayer() {
|
public MapTileLayer getMapTileLayer() {
|
||||||
return mapTileLayer;
|
return mapTileLayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapVectorLayer getMapVectorLayer() {
|
public MapVectorLayer getMapVectorLayer() {
|
||||||
return mapVectorLayer;
|
return mapVectorLayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public POIMapLayer getPoiMapLayer() {
|
public POIMapLayer getPoiMapLayer() {
|
||||||
return poiMapLayer;
|
return poiMapLayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TransportInfoLayer getTransportInfoLayer() {
|
public TransportInfoLayer getTransportInfoLayer() {
|
||||||
return transportInfoLayer;
|
return transportInfoLayer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,82 +203,82 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
||||||
// by default they handle touches for their list items... i.e. they're in charge of drawing
|
// by default they handle touches for their list items... i.e. they're in charge of drawing
|
||||||
// the pressed state (the list selector), handling list item clicks, etc.
|
// the pressed state (the list selector), handling list item clicks, etc.
|
||||||
swipeDismissListener = new SwipeDismissListViewTouchListener(
|
swipeDismissListener = new SwipeDismissListViewTouchListener(
|
||||||
listView,
|
listView,
|
||||||
new SwipeDismissListViewTouchListener.DismissCallbacks() {
|
new SwipeDismissListViewTouchListener.DismissCallbacks() {
|
||||||
@Override
|
@Override
|
||||||
public boolean canDismiss(int position) {
|
public boolean canDismiss(int position) {
|
||||||
boolean res = false;
|
boolean res = false;
|
||||||
if (visibleType == DashboardType.WAYPOINTS && listAdapter instanceof StableArrayAdapter) {
|
if (visibleType == DashboardType.WAYPOINTS && listAdapter instanceof StableArrayAdapter) {
|
||||||
List<Object> activeObjects = ((StableArrayAdapter) listAdapter).getActiveObjects();
|
List<Object> activeObjects = ((StableArrayAdapter) listAdapter).getActiveObjects();
|
||||||
Object obj = listAdapter.getItem(position);
|
Object obj = listAdapter.getItem(position);
|
||||||
res = activeObjects.contains(obj);
|
res = activeObjects.contains(obj);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Undoable onDismiss(final int position) {
|
public Undoable onDismiss(final int position) {
|
||||||
final Object item;
|
final Object item;
|
||||||
final StableArrayAdapter stableAdapter;
|
final StableArrayAdapter stableAdapter;
|
||||||
final int activeObjPos;
|
final int activeObjPos;
|
||||||
if (listAdapter instanceof StableArrayAdapter) {
|
if (listAdapter instanceof StableArrayAdapter) {
|
||||||
stableAdapter = (StableArrayAdapter) listAdapter;
|
stableAdapter = (StableArrayAdapter) listAdapter;
|
||||||
item = stableAdapter.getItem(position);
|
item = stableAdapter.getItem(position);
|
||||||
|
|
||||||
|
stableAdapter.setNotifyOnChange(false);
|
||||||
|
stableAdapter.remove(item);
|
||||||
|
stableAdapter.getObjects().remove(item);
|
||||||
|
activeObjPos = stableAdapter.getActiveObjects().indexOf(item);
|
||||||
|
stableAdapter.getActiveObjects().remove(item);
|
||||||
|
stableAdapter.refreshData();
|
||||||
|
stableAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
item = null;
|
||||||
|
stableAdapter = null;
|
||||||
|
activeObjPos = 0;
|
||||||
|
}
|
||||||
|
return new Undoable() {
|
||||||
|
@Override
|
||||||
|
public void undo() {
|
||||||
|
if (item != null) {
|
||||||
stableAdapter.setNotifyOnChange(false);
|
stableAdapter.setNotifyOnChange(false);
|
||||||
stableAdapter.remove(item);
|
stableAdapter.insert(item, position);
|
||||||
stableAdapter.getObjects().remove(item);
|
stableAdapter.getObjects().add(position, item);
|
||||||
activeObjPos = stableAdapter.getActiveObjects().indexOf(item);
|
stableAdapter.getActiveObjects().add(activeObjPos, item);
|
||||||
stableAdapter.getActiveObjects().remove(item);
|
|
||||||
stableAdapter.refreshData();
|
|
||||||
stableAdapter.notifyDataSetChanged();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
item = null;
|
|
||||||
stableAdapter = null;
|
|
||||||
activeObjPos = 0;
|
|
||||||
}
|
|
||||||
return new Undoable() {
|
|
||||||
@Override
|
|
||||||
public void undo() {
|
|
||||||
if (item != null) {
|
|
||||||
stableAdapter.setNotifyOnChange(false);
|
|
||||||
stableAdapter.insert(item, position);
|
|
||||||
stableAdapter.getObjects().add(position, item);
|
|
||||||
stableAdapter.getActiveObjects().add(activeObjPos, item);
|
|
||||||
stableAdapter.refreshData();
|
|
||||||
onItemsSwapped(stableAdapter.getActiveObjects());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTitle() {
|
|
||||||
if (visibleType == DashboardType.WAYPOINTS
|
|
||||||
&& (getMyApplication().getRoutingHelper().isRoutePlanningMode() || getMyApplication().getRoutingHelper().isFollowingMode())
|
|
||||||
&& item != null
|
|
||||||
&& stableAdapter.getActiveObjects().size() == 0) {
|
|
||||||
return mapActivity.getResources().getString(R.string.cancel_navigation);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onHidePopup() {
|
|
||||||
if (listAdapter instanceof StableArrayAdapter) {
|
|
||||||
StableArrayAdapter stableAdapter = (StableArrayAdapter) listAdapter;
|
|
||||||
stableAdapter.refreshData();
|
stableAdapter.refreshData();
|
||||||
onItemsSwapped(stableAdapter.getActiveObjects());
|
onItemsSwapped(stableAdapter.getActiveObjects());
|
||||||
if (stableAdapter.getActiveObjects().size() == 0) {
|
|
||||||
hideDashboard();
|
|
||||||
mapActivity.getMapActions().stopNavigationWithoutConfirm();
|
|
||||||
mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().hide();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
@Override
|
||||||
|
public String getTitle() {
|
||||||
|
if (visibleType == DashboardType.WAYPOINTS
|
||||||
|
&& (getMyApplication().getRoutingHelper().isRoutePlanningMode() || getMyApplication().getRoutingHelper().isFollowingMode())
|
||||||
|
&& item != null
|
||||||
|
&& stableAdapter.getActiveObjects().size() == 0) {
|
||||||
|
return mapActivity.getResources().getString(R.string.cancel_navigation);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onHidePopup() {
|
||||||
|
if (listAdapter instanceof StableArrayAdapter) {
|
||||||
|
StableArrayAdapter stableAdapter = (StableArrayAdapter) listAdapter;
|
||||||
|
stableAdapter.refreshData();
|
||||||
|
onItemsSwapped(stableAdapter.getActiveObjects());
|
||||||
|
if (stableAdapter.getActiveObjects().size() == 0) {
|
||||||
|
hideDashboard();
|
||||||
|
mapActivity.getMapActions().stopNavigationWithoutConfirm();
|
||||||
|
mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
gradientToolbar = mapActivity.getResources().getDrawable(R.drawable.gradient_toolbar).mutate();
|
gradientToolbar = mapActivity.getResources().getDrawable(R.drawable.gradient_toolbar).mutate();
|
||||||
if (AndroidUiHelper.isOrientationPortrait(mapActivity)) {
|
if (AndroidUiHelper.isOrientationPortrait(mapActivity)) {
|
||||||
|
|
|
@ -46,34 +46,36 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
public static final String ID = "osmand.rastermaps";
|
public static final String ID = "osmand.rastermaps";
|
||||||
private OsmandSettings settings;
|
private OsmandSettings settings;
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
|
|
||||||
private MapTileLayer overlayLayer;
|
private MapTileLayer overlayLayer;
|
||||||
private MapTileLayer underlayLayer;
|
private MapTileLayer underlayLayer;
|
||||||
private StateChangedListener<Integer> overlayLayerListener;
|
private StateChangedListener<Integer> overlayLayerListener;
|
||||||
|
|
||||||
public OsmandRasterMapsPlugin(OsmandApplication app) {
|
public OsmandRasterMapsPlugin(OsmandApplication app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
settings = app.getSettings();
|
settings = app.getSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLogoResourceId() {
|
public int getLogoResourceId() {
|
||||||
return R.drawable.ic_world_globe_dark;
|
return R.drawable.ic_world_globe_dark;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAssetResourceName() {
|
public int getAssetResourceName() {
|
||||||
return R.drawable.online_maps;
|
return R.drawable.online_maps;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return ID;
|
return ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return app.getString(R.string.osmand_rastermaps_plugin_description);
|
return app.getString(R.string.osmand_rastermaps_plugin_description);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return app.getString(R.string.shared_string_online_maps);
|
return app.getString(R.string.shared_string_online_maps);
|
||||||
|
@ -102,26 +104,26 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
// mapView.addLayer(overlayLayer, 0.7f);
|
// mapView.addLayer(overlayLayer, 0.7f);
|
||||||
settings.MAP_OVERLAY_TRANSPARENCY.addListener(overlayLayerListener);
|
settings.MAP_OVERLAY_TRANSPARENCY.addListener(overlayLayerListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
|
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
|
||||||
updateMapLayers(mapView, null, activity.getMapLayers());
|
updateMapLayers(mapView, null, activity.getMapLayers());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void updateMapLayers(OsmandMapTileView mapView, CommonPreference<String> settingsToWarnAboutMap,
|
public void updateMapLayers(OsmandMapTileView mapView, CommonPreference<String> settingsToWarnAboutMap,
|
||||||
final MapActivityLayers layers) {
|
final MapActivityLayers layers) {
|
||||||
if(overlayLayer == null) {
|
if (overlayLayer == null) {
|
||||||
createLayers();
|
createLayers();
|
||||||
}
|
}
|
||||||
overlayLayer.setAlpha(settings.MAP_OVERLAY_TRANSPARENCY.get());
|
overlayLayer.setAlpha(settings.MAP_OVERLAY_TRANSPARENCY.get());
|
||||||
if(isActive()) {
|
if (isActive()) {
|
||||||
updateLayer(mapView, settings, overlayLayer, settings.MAP_OVERLAY, 0.7f, settings.MAP_OVERLAY == settingsToWarnAboutMap);
|
updateLayer(mapView, settings, overlayLayer, settings.MAP_OVERLAY, 0.7f, settings.MAP_OVERLAY == settingsToWarnAboutMap);
|
||||||
} else {
|
} else {
|
||||||
mapView.removeLayer(overlayLayer);
|
mapView.removeLayer(overlayLayer);
|
||||||
overlayLayer.setMap(null);
|
overlayLayer.setMap(null);
|
||||||
}
|
}
|
||||||
if(isActive()) {
|
if (isActive()) {
|
||||||
updateLayer(mapView, settings, underlayLayer, settings.MAP_UNDERLAY, -0.5f, settings.MAP_UNDERLAY == settingsToWarnAboutMap);
|
updateLayer(mapView, settings, underlayLayer, settings.MAP_UNDERLAY, -0.5f, settings.MAP_UNDERLAY == settingsToWarnAboutMap);
|
||||||
} else {
|
} else {
|
||||||
mapView.removeLayer(underlayLayer);
|
mapView.removeLayer(underlayLayer);
|
||||||
|
@ -129,12 +131,12 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
}
|
}
|
||||||
layers.updateMapSource(mapView, settingsToWarnAboutMap);
|
layers.updateMapSource(mapView, settingsToWarnAboutMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLayer(OsmandMapTileView mapView, OsmandSettings settings,
|
public void updateLayer(OsmandMapTileView mapView, OsmandSettings settings,
|
||||||
MapTileLayer layer, CommonPreference<String> preference, float layerOrder, boolean warnWhenSelected) {
|
MapTileLayer layer, CommonPreference<String> preference, float layerOrder, boolean warnWhenSelected) {
|
||||||
ITileSource overlay = settings.getTileSourceByName(preference.get(), warnWhenSelected);
|
ITileSource overlay = settings.getTileSourceByName(preference.get(), warnWhenSelected);
|
||||||
if(!Algorithms.objectEquals(overlay, layer.getMap())){
|
if (!Algorithms.objectEquals(overlay, layer.getMap())) {
|
||||||
if(overlay == null){
|
if (overlay == null) {
|
||||||
mapView.removeLayer(layer);
|
mapView.removeLayer(layer);
|
||||||
} else if (mapView.getMapRenderer() == null) {
|
} else if (mapView.getMapRenderer() == null) {
|
||||||
mapView.addLayer(layer, layerOrder);
|
mapView.addLayer(layer, layerOrder);
|
||||||
|
@ -143,10 +145,10 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
mapView.refreshMap();
|
mapView.refreshMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectMapOverlayLayer(final OsmandMapTileView mapView,
|
public void selectMapOverlayLayer(final OsmandMapTileView mapView,
|
||||||
final CommonPreference<String> mapPref,
|
final CommonPreference<String> mapPref,
|
||||||
final MapActivity activity){
|
final MapActivity activity) {
|
||||||
final OsmandSettings settings = app.getSettings();
|
final OsmandSettings settings = app.getSettings();
|
||||||
final MapActivityLayers layers = activity.getMapLayers();
|
final MapActivityLayers layers = activity.getMapLayers();
|
||||||
Map<String, String> entriesMap = settings.getTileSourceEntries();
|
Map<String, String> entriesMap = settings.getTileSourceEntries();
|
||||||
|
@ -154,10 +156,10 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||||
final String[] items = new String[entriesMap.size() + 1];
|
final String[] items = new String[entriesMap.size() + 1];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(String it : entriesMap.values()){
|
for (String it : entriesMap.values()) {
|
||||||
items[i++] = it;
|
items[i++] = it;
|
||||||
}
|
}
|
||||||
|
|
||||||
items[i] = app.getString(R.string.install_more);
|
items[i] = app.getString(R.string.install_more);
|
||||||
builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
|
builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -198,7 +200,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
});
|
});
|
||||||
builder.show();
|
builder.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerLayerContextMenuActions(final OsmandMapTileView mapView,
|
public void registerLayerContextMenuActions(final OsmandMapTileView mapView,
|
||||||
ContextMenuAdapter adapter,
|
ContextMenuAdapter adapter,
|
||||||
|
@ -209,27 +211,27 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||||
if (itemId == R.string.layer_map) {
|
if (itemId == R.string.layer_map) {
|
||||||
layers.selectMapLayer(mapView);
|
layers.selectMapLayer(mapView);
|
||||||
} else if(itemId == R.string.layer_overlay){
|
} else if (itemId == R.string.layer_overlay) {
|
||||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.OVERLAY_MAP);
|
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.OVERLAY_MAP);
|
||||||
return false;
|
return false;
|
||||||
} else if(itemId == R.string.layer_underlay){
|
} else if (itemId == R.string.layer_underlay) {
|
||||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.UNDERLAY_MAP);
|
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.UNDERLAY_MAP);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
adapter.item(R.string.layer_overlay).
|
adapter.item(R.string.layer_overlay).
|
||||||
iconColor(R.drawable.ic_layer_top_dark).listen(listener).position(14).reg();
|
iconColor(R.drawable.ic_layer_top_dark).listen(listener).position(14).reg();
|
||||||
adapter.item(R.string.layer_underlay)
|
adapter.item(R.string.layer_underlay)
|
||||||
.iconColor(R.drawable.ic_layer_bottom_dark).listen(listener).position(15).reg();
|
.iconColor(R.drawable.ic_layer_bottom_dark).listen(listener).position(15).reg();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerMapContextMenuActions(final MapActivity mapActivity, final double latitude, final double longitude, ContextMenuAdapter adapter,
|
public void registerMapContextMenuActions(final MapActivity mapActivity, final double latitude, final double longitude, ContextMenuAdapter adapter,
|
||||||
Object selectedObj) {
|
Object selectedObj) {
|
||||||
final OsmandMapTileView mapView = mapActivity.getMapView();
|
final OsmandMapTileView mapView = mapActivity.getMapView();
|
||||||
if (mapView.getMainLayer() instanceof MapTileLayer) {
|
if (mapView.getMainLayer() instanceof MapTileLayer) {
|
||||||
OnContextMenuClick listener = new OnContextMenuClick() {
|
OnContextMenuClick listener = new OnContextMenuClick() {
|
||||||
|
@ -250,14 +252,13 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
.listen(listener).reg();
|
.listen(listener).reg();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends Activity> getSettingsActivity() {
|
public Class<? extends Activity> getSettingsActivity() {
|
||||||
return SettingsRasterMapsActivity.class;
|
return SettingsRasterMapsActivity.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void installMapLayers(final Activity activity, final ResultMatcher<TileSourceTemplate> result) {
|
public static void installMapLayers(final Activity activity, final ResultMatcher<TileSourceTemplate> result) {
|
||||||
final OsmandApplication app = (OsmandApplication) activity.getApplication();
|
final OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||||
final OsmandSettings settings = app.getSettings();
|
final OsmandSettings settings = app.getSettings();
|
||||||
|
@ -271,6 +272,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
protected List<TileSourceTemplate> doInBackground(Void... params) {
|
protected List<TileSourceTemplate> doInBackground(Void... params) {
|
||||||
return TileSourceManager.downloadTileSourceTemplates(Version.getVersionAsURLParam(app));
|
return TileSourceManager.downloadTileSourceTemplates(Version.getVersionAsURLParam(app));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onPostExecute(final java.util.List<TileSourceTemplate> downloaded) {
|
protected void onPostExecute(final java.util.List<TileSourceTemplate> downloaded) {
|
||||||
if (downloaded == null || downloaded.isEmpty()) {
|
if (downloaded == null || downloaded.isEmpty()) {
|
||||||
AccessibleToast.makeText(activity, R.string.shared_string_io_error, Toast.LENGTH_SHORT).show();
|
AccessibleToast.makeText(activity, R.string.shared_string_io_error, Toast.LENGTH_SHORT).show();
|
||||||
|
@ -327,9 +329,9 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
final OsmandApplication app = (OsmandApplication) activity.getApplication();
|
final OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||||
final OsmandSettings settings = app.getSettings();
|
final OsmandSettings settings = app.getSettings();
|
||||||
final Map<String, String> entriesMap = settings.getTileSourceEntries(false);
|
final Map<String, String> entriesMap = settings.getTileSourceEntries(false);
|
||||||
TileSourceTemplate ts = new TileSourceTemplate("NewMapnik","http://mapnik.osmand.net/{0}/{1}/{2}.png",
|
TileSourceTemplate ts = new TileSourceTemplate("NewMapnik", "http://mapnik.osmand.net/{0}/{1}/{2}.png",
|
||||||
"png", 17, 5, 256, 16, 32000);
|
"png", 17, 5, 256, 16, 32000);
|
||||||
final TileSourceTemplate[] result = new TileSourceTemplate[] { ts };
|
final TileSourceTemplate[] result = new TileSourceTemplate[]{ts};
|
||||||
AlertDialog.Builder bld = new AlertDialog.Builder(activity);
|
AlertDialog.Builder bld = new AlertDialog.Builder(activity);
|
||||||
View view = activity.getLayoutInflater().inflate(R.layout.editing_tile_source, null);
|
View view = activity.getLayoutInflater().inflate(R.layout.editing_tile_source, null);
|
||||||
final EditText name = (EditText) view.findViewById(R.id.Name);
|
final EditText name = (EditText) view.findViewById(R.id.Name);
|
||||||
|
@ -340,14 +342,14 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
final EditText expire = (EditText) view.findViewById(R.id.ExpirationTime);
|
final EditText expire = (EditText) view.findViewById(R.id.ExpirationTime);
|
||||||
final CheckBox elliptic = (CheckBox) view.findViewById(R.id.EllipticMercator);
|
final CheckBox elliptic = (CheckBox) view.findViewById(R.id.EllipticMercator);
|
||||||
updateTileSourceEditView(ts, name, urlToLoad, minZoom, maxZoom, expire, elliptic);
|
updateTileSourceEditView(ts, name, urlToLoad, minZoom, maxZoom, expire, elliptic);
|
||||||
|
|
||||||
final ArrayList<String> templates = new ArrayList<String>(entriesMap.keySet());
|
final ArrayList<String> templates = new ArrayList<String>(entriesMap.keySet());
|
||||||
templates.add(0, "");
|
templates.add(0, "");
|
||||||
|
|
||||||
ArrayAdapter<String> adapter = new ArrayAdapter<String>(view.getContext(),
|
ArrayAdapter<String> adapter = new ArrayAdapter<String>(view.getContext(),
|
||||||
android.R.layout.simple_spinner_item,
|
android.R.layout.simple_spinner_item,
|
||||||
templates
|
templates
|
||||||
);
|
);
|
||||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
existing.setAdapter(adapter);
|
existing.setAdapter(adapter);
|
||||||
existing.setSelection(0);
|
existing.setSelection(0);
|
||||||
|
@ -369,17 +371,17 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
public void onNothingSelected(AdapterView<?> parent) {
|
public void onNothingSelected(AdapterView<?> parent) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
bld.setView(view);
|
bld.setView(view);
|
||||||
bld.setPositiveButton(R.string.shared_string_save, new DialogInterface.OnClickListener() {
|
bld.setPositiveButton(R.string.shared_string_save, new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
TileSourceTemplate r = result[0];
|
TileSourceTemplate r = result[0];
|
||||||
try {
|
try {
|
||||||
r.setName(name.getText().toString());
|
r.setName(name.getText().toString());
|
||||||
r.setExpirationTimeMinutes(expire.getText().length() == 0 ? - 1 :
|
r.setExpirationTimeMinutes(expire.getText().length() == 0 ? -1 :
|
||||||
Integer.parseInt(expire.getText().toString()));
|
Integer.parseInt(expire.getText().toString()));
|
||||||
r.setMinZoom(Integer.parseInt(minZoom.getText().toString()));
|
r.setMinZoom(Integer.parseInt(minZoom.getText().toString()));
|
||||||
r.setMaxZoom(Integer.parseInt(maxZoom.getText().toString()));
|
r.setMaxZoom(Integer.parseInt(maxZoom.getText().toString()));
|
||||||
r.setEllipticYTile(elliptic.isChecked());
|
r.setEllipticYTile(elliptic.isChecked());
|
||||||
|
@ -402,13 +404,13 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void updateTileSourceEditView(TileSourceTemplate ts, EditText name, final EditText urlToLoad, final EditText minZoom,
|
private static void updateTileSourceEditView(TileSourceTemplate ts, EditText name, final EditText urlToLoad, final EditText minZoom,
|
||||||
final EditText maxZoom, EditText expire, final CheckBox elliptic) {
|
final EditText maxZoom, EditText expire, final CheckBox elliptic) {
|
||||||
minZoom.setText(ts.getMinimumZoomSupported()+"");
|
minZoom.setText(ts.getMinimumZoomSupported() + "");
|
||||||
maxZoom.setText(ts.getMaximumZoomSupported()+"");
|
maxZoom.setText(ts.getMaximumZoomSupported() + "");
|
||||||
name.setText(ts.getName());
|
name.setText(ts.getName());
|
||||||
expire.setText(ts.getExpirationTimeMinutes() < 0 ? "" : ts.getExpirationTimeMinutes() + "");
|
expire.setText(ts.getExpirationTimeMinutes() < 0 ? "" : ts.getExpirationTimeMinutes() + "");
|
||||||
urlToLoad.setText(ts.getUrlTemplate() == null? "" :
|
urlToLoad.setText(ts.getUrlTemplate() == null ? "" :
|
||||||
ts.getUrlTemplate().replace("{$x}", "{1}").replace("{$y}", "{2}").replace("{$z}", "{0}"));
|
ts.getUrlTemplate().replace("{$x}", "{1}").replace("{$y}", "{2}").replace("{$z}", "{0}"));
|
||||||
elliptic.setChecked(ts.isEllipticYTile());
|
elliptic.setChecked(ts.isEllipticYTile());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue