Fix bearing: added M for magnetic, move widget under 1st marker widget

This commit is contained in:
Alexey Kulish 2016-04-20 11:25:25 +03:00
parent 8be44e1e87
commit e85dbc0deb
2 changed files with 15 additions and 10 deletions

View file

@ -129,14 +129,17 @@ public class MapInfoLayer extends OsmandMapLayer {
registerSideWidget(dist, R.drawable.ic_action_target, R.string.map_widget_distance, "distance", false, 5); registerSideWidget(dist, R.drawable.ic_action_target, R.string.map_widget_distance, "distance", false, 5);
TextInfoWidget time = ric.createTimeControl(map); TextInfoWidget time = ric.createTimeControl(map);
registerSideWidget(time, new TimeControlWidgetState(app), "time", false, 10); registerSideWidget(time, new TimeControlWidgetState(app), "time", false, 10);
TextInfoWidget bearing = ric.createBearingControl(map);
registerSideWidget(bearing, new BearingWidgetState(app), "bearing", false, 11);
if (settings.USE_MAP_MARKERS.get()) { if (settings.USE_MAP_MARKERS.get()) {
TextInfoWidget marker = mwf.createMapMarkerControl(map, true); TextInfoWidget marker = mwf.createMapMarkerControl(map, true);
registerSideWidget(marker, R.drawable.ic_action_flag_dark, R.string.map_marker_1st, "map_marker_1st", false, 12); registerSideWidget(marker, R.drawable.ic_action_flag_dark, R.string.map_marker_1st, "map_marker_1st", false, 12);
TextInfoWidget bearing = ric.createBearingControl(map);
registerSideWidget(bearing, new BearingWidgetState(app), "bearing", false, 13);
TextInfoWidget marker2nd = mwf.createMapMarkerControl(map, false); TextInfoWidget marker2nd = mwf.createMapMarkerControl(map, false);
registerSideWidget(marker2nd, R.drawable.ic_action_flag_dark, R.string.map_marker_2nd, "map_marker_2nd", false, 13); registerSideWidget(marker2nd, R.drawable.ic_action_flag_dark, R.string.map_marker_2nd, "map_marker_2nd", false, 14);
} else {
TextInfoWidget bearing = ric.createBearingControl(map);
registerSideWidget(bearing, new BearingWidgetState(app), "bearing", false, 13);
} }
TextInfoWidget speed = ric.createSpeedControl(map); TextInfoWidget speed = ric.createSpeedControl(map);

View file

@ -622,13 +622,13 @@ public class RouteInfoWidgetsFactory {
@Override @Override
public boolean updateInfo(DrawSettings drawSettings) { public boolean updateInfo(DrawSettings drawSettings) {
boolean relative = showRelativeBearing.get(); boolean relative = showRelativeBearing.get();
setIcons(relative ? relativeBearingResId : bearingResId, relative ? relativeBearingNightResId : bearingNightResId); boolean modeChanged = setIcons(relative ? relativeBearingResId : bearingResId, relative ? relativeBearingNightResId : bearingNightResId);
setContentTitle(relative ? R.string.map_widget_bearing : R.string.map_widget_magnetic_bearing); setContentTitle(relative ? R.string.map_widget_bearing : R.string.map_widget_magnetic_bearing);
int b = getBearing(relative); int b = getBearing(relative);
if (distChanged(cachedDegrees, b)) { if (degreesChanged(cachedDegrees, b) || modeChanged) {
cachedDegrees = b; cachedDegrees = b;
if (b != -1000) { if (b != -1000) {
setText(String.valueOf(b) + "°", null); setText(String.valueOf(b) + "°" + (relative ? "" : " M"), null);
} else { } else {
setText(null, null); setText(null, null);
} }
@ -688,9 +688,7 @@ public class RouteInfoWidgetsFactory {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
showRelativeBearing.set(!showRelativeBearing.get()); showRelativeBearing.set(!showRelativeBearing.get());
bearingControl.setIcons(!showRelativeBearing.get() ? bearingResId : relativeBearingResId, map.refreshMap();
!showRelativeBearing.get() ? bearingNightResId : relativeBearingNightResId);
map.getMapView().refreshMap();
} }
}); });
@ -1198,12 +1196,16 @@ public class RouteInfoWidgetsFactory {
public static boolean distChanged(int oldDist, int dist){ public static boolean distChanged(int oldDist, int dist){
if(oldDist != 0 && Math.abs(oldDist - dist) < 10){ if (oldDist != 0 && Math.abs(oldDist - dist) < 10) {
return false; return false;
} }
return true; return true;
} }
public static boolean degreesChanged(int oldDegrees, int degrees){
return Math.abs(oldDegrees - degrees) >= 1;
}
public AlarmWidget createAlarmInfoControl(OsmandApplication app, MapActivity map) { public AlarmWidget createAlarmInfoControl(OsmandApplication app, MapActivity map) {
return new AlarmWidget(app, map); return new AlarmWidget(app, map);
} }