Added total time/distance to PT card

This commit is contained in:
crimean 2019-03-15 21:46:47 +03:00
parent e9febc4932
commit 9756e119e9
3 changed files with 15 additions and 8 deletions

View file

@ -10,7 +10,9 @@
- For wording and consistency, please note https://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience
Thx - Hardy
--> <string name="save_poi_value_exceed_length">Value of tag \"%s\" cannot exceed 255 chars. \nPlease edit it before continue.</string>
-->
<string name="shared_string_walk">Walk</string>
<string name="save_poi_value_exceed_length">Value of tag \"%s\" cannot exceed 255 chars. \nPlease edit it before continue.</string>
<string name="save_poi_value_exceed_length_title">Length of \"%s\" value</string>
<string name="public_transport_warning_descr_blog">Learn more about how OsmAnd calculates routes in our blog.</string>
<string name="public_transport_warning_title">Public transport navigation is currently in beta testing, errors and inaccuracies may occur.</string>

View file

@ -736,7 +736,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment implements P
spannable.append(OsmAndFormatter.getFormattedDuration(walkTime, app)).append(" ");
spannable.setSpan(new CustomTypefaceSpan(typeface), startIndex, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
startIndex = spannable.length();
spannable.append(getString(R.string.on_foot)).append(", ").append(OsmAndFormatter.getFormattedDistance((float) walkDist, app));
spannable.append(getString(R.string.shared_string_walk)).append(", ").append(OsmAndFormatter.getFormattedDistance((float) walkDist, app));
spannable.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.secondary_text_dark : R.color.secondary_text_light)), startIndex, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
buildRowDivider(view, true);
@ -829,7 +829,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment implements P
walkTime = 60;
}
startTime[0] += walkTime;
SpannableStringBuilder title = new SpannableStringBuilder(Algorithms.capitalizeFirstLetter(getString(R.string.on_foot)));
SpannableStringBuilder title = new SpannableStringBuilder(Algorithms.capitalizeFirstLetter(getString(R.string.shared_string_walk)));
title.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.secondary_text_dark : R.color.secondary_text_light)), 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
int startIndex = title.length();
title.append(" ").append(OsmAndFormatter.getFormattedDuration(walkTime, app));
@ -926,7 +926,7 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment implements P
spannable.append(OsmAndFormatter.getFormattedDuration(walkTime, app)).append(" ");
spannable.setSpan(new CustomTypefaceSpan(typeface), startIndex, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
startIndex = spannable.length();
spannable.append(getString(R.string.on_foot)).append(", ").append(OsmAndFormatter.getFormattedDistance((float) walkDist, app));
spannable.append(getString(R.string.shared_string_walk)).append(", ").append(OsmAndFormatter.getFormattedDistance((float) walkDist, app));
spannable.setSpan(new ForegroundColorSpan(ContextCompat.getColor(app, nightMode ? R.color.secondary_text_dark : R.color.secondary_text_light)), startIndex, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
buildWalkRow(infoContainer, spannable, imagesContainer, new OnClickListener() {

View file

@ -174,15 +174,20 @@ public class PublicTransportCard extends BaseCard {
private SpannableString getSecondLineDescrSpan(List<TransportRouteResultSegment> segments) {
TransportRoutingHelper transportRoutingHelper = app.getTransportRoutingHelper();
Typeface typeface = FontCache.getRobotoMedium(app);
String travelTimeStr = OsmAndFormatter.getFormattedDuration((int) routeResult.getTravelTime(), app);
int walkTimeReal = transportRoutingHelper.getWalkingTime(segments);
int walkTimePT = (int) routeResult.getWalkTime();
String walkTimeStr = OsmAndFormatter.getFormattedDuration(walkTimeReal > 0 ? walkTimeReal : walkTimePT, app);
int walkTime = walkTimeReal > 0 ? walkTimeReal : walkTimePT;
String walkTimeStr = OsmAndFormatter.getFormattedDuration(walkTime, app);
int walkDistanceReal = transportRoutingHelper.getWalkingDistance(segments);
int walkDistancePT = (int) routeResult.getWalkDist();
String walkDistanceStr = OsmAndFormatter.getFormattedDistance(walkDistanceReal > 0 ? walkDistanceReal : walkDistancePT, app);
int walkDistance = walkDistanceReal > 0 ? walkDistanceReal : walkDistancePT;
String walkDistanceStr = OsmAndFormatter.getFormattedDistance(walkDistance, app);
int travelTime = (int) routeResult.getTravelTime() + walkTime;
String travelTimeStr = OsmAndFormatter.getFormattedDuration(travelTime, app);
int travelDist = (int) routeResult.getTravelDist() + walkDistance;
String travelDistStr = OsmAndFormatter.getFormattedDistance(travelDist, app);
String secondLine = travelTimeStr + "" + app.getString(R.string.on_foot) + " " + walkTimeStr + ", " + walkDistanceStr;
String secondLine = travelTimeStr + ", " + travelDistStr + "" + app.getString(R.string.shared_string_walk) + " " + walkTimeStr + ", " + walkDistanceStr;
SpannableString secondLineDesc = new SpannableString(secondLine);