Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
08d5f504eb
15 changed files with 185 additions and 43 deletions
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<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:
|
||||
X.X.X#YYYYZ , where
|
||||
|
|
|
@ -163,6 +163,9 @@ public abstract class OsmandPlugin {
|
|||
plugin.setActive(false);
|
||||
}
|
||||
app.getSettings().enablePlugin(plugin.getId(), enable);
|
||||
if(activity instanceof MapActivity) {
|
||||
plugin.updateLayers(((MapActivity) activity).getMapView(), (MapActivity) activity);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -209,7 +212,7 @@ public abstract class OsmandPlugin {
|
|||
}
|
||||
|
||||
public static void refreshLayers(OsmandMapTileView mapView, MapActivity activity) {
|
||||
for (OsmandPlugin plugin : getEnabledPlugins()) {
|
||||
for (OsmandPlugin plugin : getAvailablePlugins()) {
|
||||
plugin.updateLayers(mapView, activity);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) + ")");
|
||||
}
|
||||
|
||||
registerListPreference(settings.MAP_PREFERRED_LOCALE, screen, ConfigureMapMenu.mapNamesIds, ConfigureMapMenu.getMapNamesValues(this));
|
||||
registerListPreference(settings.MAP_PREFERRED_LOCALE, screen, ConfigureMapMenu.getMapNamesValues(this), ConfigureMapMenu.mapNamesIds);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -443,8 +443,10 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
}
|
||||
audioNotesLayer = new AudioNotesLayer(activity, this);
|
||||
activity.getMapView().addLayer(audioNotesLayer, 3.5f);
|
||||
if(recordControl == null) {
|
||||
registerWidget(activity);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerMediaListener(AudioManager am) {
|
||||
|
||||
|
@ -521,6 +523,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
|
||||
@Override
|
||||
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
|
||||
if (isActive()) {
|
||||
if (SHOW_RECORDINGS.get()) {
|
||||
if (audioNotesLayer == null) {
|
||||
registerLayers(activity);
|
||||
|
@ -530,6 +533,21 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
} 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void registerWidget(MapActivity activity) {
|
||||
|
|
|
@ -94,7 +94,6 @@ public class DashPluginsFragment extends DashBaseFragment {
|
|||
public void onOpenDash() {
|
||||
View contentView = getView();
|
||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
initPlugins();
|
||||
LinearLayout pluginsContainer = (LinearLayout) contentView.findViewById(R.id.items);
|
||||
pluginsContainer.removeAllViews();
|
||||
for (OsmandPlugin p : plugins) {
|
||||
|
|
|
@ -48,11 +48,25 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin {
|
|||
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) {
|
||||
MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
|
||||
final OsmandMapTileView mv = activity.getMapView();
|
||||
if (mapInfoLayer != null) {
|
||||
if (mapInfoLayer != null && fps == null) {
|
||||
fps = new TextInfoWidget(activity) {
|
||||
@Override
|
||||
public boolean updateInfo(DrawSettings drawSettings) {
|
||||
|
|
|
@ -101,6 +101,26 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
|||
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
|
||||
public void registerLayers(MapActivity activity) {
|
||||
// remove old if existing
|
||||
|
@ -115,7 +135,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
|
|||
|
||||
private void registerWidget(MapActivity activity) {
|
||||
MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
|
||||
if (mapInfoLayer != null ) {
|
||||
if (mapInfoLayer != null && distanceControl == null ) {
|
||||
distanceControl = createDistanceControl(activity);
|
||||
mapInfoLayer.registerSideWidget(distanceControl,
|
||||
R.drawable.ic_action_ruler_dark, R.string.map_widget_distancemeasurement, "distance.measurement", false, 21);
|
||||
|
|
|
@ -18,7 +18,6 @@ import net.osmand.plus.OsmandSettings;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SavingTrackHelper;
|
||||
import net.osmand.plus.osmo.OsMoGroupsActivity;
|
||||
import net.osmand.plus.views.MapInfoLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
|
@ -105,9 +104,18 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
|
||||
@Override
|
||||
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
|
||||
if(monitoringControl == null) {
|
||||
if (isActive()) {
|
||||
if (monitoringControl == null) {
|
||||
registerLayers(activity);
|
||||
}
|
||||
} else {
|
||||
if (monitoringControl != null) {
|
||||
MapInfoLayer layer = activity.getMapLayers().getMapInfoLayer();
|
||||
layer.removeSideWidget(monitoringControl);
|
||||
layer.recreateControls();
|
||||
monitoringControl = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -76,24 +76,35 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
private EditingPOIDialogProvider poiActions;
|
||||
|
||||
@Override
|
||||
public void updateLayers(OsmandMapTileView mapView, MapActivity activity){
|
||||
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
|
||||
if (isActive()) {
|
||||
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)) {
|
||||
activity.getMapView().addLayer(osmEditsLayer, 3.5f);
|
||||
}
|
||||
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);
|
||||
}
|
||||
if(osmEditsLayer != null) {
|
||||
mapView.removeLayer(osmEditsLayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerLayers(MapActivity activity){
|
||||
osmBugsLayer = new OsmBugsLayer(activity, this);
|
||||
osmEditsLayer = new OsmEditsLayer(activity, this);
|
||||
activity.getMapView().addLayer(osmEditsLayer, 3.5f);
|
||||
}
|
||||
|
||||
public OsmEditsLayer getOsmEditsLayer(MapActivity activity){
|
||||
|
|
|
@ -17,7 +17,6 @@ import net.osmand.plus.ContextMenuAdapter;
|
|||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.Track;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
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.views.MapInfoLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
|
@ -39,7 +39,6 @@ import org.json.JSONObject;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
@ -170,14 +169,29 @@ public class OsMoPlugin extends OsmandPlugin implements OsMoReactor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void registerLayers(MapActivity activity) {
|
||||
super.registerLayers(activity);
|
||||
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
|
||||
if(isActive()) {
|
||||
if(olayer == null) {
|
||||
registerLayers(activity);
|
||||
}
|
||||
registerSideWidget(activity);
|
||||
} else {
|
||||
MapInfoLayer layer = activity.getMapLayers().getMapInfoLayer();
|
||||
osmoControl = createOsMoControl(activity);
|
||||
layer.registerSideWidget(osmoControl,
|
||||
R.drawable.ic_osmo_dark, R.string.osmo_control, "osmo_control", false, 18);
|
||||
if (layer != null && osmoControl != null) {
|
||||
layer.removeSideWidget(osmoControl);
|
||||
osmoControl = null;
|
||||
layer.recreateControls();
|
||||
}
|
||||
if(olayer != null) {
|
||||
activity.getMapView().removeLayer(olayer);
|
||||
olayer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerLayers(MapActivity activity) {
|
||||
registerSideWidget(activity);
|
||||
if(olayer != null) {
|
||||
activity.getMapView().removeLayer(olayer);
|
||||
}
|
||||
|
@ -185,6 +199,16 @@ public class OsMoPlugin extends OsmandPlugin implements OsMoReactor {
|
|||
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
|
||||
public void mapActivityPause(MapActivity activity) {
|
||||
groups.addUiListeners(olayer);
|
||||
|
|
|
@ -178,12 +178,25 @@ public class ParkingPositionPlugin extends OsmandPlugin {
|
|||
|
||||
@Override
|
||||
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
|
||||
if (isActive()) {
|
||||
if (parkingLayer == null) {
|
||||
registerLayers(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void registerWidget(MapActivity activity) {
|
||||
|
|
|
@ -110,8 +110,18 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
createLayers();
|
||||
}
|
||||
overlayLayer.setAlpha(settings.MAP_OVERLAY_TRANSPARENCY.get());
|
||||
if(isActive()) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ public class SRTMPlugin extends OsmandPlugin {
|
|||
|
||||
@Override
|
||||
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
|
||||
if (HILLSHADE.get()) {
|
||||
if (HILLSHADE.get() && isActive()) {
|
||||
if (hillshadeLayer == null) {
|
||||
registerLayers(activity);
|
||||
}
|
||||
|
|
|
@ -82,6 +82,10 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
updateReg(calculateTextState(), reg);
|
||||
}
|
||||
|
||||
public void removeSideWidget(TextInfoWidget widget) {
|
||||
mapInfoControls.removeSideWidgetInternal(widget);
|
||||
}
|
||||
|
||||
public void registerAllControls(){
|
||||
RouteInfoWidgetsFactory ric = new RouteInfoWidgetsFactory();
|
||||
MapInfoWidgetsFactory mic = new MapInfoWidgetsFactory();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.osmand.plus.views.mapwidgets;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
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,
|
||||
int messageId, String key, boolean left, int priorityOrder) {
|
||||
MapWidgetRegInfo ii = new MapWidgetRegInfo(key, widget, drawableMenu,
|
||||
|
|
Loading…
Reference in a new issue