From 64bc77eb1d7adf814cc84ccaaaa7ee41b403aa58 Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Mon, 8 Feb 2016 17:19:52 +0200 Subject: [PATCH 1/2] Fixed formatting --- OsmAnd/res/layout/map_hud_bottom.xml | 1 + .../net/osmand/plus/ContextMenuAdapter.java | 9 +- .../plus/activities/MapActivityLayers.java | 127 ++++++++-------- .../osmand/plus/dashboard/DashboardOnMap.java | 138 +++++++++--------- .../rastermaps/OsmandRasterMapsPlugin.java | 98 +++++++------ 5 files changed, 189 insertions(+), 184 deletions(-) diff --git a/OsmAnd/res/layout/map_hud_bottom.xml b/OsmAnd/res/layout/map_hud_bottom.xml index 6088fe7e4c..bc91ccae1a 100644 --- a/OsmAnd/res/layout/map_hud_bottom.xml +++ b/OsmAnd/res/layout/map_hud_bottom.xml @@ -196,6 +196,7 @@ android:layout_height="wrap_content"> + () { @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 settingsToWarnAboutMap){ + + public void updateMapSource(OsmandMapTileView mapView, CommonPreference 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 files, final OsmandMapTileView mapView) { final OsmandSettings settings = getApplication().getSettings(); CallbackWithObject callbackWithObject = new CallbackWithObject() { @@ -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 entriesMap = new LinkedHashMap(); - - + + 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> entriesMapList = new ArrayList>(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 selectedEntry = null; for (Entry 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 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 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; } diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index 8c2b27749f..4a82ed6d8f 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -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 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 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)) { diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java index a03ef5216d..f5b3880db8 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java @@ -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 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 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 preference, float layerOrder, boolean warnWhenSelected) { + MapTileLayer layer, CommonPreference 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 mapPref, - final MapActivity activity){ + + public void selectMapOverlayLayer(final OsmandMapTileView mapView, + final CommonPreference mapPref, + final MapActivity activity) { final OsmandSettings settings = app.getSettings(); final MapActivityLayers layers = activity.getMapLayers(); Map 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 getSettingsActivity() { return SettingsRasterMapsActivity.class; } - - + public static void installMapLayers(final Activity activity, final ResultMatcher result) { final OsmandApplication app = (OsmandApplication) activity.getApplication(); final OsmandSettings settings = app.getSettings(); @@ -271,6 +272,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { protected List doInBackground(Void... params) { return TileSourceManager.downloadTileSourceTemplates(Version.getVersionAsURLParam(app)); } + protected void onPostExecute(final java.util.List 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 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 templates = new ArrayList(entriesMap.keySet()); templates.add(0, ""); - - ArrayAdapter adapter = new ArrayAdapter(view.getContext(), - android.R.layout.simple_spinner_item, + + ArrayAdapter adapter = new ArrayAdapter(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()); } From 8c8fce31098afbec9f6fbf6b3e83d3f4341ae6aa Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Mon, 8 Feb 2016 18:37:01 +0200 Subject: [PATCH 2/2] Displaying map name --- OsmAnd/res/layout/two_line_list_item.xml | 2 +- .../net/osmand/plus/ContextMenuAdapter.java | 3 ++- .../osmand/plus/dialogs/RasterMapMenu.java | 20 +++++++++++++++---- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/OsmAnd/res/layout/two_line_list_item.xml b/OsmAnd/res/layout/two_line_list_item.xml index 57edd96cce..e944fd9bc6 100644 --- a/OsmAnd/res/layout/two_line_list_item.xml +++ b/OsmAnd/res/layout/two_line_list_item.xml @@ -20,7 +20,7 @@ tools:text="Germany"/> mapTransparencyPreference; + final OsmandSettings.CommonPreference mapTypePreference; + @StringRes final int mapTypeString; if (type == OsmandRasterMapsPlugin.RasterMapType.OVERLAY) { rasterMapLayer = plugin.getOverlayLayer(); mapTransparencyPreference = settings.MAP_OVERLAY_TRANSPARENCY; - } else { + mapTypePreference = settings.MAP_OVERLAY; + mapTypeString = R.string.map_overlay; + } else if (type == OsmandRasterMapsPlugin.RasterMapType.UNDERLAY){ rasterMapLayer = plugin.getUnderlayLayer(); mapTransparencyPreference = settings.MAP_TRANSPARENCY; + mapTypePreference = settings.MAP_UNDERLAY; + mapTypeString = R.string.map_underlay; + } else { + throw new RuntimeException("Unexpected raster map type"); } + final OsmandSettings.CommonPreference hidePolygonsPref = + mapActivity.getMyApplication().getSettings().getCustomRenderBooleanProperty("noPolygons"); ContextMenuAdapter.OnRowItemClick l = new ContextMenuAdapter.OnRowItemClick() { @Override public boolean onRowItemClick(ArrayAdapter adapter, View view, int itemId, int pos) { @@ -58,6 +69,8 @@ public class RasterMapMenu { mapLayers.getMapControlsLayer().hideTransparencyBar(mapTransparencyPreference); } plugin.toggleUnderlayState(mapActivity, type); + } else if (itemId == R.string.show_polygons) { + hidePolygonsPref.set(!isChecked); } return false; } @@ -74,11 +87,10 @@ public class RasterMapMenu { } }; // android:max="255" in layout is expected - //adapter.item(R.string.underlay_transparency).layout(R.layout.progress_list_item) // Please note this does not modify the transparency of the underlay map, but of the base map, of course! adapter.item(R.string.map_transparency).layout(R.layout.progress_list_item) .progress(mapTransparencyPreference.get()).listenInteger(integerListener).reg(); - adapter.item(R.string.map_underlay).layout(R.layout.two_line_list_item).listen(l).reg(); - adapter.item(R.string.show_polygons).listen(l).reg(); + adapter.item(mapTypeString).layout(R.layout.two_line_list_item).description(mapTypePreference.get()).reg(); + adapter.item(R.string.show_polygons).listen(l).selected(hidePolygonsPref.get() ? 0 : 1).reg(); } }