Add map widget to show arrival time at first intermediate point
This commit is contained in:
parent
063a2f7154
commit
b79de3c9c7
7 changed files with 57 additions and 13 deletions
|
@ -1591,6 +1591,7 @@
|
|||
<string name="layer_hillshade">Hillshade layer</string>
|
||||
<string name="map_widget_gps_info">GPS info</string>
|
||||
<string name="access_arrival_time">Arrival time</string>
|
||||
<string name="access_intermediate_arrival_time">Intermediate arrival time</string>
|
||||
<string name="item_checked">checked</string>
|
||||
<string name="item_unchecked">unchecked</string>
|
||||
<string name="prefer_motorways">Prefer motorways</string>
|
||||
|
@ -1693,6 +1694,7 @@
|
|||
<string name="arrived_at_intermediate_point">You have arrived at your intermediate destination</string>
|
||||
<string name="context_menu_item_intermediate_point">Add as intermediate destination</string>
|
||||
<string name="map_widget_intermediate_distance">Intermediate destination</string>
|
||||
<string name="map_widget_intermediate_time">Intermediate time</string>
|
||||
<string name="ending_point_too_far">Ending point too far from nearest road.</string>
|
||||
<string name="add_tag">Add Tag</string>
|
||||
<string name="btn_advanced_mode">Advanced Mode…</string>
|
||||
|
|
|
@ -79,6 +79,7 @@ public class ApplicationMode {
|
|||
regWidgetVisibility("intermediate_distance", all);
|
||||
regWidgetVisibility("distance", all);
|
||||
regWidgetVisibility("time", all);
|
||||
regWidgetVisibility("intermediate_time", all);
|
||||
regWidgetVisibility("speed", exceptPedestrianAndDefault);
|
||||
regWidgetVisibility("max_speed", CAR);
|
||||
regWidgetVisibility("altitude", pedestrianBicycle);
|
||||
|
@ -86,6 +87,7 @@ public class ApplicationMode {
|
|||
regWidgetAvailability("intermediate_distance", all);
|
||||
regWidgetAvailability("distance", all);
|
||||
regWidgetAvailability("time", all);
|
||||
regWidgetAvailability("intermediate_time", all);
|
||||
regWidgetAvailability("map_marker_1st", none);
|
||||
regWidgetAvailability("map_marker_2nd", none);
|
||||
|
||||
|
|
|
@ -3013,6 +3013,9 @@ public class OsmandSettings {
|
|||
public final OsmandPreference<Boolean> SHOW_ARRIVAL_TIME_OTHERWISE_EXPECTED_TIME =
|
||||
new BooleanPreference("show_arrival_time", true).makeGlobal();
|
||||
|
||||
public final OsmandPreference<Boolean> SHOW_INTERMEDIATE_ARRIVAL_TIME_OTHERWISE_EXPECTED_TIME =
|
||||
new BooleanPreference("show_intermediate_arrival_time", true).makeGlobal();
|
||||
|
||||
public final OsmandPreference<Boolean> SHOW_RELATIVE_BEARING_OTHERWISE_REGULAR_BEARING =
|
||||
new BooleanPreference("show_relative_bearing", true).makeGlobal();
|
||||
|
||||
|
|
|
@ -992,6 +992,15 @@ public class RouteCalculationResult {
|
|||
return time;
|
||||
}
|
||||
|
||||
public int getLeftTimeToNextIntermediate(Location fromLoc){
|
||||
|
||||
if(nextIntermediate >= intermediatePoints.length ){
|
||||
return 0;
|
||||
} else {
|
||||
return getLeftTime(fromLoc) - directions.get(intermediatePoints[nextIntermediate]).afterLeftTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class NextDirectionInfo {
|
||||
public RouteDirectionInfo directionInfo;
|
||||
|
|
|
@ -700,6 +700,10 @@ public class RoutingHelper {
|
|||
return route.getLeftTime(lastFixedLocation);
|
||||
}
|
||||
|
||||
public int getLeftTimeNextIntermediate() {
|
||||
return route.getLeftTimeToNextIntermediate(lastFixedLocation);
|
||||
}
|
||||
|
||||
public OsmandSettings getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
|
|
@ -163,17 +163,20 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
// priorityOrder: 10s navigation-related, 20s position-related, 30s recording- and other plugin-related, 40s general device information, 50s debugging-purpose
|
||||
TextInfoWidget intermediateDist = ric.createIntermediateDistanceControl(map);
|
||||
registerSideWidget(intermediateDist, R.drawable.ic_action_intermediate, R.string.map_widget_intermediate_distance, "intermediate_distance", false, 13);
|
||||
TextInfoWidget intermediateTime = ric.createTimeControl(map, true);
|
||||
registerSideWidget(intermediateTime, new TimeControlWidgetState(app, true), "intermediate_time", false, 14);
|
||||
TextInfoWidget dist = ric.createDistanceControl(map);
|
||||
registerSideWidget(dist, R.drawable.ic_action_target, R.string.map_widget_distance, "distance", false, 14);
|
||||
TextInfoWidget time = ric.createTimeControl(map);
|
||||
registerSideWidget(time, new TimeControlWidgetState(app), "time", false, 15);
|
||||
registerSideWidget(dist, R.drawable.ic_action_target, R.string.map_widget_distance, "distance", false, 15);
|
||||
TextInfoWidget time = ric.createTimeControl(map, false);
|
||||
registerSideWidget(time, new TimeControlWidgetState(app, false), "time", false, 16);
|
||||
|
||||
|
||||
TextInfoWidget marker = mwf.createMapMarkerControl(map, true);
|
||||
registerSideWidget(marker, R.drawable.ic_action_flag_dark, R.string.map_marker_1st, "map_marker_1st", false, 16);
|
||||
registerSideWidget(marker, R.drawable.ic_action_flag_dark, R.string.map_marker_1st, "map_marker_1st", false, 17);
|
||||
TextInfoWidget bearing = ric.createBearingControl(map);
|
||||
registerSideWidget(bearing, new BearingWidgetState(app), "bearing", false, 17);
|
||||
registerSideWidget(bearing, new BearingWidgetState(app), "bearing", false, 18);
|
||||
TextInfoWidget marker2nd = mwf.createMapMarkerControl(map, false);
|
||||
registerSideWidget(marker2nd, R.drawable.ic_action_flag_dark, R.string.map_marker_2nd, "map_marker_2nd", false, 18);
|
||||
registerSideWidget(marker2nd, R.drawable.ic_action_flag_dark, R.string.map_marker_2nd, "map_marker_2nd", false, 19);
|
||||
|
||||
TextInfoWidget speed = ric.createSpeedControl(map);
|
||||
registerSideWidget(speed, R.drawable.ic_action_speed, R.string.map_widget_speed, "speed", false, 20);
|
||||
|
|
|
@ -198,16 +198,27 @@ public class RouteInfoWidgetsFactory {
|
|||
public static final int TIME_CONTROL_WIDGET_STATE_TIME_TO_GO = R.id.time_control_widget_state_time_to_go;
|
||||
|
||||
private final OsmandPreference<Boolean> showArrival;
|
||||
private final boolean intermediate;
|
||||
|
||||
public TimeControlWidgetState(OsmandApplication ctx) {
|
||||
public TimeControlWidgetState(OsmandApplication ctx, boolean intermediate) {
|
||||
super(ctx);
|
||||
if (intermediate) {
|
||||
showArrival = ctx.getSettings().SHOW_INTERMEDIATE_ARRIVAL_TIME_OTHERWISE_EXPECTED_TIME;
|
||||
} else {
|
||||
showArrival = ctx.getSettings().SHOW_ARRIVAL_TIME_OTHERWISE_EXPECTED_TIME;
|
||||
}
|
||||
|
||||
this.intermediate = intermediate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMenuTitleId() {
|
||||
if (intermediate) {
|
||||
return showArrival.get() ? R.string.access_intermediate_arrival_time : R.string.map_widget_intermediate_time;
|
||||
} else {
|
||||
return showArrival.get() ? R.string.access_arrival_time : R.string.map_widget_time;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMenuIconId() {
|
||||
|
@ -221,8 +232,12 @@ public class RouteInfoWidgetsFactory {
|
|||
|
||||
@Override
|
||||
public int[] getMenuTitleIds() {
|
||||
if (intermediate) {
|
||||
return new int[]{R.string.access_intermediate_arrival_time, R.string.map_widget_intermediate_time};
|
||||
} else {
|
||||
return new int[]{R.string.access_arrival_time, R.string.map_widget_time};
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getMenuIconIds() {
|
||||
|
@ -240,14 +255,15 @@ public class RouteInfoWidgetsFactory {
|
|||
}
|
||||
}
|
||||
|
||||
public TextInfoWidget createTimeControl(final MapActivity map){
|
||||
public TextInfoWidget createTimeControl(final MapActivity map, final boolean intermediate){
|
||||
final RoutingHelper routingHelper = map.getRoutingHelper();
|
||||
final int time = R.drawable.widget_time_day;
|
||||
final int timeN = R.drawable.widget_time_night;
|
||||
final int timeToGo = R.drawable.widget_time_to_distance_day;
|
||||
final int timeToGoN = R.drawable.widget_time_to_distance_night;
|
||||
final OsmandApplication ctx = map.getMyApplication();
|
||||
final OsmandPreference<Boolean> showArrival = ctx.getSettings().SHOW_ARRIVAL_TIME_OTHERWISE_EXPECTED_TIME;
|
||||
final OsmandPreference<Boolean> showArrival = intermediate?ctx.getSettings().SHOW_INTERMEDIATE_ARRIVAL_TIME_OTHERWISE_EXPECTED_TIME
|
||||
:ctx.getSettings().SHOW_ARRIVAL_TIME_OTHERWISE_EXPECTED_TIME;
|
||||
final TextInfoWidget leftTimeControl = new TextInfoWidget(map) {
|
||||
private long cachedLeftTime = 0;
|
||||
|
||||
|
@ -257,7 +273,12 @@ public class RouteInfoWidgetsFactory {
|
|||
int time = 0;
|
||||
if (routingHelper != null && routingHelper.isRouteCalculated()) {
|
||||
//boolean followingMode = routingHelper.isFollowingMode();
|
||||
if (intermediate) {
|
||||
time = routingHelper.getLeftTimeNextIntermediate();
|
||||
} else {
|
||||
time = routingHelper.getLeftTime();
|
||||
}
|
||||
|
||||
if (time != 0) {
|
||||
if (/*followingMode && */showArrival.get()) {
|
||||
long toFindTime = time * 1000 + System.currentTimeMillis();
|
||||
|
|
Loading…
Reference in a new issue