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; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19 package org.altusmetrum.AltosDroid;
21 import org.altusmetrum.altoslib_13.*;
23 import android.os.Bundle;
24 import android.view.LayoutInflater;
25 import android.view.View;
26 import android.view.ViewGroup;
27 import android.widget.TextView;
28 import android.location.Location;
30 public class TabRecover extends AltosDroidTab {
31 private TextView mBearingView;
32 private TextView mDirectionView;
33 private TextView mDistanceView;
34 private TextView mTargetLatitudeView;
35 private TextView mTargetLongitudeView;
36 private TextView mReceiverLatitudeView;
37 private TextView mReceiverLongitudeView;
38 private TextView mMaxHeightView;
39 private TextView mMaxSpeedView;
40 private TextView mMaxAccelView;
43 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
44 View v = inflater.inflate(R.layout.tab_recover, container, false);
46 mBearingView = (TextView) v.findViewById(R.id.bearing_value);
47 mDirectionView = (TextView) v.findViewById(R.id.direction_value);
48 mDistanceView = (TextView) v.findViewById(R.id.distance_value);
49 mTargetLatitudeView = (TextView) v.findViewById(R.id.target_lat_value);
50 mTargetLongitudeView = (TextView) v.findViewById(R.id.target_lon_value);
51 mReceiverLatitudeView = (TextView) v.findViewById(R.id.receiver_lat_value);
52 mReceiverLongitudeView = (TextView) v.findViewById(R.id.receiver_lon_value);
53 mMaxHeightView = (TextView) v.findViewById(R.id.max_height_value);
54 mMaxSpeedView = (TextView) v.findViewById(R.id.max_speed_value);
55 mMaxAccelView = (TextView) v.findViewById(R.id.max_accel_value);
60 public String tab_name() { return AltosDroid.tab_recover_name; }
62 public void show(TelemetryState telem_state, AltosState state, AltosGreatCircle from_receiver, Location receiver) {
63 if (from_receiver != null) {
64 mBearingView.setText(String.format("%1.0f°", from_receiver.bearing));
65 set_value(mDistanceView, AltosConvert.distance, 1, from_receiver.distance);
66 String direction = AltosDroid.direction(from_receiver, receiver);
67 if (direction == null)
68 mDirectionView.setText("");
70 mDirectionView.setText(direction);
72 if (state != null && state.gps != null) {
73 mTargetLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
74 mTargetLongitudeView.setText(AltosDroid.pos(state.gps.lon, "E", "W"));
77 if (receiver != null) {
78 mReceiverLatitudeView.setText(AltosDroid.pos(receiver.getLatitude(), "N", "S"));
79 mReceiverLongitudeView.setText(AltosDroid.pos(receiver.getLongitude(), "E", "W"));
83 set_value(mMaxHeightView, AltosConvert.height, 1, state.max_height());
84 set_value(mMaxAccelView, AltosConvert.accel, 1, state.max_acceleration());
85 set_value(mMaxSpeedView, AltosConvert.speed, 1, state.max_speed());