fix legend text for night mode;

fix duration time for route statistic
This commit is contained in:
Skalii 2021-02-26 01:38:45 +02:00
parent 428327c2cd
commit bb6099d41a
2 changed files with 5 additions and 10 deletions

View file

@ -158,6 +158,7 @@ public class CustomGraphAdapter extends BaseGraphAdapter<HorizontalBarChart, Bar
Spannable text = getSpanLegend(name, segment, selected); Spannable text = getSpanLegend(name, segment, selected);
TextView legend = (TextView) view.findViewById(R.id.legend_text); TextView legend = (TextView) view.findViewById(R.id.legend_text);
legend.setText(text); legend.setText(text);
AndroidUtils.setTextPrimaryColor(app, legend, isNightMode());
legendContainer.addView(view); legendContainer.addView(view);
} }

View file

@ -79,24 +79,18 @@ public class RouteStatisticCard extends BaseCard {
((ImageView) view.findViewById(R.id.time_icon)).setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_time_span)); ((ImageView) view.findViewById(R.id.time_icon)).setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_time_span));
int dist = routingHelper.getLeftDistance(); int dist = routingHelper.getLeftDistance();
int time = routingHelper.getLeftTime();
int hours = time / (60 * 60);
int minutes = (time / 60) % 60;
TextView distanceTv = (TextView) view.findViewById(R.id.distance);
String text = OsmAndFormatter.getFormattedDistance(dist, app); String text = OsmAndFormatter.getFormattedDistance(dist, app);
SpannableStringBuilder distanceStr = new SpannableStringBuilder(text); SpannableStringBuilder distanceStr = new SpannableStringBuilder(text);
int spaceIndex = text.indexOf(" "); int spaceIndex = text.indexOf(" ");
if (spaceIndex != -1) { if (spaceIndex != -1) {
distanceStr.setSpan(new ForegroundColorSpan(getMainFontColor()), 0, spaceIndex, 0); distanceStr.setSpan(new ForegroundColorSpan(getMainFontColor()), 0, spaceIndex, 0);
} }
TextView distanceTv = (TextView) view.findViewById(R.id.distance);
distanceTv.setText(distanceStr); distanceTv.setText(distanceStr);
int time = routingHelper.getLeftTime();
SpannableStringBuilder timeStr = new SpannableStringBuilder(); SpannableStringBuilder timeStr = new SpannableStringBuilder();
if (hours > 0) { timeStr.append(OsmAndFormatter.getFormattedDuration(time, app));
timeStr.append(String.valueOf(hours)).append(" ").append(app.getString(R.string.osmand_parking_hour)).append(" ");
}
if (minutes > 0) {
timeStr.append(String.valueOf(minutes)).append(" ").append(app.getString(R.string.osmand_parking_minute));
}
spaceIndex = timeStr.toString().lastIndexOf(" "); spaceIndex = timeStr.toString().lastIndexOf(" ");
if (spaceIndex != -1) { if (spaceIndex != -1) {
timeStr.setSpan(new ForegroundColorSpan(getMainFontColor()), 0, spaceIndex, 0); timeStr.setSpan(new ForegroundColorSpan(getMainFontColor()), 0, spaceIndex, 0);