android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>
+ <RelativeLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" >
+
+ <TextView
+ android:id="@+id/direction_label"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/direction_label" />
+
+ <TextView
+ android:id="@+id/direction_value"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true"
+ android:layout_below="@+id/direction_label"
+ android:text=""
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+ </RelativeLayout>
+
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall" />
</RelativeLayout>
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
<string name="speed_label">Speed</string>
<string name="accel_label">Acceleration</string>
<string name="bearing_label">Bearing</string>
+ <string name="direction_label">Direction</string>
<string name="elevation_label">Elevation</string>
<string name="range_label">Range</string>
<string name="distance_label">Distance</string>
}
return false;
}
+
+ static String direction(AltosGreatCircle from_receiver,
+ Location receiver) {
+ if (!receiver.hasBearing())
+ return null;
+
+ float bearing = receiver.getBearing();
+ float heading = (float) from_receiver.bearing - bearing;
+
+ while (heading <= -180.0f)
+ heading += 360.0f;
+ while (heading > 180.0f)
+ heading -= 360.0f;
+
+ int iheading = (int) (heading + 0.5f);
+
+ if (-1 < iheading && iheading < 1)
+ return "ahead";
+ else if (iheading < -179 || 179 < iheading)
+ return "backwards";
+ else if (iheading < 0)
+ return String.format("left %d", -iheading);
+ else
+ return String.format("right %d", iheading);
+ }
}
public class TabRecover extends AltosDroidTab {
private TextView mBearingView;
+ private TextView mDirectionView;
private TextView mDistanceView;
private TextView mTargetLatitudeView;
private TextView mTargetLongitudeView;
View v = inflater.inflate(R.layout.tab_recover, container, false);
mBearingView = (TextView) v.findViewById(R.id.bearing_value);
+ mDirectionView = (TextView) v.findViewById(R.id.direction_value);
mDistanceView = (TextView) v.findViewById(R.id.distance_value);
mTargetLatitudeView = (TextView) v.findViewById(R.id.target_lat_value);
mTargetLongitudeView = (TextView) v.findViewById(R.id.target_lon_value);
if (from_receiver != null) {
mBearingView.setText(String.format("%3.0f°", from_receiver.bearing));
set_value(mDistanceView, AltosConvert.distance, 6, from_receiver.distance);
+ String direction = AltosDroid.direction(from_receiver, receiver);
+ if (direction == null)
+ mDirectionView.setText("");
+ else
+ mDirectionView.setText(direction);
}
if (state != null && state.gps != null) {
mTargetLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));