Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
477a03b2b6
14 changed files with 231 additions and 186 deletions
|
@ -1940,4 +1940,5 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
|
|||
<string name="av_photo_play_sound_descr">Choose whether to play a sound when shooting photos</string>
|
||||
<string name="navigation_intent_invalid">Invalid format: %s</string>
|
||||
<string name="hide_all_waypoints">Remove all</string>
|
||||
<string name="announce_nearby_favorites">Announce nearby favorites</string>
|
||||
</resources>
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package net.osmand.plus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import android.widget.ListView;
|
||||
import net.osmand.GeoidAltitudeCorrection;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.access.NavigationInfo;
|
||||
import net.osmand.binary.RouteDataObject;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.LocationPoint;
|
||||
import net.osmand.data.QuadPoint;
|
||||
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
|
@ -67,8 +67,6 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
private float[] mGeoMags = new float[3];
|
||||
private float previousCorrectionValue = 360;
|
||||
|
||||
|
||||
|
||||
private static final boolean USE_KALMAN_FILTER = true;
|
||||
private static final float KALMAN_COEFFICIENT = 0.04f;
|
||||
|
||||
|
@ -105,6 +103,112 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
private OsmandPreference<Boolean> USE_MAGNETIC_FIELD_SENSOR_COMPASS;
|
||||
private OsmandPreference<Boolean> USE_FILTER_FOR_COMPASS;
|
||||
|
||||
private static final int NOT_ANNOUNCED = 0;
|
||||
private static final int ANNOUNCED_ONCE = 1;
|
||||
private static final int ANNOUNCED_TWICE = 2;
|
||||
|
||||
private ConcurrentHashMap<LocationPoint , Integer> locationPointsStates = new ConcurrentHashMap<LocationPoint, Integer>();
|
||||
private List<LocationPoint> visibleLocationPoints = new CopyOnWriteArrayList<LocationPoint>();
|
||||
private long locationPointsModified;
|
||||
|
||||
public List<LocationPoint> getVisibleLocationPoints() {
|
||||
return visibleLocationPoints;
|
||||
}
|
||||
|
||||
public void setVisibleLocationPoints(List<LocationPoint> points) {
|
||||
locationPointsStates.clear();
|
||||
visibleLocationPoints.clear();
|
||||
if (points == null) {
|
||||
return;
|
||||
}
|
||||
for (LocationPoint p : points) {
|
||||
locationPointsStates.put(p, NOT_ANNOUNCED);
|
||||
visibleLocationPoints.add(p);
|
||||
}
|
||||
sortVisibleLocationPoints();
|
||||
|
||||
}
|
||||
|
||||
public void addVisibleLocationPoint(LocationPoint lp) {
|
||||
this.locationPointsStates.put(lp, NOT_ANNOUNCED);
|
||||
this.locationPointsModified = System.currentTimeMillis();
|
||||
sortVisibleLocationPoints();
|
||||
}
|
||||
|
||||
public void clearAllVisiblePoints() {
|
||||
this.locationPointsStates.clear();
|
||||
this.visibleLocationPoints.clear();
|
||||
this.locationPointsModified = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void sortVisibleLocationPoints() {
|
||||
net.osmand.Location lastLocation = getLastKnownLocation();
|
||||
if (lastLocation != null) {
|
||||
Object[] loc = visibleLocationPoints.toArray();
|
||||
Arrays.sort(loc, getComparator(lastLocation));
|
||||
visibleLocationPoints.clear();
|
||||
for (Object aLoc : loc) {
|
||||
visibleLocationPoints.add((LocationPoint) aLoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
private Comparator<Object> getComparator(final net.osmand.Location lastLocation){
|
||||
return new Comparator<Object>() {
|
||||
@Override
|
||||
public int compare(Object locationPoint, Object locationPoint2) {
|
||||
double d1 = MapUtils.getDistance(lastLocation.getLatitude(), lastLocation.getLongitude(),
|
||||
((LocationPoint)locationPoint).getLatitude(), ((LocationPoint)locationPoint).getLongitude());
|
||||
double d2 = MapUtils.getDistance(lastLocation.getLatitude(), lastLocation.getLongitude(),
|
||||
((LocationPoint)locationPoint2).getLatitude(), ((LocationPoint)locationPoint2).getLongitude());
|
||||
return Double.compare(d1, d2);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
public long getLocationPointsModified() {
|
||||
return locationPointsModified;
|
||||
}
|
||||
|
||||
public void removeVisibleLocationPoint(LocationPoint lp) {
|
||||
this.visibleLocationPoints = removeFromList(visibleLocationPoints, lp);
|
||||
this.locationPointsStates.remove(lp);
|
||||
this.locationPointsModified = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
private void announceVisibleLocations() {
|
||||
final net.osmand.Location lastLocation = getLastKnownLocation();
|
||||
if (lastLocation != null && app.getRoutingHelper().isFollowingMode()) {
|
||||
String nameToAnnounce = null;
|
||||
for (LocationPoint point : locationPointsStates.keySet()) {
|
||||
double d1 = MapUtils.getDistance(lastLocation.getLatitude(), lastLocation.getLongitude(),
|
||||
point.getLatitude(), point.getLongitude());
|
||||
int state = locationPointsStates.get(point);
|
||||
if (state == NOT_ANNOUNCED && app.getRoutingHelper().getVoiceRouter().isDistanceLess(lastLocation.getSpeed(), d1, 500)){
|
||||
nameToAnnounce = (nameToAnnounce == null? "":", ")+point.getName();
|
||||
locationPointsStates.put(point, state + 1);
|
||||
} else if(state == ANNOUNCED_ONCE && app.getRoutingHelper().getVoiceRouter().isDistanceLess(lastLocation.getSpeed(), d1, 150)){
|
||||
nameToAnnounce = (nameToAnnounce == null? "":", ")+point.getName();
|
||||
locationPointsStates.remove(point);
|
||||
}
|
||||
}
|
||||
if(nameToAnnounce!= null) {
|
||||
app.getRoutingHelper().getVoiceRouter().announceWaypoint(nameToAnnounce);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<LocationPoint> removeFromList(List<LocationPoint> items, Object item){
|
||||
List<LocationPoint> newArray = new ArrayList<LocationPoint>();
|
||||
Object[] oldArray = items.toArray();
|
||||
for (int i=0; i<oldArray.length; i++){
|
||||
if (!item.equals(oldArray[i])){
|
||||
newArray.add((LocationPoint)oldArray[i]);
|
||||
}
|
||||
}
|
||||
items.clear();
|
||||
return new CopyOnWriteArrayList<LocationPoint>(newArray);
|
||||
}
|
||||
|
||||
public class SimulationProvider {
|
||||
private int currentRoad;
|
||||
|
@ -518,6 +622,10 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
|
||||
|
||||
private void updateLocation(net.osmand.Location loc ) {
|
||||
if (app.getSettings().ANNOUNCE_NEARBY_FAVORITES.get()){
|
||||
sortVisibleLocationPoints();
|
||||
announceVisibleLocations();
|
||||
}
|
||||
for(OsmAndLocationListener l : locationListeners){
|
||||
l.updateLocation(loc);
|
||||
}
|
||||
|
|
|
@ -819,7 +819,7 @@ public class OsmandSettings {
|
|||
public final OsmandPreference<Boolean> GPX_SPEAK_WPT = new BooleanPreference("speak_gpx_wpt", true).makeGlobal().cache();
|
||||
public final OsmandPreference<Boolean> GPX_ROUTE_CALC = new BooleanPreference("calc_gpx_route", false).makeGlobal().cache();
|
||||
|
||||
|
||||
public final OsmandPreference<Boolean> ANNOUNCE_NEARBY_FAVORITES = new BooleanPreference("announce_nearby_favorites", false).makeGlobal().cache();
|
||||
|
||||
public final OsmandPreference<Boolean> AVOID_TOLL_ROADS = new BooleanPreference("avoid_toll_roads", false).makeProfile().cache();
|
||||
public final OsmandPreference<Boolean> AVOID_MOTORWAY = new BooleanPreference("avoid_motorway", false).makeProfile().cache();
|
||||
|
|
|
@ -25,8 +25,6 @@ public class TargetPointsHelper {
|
|||
private RoutingHelper routingHelper;
|
||||
private List<StateChangedListener<Void>> listeners = new ArrayList<StateChangedListener<Void>>();
|
||||
private OsmandApplication ctx;
|
||||
private List<LocationPoint> visibleLocationPoints = new CopyOnWriteArrayList<LocationPoint>();
|
||||
private long locationPointsModified;
|
||||
|
||||
public TargetPointsHelper(OsmandApplication ctx){
|
||||
this.ctx = ctx;
|
||||
|
@ -69,47 +67,7 @@ public class TargetPointsHelper {
|
|||
return intermediatePoints;
|
||||
}
|
||||
|
||||
public List<LocationPoint> getVisibleLocationPoints() {
|
||||
return visibleLocationPoints;
|
||||
}
|
||||
|
||||
public void addVisibleLocationPoint(LocationPoint lp) {
|
||||
this.visibleLocationPoints.add(lp);
|
||||
this.locationPointsModified = System.currentTimeMillis();
|
||||
sortVisibleLocationPoints();
|
||||
}
|
||||
|
||||
public void removeAllVisiblePoints() {
|
||||
this.locationPointsModified = System.currentTimeMillis();
|
||||
visibleLocationPoints.clear();
|
||||
}
|
||||
|
||||
|
||||
public void sortVisibleLocationPoints() {
|
||||
final Location lastLocation = ctx.getLocationProvider().getLastKnownLocation();
|
||||
if(lastLocation != null) {
|
||||
Collections.sort(this.visibleLocationPoints, new Comparator<LocationPoint>() {
|
||||
@Override
|
||||
public int compare(LocationPoint locationPoint, LocationPoint locationPoint2) {
|
||||
double d1 = MapUtils.getDistance(lastLocation.getLatitude(), lastLocation.getLongitude(),
|
||||
locationPoint.getLatitude(), locationPoint.getLongitude());
|
||||
double d2 = MapUtils.getDistance(lastLocation.getLatitude(), lastLocation.getLongitude(),
|
||||
locationPoint2.getLatitude(), locationPoint2.getLongitude());
|
||||
return Double.compare(d1, d2);
|
||||
}
|
||||
});
|
||||
this.locationPointsModified = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
public long getLocationPointsModified() {
|
||||
return locationPointsModified;
|
||||
}
|
||||
|
||||
public void removeVisibleLocationPoint(LocationPoint lp) {
|
||||
this.visibleLocationPoints.remove(lp);
|
||||
this.locationPointsModified = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
|
||||
public List<LatLon> getIntermediatePointsWithTarget() {
|
||||
|
|
|
@ -642,6 +642,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
|
||||
mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
|
||||
mapActivity.getMapView().refreshMap(true);
|
||||
mapActivity.getMapLayers().getMapControlsLayer().showDialog();
|
||||
if(targets.hasTooLongDistanceToNavigate()) {
|
||||
app.showToastMessage(R.string.route_is_too_long);
|
||||
}
|
||||
|
|
|
@ -32,15 +32,14 @@ public class RouteCalculationResult {
|
|||
private final List<RouteDirectionInfo> directions;
|
||||
private final List<RouteSegmentResult> segments;
|
||||
private final List<AlarmInfo> alarmInfo;
|
||||
private final List<LocationPoint> waypoints;
|
||||
private final String errorMessage;
|
||||
private final int[] listDistance;
|
||||
private final int[] intermediatePoints;
|
||||
private final int[] waypointIndexes;
|
||||
private final float routingTime;
|
||||
|
||||
protected int cacheCurrentTextDirectionInfo = -1;
|
||||
protected List<RouteDirectionInfo> cacheAgreggatedDirections;
|
||||
protected List<LocationPoint> locationPoints = new ArrayList<LocationPoint>();
|
||||
|
||||
// Note always currentRoute > get(currentDirectionInfo).routeOffset,
|
||||
// but currentRoute <= get(currentDirectionInfo+1).routeOffset
|
||||
|
@ -60,12 +59,9 @@ public class RouteCalculationResult {
|
|||
this.listDistance = new int[0];
|
||||
this.directions = new ArrayList<RouteDirectionInfo>();
|
||||
this.alarmInfo = new ArrayList<AlarmInfo>();
|
||||
this.waypointIndexes = new int[0];
|
||||
this.waypoints = new ArrayList<LocationPoint>();
|
||||
}
|
||||
|
||||
public RouteCalculationResult(List<Location> list, List<RouteDirectionInfo> directions, RouteCalculationParams params,
|
||||
DataTileManager<? extends LocationPoint> waypointsTm) {
|
||||
public RouteCalculationResult(List<Location> list, List<RouteDirectionInfo> directions, RouteCalculationParams params) {
|
||||
this.routingTime = 0;
|
||||
this.errorMessage = null;
|
||||
this.intermediatePoints = new int[params.intermediates == null ? 0 : params.intermediates.size()];
|
||||
|
@ -91,13 +87,14 @@ public class RouteCalculationResult {
|
|||
calculateIntermediateIndexes(params.ctx, this.locations, params.intermediates, localDirections, this.intermediatePoints);
|
||||
this.directions = Collections.unmodifiableList(localDirections);
|
||||
updateDirectionsTime(this.directions, this.listDistance);
|
||||
this.waypoints = new ArrayList<LocationPoint>();
|
||||
this.waypointIndexes = calculateWaypointIndexes(list, waypointsTm, waypoints);
|
||||
}
|
||||
|
||||
public RouteCalculationResult(List<RouteSegmentResult> list, Location start, LatLon end, List<LatLon> intermediates,
|
||||
Context ctx, boolean leftSide, float routingTime,DataTileManager<LocationPoint> waypointsTm) {
|
||||
Context ctx, boolean leftSide, float routingTime, List<LocationPoint> waypoints) {
|
||||
this.routingTime = routingTime;
|
||||
if(waypoints != null) {
|
||||
this.locationPoints.addAll(waypoints);
|
||||
}
|
||||
List<RouteDirectionInfo> computeDirections = new ArrayList<RouteDirectionInfo>();
|
||||
this.errorMessage = null;
|
||||
this.intermediatePoints = new int[intermediates == null ? 0 : intermediates.size()];
|
||||
|
@ -115,34 +112,10 @@ public class RouteCalculationResult {
|
|||
this.directions = Collections.unmodifiableList(computeDirections);
|
||||
updateDirectionsTime(this.directions, this.listDistance);
|
||||
this.alarmInfo = Collections.unmodifiableList(alarms);
|
||||
this.waypoints = new ArrayList<LocationPoint>();
|
||||
|
||||
this.waypointIndexes = calculateWaypointIndexes(this.locations, waypointsTm, waypoints);
|
||||
}
|
||||
|
||||
public List<LocationPoint> getWaypointsToAnnounce(Location loc) {
|
||||
if (currentWaypointGPX != lastWaypointGPX && loc != null) {
|
||||
ArrayList<LocationPoint> points = new ArrayList<LocationPoint>();
|
||||
Location next = locations.get(currentRoute);
|
||||
float dist = loc.distanceTo(next);
|
||||
while (currentWaypointGPX < lastWaypointGPX) {
|
||||
WptPt w = (WptPt) waypoints.get(currentWaypointGPX);
|
||||
if(MapUtils.getDistance(w.lat, w.lon, next.getLatitude(), next.getLongitude()) > dist + 50) {
|
||||
currentWaypointGPX++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (currentWaypointGPX < lastWaypointGPX) {
|
||||
WptPt w = (WptPt) waypoints.get(currentWaypointGPX);
|
||||
if(MapUtils.getDistance(w.lat, w.lon, loc.getLatitude(), next.getLongitude()) < 60) {
|
||||
currentWaypointGPX++;
|
||||
points.add(w);
|
||||
}
|
||||
}
|
||||
return points;
|
||||
}
|
||||
return Collections.emptyList();
|
||||
public List<LocationPoint> getLocationPoints() {
|
||||
return locationPoints;
|
||||
}
|
||||
|
||||
private static void calculateIntermediateIndexes(Context ctx, List<Location> locations,
|
||||
|
@ -758,9 +731,6 @@ public class RouteCalculationResult {
|
|||
while (nextAlarmInfo < alarmInfo.size() && alarmInfo.get(nextAlarmInfo).locationIndex < currentRoute) {
|
||||
nextAlarmInfo++;
|
||||
}
|
||||
while(lastWaypointGPX < waypointIndexes.length && waypointIndexes[lastWaypointGPX] <= currentRoute) {
|
||||
lastWaypointGPX++;
|
||||
}
|
||||
while(nextIntermediate < intermediatePoints.length) {
|
||||
RouteDirectionInfo dir = directions.get(intermediatePoints[nextIntermediate]);
|
||||
if(dir.routePointOffset < currentRoute) {
|
||||
|
|
|
@ -29,6 +29,7 @@ import net.osmand.binary.BinaryMapIndexReader;
|
|||
import net.osmand.data.DataTileManager;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.LocationPoint;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
|
@ -203,11 +204,11 @@ public class RouteProvider {
|
|||
public static class GPXRouteParams {
|
||||
List<Location> points = new ArrayList<Location>();
|
||||
List<RouteDirectionInfo> directions;
|
||||
DataTileManager<WptPt> wpt;
|
||||
boolean calculateOsmAndRoute;
|
||||
boolean passWholeRoute;
|
||||
boolean calculateOsmAndRouteParts;
|
||||
boolean useIntermediatePointsRTE;
|
||||
private List<LocationPoint> wpt;
|
||||
|
||||
public List<Location> getPoints() {
|
||||
return points;
|
||||
|
@ -244,6 +245,9 @@ public class RouteProvider {
|
|||
useIntermediatePointsRTE = builder.useIntermediatePointsRTE;
|
||||
boolean announceWaypoints = builder.announceWaypoints;
|
||||
builder.calculateOsmAndRoute = false; // Disabled temporary builder.calculateOsmAndRoute;
|
||||
if(announceWaypoints && !file.points.isEmpty()) {
|
||||
wpt = new ArrayList<LocationPoint>(file.points );
|
||||
}
|
||||
if(file.isCloudmadeRouteFile() || OSMAND_ROUTER.equals(file.author)){
|
||||
directions = parseOsmAndGPXRoute(points, file, OSMAND_ROUTER.equals(file.author), builder.leftSide, 10);
|
||||
if(reverse){
|
||||
|
@ -273,14 +277,6 @@ public class RouteProvider {
|
|||
Collections.reverse(points);
|
||||
}
|
||||
}
|
||||
wpt = null;
|
||||
if(announceWaypoints && !file.points.isEmpty()) {
|
||||
wpt = new DataTileManager<WptPt>(17);
|
||||
for(WptPt w : file.points ) {
|
||||
wpt.registerObjectXY(MapUtils.get31TileNumberX(w.lon),
|
||||
MapUtils.get31TileNumberY(w.lat),w) ;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -358,7 +354,7 @@ public class RouteProvider {
|
|||
locs = findStartAndEndLocationsFromRoute(locs, params.start, params.end, startI, endI);
|
||||
List<RouteDirectionInfo> directions = calcDirections(startI, endI, rcr.getRouteDirections());
|
||||
insertInitialSegment(params, locs, directions, true);
|
||||
res = new RouteCalculationResult(locs, directions, params, null);
|
||||
res = new RouteCalculationResult(locs, directions, params);
|
||||
} catch (RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -392,7 +388,7 @@ public class RouteProvider {
|
|||
info.distance = 0;
|
||||
info.afterLeftTime = 0;
|
||||
}
|
||||
RouteCalculationResult res = new RouteCalculationResult(gpxRoute, gpxDirections, routeParams, gpxParams.wpt);
|
||||
RouteCalculationResult res = new RouteCalculationResult(gpxRoute, gpxDirections, routeParams);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -626,7 +622,7 @@ public class RouteProvider {
|
|||
}
|
||||
}
|
||||
params.intermediates = null;
|
||||
return new RouteCalculationResult(res, null, params, null);
|
||||
return new RouteCalculationResult(res, null, params);
|
||||
}
|
||||
|
||||
protected RouteCalculationResult findVectorMapsRoute(final RouteCalculationParams params, boolean calcGPXRoute) throws IOException {
|
||||
|
@ -777,13 +773,8 @@ public class RouteProvider {
|
|||
// something really strange better to see that message on the scren
|
||||
return emptyResult();
|
||||
} else {
|
||||
DataTileManager mngr = new DataTileManager<Object>(17);
|
||||
List<FavouritePoint> points = params.ctx.getFavorites().getFavouritePoints();
|
||||
for(FavouritePoint point : points){
|
||||
mngr.registerObject(point.getLatitude(), point.getLongitude(), point);
|
||||
}
|
||||
RouteCalculationResult res = new RouteCalculationResult(result, params.start, params.end,
|
||||
params.intermediates, params.ctx, params.leftSide, ctx.routingTime, mngr);
|
||||
params.intermediates, params.ctx, params.leftSide, ctx.routingTime, params.gpxRoute == null? null: params.gpxRoute.wpt);
|
||||
return res;
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
|
@ -1000,7 +991,7 @@ public class RouteProvider {
|
|||
}
|
||||
}
|
||||
params.intermediates = null;
|
||||
return new RouteCalculationResult(res, null, params, null);
|
||||
return new RouteCalculationResult(res, null, params);
|
||||
}
|
||||
|
||||
public GPXFile createOsmandRouterGPX(RouteCalculationResult srcRoute, OsmandApplication ctx){
|
||||
|
@ -1145,7 +1136,7 @@ public class RouteProvider {
|
|||
res.add(createLocation(pt));
|
||||
}
|
||||
params.intermediates = null;
|
||||
return new RouteCalculationResult(res, null, params, null);
|
||||
return new RouteCalculationResult(res, null, params);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1221,7 +1212,7 @@ public class RouteProvider {
|
|||
} catch (Exception e) {
|
||||
return new RouteCalculationResult("Exception calling BRouter: " + e); //$NON-NLS-1$
|
||||
}
|
||||
return new RouteCalculationResult(res, null, params, null);
|
||||
return new RouteCalculationResult(res, null, params);
|
||||
}
|
||||
|
||||
private RouteCalculationResult findStraightRoute(RouteCalculationParams params) {
|
||||
|
@ -1247,7 +1238,7 @@ public class RouteProvider {
|
|||
location.setLatitude(lats[1]);
|
||||
location.setLongitude(lons[1]);
|
||||
dots.add(location);
|
||||
return new RouteCalculationResult(dots,null,params,null);
|
||||
return new RouteCalculationResult(dots,null,params);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.data.LocationPoint;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.NavigationService;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -26,7 +25,6 @@ import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
|
|||
import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo;
|
||||
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
|
||||
import net.osmand.plus.routing.RouteProvider.RouteService;
|
||||
import net.osmand.plus.sherpafy.WaypointDialogHelper;
|
||||
import net.osmand.plus.voice.CommandPlayer;
|
||||
import net.osmand.router.RouteCalculationProgress;
|
||||
import net.osmand.router.RouteSegmentResult;
|
||||
|
@ -270,7 +268,6 @@ public class RoutingHelper {
|
|||
// 5. Update Voice router
|
||||
if (isFollowingMode) {
|
||||
// don't update in route planing mode
|
||||
announceGpxWaypoints(currentLocation);
|
||||
boolean inRecalc = calculateRoute || isRouteBeingCalculated();
|
||||
if (!inRecalc && !wrongMovementDirection) {
|
||||
voiceRouter.updateStatus(currentLocation, false);
|
||||
|
@ -317,25 +314,6 @@ public class RoutingHelper {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private void announceGpxWaypoints(Location currentLocation) {
|
||||
if (currentLocation != null) {
|
||||
List<LocationPoint> wpt = route.getWaypointsToAnnounce(currentLocation);
|
||||
if (wpt.size() > 0) {
|
||||
String s = "";
|
||||
for (LocationPoint w : wpt) {
|
||||
if(!Algorithms.isEmpty(w.getName())) {
|
||||
s = w.getName() +",";
|
||||
}
|
||||
}
|
||||
if(!Algorithms.isEmpty(s)) {
|
||||
voiceRouter.announceWaypoint(s);
|
||||
// dialogHelper.addWptDialog(wpt.get(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static double getOrthogonalDistance(Location loc, Location from, Location to) {
|
||||
return MapUtils.getOrthogonalDistance(loc.getLatitude(),
|
||||
loc.getLongitude(), from.getLatitude(), from.getLongitude(),
|
||||
|
@ -537,6 +515,12 @@ public class RoutingHelper {
|
|||
}
|
||||
|
||||
private synchronized void setNewRoute(RouteCalculationResult res, Location start){
|
||||
ArrayList<LocationPoint> locationPoints = new ArrayList<LocationPoint>();
|
||||
if (app.getSettings().ANNOUNCE_NEARBY_FAVORITES.get()){
|
||||
locationPoints.addAll(app.getFavorites().getFavouritePoints());
|
||||
}
|
||||
locationPoints.addAll(res.getLocationPoints());
|
||||
app.getLocationProvider().setVisibleLocationPoints(locationPoints);
|
||||
final boolean newRoute = !this.route.isCalculated();
|
||||
route = res;
|
||||
if (isFollowingMode) {
|
||||
|
|
|
@ -154,7 +154,7 @@ public class VoiceRouter {
|
|||
}
|
||||
}
|
||||
|
||||
protected boolean isDistanceLess(float currentSpeed, double dist, double etalon){
|
||||
public boolean isDistanceLess(float currentSpeed, double dist, double etalon){
|
||||
if(currentSpeed <= 0) {
|
||||
currentSpeed = DEFAULT_SPEED;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package net.osmand.plus.sherpafy;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
|
@ -17,7 +16,6 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.*;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.LocationPoint;
|
||||
import net.osmand.plus.*;
|
||||
import net.osmand.plus.activities.FavouritesActivity;
|
||||
|
@ -35,7 +33,7 @@ public class WaypointDialogHelper {
|
|||
private MapActivity mapActivity;
|
||||
private OsmandApplication app;
|
||||
private FrameLayout mainLayout;
|
||||
private TargetPointsHelper targetPointsHelper;
|
||||
private OsmAndLocationProvider locationProvider;
|
||||
|
||||
public static boolean OVERLAP_LAYOUT = true;
|
||||
private long uiModified;
|
||||
|
@ -43,14 +41,14 @@ public class WaypointDialogHelper {
|
|||
|
||||
public WaypointDialogHelper(MapActivity mapActivity) {
|
||||
this.app = mapActivity.getMyApplication();
|
||||
targetPointsHelper = this.app.getTargetPointsHelper();
|
||||
locationProvider = this.app.getLocationProvider();
|
||||
this.mapActivity = mapActivity;
|
||||
this.mainLayout = (FrameLayout) ((FrameLayout) mapActivity.getLayout()).getChildAt(0);
|
||||
}
|
||||
|
||||
public void updateDialog() {
|
||||
List<LocationPoint> vlp = targetPointsHelper.getVisibleLocationPoints();
|
||||
long locationPointsModified = targetPointsHelper.getLocationPointsModified();
|
||||
List<LocationPoint> vlp = locationProvider.getVisibleLocationPoints();
|
||||
long locationPointsModified = locationProvider.getLocationPointsModified();
|
||||
if (locationPointsModified != uiModified) {
|
||||
uiModified = locationPointsModified;
|
||||
if (vlp.isEmpty()) {
|
||||
|
@ -80,7 +78,7 @@ public class WaypointDialogHelper {
|
|||
btnN.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
targetPointsHelper.removeVisibleLocationPoint(point);
|
||||
locationProvider.removeVisibleLocationPoint(point);
|
||||
updateDialog();
|
||||
}
|
||||
});
|
||||
|
@ -189,7 +187,7 @@ public class WaypointDialogHelper {
|
|||
}
|
||||
|
||||
public void showAllDialog(){
|
||||
final List<LocationPoint> visibleLocationPoints = targetPointsHelper.getVisibleLocationPoints();
|
||||
final List<LocationPoint> visibleLocationPoints = locationProvider.getVisibleLocationPoints();
|
||||
final ArrayAdapter<LocationPoint> listAdapter = new ArrayAdapter<LocationPoint>(mapActivity, R.layout.waypoint_reached, R.id.title,
|
||||
visibleLocationPoints) {
|
||||
@Override
|
||||
|
@ -205,6 +203,13 @@ public class WaypointDialogHelper {
|
|||
v.findViewById(R.id.waypoint_icon).setLayoutParams(ll);
|
||||
}
|
||||
createView(v, getItem(position));
|
||||
TextView text = (TextView) v.findViewById(R.id.waypoint_text);
|
||||
text.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
showOnMap(visibleLocationPoints.get(position));
|
||||
}
|
||||
});
|
||||
|
||||
View remove = v.findViewById(R.id.info_close);
|
||||
((ImageButton) remove).setImageDrawable(mapActivity.getResources().getDrawable(
|
||||
|
@ -213,9 +218,9 @@ public class WaypointDialogHelper {
|
|||
remove.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
LocationPoint point = targetPointsHelper.getVisibleLocationPoints().get(position);
|
||||
LocationPoint point = locationProvider.getVisibleLocationPoints().get(position);
|
||||
remove(point);
|
||||
targetPointsHelper.removeVisibleLocationPoint(point);
|
||||
locationProvider.removeVisibleLocationPoint(point);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
|
@ -229,7 +234,7 @@ public class WaypointDialogHelper {
|
|||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||
itemClick(visibleLocationPoints.get(i));
|
||||
showOnMap(visibleLocationPoints.get(i));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -242,10 +247,18 @@ public class WaypointDialogHelper {
|
|||
builder.setNegativeButton(mapActivity.getString(R.string.hide_all_waypoints), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
targetPointsHelper.removeAllVisiblePoints();
|
||||
locationProvider.clearAllVisiblePoints();
|
||||
updateDialog();
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
}
|
||||
|
||||
private void showOnMap(LocationPoint locationPoint) {
|
||||
// AnimateDraggingMapThread thread = mapActivity.getMapView().getAnimatedDraggingThread();
|
||||
int fZoom = mapActivity.getMapView().getZoom() < 15 ? 15 : mapActivity.getMapView().getZoom();
|
||||
// thread.startMoving(pointToNavigate.getLatitude(), pointToNavigate.getLongitude(), fZoom, true);
|
||||
mapActivity.getMapView().setIntZoom(fZoom);
|
||||
mapActivity.getMapView().setLatLon(locationPoint.getLatitude(), locationPoint.getLongitude());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -320,6 +320,10 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
}
|
||||
}
|
||||
|
||||
public void showDialog(){
|
||||
mapInfoNavigationControl.setShowDialog();
|
||||
}
|
||||
|
||||
public WaypointDialogHelper getWaypointDialogHelper() {
|
||||
return waypointDialogHelper;
|
||||
}
|
||||
|
|
|
@ -208,4 +208,8 @@ public abstract class MapControls {
|
|||
public void setExtraVerticalMargin(int extraVerticalMargin) {
|
||||
this.extraVerticalMargin = extraVerticalMargin;
|
||||
}
|
||||
|
||||
public int getExtraVerticalMargin() {
|
||||
return this.extraVerticalMargin;
|
||||
}
|
||||
}
|
|
@ -3,6 +3,9 @@ package net.osmand.plus.views.controls;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.os.SystemClock;
|
||||
import android.view.*;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
|
@ -31,10 +34,6 @@ import android.graphics.Canvas;
|
|||
import android.graphics.PointF;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Handler;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
|
@ -57,6 +56,7 @@ public class MapRouteInfoControl extends MapControls implements IRouteInformatio
|
|||
private boolean selectFromMapTouch;
|
||||
private boolean selectFromMapForTarget;
|
||||
|
||||
private boolean showDialog = false;
|
||||
|
||||
public MapRouteInfoControl(ContextMenuLayer contextMenu,
|
||||
MapActivity mapActivity, Handler showUIHandler, float scaleCoefficient) {
|
||||
|
@ -86,6 +86,10 @@ public class MapRouteInfoControl extends MapControls implements IRouteInformatio
|
|||
@Override
|
||||
public void showControls(FrameLayout parent) {
|
||||
infoButton = addButton(parent, R.string.route_info, R.drawable.map_btn_signpost);
|
||||
if (showDialog){
|
||||
showDialog();
|
||||
showDialog = false;
|
||||
}
|
||||
controlVisible = true;
|
||||
infoButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -98,9 +102,6 @@ public class MapRouteInfoControl extends MapControls implements IRouteInformatio
|
|||
}
|
||||
}
|
||||
});
|
||||
if(getTargets().getPointToNavigate() == null) {
|
||||
showDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private Dialog createDialog() {
|
||||
|
@ -131,7 +132,7 @@ public class MapRouteInfoControl extends MapControls implements IRouteInformatio
|
|||
lp.width = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||
lp.gravity = Gravity.BOTTOM;
|
||||
lp.y = (int) (infoButton.getBottom() - infoButton.getTop() + scaleCoefficient * 5);
|
||||
lp.y = (int) (infoButton.getBottom() - infoButton.getTop() + scaleCoefficient * 5 + getExtraVerticalMargin());
|
||||
dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
|
||||
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.getWindow().setAttributes(lp);
|
||||
|
@ -456,4 +457,8 @@ public class MapRouteInfoControl extends MapControls implements IRouteInformatio
|
|||
infoButton.setBackgroundResource(R.drawable.map_btn_signpost);
|
||||
}
|
||||
}
|
||||
|
||||
public void setShowDialog() {
|
||||
showDialog = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -210,11 +210,16 @@ public class MapRoutePreferencesControl extends MapControls {
|
|||
if (gpxParam.id == R.string.fast_route_mode) {
|
||||
settings.FAST_ROUTE_MODE.set(selected);
|
||||
}
|
||||
if (gpxParam.id == R.string.announce_nearby_favorites){
|
||||
settings.ANNOUNCE_NEARBY_FAVORITES.set(selected);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List<LocalRoutingParameter> getRoutingParameters(ApplicationMode am) {
|
||||
List<LocalRoutingParameter> list = new ArrayList<LocalRoutingParameter>();
|
||||
list.add(new OtherLocalRoutingParameter(R.string.announce_nearby_favorites,
|
||||
mapActivity.getString(R.string.announce_nearby_favorites), settings.ANNOUNCE_NEARBY_FAVORITES.get()));
|
||||
GPXRouteParamsBuilder rparams = mapActivity.getRoutingHelper().getCurrentGPXRoute();
|
||||
boolean osmandRouter = settings.ROUTER_SERVICE.get() == RouteService.OSMAND ;
|
||||
if(!osmandRouter) {
|
||||
|
@ -255,6 +260,7 @@ public class MapRoutePreferencesControl extends MapControls {
|
|||
list.add(rp);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
private String getString(int id) {
|
||||
|
|
Loading…
Reference in a new issue