Merge pull request #11013 from osmandapp/fix_night_mode_in_road_info

Fix text color in night mode for road info
This commit is contained in:
Vitaliy 2021-02-28 19:49:52 +02:00 committed by GitHub
commit 07c371f472
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 13 deletions

View file

@ -22,10 +22,10 @@ import net.osmand.AndroidUtils;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.helpers.CustomBarChartRenderer; import net.osmand.plus.helpers.CustomBarChartRenderer;
import net.osmand.router.RouteStatisticsHelper;
import net.osmand.router.RouteStatisticsHelper.RouteStatistics;
import net.osmand.router.RouteStatisticsHelper.RouteSegmentAttribute; import net.osmand.router.RouteStatisticsHelper.RouteSegmentAttribute;
import net.osmand.router.RouteStatisticsHelper.RouteStatistics;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import java.util.ArrayList; import java.util.ArrayList;
@ -140,7 +140,7 @@ public class CustomGraphAdapter extends BaseGraphAdapter<HorizontalBarChart, Bar
private void attachLegend(List<RouteSegmentAttribute> list, private void attachLegend(List<RouteSegmentAttribute> list,
String propertyNameToFullSpan) { String propertyNameToFullSpan) {
OsmandApplication app = getMyApplication(); OsmandApplication app = getMyApplication();
LayoutInflater inflater = LayoutInflater.from(app); LayoutInflater inflater = UiUtilities.getInflater(app, isNightMode());
for (RouteSegmentAttribute segment : list) { for (RouteSegmentAttribute segment : list) {
View view = inflater.inflate(R.layout.route_details_legend, legendContainer, false); View view = inflater.inflate(R.layout.route_details_legend, legendContainer, false);
int segmentColor = segment.getColor(); int segmentColor = segment.getColor();

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);