Skip to content

Commit

Permalink
osmandapp#19095 Android Auto: show time and distance to next intermed…
Browse files Browse the repository at this point in the history
…iate (if any)
  • Loading branch information
ntruchsess committed Feb 19, 2024
1 parent 28c9679 commit c727161
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 10 additions & 2 deletions OsmAnd/src/net/osmand/plus/auto/TripHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,16 @@ public Pair<Destination, TravelEstimate> getDestination(@NonNull TargetPoint poi
destBuilder.setImage(new CarIcon.Builder(IconCompat.createWithResource(app,
R.drawable.ic_action_point_destination)).build());

Distance distance = getDistance(app, routingHelper.getLeftDistance());
int leftTimeSec = routingHelper.getLeftTime();
int leftTimeSec;
int leftDistance;
if (routingHelper.hasIntermediatePointsToPass()) {
leftTimeSec = routingHelper.getLeftTimeNextIntermediate();
leftDistance = routingHelper.getLeftDistanceNextIntermediate();
} else {
leftTimeSec = routingHelper.getLeftTime();
leftDistance = routingHelper.getLeftDistance();
}
Distance distance = getDistance(app, leftDistance);
DateTimeWithZone dateTime = DateTimeWithZone.create(System.currentTimeMillis() + leftTimeSec * 1000L, TimeZone.getDefault());
TravelEstimate.Builder travelEstimateBuilder = new TravelEstimate.Builder(distance, dateTime);
travelEstimateBuilder.setRemainingTimeSeconds(leftTimeSec);
Expand Down
4 changes: 4 additions & 0 deletions OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,10 @@ public int getLeftTimeNextIntermediate() {
return route.getLeftTimeToNextIntermediate(lastFixedLocation);
}

public boolean hasIntermediatePointsToPass() {
return route.getIntermediatePointsToPass() > 0;
}

public OsmandSettings getSettings() {
return settings;
}
Expand Down

0 comments on commit c727161

Please sign in to comment.