2 * Copyright © 2013 Mike Beattie <mike@ethernal.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
18 package org.altusmetrum.AltosDroid;
20 import org.altusmetrum.altoslib_10.*;
22 import android.app.Activity;
23 import android.os.Bundle;
24 import android.support.v4.app.Fragment;
25 import android.view.LayoutInflater;
26 import android.view.View;
27 import android.view.ViewGroup;
28 import android.widget.TextView;
29 import android.location.Location;
31 public class TabRecover extends AltosDroidTab {
32 private TextView mBearingView;
33 private TextView mDirectionView;
34 private TextView mDistanceView;
35 private TextView mTargetLatitudeView;
36 private TextView mTargetLongitudeView;
37 private TextView mReceiverLatitudeView;
38 private TextView mReceiverLongitudeView;
39 private TextView mMaxHeightView;
40 private TextView mMaxSpeedView;
41 private TextView mMaxAccelView;
44 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
45 View v = inflater.inflate(R.layout.tab_recover, container, false);
47 mBearingView = (TextView) v.findViewById(R.id.bearing_value);
48 mDirectionView = (TextView) v.findViewById(R.id.direction_value);
49 mDistanceView = (TextView) v.findViewById(R.id.distance_value);
50 mTargetLatitudeView = (TextView) v.findViewById(R.id.target_lat_value);
51 mTargetLongitudeView = (TextView) v.findViewById(R.id.target_lon_value);
52 mReceiverLatitudeView = (TextView) v.findViewById(R.id.receiver_lat_value);
53 mReceiverLongitudeView = (TextView) v.findViewById(R.id.receiver_lon_value);
54 mMaxHeightView = (TextView) v.findViewById(R.id.max_height_value);
55 mMaxSpeedView = (TextView) v.findViewById(R.id.max_speed_value);
56 mMaxAccelView = (TextView) v.findViewById(R.id.max_accel_value);
61 public String tab_name() { return AltosDroid.tab_recover_name; }
63 public void show(TelemetryState telem_state, AltosState state, AltosGreatCircle from_receiver, Location receiver) {
64 if (from_receiver != null) {
65 mBearingView.setText(String.format("%3.0f°", from_receiver.bearing));
66 set_value(mDistanceView, AltosConvert.distance, 6, from_receiver.distance);
67 String direction = AltosDroid.direction(from_receiver, receiver);
68 if (direction == null)
69 mDirectionView.setText("");
71 mDirectionView.setText(direction);
73 if (state != null && state.gps != null) {
74 mTargetLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
75 mTargetLongitudeView.setText(AltosDroid.pos(state.gps.lon, "E", "W"));
78 if (receiver != null) {
79 mReceiverLatitudeView.setText(AltosDroid.pos(receiver.getLatitude(), "N", "S"));
80 mReceiverLongitudeView.setText(AltosDroid.pos(receiver.getLongitude(), "E", "W"));
84 set_value(mMaxHeightView, AltosConvert.height, 6, state.max_height());
85 set_value(mMaxAccelView, AltosConvert.accel, 6, state.max_acceleration());
86 set_value(mMaxSpeedView, AltosConvert.speed, 6, state.max_speed());