Add allowed speed widget
This commit is contained in:
parent
76683cc913
commit
5862b0e57e
9 changed files with 38 additions and 1 deletions
BIN
OsmAnd/res/drawable-hdpi/info_max_speed.png
Normal file
BIN
OsmAnd/res/drawable-hdpi/info_max_speed.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4 KiB |
BIN
OsmAnd/res/drawable-hdpi/widget_max_speed.png
Normal file
BIN
OsmAnd/res/drawable-hdpi/widget_max_speed.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
BIN
OsmAnd/res/drawable-large/widget_max_speed.png
Normal file
BIN
OsmAnd/res/drawable-large/widget_max_speed.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
BIN
OsmAnd/res/drawable-mdpi/info_max_speed.png
Normal file
BIN
OsmAnd/res/drawable-mdpi/info_max_speed.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
BIN
OsmAnd/res/drawable-mdpi/widget_max_speed.png
Normal file
BIN
OsmAnd/res/drawable-mdpi/widget_max_speed.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
|
@ -9,6 +9,7 @@
|
|||
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
|
||||
-->
|
||||
<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_current_location">Current position</string>
|
||||
<string name="route_descr_from_to">From : %1$s\nTo : %2$s</string>
|
||||
|
|
|
@ -513,6 +513,10 @@ public class RoutingHelper {
|
|||
return i;
|
||||
}
|
||||
|
||||
public synchronized float getCurrentMaxSpeed() {
|
||||
return route.getCurrentMaxSpeed();
|
||||
}
|
||||
|
||||
public synchronized AlarmInfo getMostImportantAlarm(MetricsConstants mc, boolean showCameras){
|
||||
float mxspeed = route.getCurrentMaxSpeed();
|
||||
AlarmInfo speedAlarm = null;
|
||||
|
@ -574,7 +578,6 @@ public class RoutingHelper {
|
|||
|
||||
private class RouteRecalculationThread extends Thread {
|
||||
|
||||
private boolean interrupted = false;
|
||||
private final RouteCalculationParams params;
|
||||
|
||||
public RouteRecalculationThread(String name, RouteCalculationParams params) {
|
||||
|
|
|
@ -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);
|
||||
TextInfoControl speed = ric.createSpeedControl(map, paintText, paintSubText);
|
||||
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);
|
||||
mapInfoControls.registerSideWidget(alt, R.drawable.widget_altitude, R.string.map_widget_altitude, "altitude", false, EnumSet.of(ApplicationMode.PEDESTRIAN), none, 20);
|
||||
|
||||
|
|
|
@ -307,6 +307,37 @@ public class RouteInfoControls {
|
|||
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) {
|
||||
final TextInfoControl speedControl = new TextInfoControl(map, 3, paintText, paintSubText) {
|
||||
private float cachedSpeed = 0;
|
||||
|
|
Loading…
Reference in a new issue