altosdroid: Display direction in map view
[fw/altos] / altosdroid / src / org / altusmetrum / AltosDroid / TabMap.java
index 0ee202a46da696b35529e8dddfe9b4424697e6e4..81b6fe5433d442dbea661f1b47296b7fbf766283 100644 (file)
@@ -37,6 +37,7 @@ public class TabMap extends AltosDroidTab {
        AltosLatLon     here;
 
        private TextView mDistanceView;
        AltosLatLon     here;
 
        private TextView mDistanceView;
+       private TextView mBearingLabel;
        private TextView mBearingView;
        private TextView mTargetLatitudeView;
        private TextView mTargetLongitudeView;
        private TextView mBearingView;
        private TextView mTargetLatitudeView;
        private TextView mTargetLongitudeView;
@@ -63,6 +64,7 @@ public class TabMap extends AltosDroidTab {
                int map_source = AltosDroidPreferences.map_source();
 
                mDistanceView  = (TextView)view.findViewById(R.id.distance_value);
                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);
                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);
@@ -99,8 +101,19 @@ public class TabMap extends AltosDroidTab {
 
        public void show(TelemetryState telem_state, AltosState state, AltosGreatCircle from_receiver, Location receiver) {
                if (from_receiver != null) {
 
        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);
                        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) {
                }
 
                if (state != null) {