Add allowed speed widget

This commit is contained in:
Victor Shcherb 2012-11-27 22:58:50 +01:00
parent 76683cc913
commit 5862b0e57e
9 changed files with 38 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View file

@ -9,6 +9,7 @@
1. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 1. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
--> -->
<string name="map_widget_max_speed">Allowed speed</string>
<string name="route_descr_lat_lon">Lat %1$.3f, lon %2$.3f</string> <string name="route_descr_lat_lon">Lat %1$.3f, lon %2$.3f</string>
<string name="route_descr_current_location">Current position</string> <string name="route_descr_current_location">Current position</string>
<string name="route_descr_from_to">From : %1$s\nTo : %2$s</string> <string name="route_descr_from_to">From : %1$s\nTo : %2$s</string>

View file

@ -513,6 +513,10 @@ public class RoutingHelper {
return i; return i;
} }
public synchronized float getCurrentMaxSpeed() {
return route.getCurrentMaxSpeed();
}
public synchronized AlarmInfo getMostImportantAlarm(MetricsConstants mc, boolean showCameras){ public synchronized AlarmInfo getMostImportantAlarm(MetricsConstants mc, boolean showCameras){
float mxspeed = route.getCurrentMaxSpeed(); float mxspeed = route.getCurrentMaxSpeed();
AlarmInfo speedAlarm = null; AlarmInfo speedAlarm = null;
@ -574,7 +578,6 @@ public class RoutingHelper {
private class RouteRecalculationThread extends Thread { private class RouteRecalculationThread extends Thread {
private boolean interrupted = false;
private final RouteCalculationParams params; private final RouteCalculationParams params;
public RouteRecalculationThread(String name, RouteCalculationParams params) { public RouteRecalculationThread(String name, RouteCalculationParams params) {

View file

@ -247,6 +247,8 @@ public class MapInfoLayer extends OsmandMapLayer {
mapInfoControls.registerSideWidget(time, R.drawable.widget_time, R.string.map_widget_time, "time",false, all, none, 10); mapInfoControls.registerSideWidget(time, R.drawable.widget_time, R.string.map_widget_time, "time",false, all, none, 10);
TextInfoControl speed = ric.createSpeedControl(map, paintText, paintSubText); TextInfoControl speed = ric.createSpeedControl(map, paintText, paintSubText);
mapInfoControls.registerSideWidget(speed, R.drawable.widget_speed, R.string.map_widget_speed, "speed", false, all, none, 15); mapInfoControls.registerSideWidget(speed, R.drawable.widget_speed, R.string.map_widget_speed, "speed", false, all, none, 15);
TextInfoControl maxspeed = ric.createMaxSpeedControl(map, paintText, paintSubText);
mapInfoControls.registerSideWidget(maxspeed, R.drawable.widget_max_speed, R.string.map_widget_max_speed, "max_speed", false, none, none, 18);
TextInfoControl alt = ric.createAltitudeControl(map, paintText, paintSubText); TextInfoControl alt = ric.createAltitudeControl(map, paintText, paintSubText);
mapInfoControls.registerSideWidget(alt, R.drawable.widget_altitude, R.string.map_widget_altitude, "altitude", false, EnumSet.of(ApplicationMode.PEDESTRIAN), none, 20); mapInfoControls.registerSideWidget(alt, R.drawable.widget_altitude, R.string.map_widget_altitude, "altitude", false, EnumSet.of(ApplicationMode.PEDESTRIAN), none, 20);

View file

@ -307,6 +307,37 @@ public class RouteInfoControls {
return altitudeControl; return altitudeControl;
} }
protected TextInfoControl createMaxSpeedControl(final MapActivity map, Paint paintText, Paint paintSubText) {
final RoutingHelper rh = map.getRoutingHelper();
final TextInfoControl speedControl = new TextInfoControl(map, 3, paintText, paintSubText) {
private float cachedSpeed = 0;
@Override
public boolean updateInfo() {
float mx = rh == null ? 0 : rh.getCurrentMaxSpeed();
if (cachedSpeed != mx) {
cachedSpeed = mx;
if (cachedSpeed == 0) {
setText(null, null);
} else {
String ds = OsmAndFormatter.getFormattedSpeed(cachedSpeed, map);
int ls = ds.lastIndexOf(' ');
if (ls == -1) {
setText(ds, null);
} else {
setText(ds.substring(0, ls), ds.substring(ls + 1));
}
}
return true;
}
return false;
}
};
speedControl.setImageDrawable(map.getResources().getDrawable(R.drawable.info_max_speed));
speedControl.setText(null, null);
return speedControl;
}
protected TextInfoControl createSpeedControl(final MapActivity map, Paint paintText, Paint paintSubText) { protected TextInfoControl createSpeedControl(final MapActivity map, Paint paintText, Paint paintSubText) {
final TextInfoControl speedControl = new TextInfoControl(map, 3, paintText, paintSubText) { final TextInfoControl speedControl = new TextInfoControl(map, 3, paintText, paintSubText) {
private float cachedSpeed = 0; private float cachedSpeed = 0;