Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-02-09 09:44:38 +01:00
commit eced60bed9
7 changed files with 208 additions and 190 deletions

View file

@ -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"

View file

@ -20,7 +20,7 @@
tools:text="Germany"/>
<TextView
android:id="@+id/subtitle"
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"

View file

@ -5,6 +5,7 @@ import android.content.Context;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.StringRes;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
@ -195,7 +196,7 @@ public class ContextMenuAdapter {
}
public Item item(int resId) {
public Item item(@StringRes int resId) {
Item i = new Item();
i.id = resId;
i.name = ctx.getString(resId);
@ -351,6 +352,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 +447,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

View file

@ -91,12 +91,12 @@ public class MapActivityLayers {
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();
@ -171,12 +171,12 @@ public class MapActivityLayers {
}
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);
@ -185,7 +185,7 @@ 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
@ -205,7 +205,7 @@ public class MapActivityLayers {
boolean vectorData = !settings.MAP_ONLINE_DATA.get();
mapTileLayer.setVisible(!vectorData);
mapVectorLayer.setVisible(vectorData);
if(vectorData){
if (vectorData) {
mapView.setMainLayer(mapVectorLayer);
} else {
mapView.setMainLayer(mapTileLayer);
@ -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);
@ -266,12 +266,12 @@ public class MapActivityLayers {
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,7 +283,7 @@ 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;
}
}
@ -305,8 +305,8 @@ 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;
}
@ -355,7 +355,7 @@ public class MapActivityLayers {
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();
@ -383,10 +383,11 @@ public class MapActivityLayers {
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,7 +395,7 @@ public class MapActivityLayers {
selectMapLayer(mapView);
}
} else {
count ++;
count++;
template = object;
}
return false;

View file

@ -1,5 +1,6 @@
package net.osmand.plus.dialogs;
import android.support.annotation.StringRes;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
@ -33,13 +34,23 @@ public class RasterMapMenu {
final OsmandRasterMapsPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class);
final MapTileLayer rasterMapLayer;
final OsmandSettings.CommonPreference<Integer> mapTransparencyPreference;
final OsmandSettings.CommonPreference<String> 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<Boolean> 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();
}
}

View file

@ -70,10 +70,12 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
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);
@ -111,17 +113,17 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
public void updateMapLayers(OsmandMapTileView mapView, CommonPreference<String> settingsToWarnAboutMap,
final MapActivityLayers layers) {
if(overlayLayer == null) {
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);
@ -133,8 +135,8 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
public void updateLayer(OsmandMapTileView mapView, OsmandSettings settings,
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);
@ -146,7 +148,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
public void selectMapOverlayLayer(final OsmandMapTileView mapView,
final CommonPreference<String> mapPref,
final MapActivity activity){
final MapActivity activity) {
final OsmandSettings settings = app.getSettings();
final MapActivityLayers layers = activity.getMapLayers();
Map<String, String> entriesMap = settings.getTileSourceEntries();
@ -154,7 +156,7 @@ 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;
}
@ -209,10 +211,10 @@ 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;
}
@ -257,7 +259,6 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
}
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);
@ -378,7 +380,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
TileSourceTemplate r = result[0];
try {
r.setName(name.getText().toString());
r.setExpirationTimeMinutes(expire.getText().length() == 0 ? - 1 :
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()));
@ -403,11 +405,11 @@ 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()+"");
minZoom.setText(ts.getMinimumZoomSupported() + "");
maxZoom.setText(ts.getMaximumZoomSupported() + "");
name.setText(ts.getName());
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}"));
elliptic.setChecked(ts.isEllipticYTile());
}