Fix announce issues
This commit is contained in:
parent
163b486651
commit
f5dc2a5462
3 changed files with 24 additions and 21 deletions
|
@ -21,6 +21,7 @@
|
|||
android:layout_gravity="center_vertical"
|
||||
android:textColor="@color/distance_color"
|
||||
android:maxLines="2"
|
||||
android:textStyle="bold"
|
||||
android:textSize="15sp"></TextView>
|
||||
|
||||
<TextView android:id="@+id/waypoint_text"
|
||||
|
|
|
@ -44,7 +44,7 @@ public class WaypointHelper {
|
|||
private static final int ANNOUNCED_DONE = 2;
|
||||
|
||||
private int searchDeviationRadius = 500;
|
||||
private static final int LONG_ANNOUNCE_RADIUS = 500;
|
||||
private static final int LONG_ANNOUNCE_RADIUS = 700;
|
||||
private static final int SHORT_ANNOUNCE_RADIUS = 150;
|
||||
|
||||
OsmandApplication app;
|
||||
|
@ -169,12 +169,12 @@ public class WaypointHelper {
|
|||
LocationPointWrapper lwp = lp.get(kIterator);
|
||||
if (lp.get(kIterator).routeIndex < route.getCurrentRoute()) {
|
||||
// skip
|
||||
} else if (route.getDistanceToPoint(lwp.routeIndex) > LONG_ANNOUNCE_RADIUS) {
|
||||
} else if (route.getDistanceToPoint(lwp.routeIndex) > LONG_ANNOUNCE_RADIUS / 2) {
|
||||
break;
|
||||
} else {
|
||||
AlarmInfo inf = (AlarmInfo) lwp.point;
|
||||
int d = route.getDistanceToPoint(lwp.routeIndex);
|
||||
if (d > 250) {
|
||||
if (d > LONG_ANNOUNCE_RADIUS) {
|
||||
break;
|
||||
}
|
||||
float speed = lastProjection != null && lastProjection.hasSpeed() ? lastProjection.getSpeed() : 0;
|
||||
|
@ -287,8 +287,8 @@ public class WaypointHelper {
|
|||
if (lastKnownLocation != null && app.getRoutingHelper().isFollowingMode()) {
|
||||
for (int type = 0; type < locationPoints.size(); type++) {
|
||||
int currentRoute = route.getCurrentRoute();
|
||||
List<LocationPoint> approachPoints = new ArrayList<LocationPoint>();
|
||||
List<LocationPoint> announcePoints = new ArrayList<LocationPoint>();
|
||||
List<LocationPointWrapper> approachPoints = new ArrayList<LocationPointWrapper>();
|
||||
List<LocationPointWrapper> announcePoints = new ArrayList<LocationPointWrapper>();
|
||||
List<LocationPointWrapper> lp = locationPoints.get(type);
|
||||
if(lp != null) {
|
||||
int kIterator = pointsProgress.get(type);
|
||||
|
@ -303,18 +303,18 @@ public class WaypointHelper {
|
|||
}
|
||||
LocationPoint point = lwp.point;
|
||||
double d1 = MapUtils.getDistance(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude(),
|
||||
point.getLatitude(), point.getLongitude());
|
||||
point.getLatitude(), point.getLongitude()) + lwp.getDeviationDistance();
|
||||
Integer state = locationPointsStates.get(point);
|
||||
if (state != null && state.intValue() == ANNOUNCED_ONCE
|
||||
&& getVoiceRouter()
|
||||
.isDistanceLess(lastKnownLocation.getSpeed(), d1, SHORT_ANNOUNCE_RADIUS)) {
|
||||
locationPointsStates.put(point, ANNOUNCED_DONE);
|
||||
announcePoints.add(point);
|
||||
announcePoints.add(lwp);
|
||||
} else if ((state == null || state == NOT_ANNOUNCED)
|
||||
&& getVoiceRouter()
|
||||
.isDistanceLess(lastKnownLocation.getSpeed(), d1, LONG_ANNOUNCE_RADIUS)) {
|
||||
locationPointsStates.put(point, ANNOUNCED_ONCE);
|
||||
approachPoints.add(point);
|
||||
approachPoints.add(lwp);
|
||||
}
|
||||
kIterator++;
|
||||
}
|
||||
|
@ -336,8 +336,8 @@ public class WaypointHelper {
|
|||
getVoiceRouter().approachPoi(lastKnownLocation, announcePoints);
|
||||
} else if (type == ALARMS) {
|
||||
EnumSet<AlarmInfoType> ait = EnumSet.noneOf(AlarmInfoType.class);
|
||||
for(LocationPoint pw : announcePoints) {
|
||||
ait.add(((AlarmInfo) pw).getType());
|
||||
for(LocationPointWrapper pw : announcePoints) {
|
||||
ait.add(((AlarmInfo) pw.point).getType());
|
||||
}
|
||||
for(AlarmInfoType t : ait) {
|
||||
app.getRoutingHelper().getVoiceRouter().announceAlarm(t);
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.osmand.binary.RouteDataObject;
|
|||
import net.osmand.data.LocationPoint;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
|
||||
import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
|
||||
import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo;
|
||||
import net.osmand.plus.voice.AbstractPrologCommandPlayer;
|
||||
|
@ -219,7 +220,7 @@ public class VoiceRouter {
|
|||
}
|
||||
}
|
||||
|
||||
public void announceWaypoint(List<LocationPoint> points) {
|
||||
public void announceWaypoint(List<LocationPointWrapper> points) {
|
||||
CommandBuilder p = getNewCommandPlayerToPlay();
|
||||
if (p == null){
|
||||
return;
|
||||
|
@ -228,7 +229,7 @@ public class VoiceRouter {
|
|||
p.arrivedAtWayPoint(text).play();
|
||||
}
|
||||
|
||||
public void announceFavorite(List<LocationPoint> points) {
|
||||
public void announceFavorite(List<LocationPointWrapper> points) {
|
||||
CommandBuilder p = getNewCommandPlayerToPlay();
|
||||
if (p == null){
|
||||
return;
|
||||
|
@ -237,7 +238,7 @@ public class VoiceRouter {
|
|||
p.arrivedAtFavorite(text).play();
|
||||
}
|
||||
|
||||
public void announcePoi(List<LocationPoint> points) {
|
||||
public void announcePoi(List<LocationPointWrapper> points) {
|
||||
CommandBuilder p = getNewCommandPlayerToPlay();
|
||||
if (p == null){
|
||||
return;
|
||||
|
@ -246,7 +247,7 @@ public class VoiceRouter {
|
|||
p.arrivedAtPoi(text).play();
|
||||
}
|
||||
|
||||
public void approachFavorite(Location location, List<LocationPoint> points){
|
||||
public void approachFavorite(Location location, List<LocationPointWrapper> points){
|
||||
CommandBuilder p = getNewCommandPlayerToPlay();
|
||||
if (p == null){
|
||||
return;
|
||||
|
@ -256,7 +257,7 @@ public class VoiceRouter {
|
|||
p.goAhead(dist[0], null).andArriveAtFavorite(text).play();
|
||||
}
|
||||
|
||||
public void approachWaypoint(Location location, List<LocationPoint> points){
|
||||
public void approachWaypoint(Location location, List<LocationPointWrapper> points){
|
||||
CommandBuilder p = getNewCommandPlayerToPlay();
|
||||
if (p == null){
|
||||
return;
|
||||
|
@ -266,7 +267,7 @@ public class VoiceRouter {
|
|||
p.goAhead(dist[0], null).andArriveAtWayPoint(text).play();
|
||||
}
|
||||
|
||||
public void approachPoi(Location location, List<LocationPoint> points){
|
||||
public void approachPoi(Location location, List<LocationPointWrapper> points){
|
||||
CommandBuilder p = getNewCommandPlayerToPlay();
|
||||
if (p == null){
|
||||
return;
|
||||
|
@ -276,19 +277,20 @@ public class VoiceRouter {
|
|||
p.goAhead(dist[0], null).andArriveAtPoiWaypoint(text).play();
|
||||
}
|
||||
|
||||
protected String getText(Location location, List<LocationPoint> points, double[] dist) {
|
||||
protected String getText(Location location, List<LocationPointWrapper> points, double[] dist) {
|
||||
String text = "";
|
||||
for (LocationPoint point : points) {
|
||||
for (LocationPointWrapper point : points) {
|
||||
// need to calculate distance to nearest point
|
||||
if (text.length() == 0) {
|
||||
if (location != null && dist != null) {
|
||||
dist[0] = MapUtils.getDistance(location.getLatitude(), location.getLongitude(),
|
||||
point.getLatitude(), point.getLongitude());
|
||||
dist[0] = point.getDeviationDistance() +
|
||||
MapUtils.getDistance(location.getLatitude(), location.getLongitude(),
|
||||
point.getPoint().getLatitude(), point.getPoint().getLongitude());
|
||||
}
|
||||
} else {
|
||||
text += ", ";
|
||||
}
|
||||
text += point.getName(router.getApplication());
|
||||
text += point.getPoint().getName(router.getApplication());
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue