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_1.AltosState;
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;
30 public class TabLanded extends Fragment implements AltosDroidTab {
31 AltosDroid mAltosDroid;
33 private TextView mBearingView;
34 private TextView mDistanceView;
35 private TextView mLatitudeView;
36 private TextView mLongitudeView;
37 private TextView mMaxHeightView;
38 private TextView mMaxSpeedView;
39 private TextView mMaxAccelView;
43 public void onAttach(Activity activity) {
44 super.onAttach(activity);
45 mAltosDroid = (AltosDroid) activity;
46 mAltosDroid.registerTab(this);
50 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
51 View v = inflater.inflate(R.layout.tab_landed, container, false);
53 mBearingView = (TextView) v.findViewById(R.id.bearing_value);
54 mDistanceView = (TextView) v.findViewById(R.id.distance_value);
55 mLatitudeView = (TextView) v.findViewById(R.id.lat_value);
56 mLongitudeView = (TextView) v.findViewById(R.id.lon_value);
57 mMaxHeightView = (TextView) v.findViewById(R.id.max_height_value);
58 mMaxSpeedView = (TextView) v.findViewById(R.id.max_speed_value);
59 mMaxAccelView = (TextView) v.findViewById(R.id.max_accel_value);
65 public void onDestroy() {
67 mAltosDroid.unregisterTab(this);
71 public void update_ui(AltosState state) {
72 if (state.from_pad != null) {
73 mBearingView.setText(String.format("%3.0f°", state.from_pad.bearing));
74 mDistanceView.setText(String.format("%6.0f m", state.from_pad.distance));
76 mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
77 mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E"));
78 mMaxHeightView.setText(String.format("%6.0f m", state.max_height));
79 mMaxAccelView.setText(String.format("%6.0f m/s²", state.max_acceleration));
80 mMaxSpeedView.setText(String.format("%6.0f m/s", state.max_speed()));