User suggestion
This commit is contained in:
parent
27002fd152
commit
be85c4dcd6
1 changed files with 16 additions and 19 deletions
|
@ -210,24 +210,21 @@ public class AnnounceTimeDistances {
|
||||||
return (int) (dist - voicePromptDelayTimeSec * speed);
|
return (int) (dist - voicePromptDelayTimeSec * speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void appendTurnDesc(SpannableStringBuilder builder, String name, int dist, String meter, String second) {
|
private void appendTurnDesc(OsmandApplication app, SpannableStringBuilder builder, String name, int dist, String meter, String second) {
|
||||||
appendTurnDesc(builder, name, dist, DEFAULT_SPEED, meter, second);
|
appendTurnDesc(app, builder, name, dist, DEFAULT_SPEED, meter, second);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void appendTurnDesc(SpannableStringBuilder builder, String name, int dist, float speed, String meter, String second) {
|
private void appendTurnDesc(OsmandApplication app, SpannableStringBuilder builder, String name, int dist, float speed, String meter, String second) {
|
||||||
int minDist = (dist / 5) * 5;
|
int minDist = (dist / 5) * 5;
|
||||||
int time = (int) (dist / speed);
|
int time = (int) (dist / speed);
|
||||||
if (time > 15) {
|
if (time > 15) {
|
||||||
// round to 5
|
// round to 5
|
||||||
time = (time / 5) * 5;
|
time = (time / 5) * 5;
|
||||||
}
|
}
|
||||||
boolean isLeftToRight = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_LTR;
|
String distStr = String.format("\n%s: %d - %d %s", name, minDist, minDist + 5, meter);
|
||||||
if (isLeftToRight) {
|
String timeStr = String.format("%d %s.", time, second);
|
||||||
builder.append(String.format("\n%s: %d - %d %s, %d %s.", name, minDist, minDist + 5, meter, time, second));
|
builder.append(app.getString(R.string.ltr_or_rtl_combine_via_comma, distStr, timeStr));
|
||||||
} else {
|
|
||||||
builder.append(String.format("\n%s: %s %d, %s %d - %d.", name, second, time, meter, minDist, minDist + 5));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Spannable getIntervalsDescription(OsmandApplication app) {
|
public Spannable getIntervalsDescription(OsmandApplication app) {
|
||||||
|
@ -253,35 +250,35 @@ public class AnnounceTimeDistances {
|
||||||
builder.append(turn);
|
builder.append(turn);
|
||||||
makeBold(builder, turn);
|
makeBold(builder, turn);
|
||||||
if (PREPARE_DISTANCE_END <= PREPARE_DISTANCE) {
|
if (PREPARE_DISTANCE_END <= PREPARE_DISTANCE) {
|
||||||
appendTurnDesc(builder, prepare, PREPARE_DISTANCE, meter, second);
|
appendTurnDesc(app, builder, prepare, PREPARE_DISTANCE, meter, second);
|
||||||
}
|
}
|
||||||
if (PREPARE_LONG_DISTANCE_END <= PREPARE_LONG_DISTANCE) {
|
if (PREPARE_LONG_DISTANCE_END <= PREPARE_LONG_DISTANCE) {
|
||||||
appendTurnDesc(builder, longPrepare, PREPARE_LONG_DISTANCE, meter, second);
|
appendTurnDesc(app, builder, longPrepare, PREPARE_LONG_DISTANCE, meter, second);
|
||||||
}
|
}
|
||||||
appendTurnDesc(builder, approach, TURN_IN_DISTANCE, meter, second);
|
appendTurnDesc(app, builder, approach, TURN_IN_DISTANCE, meter, second);
|
||||||
appendTurnDesc(builder, passing, TURN_NOW_DISTANCE, TURN_NOW_SPEED, meter, second);
|
appendTurnDesc(app, builder, passing, TURN_NOW_DISTANCE, TURN_NOW_SPEED, meter, second);
|
||||||
|
|
||||||
// Arrive at destination
|
// Arrive at destination
|
||||||
appendTurnDesc(builder, arrive, (int) (getArrivalDistance()), meter, second);
|
appendTurnDesc(app, builder, arrive, (int) (getArrivalDistance()), meter, second);
|
||||||
makeBoldFormatted(builder, arrive);
|
makeBoldFormatted(builder, arrive);
|
||||||
|
|
||||||
// Off-route
|
// Off-route
|
||||||
if (getOffRouteDistance() > 0) {
|
if (getOffRouteDistance() > 0) {
|
||||||
appendTurnDesc(builder, offRoute, (int) getOffRouteDistance(), meter, second);
|
appendTurnDesc(app, builder, offRoute, (int) getOffRouteDistance(), meter, second);
|
||||||
makeBoldFormatted(builder, offRoute);
|
makeBoldFormatted(builder, offRoute);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Traffic warnings
|
// Traffic warnings
|
||||||
builder.append(traffic);
|
builder.append(traffic);
|
||||||
makeBold(builder, traffic);
|
makeBold(builder, traffic);
|
||||||
appendTurnDesc(builder, approach, LONG_ALARM_ANNOUNCE_RADIUS, meter, second);
|
appendTurnDesc(app, builder, approach, LONG_ALARM_ANNOUNCE_RADIUS, meter, second);
|
||||||
appendTurnDesc(builder, passing, SHORT_ALARM_ANNOUNCE_RADIUS, meter, second);
|
appendTurnDesc(app, builder, passing, SHORT_ALARM_ANNOUNCE_RADIUS, meter, second);
|
||||||
|
|
||||||
// Waypoint / Favorite / POI
|
// Waypoint / Favorite / POI
|
||||||
builder.append(point);
|
builder.append(point);
|
||||||
makeBold(builder, point);
|
makeBold(builder, point);
|
||||||
appendTurnDesc(builder, approach, LONG_PNT_ANNOUNCE_RADIUS, meter, second);
|
appendTurnDesc(app, builder, approach, LONG_PNT_ANNOUNCE_RADIUS, meter, second);
|
||||||
appendTurnDesc(builder, passing, SHORT_PNT_ANNOUNCE_RADIUS, meter, second);
|
appendTurnDesc(app, builder, passing, SHORT_PNT_ANNOUNCE_RADIUS, meter, second);
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue