Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-07-04 16:14:17 +02:00
commit 08d5f504eb
15 changed files with 185 additions and 43 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?> <?xml version="1.0" encoding="utf-8" standalone="no"?>
<resources xmlns:tools="http://schemas.android.com/tools"> <resources xmlns:tools="http://schemas.android.com/tools">
<string name="app_name">OsmAnd~</string> <string name="app_name">OsmAnd~</string>
<string name="app_version">2.1.0</string> <string name="app_version">2.2.0</string>
<!-- <!--
Note: For our dev build apk's, the above "app_version" is provided (via osmand/build.xml) as the base version prefix to our build number in the format: Note: For our dev build apk's, the above "app_version" is provided (via osmand/build.xml) as the base version prefix to our build number in the format:
X.X.X#YYYYZ , where X.X.X#YYYYZ , where

View file

@ -163,6 +163,9 @@ public abstract class OsmandPlugin {
plugin.setActive(false); plugin.setActive(false);
} }
app.getSettings().enablePlugin(plugin.getId(), enable); app.getSettings().enablePlugin(plugin.getId(), enable);
if(activity instanceof MapActivity) {
plugin.updateLayers(((MapActivity) activity).getMapView(), (MapActivity) activity);
}
return true; return true;
} }
@ -209,7 +212,7 @@ public abstract class OsmandPlugin {
} }
public static void refreshLayers(OsmandMapTileView mapView, MapActivity activity) { public static void refreshLayers(OsmandMapTileView mapView, MapActivity activity) {
for (OsmandPlugin plugin : getEnabledPlugins()) { for (OsmandPlugin plugin : getAvailablePlugins()) {
plugin.updateLayers(mapView, activity); plugin.updateLayers(mapView, activity);
} }
} }

View file

@ -258,7 +258,7 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
((ListPreference) screen.findPreference(settings.PREFERRED_LOCALE.getId())).setTitle(getString(R.string.preferred_locale) + " (" + getString(R.string.preferred_locale_no_translate) + ")"); ((ListPreference) screen.findPreference(settings.PREFERRED_LOCALE.getId())).setTitle(getString(R.string.preferred_locale) + " (" + getString(R.string.preferred_locale_no_translate) + ")");
} }
registerListPreference(settings.MAP_PREFERRED_LOCALE, screen, ConfigureMapMenu.mapNamesIds, ConfigureMapMenu.getMapNamesValues(this)); registerListPreference(settings.MAP_PREFERRED_LOCALE, screen, ConfigureMapMenu.getMapNamesValues(this), ConfigureMapMenu.mapNamesIds);
} }

View file

@ -443,7 +443,9 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
} }
audioNotesLayer = new AudioNotesLayer(activity, this); audioNotesLayer = new AudioNotesLayer(activity, this);
activity.getMapView().addLayer(audioNotesLayer, 3.5f); activity.getMapView().addLayer(audioNotesLayer, 3.5f);
registerWidget(activity); if(recordControl == null) {
registerWidget(activity);
}
} }
private void registerMediaListener(AudioManager am) { private void registerMediaListener(AudioManager am) {
@ -521,14 +523,30 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
@Override @Override
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) { public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
if (SHOW_RECORDINGS.get()) { if (isActive()) {
if (audioNotesLayer == null) { if (SHOW_RECORDINGS.get()) {
registerLayers(activity); if (audioNotesLayer == null) {
} else if (!mapView.getLayers().contains(audioNotesLayer)) { registerLayers(activity);
mapView.addLayer(audioNotesLayer, 3.5f); } else if (!mapView.getLayers().contains(audioNotesLayer)) {
mapView.addLayer(audioNotesLayer, 3.5f);
}
} else if (audioNotesLayer != null) {
mapView.removeLayer(audioNotesLayer);
}
if(recordControl == null) {
registerWidget(activity);
}
} else {
if (audioNotesLayer != null) {
mapView.removeLayer(audioNotesLayer);
audioNotesLayer = null;
}
MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
if(recordControl != null && mapInfoLayer != null) {
mapInfoLayer.removeSideWidget(recordControl);
recordControl = null;
mapInfoLayer.recreateControls();
} }
} else if (audioNotesLayer != null) {
mapView.removeLayer(audioNotesLayer);
} }
} }

View file

@ -94,7 +94,6 @@ public class DashPluginsFragment extends DashBaseFragment {
public void onOpenDash() { public void onOpenDash() {
View contentView = getView(); View contentView = getView();
LayoutInflater inflater = getActivity().getLayoutInflater(); LayoutInflater inflater = getActivity().getLayoutInflater();
initPlugins();
LinearLayout pluginsContainer = (LinearLayout) contentView.findViewById(R.id.items); LinearLayout pluginsContainer = (LinearLayout) contentView.findViewById(R.id.items);
pluginsContainer.removeAllViews(); pluginsContainer.removeAllViews();
for (OsmandPlugin p : plugins) { for (OsmandPlugin p : plugins) {

View file

@ -47,12 +47,26 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin {
public void registerLayers(MapActivity activity) { public void registerLayers(MapActivity activity) {
registerWidget(activity); registerWidget(activity);
} }
@Override
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
if(isActive()) {
registerWidget(activity);
} else {
MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
if (mapInfoLayer != null && fps != null) {
mapInfoLayer.removeSideWidget(fps);
mapInfoLayer.recreateControls();
fps = null;
}
}
}
private void registerWidget(MapActivity activity) { private void registerWidget(MapActivity activity) {
MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer(); MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
final OsmandMapTileView mv = activity.getMapView(); final OsmandMapTileView mv = activity.getMapView();
if (mapInfoLayer != null) { if (mapInfoLayer != null && fps == null) {
fps = new TextInfoWidget(activity) { fps = new TextInfoWidget(activity) {
@Override @Override
public boolean updateInfo(DrawSettings drawSettings) { public boolean updateInfo(DrawSettings drawSettings) {

View file

@ -100,6 +100,26 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
public boolean init(OsmandApplication app, Activity activity) { public boolean init(OsmandApplication app, Activity activity) {
return true; return true;
} }
@Override
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
if(isActive()) {
if(!mapView.isLayerVisible(distanceCalculatorLayer)) {
activity.getMapView().addLayer(distanceCalculatorLayer, 4.5f);
}
registerWidget(activity);
} else {
MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
if(distanceCalculatorLayer != null) {
activity.getMapView().removeLayer(distanceCalculatorLayer);
}
if (mapInfoLayer != null && distanceControl != null ) {
mapInfoLayer.removeSideWidget(distanceControl);
mapInfoLayer.recreateControls();
distanceControl = null;
}
}
}
@Override @Override
public void registerLayers(MapActivity activity) { public void registerLayers(MapActivity activity) {
@ -115,7 +135,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
private void registerWidget(MapActivity activity) { private void registerWidget(MapActivity activity) {
MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer(); MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
if (mapInfoLayer != null ) { if (mapInfoLayer != null && distanceControl == null ) {
distanceControl = createDistanceControl(activity); distanceControl = createDistanceControl(activity);
mapInfoLayer.registerSideWidget(distanceControl, mapInfoLayer.registerSideWidget(distanceControl,
R.drawable.ic_action_ruler_dark, R.string.map_widget_distancemeasurement, "distance.measurement", false, 21); R.drawable.ic_action_ruler_dark, R.string.map_widget_distancemeasurement, "distance.measurement", false, 21);

View file

@ -18,7 +18,6 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.osmo.OsMoGroupsActivity;
import net.osmand.plus.views.MapInfoLayer; import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings; import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
@ -105,8 +104,17 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
@Override @Override
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) { public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
if(monitoringControl == null) { if (isActive()) {
registerLayers(activity); if (monitoringControl == null) {
registerLayers(activity);
}
} else {
if (monitoringControl != null) {
MapInfoLayer layer = activity.getMapLayers().getMapInfoLayer();
layer.removeSideWidget(monitoringControl);
layer.recreateControls();
monitoringControl = null;
}
} }
} }

View file

@ -76,16 +76,28 @@ public class OsmEditingPlugin extends OsmandPlugin {
private EditingPOIDialogProvider poiActions; private EditingPOIDialogProvider poiActions;
@Override @Override
public void updateLayers(OsmandMapTileView mapView, MapActivity activity){ public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
if (osmBugsLayer == null) { if (isActive()) {
registerLayers(activity); if (osmBugsLayer == null) {
} registerLayers(activity);
if(mapView.getLayers().contains(osmBugsLayer) != settings.SHOW_OSM_BUGS.get()){ }
if(settings.SHOW_OSM_BUGS.get()){ if (!mapView.getLayers().contains(osmEditsLayer)) {
mapView.addLayer(osmBugsLayer, 2); activity.getMapView().addLayer(osmEditsLayer, 3.5f);
} else { }
if (mapView.getLayers().contains(osmBugsLayer) != settings.SHOW_OSM_BUGS.get()) {
if (settings.SHOW_OSM_BUGS.get()) {
mapView.addLayer(osmBugsLayer, 2);
} else {
mapView.removeLayer(osmBugsLayer);
}
}
} else {
if(osmBugsLayer != null) {
mapView.removeLayer(osmBugsLayer); mapView.removeLayer(osmBugsLayer);
} }
if(osmEditsLayer != null) {
mapView.removeLayer(osmEditsLayer);
}
} }
} }
@ -93,7 +105,6 @@ public class OsmEditingPlugin extends OsmandPlugin {
public void registerLayers(MapActivity activity){ public void registerLayers(MapActivity activity){
osmBugsLayer = new OsmBugsLayer(activity, this); osmBugsLayer = new OsmBugsLayer(activity, this);
osmEditsLayer = new OsmEditsLayer(activity, this); osmEditsLayer = new OsmEditsLayer(activity, this);
activity.getMapView().addLayer(osmEditsLayer, 3.5f);
} }
public OsmEditsLayer getOsmEditsLayer(MapActivity activity){ public OsmEditsLayer getOsmEditsLayer(MapActivity activity){

View file

@ -17,7 +17,6 @@ import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick; import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.GPXUtilities; import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile; import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.Track;
import net.osmand.plus.GPXUtilities.WptPt; import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
@ -30,6 +29,7 @@ import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoDevice;
import net.osmand.plus.osmo.OsMoService.SessionInfo; import net.osmand.plus.osmo.OsMoService.SessionInfo;
import net.osmand.plus.views.MapInfoLayer; import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings; import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.mapwidgets.TextInfoWidget; import net.osmand.plus.views.mapwidgets.TextInfoWidget;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -39,7 +39,6 @@ import org.json.JSONObject;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.view.View; import android.view.View;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
@ -169,21 +168,46 @@ public class OsMoPlugin extends OsmandPlugin implements OsMoReactor {
super.registerMapContextMenuActions(mapActivity, latitude, longitude, adapter, selectedObj); super.registerMapContextMenuActions(mapActivity, latitude, longitude, adapter, selectedObj);
} }
@Override
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
if(isActive()) {
if(olayer == null) {
registerLayers(activity);
}
registerSideWidget(activity);
} else {
MapInfoLayer layer = activity.getMapLayers().getMapInfoLayer();
if (layer != null && osmoControl != null) {
layer.removeSideWidget(osmoControl);
osmoControl = null;
layer.recreateControls();
}
if(olayer != null) {
activity.getMapView().removeLayer(olayer);
olayer = null;
}
}
}
@Override @Override
public void registerLayers(MapActivity activity) { public void registerLayers(MapActivity activity) {
super.registerLayers(activity); registerSideWidget(activity);
MapInfoLayer layer = activity.getMapLayers().getMapInfoLayer();
osmoControl = createOsMoControl(activity);
layer.registerSideWidget(osmoControl,
R.drawable.ic_osmo_dark, R.string.osmo_control, "osmo_control", false, 18);
layer.recreateControls();
if(olayer != null) { if(olayer != null) {
activity.getMapView().removeLayer(olayer); activity.getMapView().removeLayer(olayer);
} }
olayer = new OsMoPositionLayer(activity, this); olayer = new OsMoPositionLayer(activity, this);
activity.getMapView().addLayer(olayer, 5.5f); activity.getMapView().addLayer(olayer, 5.5f);
} }
private void registerSideWidget(MapActivity activity) {
MapInfoLayer layer = activity.getMapLayers().getMapInfoLayer();
if (layer != null && osmoControl == null) {
osmoControl = createOsMoControl(activity);
layer.registerSideWidget(osmoControl, R.drawable.ic_osmo_dark, R.string.osmo_control, "osmo_control",
false, 18);
layer.recreateControls();
}
}
@Override @Override
public void mapActivityPause(MapActivity activity) { public void mapActivityPause(MapActivity activity) {

View file

@ -178,11 +178,24 @@ public class ParkingPositionPlugin extends OsmandPlugin {
@Override @Override
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) { public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
if (parkingLayer == null) { if (isActive()) {
registerLayers(activity); if (parkingLayer == null) {
} registerLayers(activity);
if (parkingPlaceControl == null) { }
registerWidget(activity); if (parkingPlaceControl == null) {
registerWidget(activity);
}
} else {
if (parkingLayer != null) {
activity.getMapView().removeLayer(parkingLayer);
parkingLayer = null;
}
MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
if (mapInfoLayer != null && parkingPlaceControl != null) {
mapInfoLayer.removeSideWidget(parkingPlaceControl);
mapInfoLayer.recreateControls();
parkingPlaceControl = null;
}
} }
} }

View file

@ -110,8 +110,18 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
createLayers(); createLayers();
} }
overlayLayer.setAlpha(settings.MAP_OVERLAY_TRANSPARENCY.get()); overlayLayer.setAlpha(settings.MAP_OVERLAY_TRANSPARENCY.get());
updateLayer(mapView, settings, overlayLayer, settings.MAP_OVERLAY, 0.7f, settings.MAP_OVERLAY == settingsToWarnAboutMap); if(isActive()) {
updateLayer(mapView, settings, underlayLayer, settings.MAP_UNDERLAY, -0.5f, settings.MAP_UNDERLAY == settingsToWarnAboutMap); updateLayer(mapView, settings, overlayLayer, settings.MAP_OVERLAY, 0.7f, settings.MAP_OVERLAY == settingsToWarnAboutMap);
} else {
mapView.removeLayer(overlayLayer);
overlayLayer.setMap(null);
}
if(isActive()) {
updateLayer(mapView, settings, underlayLayer, settings.MAP_UNDERLAY, -0.5f, settings.MAP_UNDERLAY == settingsToWarnAboutMap);
} else {
mapView.removeLayer(underlayLayer);
underlayLayer.setMap(null);
}
layers.updateMapSource(mapView, settingsToWarnAboutMap); layers.updateMapSource(mapView, settingsToWarnAboutMap);
} }

View file

@ -84,7 +84,7 @@ public class SRTMPlugin extends OsmandPlugin {
@Override @Override
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) { public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
if (HILLSHADE.get()) { if (HILLSHADE.get() && isActive()) {
if (hillshadeLayer == null) { if (hillshadeLayer == null) {
registerLayers(activity); registerLayers(activity);
} }

View file

@ -82,6 +82,10 @@ public class MapInfoLayer extends OsmandMapLayer {
updateReg(calculateTextState(), reg); updateReg(calculateTextState(), reg);
} }
public void removeSideWidget(TextInfoWidget widget) {
mapInfoControls.removeSideWidgetInternal(widget);
}
public void registerAllControls(){ public void registerAllControls(){
RouteInfoWidgetsFactory ric = new RouteInfoWidgetsFactory(); RouteInfoWidgetsFactory ric = new RouteInfoWidgetsFactory();
MapInfoWidgetsFactory mic = new MapInfoWidgetsFactory(); MapInfoWidgetsFactory mic = new MapInfoWidgetsFactory();

View file

@ -1,6 +1,7 @@
package net.osmand.plus.views.mapwidgets; package net.osmand.plus.views.mapwidgets;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Map; import java.util.Map;
@ -89,6 +90,23 @@ public class MapWidgetRegistry {
} }
} }
} }
public void removeSideWidgetInternal(TextInfoWidget widget) {
Iterator<MapWidgetRegInfo> it = left.iterator();
while (it.hasNext()) {
if (it.next().widget == widget) {
it.remove();
}
}
it = right.iterator();
while (it.hasNext()) {
if (it.next().widget == widget) {
it.remove();
}
}
}
public MapWidgetRegInfo registerSideWidgetInternal(TextInfoWidget widget, int drawableMenu, public MapWidgetRegInfo registerSideWidgetInternal(TextInfoWidget widget, int drawableMenu,
int messageId, String key, boolean left, int priorityOrder) { int messageId, String key, boolean left, int priorityOrder) {
MapWidgetRegInfo ii = new MapWidgetRegInfo(key, widget, drawableMenu, MapWidgetRegInfo ii = new MapWidgetRegInfo(key, widget, drawableMenu,