Merge pull request #6663 from osmandapp/Fix_6613

Fix_6613
This commit is contained in:
Alexey 2019-03-12 12:39:09 +03:00 committed by GitHub
commit d0f4378b0c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 561 additions and 551 deletions

View file

@ -11,6 +11,49 @@
Thx - Hardy Thx - Hardy
--> -->
<string name="rendering_attr_surface_unpaved_name">Unpaved</string>
<string name="rendering_attr_surface_sand_name">Sand</string>
<string name="rendering_attr_surface_grass_name">Grass</string>
<string name="rendering_attr_surface_grass_paver_name">Grass paver</string>
<string name="rendering_attr_surface_ground_name">Ground</string>
<string name="rendering_attr_surface_dirt_name">Dirt</string>
<string name="rendering_attr_surface_mud_name">Mud</string>
<string name="rendering_attr_surface_ice_name">Ice</string>
<string name="rendering_attr_surface_salt_name">Salt</string>
<string name="rendering_attr_surface_snow_name">Snow</string>
<string name="rendering_attr_surface_asphalt_name">Asphalt</string>
<string name="rendering_attr_surface_paved_name">Paved</string>
<string name="rendering_attr_surface_concrete_name">Concrete</string>
<string name="rendering_attr_surface_sett_name">Sett</string>
<string name="rendering_attr_surface_cobblestone_name">Cobblestone</string>
<string name="rendering_attr_surface_paving_stones_name">Paving stones</string>
<string name="rendering_attr_surface_pebblestone_name">Pebblestone</string>
<string name="rendering_attr_surface_stone_name">Stone</string>
<string name="rendering_attr_surface_metal_name">Metal</string>
<string name="rendering_attr_surface_wood_name">Wood</string>
<string name="rendering_attr_surface_gravel_name">Gravel</string>
<string name="rendering_attr_surface_fine_gravel_name">Fine gravel</string>
<string name="rendering_attr_surface_compacted_name">Compacted</string>
<string name="rendering_attr_smoothness_excellent_name">Excellent</string>
<string name="rendering_attr_smoothness_good_name">Good</string>
<string name="rendering_attr_smoothness_intermediate_name">Intermediate</string>
<string name="rendering_attr_smoothness_bad_name">Bad</string>
<string name="rendering_attr_smoothness_very_bad_name">Very bad</string>
<string name="rendering_attr_smoothness_horrible_name">Horrible</string>
<string name="rendering_attr_smoothness_very_horrible_name">Very horrible</string>
<string name="rendering_attr_smoothness_impassable_name">Impassable</string>
<string name="rendering_attr_highway_class_motorway_name">Motorway</string>
<string name="rendering_attr_highway_class_state_road_name">State road</string>
<string name="rendering_attr_highway_class_road_name">Road</string>
<string name="rendering_attr_highway_class_street_name">Street</string>
<string name="rendering_attr_highway_class_service_name">Service</string>
<string name="rendering_attr_highway_class_footway_name">Footway</string>
<string name="rendering_attr_highway_class_track_name">Track</string>
<string name="rendering_attr_highway_class_bridleway_name">Bridleway</string>
<string name="rendering_attr_highway_class_steps_name">Steps</string>
<string name="rendering_attr_highway_class_path_name">Path</string>
<string name="rendering_attr_highway_class_cycleway_name">Cycleway</string>
<string name="rendering_attr_undefined_name">Undefined</string>
<string name="release_3_3"> <string name="release_3_3">
• New \'Directions\' screen: Displays Home and Work destination buttons, \'previous route\' shortcut, list of active GPX tracks and markers, search history\n\n • New \'Directions\' screen: Displays Home and Work destination buttons, \'previous route\' shortcut, list of active GPX tracks and markers, search history\n\n
• Additional info under \'Route details\': road types, surface, steepness, smoothness\n\n • Additional info under \'Route details\': road types, surface, steepness, smoothness\n\n

View file

@ -102,6 +102,7 @@ import net.osmand.plus.views.TurnPathHelper;
import net.osmand.plus.views.controls.HorizontalSwipeConfirm; import net.osmand.plus.views.controls.HorizontalSwipeConfirm;
import net.osmand.plus.widgets.TextViewEx; import net.osmand.plus.widgets.TextViewEx;
import net.osmand.plus.widgets.style.CustomTypefaceSpan; import net.osmand.plus.widgets.style.CustomTypefaceSpan;
import net.osmand.render.RenderingRulesStorage;
import net.osmand.router.RouteSegmentResult; import net.osmand.router.RouteSegmentResult;
import net.osmand.router.RouteStatistics; import net.osmand.router.RouteStatistics;
import net.osmand.router.RouteStatistics.Incline; import net.osmand.router.RouteStatistics.Incline;
@ -504,7 +505,9 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
elevationDataSet = statisticCard.getElevationDataSet(); elevationDataSet = statisticCard.getElevationDataSet();
List<RouteSegmentResult> route = routingHelper.getRoute().getOriginalRoute(); List<RouteSegmentResult> route = routingHelper.getRoute().getOriginalRoute();
if (route != null) { if (route != null) {
RouteStatistics routeStatistics = RouteStatistics.newRouteStatistic(route); RenderingRulesStorage currentRenderer = app.getRendererRegistry().getCurrentSelectedRenderer();
RenderingRulesStorage defaultRender = app.getRendererRegistry().defaultRender();
RouteStatistics routeStatistics = RouteStatistics.newRouteStatistic(route, currentRenderer,defaultRender, nightMode);
GPXUtilities.GPXTrackAnalysis analysis = gpx.getAnalysis(0); GPXUtilities.GPXTrackAnalysis analysis = gpx.getAnalysis(0);
RouteInfoCard routeClassCard = new RouteInfoCard(mapActivity, routeStatistics.getRouteClassStatistic(), analysis); RouteInfoCard routeClassCard = new RouteInfoCard(mapActivity, routeStatistics.getRouteClassStatistic(), analysis);

View file

@ -9,7 +9,6 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener; import android.content.DialogInterface.OnClickListener;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
@ -92,7 +91,6 @@ import net.osmand.plus.dialogs.ConfigureMapMenu.GpxAppearanceAdapter;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin; import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.routing.RouteCalculationResult; import net.osmand.plus.routing.RouteCalculationResult;
import net.osmand.render.RenderingRuleProperty; import net.osmand.render.RenderingRuleProperty;
import net.osmand.render.RenderingRuleSearchRequest;
import net.osmand.render.RenderingRulesStorage; import net.osmand.render.RenderingRulesStorage;
import net.osmand.router.RouteStatistics; import net.osmand.router.RouteStatistics;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -1268,8 +1266,7 @@ public class GpxUiHelper {
@NonNull HorizontalBarChart mChart, @NonNull HorizontalBarChart mChart,
@NonNull RouteStatistics.Statistics<E> routeStatistics, @NonNull RouteStatistics.Statistics<E> routeStatistics,
@NonNull GPXTrackAnalysis analysis, @NonNull GPXTrackAnalysis analysis,
boolean useRightAxis, boolean useRightAxis) {
boolean nightMode) {
XAxis xAxis = mChart.getXAxis(); XAxis xAxis = mChart.getXAxis();
xAxis.setEnabled(false); xAxis.setEnabled(false);
@ -1290,7 +1287,7 @@ public class GpxUiHelper {
for (int i = 0; i < stacks.length; i++) { for (int i = 0; i < stacks.length; i++) {
RouteStatistics.RouteSegmentAttribute segment = segments.get(i); RouteStatistics.RouteSegmentAttribute segment = segments.get(i);
stacks[i] = segment.getDistance() / divX; stacks[i] = segment.getDistance() / divX;
colors[i] = getColorFromRouteSegmentAttribute(app, segment, nightMode); colors[i] = segment.getColor();
} }
entries.add(new BarEntry(0, stacks)); entries.add(new BarEntry(0, stacks));
BarDataSet barDataSet = new BarDataSet(entries, ""); BarDataSet barDataSet = new BarDataSet(entries, "");
@ -1304,31 +1301,6 @@ public class GpxUiHelper {
return dataSet; return dataSet;
} }
public static int getColorFromRouteSegmentAttribute(OsmandApplication app, RouteStatistics.RouteSegmentAttribute segment, boolean nightMode) {
String colorAttrName = segment.getColorAttrName();
String colorName = segment.getColorName();
int color = 0;
if (colorName != null) {
try {
color = Color.parseColor(colorName);
} catch (Exception e) {
}
} else if (colorAttrName != null) {
color = GpxUiHelper.getColorFromStyle(app, colorAttrName, nightMode);
}
return color;
}
public static int getColorFromStyle(OsmandApplication app, String colorAttrName, boolean nightMode) {
RenderingRulesStorage rrs = app.getRendererRegistry().getCurrentSelectedRenderer();
RenderingRuleSearchRequest req = new RenderingRuleSearchRequest(rrs);
req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, nightMode);
if (req.searchRenderingAttribute(colorAttrName)) {
return req.getIntPropertyValue(rrs.PROPS.R_ATTR_COLOR_VALUE);
}
return 0;
}
public static OrderedLineDataSet createGPXElevationDataSet(@NonNull OsmandApplication ctx, public static OrderedLineDataSet createGPXElevationDataSet(@NonNull OsmandApplication ctx,
@NonNull LineChart mChart, @NonNull LineChart mChart,
@NonNull GPXTrackAnalysis analysis, @NonNull GPXTrackAnalysis analysis,

View file

@ -18,15 +18,12 @@ import net.osmand.GPXUtilities;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SettingsNavigationActivity;
import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.router.RouteStatistics; import net.osmand.router.RouteStatistics;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
public class RouteInfoCard extends BaseCard { public class RouteInfoCard extends BaseCard {
@ -49,7 +46,7 @@ public class RouteInfoCard extends BaseCard {
updateHeader(); updateHeader();
final HorizontalBarChart chart = (HorizontalBarChart) view.findViewById(R.id.chart); final HorizontalBarChart chart = (HorizontalBarChart) view.findViewById(R.id.chart);
GpxUiHelper.setupHorizontalGPXChart(app, chart, 5, 10, 10, true, nightMode); GpxUiHelper.setupHorizontalGPXChart(app, chart, 5, 10, 10, true, nightMode);
BarData barData = GpxUiHelper.buildStatisticChart(app, chart, routeStatistics, analysis, true, nightMode); BarData barData = GpxUiHelper.buildStatisticChart(app, chart, routeStatistics, analysis, true);
chart.setData(barData); chart.setData(barData);
LinearLayout container = view.findViewById(R.id.route_items); LinearLayout container = view.findViewById(R.id.route_items);
attachLegend(container, routeStatistics); attachLegend(container, routeStatistics);
@ -82,9 +79,11 @@ public class RouteInfoCard extends BaseCard {
Map<E, RouteStatistics.RouteSegmentAttribute<E>> partition = routeStatistics.getPartition(); Map<E, RouteStatistics.RouteSegmentAttribute<E>> partition = routeStatistics.getPartition();
for (E key : partition.keySet()) { for (E key : partition.keySet()) {
RouteStatistics.RouteSegmentAttribute<E> segment = partition.get(key); RouteStatistics.RouteSegmentAttribute<E> segment = partition.get(key);
int color = GpxUiHelper.getColorFromRouteSegmentAttribute(app, segment, nightMode); int color = segment.getColor();
Drawable circle = app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_circle, color); Drawable circle = app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_circle, color);
Spannable text = getSpanLegend(key.toString().toLowerCase(), segment); String propertyName = segment.getPropertyName();
String name = SettingsNavigationActivity.getStringPropertyName(app, propertyName, propertyName.replaceAll("_", " "));
Spannable text = getSpanLegend(name, segment);
TextView legend = new TextView(app); TextView legend = new TextView(app);
AndroidUtils.setTextPrimaryColor(app, legend, nightMode); AndroidUtils.setTextPrimaryColor(app, legend, nightMode);