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