static String direction(AltosGreatCircle from_receiver,
Location receiver) {
+ if (from_receiver == null)
+ return null;
+
+ if (receiver == null)
+ return null;
+
if (!receiver.hasBearing())
return null;
else if (iheading < -179 || 179 < iheading)
return "backwards";
else if (iheading < 0)
- return String.format("left %d", -iheading);
+ return String.format("left %d°", -iheading);
else
- return String.format("right %d", iheading);
+ return String.format("right %d°", iheading);
}
}
AltosLatLon here;
private TextView mDistanceView;
+ private TextView mBearingLabel;
private TextView mBearingView;
private TextView mTargetLatitudeView;
private TextView mTargetLongitudeView;
int map_source = AltosDroidPreferences.map_source();
mDistanceView = (TextView)view.findViewById(R.id.distance_value);
+ mBearingLabel = (TextView)view.findViewById(R.id.bearing_label);
mBearingView = (TextView)view.findViewById(R.id.bearing_value);
mTargetLatitudeView = (TextView)view.findViewById(R.id.target_lat_value);
mTargetLongitudeView = (TextView)view.findViewById(R.id.target_lon_value);
public void show(TelemetryState telem_state, AltosState state, AltosGreatCircle from_receiver, Location receiver) {
if (from_receiver != null) {
- mBearingView.setText(String.format("%3.0f°", from_receiver.bearing));
+ String direction = AltosDroid.direction(from_receiver, receiver);
+ if (direction != null) {
+ mBearingLabel.setText("Direction");
+ mBearingView.setText(direction);
+ } else {
+ mBearingLabel.setText("Bearing");
+ mBearingView.setText(String.format("%3.0f°", from_receiver.bearing));
+ }
set_value(mDistanceView, AltosConvert.distance, 6, from_receiver.distance);
+ } else {
+ mBearingLabel.setText("Bearing");
+ mBearingView.setText("");
+ set_value(mDistanceView, AltosConvert.distance, 6, AltosLib.MISSING);
}
if (state != null) {