Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
a83603cd77
6 changed files with 121 additions and 23 deletions
|
@ -149,8 +149,10 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
for (Object aLoc : loc) {
|
||||
visibleLocationPoints.add((LocationPoint) aLoc);
|
||||
}
|
||||
locationPointsModified = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
private Comparator<Object> getComparator(final net.osmand.Location lastLocation){
|
||||
return new Comparator<Object>() {
|
||||
@Override
|
||||
|
@ -179,6 +181,8 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
final net.osmand.Location lastLocation = getLastKnownLocation();
|
||||
if (lastLocation != null && app.getRoutingHelper().isFollowingMode()) {
|
||||
String nameToAnnounce = null;
|
||||
List<LocationPoint> approachPoints = new ArrayList<LocationPoint>();
|
||||
List<LocationPoint> announcePoints = new ArrayList<LocationPoint>();
|
||||
for (LocationPoint point : locationPointsStates.keySet()) {
|
||||
double d1 = MapUtils.getDistance(lastLocation.getLatitude(), lastLocation.getLongitude(),
|
||||
point.getLatitude(), point.getLongitude());
|
||||
|
@ -186,14 +190,23 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
if (state <= ANNOUNCED_ONCE && app.getRoutingHelper().getVoiceRouter().isDistanceLess(lastLocation.getSpeed(), d1, 150)) {
|
||||
nameToAnnounce = (nameToAnnounce == null ? "" : ", ") + point.getName();
|
||||
locationPointsStates.remove(point);
|
||||
this.locationPointsModified = System.currentTimeMillis();
|
||||
app.getMapActivity().getMapLayers().getMapControlsLayer().getWaypointDialogHelper().updateDialog();
|
||||
announcePoints.add(point);
|
||||
} else if (state == NOT_ANNOUNCED && app.getRoutingHelper().getVoiceRouter().isDistanceLess(lastLocation.getSpeed(), d1, 500)) {
|
||||
nameToAnnounce = (nameToAnnounce == null? "":", ")+point.getName();
|
||||
locationPointsStates.put(point, state + 1);
|
||||
this.locationPointsModified = System.currentTimeMillis();
|
||||
app.getMapActivity().getMapLayers().getMapControlsLayer().getWaypointDialogHelper().updateDialog();
|
||||
approachPoints.add(point);
|
||||
}
|
||||
}
|
||||
if(nameToAnnounce!= null) {
|
||||
app.getRoutingHelper().getVoiceRouter().announceWaypoint(nameToAnnounce);
|
||||
if (!announcePoints.isEmpty()) {
|
||||
app.getRoutingHelper().getVoiceRouter().announceWaypoint(announcePoints);
|
||||
}
|
||||
if (!approachPoints.isEmpty()) {
|
||||
app.getRoutingHelper().getVoiceRouter().approachWaypoint(lastLocation, approachPoints);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -621,8 +634,9 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
|
||||
|
||||
private void updateLocation(net.osmand.Location loc ) {
|
||||
if (app.getSettings().ANNOUNCE_NEARBY_FAVORITES.get()){
|
||||
if (app.getSettings().ANNOUNCE_NEARBY_FAVORITES.get() && app.getRoutingHelper().isFollowingMode()){
|
||||
sortVisibleLocationPoints();
|
||||
app.getMapActivity().getMapLayers().getMapControlsLayer().getWaypointDialogHelper().updateDialog();
|
||||
announceVisibleLocations();
|
||||
}
|
||||
for(OsmAndLocationListener l : locationListeners){
|
||||
|
|
|
@ -3,7 +3,10 @@ package net.osmand.plus.routing;
|
|||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.binary.RouteDataObject;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LocationPoint;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
|
||||
import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo;
|
||||
|
@ -16,6 +19,9 @@ import net.osmand.util.Algorithms;
|
|||
import alice.tuprolog.Struct;
|
||||
import alice.tuprolog.Term;
|
||||
import android.content.Context;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class VoiceRouter {
|
||||
|
@ -217,10 +223,75 @@ public class VoiceRouter {
|
|||
}
|
||||
}
|
||||
|
||||
public void announceWaypoint(String w) {
|
||||
public void announceWaypoint(List<LocationPoint> points) {
|
||||
CommandBuilder p = getNewCommandPlayerToPlay();
|
||||
if(p != null) {
|
||||
p.arrivedAtWayPoint(getSpeakablePointName(w)).play();
|
||||
if (p == null){
|
||||
return;
|
||||
}
|
||||
String favoritesWaypoints = null;
|
||||
String gpxWaypoints = null;
|
||||
String poiWaypoints = null;
|
||||
for (LocationPoint point : points) {
|
||||
if (point instanceof GPXUtilities.WptPt) {
|
||||
gpxWaypoints = (favoritesWaypoints == null ? "" : ", ") + point.getName();
|
||||
} else if (point instanceof FavouritePoint) {
|
||||
favoritesWaypoints = (favoritesWaypoints == null ? "" : ", ") + point.getName();
|
||||
} else {
|
||||
poiWaypoints = (favoritesWaypoints == null ? "" : ", ") + point.getName();
|
||||
}
|
||||
}
|
||||
if (gpxWaypoints != null){
|
||||
p.arrivedAtWayPoint(gpxWaypoints).play();
|
||||
}
|
||||
if (favoritesWaypoints != null){
|
||||
p.arrivedAtFavorite(favoritesWaypoints).play();
|
||||
}
|
||||
if (poiWaypoints != null){
|
||||
p.arrivedAtPoi(poiWaypoints).play();
|
||||
}
|
||||
}
|
||||
|
||||
public void approachWaypoint(Location location, List<LocationPoint> points){
|
||||
CommandBuilder p = getNewCommandPlayerToPlay();
|
||||
if (p == null){
|
||||
return;
|
||||
}
|
||||
String favoritesWaypoints = null;
|
||||
String gpxWaypoints = null;
|
||||
String poiWaypoints = null;
|
||||
double favDistance = -1;
|
||||
double gpxDistance = -1;
|
||||
double poiDistance = -1;
|
||||
for (LocationPoint point : points) {
|
||||
if (point instanceof GPXUtilities.WptPt) {
|
||||
gpxWaypoints = (favoritesWaypoints == null ? "" : ", ") + point.getName();
|
||||
//need to calculate distance to nearest point
|
||||
if (favDistance == -1){
|
||||
favDistance = MapUtils.getDistance(location.getLatitude(), location.getLongitude(),
|
||||
point.getLatitude(), point.getLongitude());
|
||||
}
|
||||
} else if (point instanceof FavouritePoint) {
|
||||
favoritesWaypoints = (favoritesWaypoints == null ? "" : ", ") + point.getName();
|
||||
if (gpxDistance == -1){
|
||||
gpxDistance = MapUtils.getDistance(location.getLatitude(), location.getLongitude(),
|
||||
point.getLatitude(), point.getLongitude());
|
||||
}
|
||||
} else {
|
||||
poiWaypoints = (favoritesWaypoints == null ? "" : ", ") + point.getName();
|
||||
if (poiDistance == -1){
|
||||
poiDistance = MapUtils.getDistance(location.getLatitude(), location.getLongitude(),
|
||||
point.getLatitude(), point.getLongitude());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (gpxWaypoints != null){
|
||||
p.goAhead(gpxDistance, null).andArriveAtWayPoint(gpxWaypoints).play();
|
||||
}
|
||||
if (favoritesWaypoints != null) {
|
||||
p.goAhead(favDistance, null).andArriveAtFavorite(favoritesWaypoints).play();
|
||||
}
|
||||
if (poiWaypoints != null){
|
||||
p.goAhead(poiDistance, null).andArriveAtPoiWaypoint(poiWaypoints).play();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public class WaypointDialogHelper {
|
|||
closePointDialog = vi.inflate(R.layout.waypoint_reached, null);
|
||||
}
|
||||
|
||||
createView(closePointDialog, point);
|
||||
updatePointInfoView(closePointDialog, point);
|
||||
closePointDialog.setBackgroundColor(mapActivity.getResources().getColor(R.color.color_black));
|
||||
((TextView)closePointDialog.findViewById(R.id.waypoint_text)).setTextColor(Color.WHITE);
|
||||
View all = closePointDialog.findViewById(R.id.all_points);
|
||||
|
@ -91,7 +91,7 @@ public class WaypointDialogHelper {
|
|||
}
|
||||
}
|
||||
|
||||
private void createView(View localView, final LocationPoint point) {
|
||||
private void updatePointInfoView(View localView, final LocationPoint point) {
|
||||
TextView text = (TextView) localView.findViewById(R.id.waypoint_text);
|
||||
text.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -102,7 +102,6 @@ public class WaypointDialogHelper {
|
|||
|
||||
((ImageView) localView.findViewById(R.id.waypoint_icon)).setImageDrawable(FavoriteImageDrawable.getOrCreate(mapActivity, point.getColor()));
|
||||
Location lastKnownMapLocation = app.getLocationProvider().getLastKnownLocation();
|
||||
// LatLon lastKnownMapLocation = app.getSettings().getLastKnownMapLocation();
|
||||
String distance;
|
||||
if (lastKnownMapLocation != null) {
|
||||
int dist = (int) (MapUtils.getDistance(point.getLatitude(), point.getLongitude(),
|
||||
|
@ -202,7 +201,7 @@ public class WaypointDialogHelper {
|
|||
ll.setMargins(vl / 4, vl / 4, vl / 4, vl / 4);
|
||||
v.findViewById(R.id.waypoint_icon).setLayoutParams(ll);
|
||||
}
|
||||
createView(v, getItem(position));
|
||||
updatePointInfoView(v, getItem(position));
|
||||
TextView text = (TextView) v.findViewById(R.id.waypoint_text);
|
||||
text.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
|
|
@ -184,7 +184,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
(zoomControls.getHeight() + zoomControls.getTotalVerticalMargin()): 0;
|
||||
rulerControl.setVerticalMargin(vmargin);
|
||||
checkVisibilityAndDraw(true, rulerControl, canvas, tileBox, nightMode);
|
||||
waypointDialogHelper.updateDialog();
|
||||
}
|
||||
|
||||
private void updatextColor(int textColor, int shadowColor, MapControls... mc) {
|
||||
|
|
|
@ -87,7 +87,9 @@ public class MapRouteInfoControl extends MapControls implements IRouteInformatio
|
|||
public void showControls(FrameLayout parent) {
|
||||
infoButton = addButton(parent, R.string.route_info, R.drawable.map_btn_signpost);
|
||||
if (showDialog){
|
||||
if (getTargets().getPointToNavigate() == null){
|
||||
showDialog();
|
||||
}
|
||||
showDialog = false;
|
||||
}
|
||||
controlVisible = true;
|
||||
|
|
|
@ -28,7 +28,11 @@ public class CommandBuilder {
|
|||
protected static final String C_AND_ARRIVE_INTERMEDIATE = "and_arrive_intermediate"; //$NON-NLS-1$
|
||||
protected static final String C_REACHED_INTERMEDIATE = "reached_intermediate"; //$NON-NLS-1$
|
||||
protected static final String C_AND_ARRIVE_WAYPOINT = "and_arrive_waypoint"; //$NON-NLS-1$
|
||||
protected static final String C_AND_ARRIVE_FAVORITE = "and_arrive_favorite"; //$NON-NLS-1$
|
||||
protected static final String C_AND_ARRIVE_POI_WAYPOINT = "and_arrive_poi"; //$NON-NLS-1$
|
||||
protected static final String C_REACHED_WAYPOINT = "reached_waypoint"; //$NON-NLS-1$
|
||||
protected static final String C_REACHED_FAVORITE = "reached_favorite"; //$NON-NLS-1$
|
||||
protected static final String C_REACHED_POI = "reached_poi"; //$NON-NLS-1$
|
||||
protected static final String C_THEN = "then"; //$NON-NLS-1$
|
||||
protected static final String C_SPEAD_ALARM = "speed_alarm"; //$NON-NLS-1$
|
||||
protected static final String C_ATTENTION = "attention"; //$NON-NLS-1$
|
||||
|
@ -191,8 +195,12 @@ public class CommandBuilder {
|
|||
return addCommand(C_REACHED_WAYPOINT, name);
|
||||
}
|
||||
|
||||
public CommandBuilder andArriveAtWayPoint(String name){
|
||||
return addCommand(C_AND_ARRIVE_WAYPOINT, name);
|
||||
public CommandBuilder arrivedAtFavorite(String name) {
|
||||
return addCommand(C_REACHED_FAVORITE, name);
|
||||
}
|
||||
|
||||
public CommandBuilder arrivedAtPoi(String name) {
|
||||
return addCommand(C_REACHED_POI, name);
|
||||
}
|
||||
|
||||
public CommandBuilder bearLeft(Term streetName){
|
||||
|
@ -223,8 +231,6 @@ public class CommandBuilder {
|
|||
return alt(prepareStruct(C_ROUTE_RECALC, dist, time), prepareStruct(C_ROUTE_RECALC, dist));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void play(){
|
||||
this.commandPlayer.playCommands(this);
|
||||
}
|
||||
|
@ -234,8 +240,15 @@ public class CommandBuilder {
|
|||
return this.commandPlayer.execute(listStruct);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public CommandBuilder andArriveAtWayPoint(String name){
|
||||
return addCommand(C_AND_ARRIVE_WAYPOINT, name);
|
||||
}
|
||||
|
||||
public CommandBuilder andArriveAtPoiWaypoint(String name) {
|
||||
return addCommand(C_AND_ARRIVE_POI_WAYPOINT, name);
|
||||
}
|
||||
|
||||
public CommandBuilder andArriveAtFavorite(String name) {
|
||||
return addCommand(C_AND_ARRIVE_FAVORITE, name);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue