Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
c5f412d9b5
4 changed files with 66 additions and 103 deletions
|
@ -251,7 +251,9 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
|
|||
&& !app.getRoutingHelper().isRouteBeingCalculated()) {
|
||||
FailSafeFuntions.restoreRoutingMode(this);
|
||||
} else if (app.getSettings().USE_MAP_MARKERS.get()
|
||||
&& !app.getRoutingHelper().isRoutePlanningMode() && app.getTargetPointsHelper().getAllPoints().size() > 0) {
|
||||
&& !app.getRoutingHelper().isRoutePlanningMode()
|
||||
&& !settings.FOLLOW_THE_ROUTE.get()
|
||||
&& app.getTargetPointsHelper().getAllPoints().size() > 0) {
|
||||
app.getRoutingHelper().clearCurrentRoute(null, new ArrayList<LatLon>());
|
||||
app.getTargetPointsHelper().removeAllWayPoints(false);
|
||||
}
|
||||
|
|
|
@ -124,9 +124,9 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
registerSideWidget(time, R.drawable.ic_action_time, R.string.map_widget_time, "time", false, 10);
|
||||
|
||||
if (settings.USE_MAP_MARKERS.get()) {
|
||||
TextInfoWidget marker = mwf.createMapMarkerControl(map);
|
||||
TextInfoWidget marker = mwf.createMapMarkerControl(map, true);
|
||||
registerSideWidget(marker, R.drawable.ic_action_flag_dark, R.string.map_marker_1st, "map_marker_1st", false, 11);
|
||||
TextInfoWidget marker2nd = mwf.createMapMarkerControl2nd(map);
|
||||
TextInfoWidget marker2nd = mwf.createMapMarkerControl(map, false);
|
||||
registerSideWidget(marker2nd, R.drawable.ic_action_flag_dark, R.string.map_marker_2nd, "map_marker_2nd", false, 12);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@ import net.osmand.plus.IconsCache;
|
|||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.OsmandSettings.MapMarkersMode;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dashboard.DashLocationFragment;
|
||||
|
@ -22,6 +20,8 @@ import net.osmand.plus.helpers.AndroidUiHelper;
|
|||
import net.osmand.plus.helpers.MapMarkerDialogHelper;
|
||||
import net.osmand.plus.views.DirectionDrawable;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory.DistanceToPointInfoControl;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
|
@ -55,11 +55,7 @@ public class MapMarkersWidgetsFactory {
|
|||
private ImageButton moreButton2nd;
|
||||
|
||||
private MapMarker marker;
|
||||
private int markerColorIndex = -1;
|
||||
private String markerDistText;
|
||||
private MapMarker marker2nd;
|
||||
private int markerColorIndex2nd = -1;
|
||||
private String markerDistText2nd;
|
||||
|
||||
public MapMarkersWidgetsFactory(final MapActivity map) {
|
||||
this.map = map;
|
||||
|
@ -281,112 +277,66 @@ public class MapMarkersWidgetsFactory {
|
|||
|
||||
if (firstLine) {
|
||||
this.marker = marker;
|
||||
markerColorIndex = marker.colorIndex;
|
||||
if (txt != null) {
|
||||
markerDistText = txt;
|
||||
}
|
||||
} else {
|
||||
this.marker2nd = marker;
|
||||
markerColorIndex2nd = marker.colorIndex;
|
||||
if (txt != null) {
|
||||
markerDistText2nd = txt;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public TextInfoWidget createMapMarkerControl(final MapActivity map) {
|
||||
final TextInfoWidget mapMarkerControl = new TextInfoWidget(map) {
|
||||
public TextInfoWidget createMapMarkerControl(final MapActivity map, final boolean firstMarker) {
|
||||
DistanceToPointInfoControl ctrl = new DistanceToPointInfoControl(map, 0, 0) {
|
||||
private int cachedMarkerColorIndex = -1;
|
||||
private String cachedMarkerDistText;
|
||||
|
||||
@Override
|
||||
public boolean updateInfo(DrawSettings d) {
|
||||
if (markerColorIndex != -1 && markerDistText != null) {
|
||||
boolean res = false;
|
||||
if (markerColorIndex != cachedMarkerColorIndex) {
|
||||
public LatLon getPointToNavigate() {
|
||||
MapMarker marker = getMarker();
|
||||
if (marker != null) {
|
||||
return marker.point;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private MapMarker getMarker() {
|
||||
List<MapMarker> markers = helper.getSortedMapMarkers();
|
||||
if (firstMarker) {
|
||||
if (markers.size() > 0) {
|
||||
return markers.get(0);
|
||||
}
|
||||
} else {
|
||||
if (markers.size() > 1) {
|
||||
return markers.get(1);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateInfo(DrawSettings drawSettings) {
|
||||
MapMarker marker = getMarker();
|
||||
if (marker == null) {
|
||||
setText(null, null);
|
||||
return false;
|
||||
}
|
||||
boolean res = super.updateInfo(drawSettings);
|
||||
|
||||
if (marker.colorIndex != -1) {
|
||||
if (marker.colorIndex != cachedMarkerColorIndex) {
|
||||
setImageDrawable(map.getMyApplication().getIconsCache()
|
||||
.getIcon(R.drawable.widget_marker_day,
|
||||
MapMarkerDialogHelper.getMapMarkerColorId(markerColorIndex)));
|
||||
cachedMarkerColorIndex = markerColorIndex;
|
||||
res = true;
|
||||
MapMarkerDialogHelper.getMapMarkerColorId(marker.colorIndex)));
|
||||
cachedMarkerColorIndex = marker.colorIndex;
|
||||
}
|
||||
if (!markerDistText.equals(cachedMarkerDistText)) {
|
||||
int ls = markerDistText.lastIndexOf(' ');
|
||||
if (ls == -1) {
|
||||
setText(markerDistText, null);
|
||||
} else {
|
||||
setText(markerDistText.substring(0, ls), markerDistText.substring(ls + 1));
|
||||
}
|
||||
cachedMarkerDistText = markerDistText;
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
|
||||
} else if (cachedMarkerDistText != null) {
|
||||
cachedMarkerColorIndex = -1;
|
||||
cachedMarkerDistText = null;
|
||||
setText(null, null);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void click(OsmandMapTileView view) {
|
||||
showMarkerOnMap(firstMarker ? 0 : 1);
|
||||
}
|
||||
};
|
||||
mapMarkerControl.setText(null, null);
|
||||
mapMarkerControl.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showMarkerOnMap(0);
|
||||
}
|
||||
});
|
||||
return mapMarkerControl;
|
||||
}
|
||||
|
||||
public TextInfoWidget createMapMarkerControl2nd(final MapActivity map) {
|
||||
final TextInfoWidget mapMarkerControl = new TextInfoWidget(map) {
|
||||
private int cachedMarkerColorIndex = -1;
|
||||
private String cachedMarkerDistText;
|
||||
|
||||
@Override
|
||||
public boolean updateInfo(DrawSettings d) {
|
||||
if (markerColorIndex2nd != -1 && markerDistText2nd != null) {
|
||||
boolean res = false;
|
||||
if (markerColorIndex2nd != cachedMarkerColorIndex) {
|
||||
setImageDrawable(map.getMyApplication().getIconsCache()
|
||||
.getIcon(R.drawable.widget_marker_day,
|
||||
MapMarkerDialogHelper.getMapMarkerColorId(markerColorIndex2nd)));
|
||||
cachedMarkerColorIndex = markerColorIndex2nd;
|
||||
res = true;
|
||||
}
|
||||
if (!markerDistText2nd.equals(cachedMarkerDistText)) {
|
||||
int ls = markerDistText2nd.lastIndexOf(' ');
|
||||
if (ls == -1) {
|
||||
setText(markerDistText2nd, null);
|
||||
} else {
|
||||
setText(markerDistText2nd.substring(0, ls), markerDistText2nd.substring(ls + 1));
|
||||
}
|
||||
cachedMarkerDistText = markerDistText2nd;
|
||||
res = true;
|
||||
}
|
||||
return res;
|
||||
|
||||
} else if (cachedMarkerDistText != null) {
|
||||
cachedMarkerColorIndex = -1;
|
||||
cachedMarkerDistText = null;
|
||||
setText(null, null);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
mapMarkerControl.setText(null, null);
|
||||
mapMarkerControl.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showMarkerOnMap(1);
|
||||
}
|
||||
});
|
||||
return mapMarkerControl;
|
||||
ctrl.setAutoHide(false);
|
||||
return ctrl;
|
||||
}
|
||||
|
||||
public boolean isLandscapeLayout() {
|
||||
|
|
|
@ -385,11 +385,14 @@ public class RouteInfoWidgetsFactory {
|
|||
private final OsmandMapTileView view;
|
||||
private float[] calculations = new float[1];
|
||||
private int cachedMeters;
|
||||
private boolean autoHide = true;
|
||||
|
||||
public DistanceToPointInfoControl(MapActivity ma, int res, int resNight) {
|
||||
super(ma);
|
||||
this.view = ma.getMapView();
|
||||
setIcons(res, resNight);
|
||||
if (res != 0 && resNight != 0) {
|
||||
setIcons(res, resNight);
|
||||
}
|
||||
setText(null, null);
|
||||
setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
|
@ -400,6 +403,14 @@ public class RouteInfoWidgetsFactory {
|
|||
});
|
||||
}
|
||||
|
||||
public boolean isAutoHide() {
|
||||
return autoHide;
|
||||
}
|
||||
|
||||
public void setAutoHide(boolean autoHide) {
|
||||
this.autoHide = autoHide;
|
||||
}
|
||||
|
||||
protected void click(final OsmandMapTileView view) {
|
||||
AnimateDraggingMapThread thread = view.getAnimatedDraggingThread();
|
||||
LatLon pointToNavigate = getPointToNavigate();
|
||||
|
@ -414,7 +425,7 @@ public class RouteInfoWidgetsFactory {
|
|||
int d = getDistance();
|
||||
if (distChanged(cachedMeters, d)) {
|
||||
cachedMeters = d;
|
||||
if (cachedMeters <= 20) {
|
||||
if (autoHide && cachedMeters <= 20) {
|
||||
cachedMeters = 0;
|
||||
setText(null, null);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue