Add custom colors for route details
This commit is contained in:
parent
349e8018de
commit
9440f61360
5 changed files with 546 additions and 555 deletions
File diff suppressed because it is too large
Load diff
|
@ -11,6 +11,49 @@
|
|||
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">
|
||||
• 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
|
||||
|
|
|
@ -96,6 +96,7 @@ import net.osmand.plus.views.TurnPathHelper;
|
|||
import net.osmand.plus.views.controls.HorizontalSwipeConfirm;
|
||||
import net.osmand.plus.widgets.TextViewEx;
|
||||
import net.osmand.plus.widgets.style.CustomTypefaceSpan;
|
||||
import net.osmand.render.RenderingRulesStorage;
|
||||
import net.osmand.router.RouteSegmentResult;
|
||||
import net.osmand.router.RouteStatistics;
|
||||
import net.osmand.router.RouteStatistics.Incline;
|
||||
|
@ -107,6 +108,7 @@ import java.io.FileOutputStream;
|
|||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Field;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
@ -496,7 +498,8 @@ public class ShowRouteInfoDialogFragment extends BaseOsmAndFragment {
|
|||
elevationDataSet = statisticCard.getElevationDataSet();
|
||||
List<RouteSegmentResult> route = routingHelper.getRoute().getOriginalRoute();
|
||||
if (route != null) {
|
||||
RouteStatistics routeStatistics = RouteStatistics.newRouteStatistic(route);
|
||||
RenderingRulesStorage rrs = app.getRendererRegistry().getCurrentSelectedRenderer();
|
||||
RouteStatistics routeStatistics = RouteStatistics.newRouteStatistic(route,rrs,nightMode);
|
||||
GPXUtilities.GPXTrackAnalysis analysis = gpx.getAnalysis(0);
|
||||
|
||||
RouteInfoCard routeClassCard = new RouteInfoCard(mapActivity, routeStatistics.getRouteClassStatistic(), analysis);
|
||||
|
|
|
@ -9,7 +9,6 @@ import android.content.Context;
|
|||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
|
@ -61,18 +60,18 @@ import com.github.mikephil.charting.utils.MPPointF;
|
|||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.Elevation;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.GPXUtilities.Speed;
|
||||
import net.osmand.GPXUtilities.TrkSegment;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -98,6 +97,8 @@ import net.osmand.router.RouteStatistics;
|
|||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DateFormat;
|
||||
import java.text.MessageFormat;
|
||||
|
@ -108,7 +109,6 @@ import java.util.Date;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import static com.github.mikephil.charting.components.XAxis.XAxisPosition.BOTTOM;
|
||||
import static net.osmand.binary.RouteDataObject.HEIGHT_UNDEFINED;
|
||||
|
@ -1268,8 +1268,7 @@ public class GpxUiHelper {
|
|||
@NonNull HorizontalBarChart mChart,
|
||||
@NonNull RouteStatistics.Statistics<E> routeStatistics,
|
||||
@NonNull GPXTrackAnalysis analysis,
|
||||
boolean useRightAxis,
|
||||
boolean nightMode) {
|
||||
boolean useRightAxis) {
|
||||
|
||||
XAxis xAxis = mChart.getXAxis();
|
||||
xAxis.setEnabled(false);
|
||||
|
@ -1290,7 +1289,7 @@ public class GpxUiHelper {
|
|||
for (int i = 0; i < stacks.length; i++) {
|
||||
RouteStatistics.RouteSegmentAttribute segment = segments.get(i);
|
||||
stacks[i] = segment.getDistance() / divX;
|
||||
colors[i] = getColorFromRouteSegmentAttribute(app, segment, nightMode);
|
||||
colors[i] = segment.getColor();
|
||||
}
|
||||
entries.add(new BarEntry(0, stacks));
|
||||
BarDataSet barDataSet = new BarDataSet(entries, "");
|
||||
|
@ -1304,31 +1303,6 @@ public class GpxUiHelper {
|
|||
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,
|
||||
@NonNull LineChart mChart,
|
||||
@NonNull GPXTrackAnalysis analysis,
|
||||
|
|
|
@ -18,15 +18,12 @@ import net.osmand.GPXUtilities;
|
|||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SettingsNavigationActivity;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.router.RouteStatistics;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class RouteInfoCard extends BaseCard {
|
||||
|
||||
|
@ -49,7 +46,7 @@ public class RouteInfoCard extends BaseCard {
|
|||
updateHeader();
|
||||
final HorizontalBarChart chart = (HorizontalBarChart) view.findViewById(R.id.chart);
|
||||
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);
|
||||
LinearLayout container = view.findViewById(R.id.route_items);
|
||||
attachLegend(container, routeStatistics);
|
||||
|
@ -82,9 +79,11 @@ public class RouteInfoCard extends BaseCard {
|
|||
Map<E, RouteStatistics.RouteSegmentAttribute<E>> partition = routeStatistics.getPartition();
|
||||
for (E key : partition.keySet()) {
|
||||
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);
|
||||
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);
|
||||
AndroidUtils.setTextPrimaryColor(app, legend, nightMode);
|
||||
|
|
Loading…
Reference in a new issue