From 2b6768ed32d7be444c49caa40d30b520177bb22a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 22 Jun 2015 20:43:23 -0700 Subject: [PATCH] altosdroid: Switch to four tabs (pad/flight/recover/map) Ascent and descent were almost the same; no reason to have both. Signed-off-by: Keith Packard --- altosdroid/res/layout/tab_ascent.xml | 299 ------------------ .../{tab_descent.xml => tab_flight.xml} | 52 +++ .../{tab_landed.xml => tab_recover.xml} | 0 .../altusmetrum/AltosDroid/AltosDroid.java | 18 +- .../AltosDroid/PreloadMapActivity.java | 3 + .../org/altusmetrum/AltosDroid/TabAscent.java | 101 ------ .../altusmetrum/AltosDroid/TabDescent.java | 106 ------- .../org/altusmetrum/AltosDroid/TabFlight.java | 134 ++++++++ .../{TabLanded.java => TabRecover.java} | 6 +- 9 files changed, 199 insertions(+), 520 deletions(-) delete mode 100644 altosdroid/res/layout/tab_ascent.xml rename altosdroid/res/layout/{tab_descent.xml => tab_flight.xml} (87%) rename altosdroid/res/layout/{tab_landed.xml => tab_recover.xml} (100%) delete mode 100644 altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java delete mode 100644 altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java create mode 100644 altosdroid/src/org/altusmetrum/AltosDroid/TabFlight.java rename altosdroid/src/org/altusmetrum/AltosDroid/{TabLanded.java => TabRecover.java} (94%) diff --git a/altosdroid/res/layout/tab_ascent.xml b/altosdroid/res/layout/tab_ascent.xml deleted file mode 100644 index b21ec426..00000000 --- a/altosdroid/res/layout/tab_ascent.xml +++ /dev/null @@ -1,299 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/altosdroid/res/layout/tab_descent.xml b/altosdroid/res/layout/tab_flight.xml similarity index 87% rename from altosdroid/res/layout/tab_descent.xml rename to altosdroid/res/layout/tab_flight.xml index 9e1fc820..4fa026ca 100644 --- a/altosdroid/res/layout/tab_descent.xml +++ b/altosdroid/res/layout/tab_flight.xml @@ -72,6 +72,58 @@ + + + + + + + + + + + + + + + + + + - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -package org.altusmetrum.AltosDroid; - -import org.altusmetrum.altoslib_7.*; - -import android.app.Activity; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; -import android.location.Location; - -public class TabAscent extends AltosDroidTab { - private TextView mHeightView; - private TextView mMaxHeightView; - private TextView mSpeedView; - private TextView mMaxSpeedView; - private TextView mAccelView; - private TextView mMaxAccelView; - private TextView mLatitudeView; - private TextView mLongitudeView; - private TextView mApogeeVoltageView; - private GoNoGoLights mApogeeLights; - private TextView mMainVoltageView; - private GoNoGoLights mMainLights; - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View v = inflater.inflate(R.layout.tab_ascent, container, false); - - mHeightView = (TextView) v.findViewById(R.id.height_value); - mMaxHeightView = (TextView) v.findViewById(R.id.max_height_value); - mSpeedView = (TextView) v.findViewById(R.id.speed_value); - mMaxSpeedView = (TextView) v.findViewById(R.id.max_speed_value); - mAccelView = (TextView) v.findViewById(R.id.accel_value); - mMaxAccelView = (TextView) v.findViewById(R.id.max_accel_value); - mLatitudeView = (TextView) v.findViewById(R.id.lat_value); - mLongitudeView = (TextView) v.findViewById(R.id.lon_value); - - mApogeeVoltageView = (TextView) v.findViewById(R.id.apogee_voltage_value); - mApogeeLights = new GoNoGoLights((ImageView) v.findViewById(R.id.apogee_redled), - (ImageView) v.findViewById(R.id.apogee_greenled), - getResources()); - - mMainVoltageView = (TextView) v.findViewById(R.id.main_voltage_value); - mMainLights = new GoNoGoLights((ImageView) v.findViewById(R.id.main_redled), - (ImageView) v.findViewById(R.id.main_greenled), - getResources()); - - return v; - } - - public String tab_name() { - return "ascent"; - } - - public void show(TelemetryState telem_state, AltosState state, AltosGreatCircle from_receiver, Location receiver) { - if (state != null) { - set_value(mHeightView, AltosConvert.height, 6, state.height()); - set_value(mHeightView, AltosConvert.height, 6, state.height()); - set_value(mMaxHeightView, AltosConvert.height, 6, state.max_height()); - set_value(mSpeedView, AltosConvert.speed, 6, state.speed()); - set_value(mMaxSpeedView, AltosConvert.speed, 6, state.max_speed()); - set_value(mAccelView, AltosConvert.accel, 6, state.acceleration()); - set_value(mMaxAccelView, AltosConvert.accel, 6, state.max_acceleration()); - - if (state.gps != null) { - mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S")); - mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "E", "W")); - } else { - mLatitudeView.setText(""); - mLongitudeView.setText(""); - } - - mApogeeVoltageView.setText(AltosDroid.number("%4.2f V", state.apogee_voltage)); - mApogeeLights.set(state.apogee_voltage > 3.2, state.apogee_voltage == AltosLib.MISSING); - - mMainVoltageView.setText(AltosDroid.number("%4.2f V", state.main_voltage)); - mMainLights.set(state.main_voltage > 3.2, state.main_voltage == AltosLib.MISSING); - } - } -} diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java deleted file mode 100644 index 3429ee72..00000000 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright © 2013 Mike Beattie - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -package org.altusmetrum.AltosDroid; - -import org.altusmetrum.altoslib_7.*; - -import android.app.Activity; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; -import android.location.Location; - -public class TabDescent extends AltosDroidTab { - private TextView mSpeedView; - private TextView mHeightView; - private TextView mElevationView; - private TextView mRangeView; - private TextView mBearingView; - private TextView mCompassView; - private TextView mDistanceView; - private TextView mLatitudeView; - private TextView mLongitudeView; - private TextView mApogeeVoltageView; - private GoNoGoLights mApogeeLights; - private TextView mMainVoltageView; - private GoNoGoLights mMainLights; - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View v = inflater.inflate(R.layout.tab_descent, container, false); - - mSpeedView = (TextView) v.findViewById(R.id.speed_value); - mHeightView = (TextView) v.findViewById(R.id.height_value); - mElevationView = (TextView) v.findViewById(R.id.elevation_value); - mRangeView = (TextView) v.findViewById(R.id.range_value); - mBearingView = (TextView) v.findViewById(R.id.bearing_value); - mCompassView = (TextView) v.findViewById(R.id.compass_value); - mDistanceView = (TextView) v.findViewById(R.id.distance_value); - mLatitudeView = (TextView) v.findViewById(R.id.lat_value); - mLongitudeView = (TextView) v.findViewById(R.id.lon_value); - - mApogeeVoltageView = (TextView) v.findViewById(R.id.apogee_voltage_value); - mApogeeLights = new GoNoGoLights((ImageView) v.findViewById(R.id.apogee_redled), - (ImageView) v.findViewById(R.id.apogee_greenled), - getResources()); - - mMainVoltageView = (TextView) v.findViewById(R.id.main_voltage_value); - mMainLights = new GoNoGoLights((ImageView) v.findViewById(R.id.main_redled), - (ImageView) v.findViewById(R.id.main_greenled), - getResources()); - - return v; - } - - public String tab_name() { return "descent"; } - - public void show(TelemetryState telem_state, AltosState state, AltosGreatCircle from_receiver, Location receiver) { - if (state != null) { - set_value(mSpeedView, AltosConvert.speed, 6, state.speed()); - set_value(mHeightView, AltosConvert.height, 6, state.height()); - if (from_receiver != null) { - mElevationView.setText(AltosDroid.number("%3.0f°", from_receiver.elevation)); - set_value(mRangeView, AltosConvert.distance, 6, from_receiver.range); - mBearingView.setText(AltosDroid.number("%3.0f°", from_receiver.bearing)); - mCompassView.setText(from_receiver.bearing_words(AltosGreatCircle.BEARING_LONG)); - set_value(mDistanceView, AltosConvert.distance, 6, from_receiver.distance); - } else { - mElevationView.setText(""); - mRangeView.setText(""); - mBearingView.setText(""); - mCompassView.setText(""); - mDistanceView.setText(""); - } - if (state.gps != null) { - mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S")); - mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "E", "W")); - } - - mApogeeVoltageView.setText(AltosDroid.number("%4.2f V", state.apogee_voltage)); - mApogeeLights.set(state.apogee_voltage > 3.2, state.apogee_voltage == AltosLib.MISSING); - - mMainVoltageView.setText(AltosDroid.number("%4.2f V", state.main_voltage)); - mMainLights.set(state.main_voltage > 3.2, state.main_voltage == AltosLib.MISSING); - } - } - -} diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabFlight.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabFlight.java new file mode 100644 index 00000000..e1fc737d --- /dev/null +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabFlight.java @@ -0,0 +1,134 @@ +/* + * Copyright © 2013 Mike Beattie + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.AltosDroid; + +import org.altusmetrum.altoslib_7.*; + +import android.app.Activity; +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; +import android.location.Location; + +public class TabFlight extends AltosDroidTab { + private TextView speed_view; + private TextView height_view; + private TextView max_speed_view; + private TextView max_height_view; + private TextView elevation_view; + private TextView range_view; + private TextView bearing_view; + private TextView compass_view; + private TextView distance_view; + private TextView latitude_view; + private TextView longitude_view; + private TextView apogee_voltage_view; + private TextView apogee_voltage_label; + private GoNoGoLights apogee_lights; + private TextView main_voltage_view; + private TextView main_voltage_label; + private GoNoGoLights main_lights; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + View v = inflater.inflate(R.layout.tab_flight, container, false); + + speed_view = (TextView) v.findViewById(R.id.speed_value); + height_view = (TextView) v.findViewById(R.id.height_value); + max_speed_view = (TextView) v.findViewById(R.id.max_speed_value); + max_height_view= (TextView) v.findViewById(R.id.max_height_value); + elevation_view = (TextView) v.findViewById(R.id.elevation_value); + range_view = (TextView) v.findViewById(R.id.range_value); + bearing_view = (TextView) v.findViewById(R.id.bearing_value); + compass_view = (TextView) v.findViewById(R.id.compass_value); + distance_view = (TextView) v.findViewById(R.id.distance_value); + latitude_view = (TextView) v.findViewById(R.id.lat_value); + longitude_view = (TextView) v.findViewById(R.id.lon_value); + + apogee_voltage_view = (TextView) v.findViewById(R.id.apogee_voltage_value); + apogee_lights = new GoNoGoLights((ImageView) v.findViewById(R.id.apogee_redled), + (ImageView) v.findViewById(R.id.apogee_greenled), + getResources()); + apogee_voltage_label = (TextView) v.findViewById(R.id.apogee_voltage_label); + + main_voltage_view = (TextView) v.findViewById(R.id.main_voltage_value); + main_lights = new GoNoGoLights((ImageView) v.findViewById(R.id.main_redled), + (ImageView) v.findViewById(R.id.main_greenled), + getResources()); + main_voltage_label = (TextView) v.findViewById(R.id.main_voltage_label); + + return v; + } + + public String tab_name() { return "flight"; } + + public void show(TelemetryState telem_state, AltosState state, AltosGreatCircle from_receiver, Location receiver) { + if (state != null) { + set_value(speed_view, AltosConvert.speed, 6, state.speed()); + set_value(height_view, AltosConvert.height, 6, state.height()); + set_value(max_speed_view, AltosConvert.speed, 6, state.max_speed()); + set_value(max_height_view, AltosConvert.speed, 6, state.max_height()); + if (from_receiver != null) { + elevation_view.setText(AltosDroid.number("%3.0f°", from_receiver.elevation)); + set_value(range_view, AltosConvert.distance, 6, from_receiver.range); + bearing_view.setText(AltosDroid.number("%3.0f°", from_receiver.bearing)); + compass_view.setText(from_receiver.bearing_words(AltosGreatCircle.BEARING_LONG)); + set_value(distance_view, AltosConvert.distance, 6, from_receiver.distance); + } else { + elevation_view.setText(""); + range_view.setText(""); + bearing_view.setText(""); + compass_view.setText(""); + distance_view.setText(""); + } + if (state.gps != null) { + latitude_view.setText(AltosDroid.pos(state.gps.lat, "N", "S")); + longitude_view.setText(AltosDroid.pos(state.gps.lon, "E", "W")); + } + + if (state.apogee_voltage == AltosLib.MISSING) { + apogee_voltage_view.setVisibility(View.GONE); + apogee_voltage_label.setVisibility(View.GONE); + apogee_lights.hide(); + } else { + apogee_voltage_view.setText(AltosDroid.number("%4.2f V", state.apogee_voltage)); + apogee_voltage_view.setVisibility(View.VISIBLE); + apogee_voltage_label.setVisibility(View.VISIBLE); + apogee_lights.set(state.apogee_voltage > 3.2, state.apogee_voltage == AltosLib.MISSING); + apogee_lights.show(); + } + + if (state.main_voltage == AltosLib.MISSING) { + main_voltage_view.setVisibility(View.GONE); + main_voltage_label.setVisibility(View.GONE); + main_lights.hide(); + } else { + main_voltage_view.setText(AltosDroid.number("%4.2f V", state.main_voltage)); + main_voltage_view.setVisibility(View.VISIBLE); + main_voltage_label.setVisibility(View.VISIBLE); + main_lights.set(state.main_voltage > 3.2, state.main_voltage == AltosLib.MISSING); + main_lights.show(); + } + } + } + +} diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabRecover.java similarity index 94% rename from altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java rename to altosdroid/src/org/altusmetrum/AltosDroid/TabRecover.java index dd3f938e..0ab20f5f 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabRecover.java @@ -28,7 +28,7 @@ import android.view.ViewGroup; import android.widget.TextView; import android.location.Location; -public class TabLanded extends AltosDroidTab { +public class TabRecover extends AltosDroidTab { private TextView mBearingView; private TextView mDistanceView; private TextView mTargetLatitudeView; @@ -41,7 +41,7 @@ public class TabLanded extends AltosDroidTab { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View v = inflater.inflate(R.layout.tab_landed, container, false); + View v = inflater.inflate(R.layout.tab_recover, container, false); mBearingView = (TextView) v.findViewById(R.id.bearing_value); mDistanceView = (TextView) v.findViewById(R.id.distance_value); @@ -56,7 +56,7 @@ public class TabLanded extends AltosDroidTab { return v; } - public String tab_name() { return "landed"; } + public String tab_name() { return "recover"; } public void show(TelemetryState telem_state, AltosState state, AltosGreatCircle from_receiver, Location receiver) { if (from_receiver != null) { -- 2.30.2