From 9a54e278298540582b91ff3eda476265082e890c Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Thu, 7 Mar 2013 18:46:32 +1300 Subject: altosdroid: update copyrights/licensing Signed-off-by: Mike Beattie --- altosdroid/res/layout/altosdroid.xml | 22 ++++++++++++---------- altosdroid/res/values/strings.xml | 22 ++++++++++++---------- .../src/org/altusmetrum/AltosDroid/AltosDroid.java | 2 +- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/altosdroid/res/layout/altosdroid.xml b/altosdroid/res/layout/altosdroid.xml index 691c5e04..dd277ffb 100644 --- a/altosdroid/res/layout/altosdroid.xml +++ b/altosdroid/res/layout/altosdroid.xml @@ -1,17 +1,19 @@ - - diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index 61931731..e11a8997 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -1,5 +1,5 @@ /* - * Copyright © 2012 Mike Beattie + * Copyright © 2012-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 -- cgit v1.2.3 From 5560148ffea1a718a303d999a0f8a625deceef23 Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Thu, 7 Mar 2013 18:51:27 +1300 Subject: altosdroid: minor whitespace cleanup (damn my OCD!) Signed-off-by: Mike Beattie --- altosdroid/AndroidManifest.xml | 2 -- altosdroid/res/values/strings.xml | 1 - altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java | 3 --- 3 files changed, 6 deletions(-) diff --git a/altosdroid/AndroidManifest.xml b/altosdroid/AndroidManifest.xml index 8ecfcbb5..62d9939b 100644 --- a/altosdroid/AndroidManifest.xml +++ b/altosdroid/AndroidManifest.xml @@ -38,9 +38,7 @@ android:theme="@android:style/Theme.Dialog" android:configChanges="orientation|keyboardHidden" /> - - diff --git a/altosdroid/res/values/strings.xml b/altosdroid/res/values/strings.xml index f00f0b55..1c86f42d 100644 --- a/altosdroid/res/values/strings.xml +++ b/altosdroid/res/values/strings.xml @@ -15,7 +15,6 @@ with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. --> - AltosDroid diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index e11a8997..5019f2fc 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -300,9 +300,6 @@ public class AltosDroid extends Activity { mAltosVoice.stop(); } - - - public void onActivityResult(int requestCode, int resultCode, Intent data) { if(D) Log.d(TAG, "onActivityResult " + resultCode); switch (requestCode) { -- cgit v1.2.3 From 10042fed36d19c1b21b8f04c57da708afc085b25 Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Thu, 7 Mar 2013 18:54:45 +1300 Subject: altosdroid: Fix up some formatting in manifest (And add flag to allow settings backup by google services) Signed-off-by: Mike Beattie --- altosdroid/AndroidManifest.xml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/altosdroid/AndroidManifest.xml b/altosdroid/AndroidManifest.xml index 62d9939b..adcfe94f 100644 --- a/altosdroid/AndroidManifest.xml +++ b/altosdroid/AndroidManifest.xml @@ -16,18 +16,20 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. --> + package="org.altusmetrum.AltosDroid" + android:versionCode="1" + android:versionName="1.1.9.3"> - + android:icon="@drawable/app_icon" + android:allowBackup="true" > + -- cgit v1.2.3 From 1c9a3a5080ca0e21f45c2b7ea889793645796751 Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Thu, 7 Mar 2013 18:59:30 +1300 Subject: altosdroid: Only update BuildInfo.java when other source files change Signed-off-by: Mike Beattie --- altosdroid/Makefile.am | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/altosdroid/Makefile.am b/altosdroid/Makefile.am index 39f3c2b6..7716b49b 100644 --- a/altosdroid/Makefile.am +++ b/altosdroid/Makefile.am @@ -39,7 +39,7 @@ $(ALTOSLIB): $(ALTOSLIB_SRCDIR)/$(ALTOSLIB_JAR) mkdir -p $(EXT_LIBDIR) cd $(EXT_LIBDIR) && ln -s $(shell echo $(EXT_LIBDIR) | sed 's|[^/]\+|..|g')/$(ALTOSLIB_SRCDIR)/$(ALTOSLIB_JAR) . -$(SRC_DIR)/BuildInfo.java: +$(SRC_DIR)/BuildInfo.java: $(SRC) ./buildinfo.sh if ANDROID @@ -71,4 +71,3 @@ clean: clean-local clean-local: rm -rf $(EXT_LIBDIR) -.PHONY: $(SRC_DIR)/BuildInfo.java -- cgit v1.2.3 From 353372425550177cf0531a05706491a96414d12c Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Thu, 7 Mar 2013 19:02:48 +1300 Subject: altosdroid: use a glob for source files Signed-off-by: Mike Beattie --- altosdroid/Makefile.am | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/altosdroid/Makefile.am b/altosdroid/Makefile.am index 7716b49b..e4405d42 100644 --- a/altosdroid/Makefile.am +++ b/altosdroid/Makefile.am @@ -21,17 +21,7 @@ ALTOSLIB_JAR=altoslib_$(ALTOSLIB_VERSION).jar ALTOSLIB=$(EXT_LIBDIR)/$(ALTOSLIB_JAR) -SRC=\ - $(SRC_DIR)/AltosDroid.java \ - $(SRC_DIR)/AltosDroidPreferences.java \ - $(SRC_DIR)/AltosVoice.java \ - $(SRC_DIR)/TelemetryService.java \ - $(SRC_DIR)/TelemetryReader.java \ - $(SRC_DIR)/TelemetryLogger.java \ - $(SRC_DIR)/AltosBluetooth.java \ - $(SRC_DIR)/DeviceListActivity.java \ - $(SRC_DIR)/BuildInfo.java \ - $(SRC_DIR)/Dumper.java +SRC=$(SRC_DIR)/*.java all: $(all_target) -- cgit v1.2.3 From b7dc6045892b33b04ec7c27bdc940b4d3e1b9cbf Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Thu, 7 Mar 2013 19:05:43 +1300 Subject: altosdroid: adjust Makefile rules separate altoslib linking and, making of external lib directory. Signed-off-by: Mike Beattie --- altosdroid/Makefile.am | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/altosdroid/Makefile.am b/altosdroid/Makefile.am index e4405d42..9ca24531 100644 --- a/altosdroid/Makefile.am +++ b/altosdroid/Makefile.am @@ -25,9 +25,11 @@ SRC=$(SRC_DIR)/*.java all: $(all_target) -$(ALTOSLIB): $(ALTOSLIB_SRCDIR)/$(ALTOSLIB_JAR) +$(EXT_LIBDIR): mkdir -p $(EXT_LIBDIR) - cd $(EXT_LIBDIR) && ln -s $(shell echo $(EXT_LIBDIR) | sed 's|[^/]\+|..|g')/$(ALTOSLIB_SRCDIR)/$(ALTOSLIB_JAR) . + +$(ALTOSLIB): $(EXT_LIBDIR) $(ALTOSLIB_SRCDIR)/$(ALTOSLIB_JAR) + cd $(EXT_LIBDIR) && ln -sf $(shell echo $(EXT_LIBDIR) | sed 's|[^/]\+|..|g')/$(ALTOSLIB_SRCDIR)/$(ALTOSLIB_JAR) . $(SRC_DIR)/BuildInfo.java: $(SRC) ./buildinfo.sh -- cgit v1.2.3 From 795fba09a3ca273cd2daeeb7d9fed6bae6fa6a86 Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Thu, 7 Mar 2013 19:23:39 +1300 Subject: altosdroid: Adjust build system for GMaps & Tabs support * Use SupportV4 library for Tab support * Use Google Services Lib for Google Maps * revert to a standard Android target, not Google API's * Add permissions required for Google Maps to manifest, and API key Signed-off-by: Mike Beattie --- altosdroid/.classpath | 4 +++- altosdroid/.gitignore | 1 + altosdroid/AndroidManifest.xml | 17 +++++++++++++++++ altosdroid/Makefile.am | 37 +++++++++++++++++++++++++++---------- altosdroid/project.properties | 3 ++- 5 files changed, 50 insertions(+), 12 deletions(-) diff --git a/altosdroid/.classpath b/altosdroid/.classpath index 0ca188f9..fce248e6 100644 --- a/altosdroid/.classpath +++ b/altosdroid/.classpath @@ -1,8 +1,10 @@ + - + + diff --git a/altosdroid/.gitignore b/altosdroid/.gitignore index 0d2ee6e0..56d0776d 100644 --- a/altosdroid/.gitignore +++ b/altosdroid/.gitignore @@ -2,4 +2,5 @@ local.properties bin gen libs +google-play-services_lib src/org/altusmetrum/AltosDroid/BuildInfo.java diff --git a/altosdroid/AndroidManifest.xml b/altosdroid/AndroidManifest.xml index adcfe94f..237c6dcf 100644 --- a/altosdroid/AndroidManifest.xml +++ b/altosdroid/AndroidManifest.xml @@ -20,9 +20,24 @@ android:versionCode="1" android:versionName="1.1.9.3"> + + + + + + + + + + + + + + + diff --git a/altosdroid/Makefile.am b/altosdroid/Makefile.am index 9ca24531..daa64963 100644 --- a/altosdroid/Makefile.am +++ b/altosdroid/Makefile.am @@ -1,12 +1,11 @@ if ANDROID -all_target=bin/AltosDroid-debug.apk bin/AltosDroid-release.apk -clean_command=ant clean +all_target=bin/AltosDroid-debug.apk bin/AltosDroid-release-unsigned.apk else all_target= -clean_command=echo done endif SDK=$(ANDROID_SDK) +SDK_TARGET=$(shell sed -ne 's/^target=//p' project.properties) DX=$(SDK)/platform-tools/dx ADB=$(SDK)/platform-tools/adb @@ -21,6 +20,14 @@ ALTOSLIB_JAR=altoslib_$(ALTOSLIB_VERSION).jar ALTOSLIB=$(EXT_LIBDIR)/$(ALTOSLIB_JAR) +SUPPORT_V4_SRCDIR=$(SDK)/extras/android/support/v4 +SUPPORT_V4_JAR=android-support-v4.jar + +SUPPORT_V4=$(EXT_LIBDIR)/$(SUPPORT_V4_JAR) + +GOOGLE_PLAY_SERVICES_LIB_SRCDIR=$(SDK)/extras/google/google_play_services/libproject +GOOGLE_PLAY_SERVICES_LIB=google-play-services_lib + SRC=$(SRC_DIR)/*.java all: $(all_target) @@ -31,6 +38,13 @@ $(EXT_LIBDIR): $(ALTOSLIB): $(EXT_LIBDIR) $(ALTOSLIB_SRCDIR)/$(ALTOSLIB_JAR) cd $(EXT_LIBDIR) && ln -sf $(shell echo $(EXT_LIBDIR) | sed 's|[^/]\+|..|g')/$(ALTOSLIB_SRCDIR)/$(ALTOSLIB_JAR) . +$(SUPPORT_V4): $(EXT_LIBDIR) $(SUPPORT_V4_SRCDIR)/$(SUPPORT_V4_JAR) + cd $(EXT_LIBDIR) && ln -sf $(SUPPORT_V4_SRCDIR)/$(SUPPORT_V4_JAR) . + +$(GOOGLE_PLAY_SERVICES_LIB): $(GOOGLE_PLAY_SERVICES_LIB_SRCDIR)/$(GOOGLE_PLAY_SERVICES_LIB) + cp -a $(GOOGLE_PLAY_SERVICES_LIB_SRCDIR)/$(GOOGLE_PLAY_SERVICES_LIB) . + cd $(GOOGLE_PLAY_SERVICES_LIB) && $(SDK)/tools/android update project --target $(SDK_TARGET) --path . + $(SRC_DIR)/BuildInfo.java: $(SRC) ./buildinfo.sh @@ -41,10 +55,10 @@ install-release: bin/AltosDroid-release.apk install-debug: bin/AltosDroid-debug.apk $(ADB) install -r bin/AltosDroid-debug.apk -bin/AltosDroid-debug.apk: $(SRC) $(ALTOSLIB) +bin/AltosDroid-debug.apk: $(SRC) $(ALTOSLIB) $(SUPPORT_V4) $(GOOGLE_PLAY_SERVICES_LIB) ant debug -bin/AltosDroid-release.apk: $(SRC) $(ALTOSLIB) +bin/AltosDroid-release-unsigned.apk: $(SRC) $(ALTOSLIB) $(SUPPORT_V4) $(GOOGLE_PLAY_SERVICES_LIB) ant release sign: @@ -55,11 +69,14 @@ sign: bin/AltosDroid-release-signed.apk \ bin/AltosDroid-release.apk -endif +clean: $(GOOGLE_PLAY_SERVICES_LIB) + ant clean + rm -rf $(EXT_LIBDIR) + rm -rf $(GOOGLE_PLAY_SERVICES_LIB) -clean: clean-local - $(clean_command) +else -clean-local: - rm -rf $(EXT_LIBDIR) +clean: + +endif diff --git a/altosdroid/project.properties b/altosdroid/project.properties index 0a80e644..96b9551c 100644 --- a/altosdroid/project.properties +++ b/altosdroid/project.properties @@ -8,4 +8,5 @@ # project structure. # Project target. -target=Google Inc.:Google APIs:10 +target=android-10 +android.library.reference.1=google-play-services_lib/ -- cgit v1.2.3 From 6ff45bef719bafd2c827e479186c8fadf6f779aa Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Thu, 7 Mar 2013 20:48:16 +1300 Subject: altosdroid: Symlink red/green/gray LEDs via build system Signed-off-by: Mike Beattie --- altosdroid/.gitignore | 1 + altosdroid/Makefile.am | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/altosdroid/.gitignore b/altosdroid/.gitignore index 56d0776d..7f0858ea 100644 --- a/altosdroid/.gitignore +++ b/altosdroid/.gitignore @@ -4,3 +4,4 @@ gen libs google-play-services_lib src/org/altusmetrum/AltosDroid/BuildInfo.java +res/drawable/*led.png diff --git a/altosdroid/Makefile.am b/altosdroid/Makefile.am index daa64963..d21cacd8 100644 --- a/altosdroid/Makefile.am +++ b/altosdroid/Makefile.am @@ -13,8 +13,9 @@ AAPT=$(SDK)/platform-tools/aapt APKBUILDER=$(SDK)/tools/apkbuilder ZIPALIGN=$(SDK)/tools/zipalign -SRC_DIR=src/org/altusmetrum/AltosDroid +JAVA_SRC_DIR=src/org/altusmetrum/AltosDroid EXT_LIBDIR=libs +DRAWABLE_DIR=res/drawable ALTOSLIB_SRCDIR=../altoslib ALTOSLIB_JAR=altoslib_$(ALTOSLIB_VERSION).jar @@ -28,7 +29,14 @@ SUPPORT_V4=$(EXT_LIBDIR)/$(SUPPORT_V4_JAR) GOOGLE_PLAY_SERVICES_LIB_SRCDIR=$(SDK)/extras/google/google_play_services/libproject GOOGLE_PLAY_SERVICES_LIB=google-play-services_lib -SRC=$(SRC_DIR)/*.java +JAVA_SRC=$(JAVA_SRC_DIR)/*.java + +DRAWABLES=\ + $(DRAWABLE_DIR)/redled.png \ + $(DRAWABLE_DIR)/greenled.png \ + $(DRAWABLE_DIR)/grayled.png + +SRC=$(JAVA_SRC) $(DRAWABLES) all: $(all_target) @@ -45,9 +53,12 @@ $(GOOGLE_PLAY_SERVICES_LIB): $(GOOGLE_PLAY_SERVICES_LIB_SRCDIR)/$(GOOGLE_PLAY_SE cp -a $(GOOGLE_PLAY_SERVICES_LIB_SRCDIR)/$(GOOGLE_PLAY_SERVICES_LIB) . cd $(GOOGLE_PLAY_SERVICES_LIB) && $(SDK)/tools/android update project --target $(SDK_TARGET) --path . -$(SRC_DIR)/BuildInfo.java: $(SRC) +$(JAVA_SRC_DIR)/BuildInfo.java: $(JAVA_SRC) ./buildinfo.sh +$(DRAWABLE_DIR)/%.png: ../icon/%.png + cd $(DRAWABLE_DIR) && ln -sf $(shell echo $(DRAWABLE_DIR) | sed 's|[^/]\+|..|g')/$< . + if ANDROID install-release: bin/AltosDroid-release.apk $(ADB) install -r bin/AltosDroid-release.apk @@ -72,6 +83,7 @@ sign: clean: $(GOOGLE_PLAY_SERVICES_LIB) ant clean rm -rf $(EXT_LIBDIR) + rm -f $(DRAWABLES) rm -rf $(GOOGLE_PLAY_SERVICES_LIB) else -- cgit v1.2.3 From 89f8bb52ea858f059374474c0adda3cd5095a589 Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Thu, 7 Mar 2013 20:49:41 +1300 Subject: altosdroid: adjust release Makefile target * Rename target * Add dependency on unsigned release APK * use $(ZIPALIGN) variable Signed-off-by: Mike Beattie --- altosdroid/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/altosdroid/Makefile.am b/altosdroid/Makefile.am index d21cacd8..3dbabdd7 100644 --- a/altosdroid/Makefile.am +++ b/altosdroid/Makefile.am @@ -72,11 +72,11 @@ bin/AltosDroid-debug.apk: $(SRC) $(ALTOSLIB) $(SUPPORT_V4) $(GOOGLE_PLAY_SERVICE bin/AltosDroid-release-unsigned.apk: $(SRC) $(ALTOSLIB) $(SUPPORT_V4) $(GOOGLE_PLAY_SERVICES_LIB) ant release -sign: +release: bin/AltosDroid-release-unsigned.apk jarsigner -keystore release.keystore \ -signedjar bin/AltosDroid-release-signed.apk \ bin/AltosDroid-release-unsigned.apk AltosDroid - $(SDK)/tools/zipalign -f 4 \ + $(ZIPALIGN) -f 4 \ bin/AltosDroid-release-signed.apk \ bin/AltosDroid-release.apk -- cgit v1.2.3 From cf03ddb42042002bfb88e13ecfb89b27e7aeb91e Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Thu, 7 Mar 2013 20:53:26 +1300 Subject: altosdroid: convert spaces to tabs in strings.xml Signed-off-by: Mike Beattie --- altosdroid/res/values/strings.xml | 68 +++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/altosdroid/res/values/strings.xml b/altosdroid/res/values/strings.xml index 1c86f42d..679dc019 100644 --- a/altosdroid/res/values/strings.xml +++ b/altosdroid/res/values/strings.xml @@ -16,46 +16,46 @@ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. --> - AltosDroid - - Bluetooth was not enabled. - connecting… - connected: - not connected + AltosDroid - - Connect a device - Select radio frequency + + Bluetooth was not enabled. + connecting… + connected: + not connected - - scanning for devices… - select a device to connect - No devices have been paired - No devices found - Paired Devices - Other Available Devices - Scan for devices + + Connect a device + Select radio frequency - - AltosDroid Telemetry Service - Telemetry Service Started - Telemetry Service Stopped + + scanning for devices… + select a device to connect + No devices have been paired + No devices found + Paired Devices + Other Available Devices + Scan for devices + + AltosDroid Telemetry Service + Telemetry Service Started + Telemetry Service Stopped - Callsign - Serial no. - Flight no. - RSSI - State - Speed - Acceleration - Range - Height - Elevation - Bearing - Latitude - Longitude + Callsign + Serial + Flight + State + RSSI + Height + Speed + Acceleration + Bearing + Elevation + Range + Latitude + Longitude -- cgit v1.2.3 From d229d702c8532f477e2ace2af36f2d0cc6e728d3 Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Thu, 7 Mar 2013 21:20:06 +1300 Subject: altosdroid: make AltosDroid.pos() static * Will be used from tabs that display lat/lon Signed-off-by: Mike Beattie --- altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index 5019f2fc..3b76fc9b 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -193,7 +193,7 @@ public class AltosDroid extends Activity { mAltosVoice.tell(state); } - String pos(double p, String pos, String neg) { + static String pos(double p, String pos, String neg) { String h = pos; if (p < 0) { h = neg; -- cgit v1.2.3 From d6f1b176f4005af3b6fd16d8c7d22260a3ccdfd8 Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Thu, 7 Mar 2013 21:20:47 +1300 Subject: altosdroid: whitespace cleanup DAMN my OCD. Signed-off-by: Mike Beattie --- altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java | 1 - 1 file changed, 1 deletion(-) diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index 3b76fc9b..5be70953 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -150,7 +150,6 @@ public class AltosDroid extends Activity { } }; - void doBindService() { bindService(new Intent(this, TelemetryService.class), mConnection, Context.BIND_AUTO_CREATE); mIsBound = true; -- cgit v1.2.3 From 59dfcbe14622c20aaa7d5b131eece9f4c8db6887 Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Thu, 7 Mar 2013 21:28:45 +1300 Subject: altosdroid: Import initial versions of XML and Java for Tab content * Includes TabsAdapter class borrowed from Support Library sample code * New "GoNoGoLights" class for dealing with the red/green/gray LEDs * extra required strings in strings.xml * Couple of support functions in AltosDroid.java * rudimentary Maps tab - does nothing at present. Signed-off-by: Mike Beattie --- altosdroid/res/layout/tab_ascent.xml | 299 ++++++++++++++++++ altosdroid/res/layout/tab_descent.xml | 339 +++++++++++++++++++++ altosdroid/res/layout/tab_landed.xml | 169 ++++++++++ altosdroid/res/layout/tab_map.xml | 22 ++ altosdroid/res/layout/tab_pad.xml | 320 +++++++++++++++++++ altosdroid/res/values/strings.xml | 18 ++ .../src/org/altusmetrum/AltosDroid/AltosDroid.java | 6 + .../org/altusmetrum/AltosDroid/AltosDroidTab.java | 24 ++ .../org/altusmetrum/AltosDroid/GoNoGoLights.java | 55 ++++ .../src/org/altusmetrum/AltosDroid/TabAscent.java | 104 +++++++ .../src/org/altusmetrum/AltosDroid/TabDescent.java | 112 +++++++ .../src/org/altusmetrum/AltosDroid/TabLanded.java | 83 +++++ .../src/org/altusmetrum/AltosDroid/TabMap.java | 72 +++++ .../src/org/altusmetrum/AltosDroid/TabPad.java | 139 +++++++++ .../org/altusmetrum/AltosDroid/TabsAdapter.java | 133 ++++++++ 15 files changed, 1895 insertions(+) create mode 100644 altosdroid/res/layout/tab_ascent.xml create mode 100644 altosdroid/res/layout/tab_descent.xml create mode 100644 altosdroid/res/layout/tab_landed.xml create mode 100644 altosdroid/res/layout/tab_map.xml create mode 100644 altosdroid/res/layout/tab_pad.xml create mode 100644 altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java create mode 100644 altosdroid/src/org/altusmetrum/AltosDroid/GoNoGoLights.java create mode 100644 altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java create mode 100644 altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java create mode 100644 altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java create mode 100644 altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java create mode 100644 altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java create mode 100644 altosdroid/src/org/altusmetrum/AltosDroid/TabsAdapter.java diff --git a/altosdroid/res/layout/tab_ascent.xml b/altosdroid/res/layout/tab_ascent.xml new file mode 100644 index 00000000..b7e97086 --- /dev/null +++ b/altosdroid/res/layout/tab_ascent.xml @@ -0,0 +1,299 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/altosdroid/res/layout/tab_descent.xml b/altosdroid/res/layout/tab_descent.xml new file mode 100644 index 00000000..4b62acf9 --- /dev/null +++ b/altosdroid/res/layout/tab_descent.xml @@ -0,0 +1,339 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/altosdroid/res/layout/tab_landed.xml b/altosdroid/res/layout/tab_landed.xml new file mode 100644 index 00000000..b5c8d8c2 --- /dev/null +++ b/altosdroid/res/layout/tab_landed.xml @@ -0,0 +1,169 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/altosdroid/res/layout/tab_map.xml b/altosdroid/res/layout/tab_map.xml new file mode 100644 index 00000000..4737fae0 --- /dev/null +++ b/altosdroid/res/layout/tab_map.xml @@ -0,0 +1,22 @@ + + + diff --git a/altosdroid/res/layout/tab_pad.xml b/altosdroid/res/layout/tab_pad.xml new file mode 100644 index 00000000..f5ec46b5 --- /dev/null +++ b/altosdroid/res/layout/tab_pad.xml @@ -0,0 +1,320 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/altosdroid/res/values/strings.xml b/altosdroid/res/values/strings.xml index 679dc019..639611c2 100644 --- a/altosdroid/res/values/strings.xml +++ b/altosdroid/res/values/strings.xml @@ -44,18 +44,36 @@ Telemetry Service Stopped + Callsign Serial Flight State RSSI + Age + + Height Speed Acceleration Bearing Elevation Range + Distance + Ground Distance + Max Height + Max Speed + Max Accel + Battery Voltage + Apogee Igniter Voltage + Main Igniter Voltage + On-board Data Logging + GPS Locked + GPS Ready Latitude Longitude + Pad Latitude + Pad Longitude + Pad Altitude diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index 5be70953..625a2eee 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -173,6 +173,12 @@ public class AltosDroid extends Activity { } } + public void registerTab(AltosDroidTab mTab) { + } + + public void unregisterTab(AltosDroidTab mTab) { + } + void update_ui(AltosState state) { mCallsignView.setText(state.data.callsign); mRSSIView.setText(String.format("%d", state.data.rssi)); diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java new file mode 100644 index 00000000..68bbe593 --- /dev/null +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java @@ -0,0 +1,24 @@ +/* + * 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_1.AltosState; + +public interface AltosDroidTab { + public void update_ui(AltosState state); +} diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/GoNoGoLights.java b/altosdroid/src/org/altusmetrum/AltosDroid/GoNoGoLights.java new file mode 100644 index 00000000..0f95bc22 --- /dev/null +++ b/altosdroid/src/org/altusmetrum/AltosDroid/GoNoGoLights.java @@ -0,0 +1,55 @@ +/* + * 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 android.content.res.Resources; +import android.graphics.drawable.Drawable; +import android.widget.ImageView; + +public class GoNoGoLights { + private Boolean state; + + private ImageView red; + private ImageView green; + + private Drawable dRed; + private Drawable dGreen; + private Drawable dGray; + + public GoNoGoLights(ImageView in_red, ImageView in_green, Resources r) { + red = in_red; + green = in_green; + state = false; + + dRed = r.getDrawable(R.drawable.redled); + dGreen = r.getDrawable(R.drawable.greenled); + dGray = r.getDrawable(R.drawable.grayled); + } + + public void set(Boolean s) { + if (s == state) return; + state = s; + if (state) { + red.setImageDrawable(dGray); + green.setImageDrawable(dGreen); + } else { + red.setImageDrawable(dRed); + green.setImageDrawable(dGray); + } + } +} diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java new file mode 100644 index 00000000..bda6b1fd --- /dev/null +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java @@ -0,0 +1,104 @@ +/* + * 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_1.AltosState; + +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; + +public class TabAscent extends Fragment implements AltosDroidTab { + AltosDroid mAltosDroid; + + 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 void onAttach(Activity activity) { + super.onAttach(activity); + mAltosDroid = (AltosDroid) activity; + mAltosDroid.registerTab(this); + } + + @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; + } + + @Override + public void onDestroy() { + super.onDestroy(); + mAltosDroid.unregisterTab(this); + mAltosDroid = null; + } + + public void update_ui(AltosState state) { + mHeightView.setText(String.format("%6.0f m", state.height)); + mMaxHeightView.setText(String.format("%6.0f m", state.max_height)); + mSpeedView.setText(String.format("%6.0f m/s", state.speed())); + mMaxSpeedView.setText(String.format("%6.0f m/s", state.max_speed())); + mAccelView.setText(String.format("%6.0f m/s²", state.acceleration)); + mMaxAccelView.setText(String.format("%6.0f m/s²", state.max_acceleration)); + + mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S")); + mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E")); + + mApogeeVoltageView.setText(String.format("%4.2f V", state.drogue_sense)); + mApogeeLights.set(state.drogue_sense > 3.2); + + mMainVoltageView.setText(String.format("%4.2f V", state.main_sense)); + mMainLights.set(state.main_sense > 3.2); + } +} diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java new file mode 100644 index 00000000..3805b7e7 --- /dev/null +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java @@ -0,0 +1,112 @@ +/* + * 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_1.AltosGreatCircle; +import org.altusmetrum.altoslib_1.AltosState; + +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; + +public class TabDescent extends Fragment implements AltosDroidTab { + AltosDroid mAltosDroid; + + 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 void onAttach(Activity activity) { + super.onAttach(activity); + mAltosDroid = (AltosDroid) activity; + mAltosDroid.registerTab(this); + } + + @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; + } + + + @Override + public void onDestroy() { + super.onDestroy(); + mAltosDroid.unregisterTab(this); + mAltosDroid = null; + } + + public void update_ui(AltosState state) { + mSpeedView.setText(String.format("%6.0f m/s", state.speed())); + mHeightView.setText(String.format("%6.0f m", state.height)); + mElevationView.setText(String.format("%3.0f°", state.elevation)); + mRangeView.setText(String.format("%6.0f m", state.range)); + if (state.from_pad != null) { + mBearingView.setText(String.format("%3.0f°", state.from_pad.bearing)); + mCompassView.setText(state.from_pad.bearing_words(AltosGreatCircle.BEARING_LONG)); + } + mDistanceView.setText(String.format("%6.0f m", state.range)); + mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S")); + mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E")); + + mApogeeVoltageView.setText(String.format("%4.2f V", state.drogue_sense)); + mApogeeLights.set(state.drogue_sense > 3.2); + + mMainVoltageView.setText(String.format("%4.2f V", state.main_sense)); + mMainLights.set(state.main_sense > 3.2); + } + +} diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java new file mode 100644 index 00000000..a95e9145 --- /dev/null +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java @@ -0,0 +1,83 @@ +/* + * 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_1.AltosState; + +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.TextView; + +public class TabLanded extends Fragment implements AltosDroidTab { + AltosDroid mAltosDroid; + + private TextView mBearingView; + private TextView mDistanceView; + private TextView mLatitudeView; + private TextView mLongitudeView; + private TextView mMaxHeightView; + private TextView mMaxSpeedView; + private TextView mMaxAccelView; + + + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + mAltosDroid = (AltosDroid) activity; + mAltosDroid.registerTab(this); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + View v = inflater.inflate(R.layout.tab_landed, container, false); + + mBearingView = (TextView) v.findViewById(R.id.bearing_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); + mMaxHeightView = (TextView) v.findViewById(R.id.max_height_value); + mMaxSpeedView = (TextView) v.findViewById(R.id.max_speed_value); + mMaxAccelView = (TextView) v.findViewById(R.id.max_accel_value); + + return v; + } + + @Override + public void onDestroy() { + super.onDestroy(); + mAltosDroid.unregisterTab(this); + mAltosDroid = null; + } + + public void update_ui(AltosState state) { + if (state.from_pad != null) { + mBearingView.setText(String.format("%3.0f°", state.from_pad.bearing)); + mDistanceView.setText(String.format("%6.0f m", state.from_pad.distance)); + } + mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S")); + mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E")); + mMaxHeightView.setText(String.format("%6.0f m", state.max_height)); + mMaxAccelView.setText(String.format("%6.0f m/s²", state.max_acceleration)); + mMaxSpeedView.setText(String.format("%6.0f m/s", state.max_speed())); + } + +} diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java new file mode 100644 index 00000000..b30b4694 --- /dev/null +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java @@ -0,0 +1,72 @@ +/* + * 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_1.AltosState; + +import com.google.android.gms.maps.GoogleMap; + +import android.app.Activity; +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentTransaction; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +public class TabMap extends Fragment implements AltosDroidTab { + AltosDroid mAltosDroid; + + private GoogleMap mMap; + + + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + mAltosDroid = (AltosDroid) activity; + mAltosDroid.registerTab(this); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + View v = inflater.inflate(R.layout.tab_map, container, false); + return v; + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + + mAltosDroid.unregisterTab(this); + mAltosDroid = null; + + //Fragment fragment = (getFragmentManager().findFragmentById(R.id.map)); + //FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction(); + //ft.remove(fragment); + //ft.commit(); + } + + public void update_ui(AltosState state) { +// mRangeView.setText(String.format("%6.0f m", state.range)); +// if (state.from_pad != null) +// mBearingView.setText(String.format("%3.0f°", state.from_pad.bearing)); +// mLatitudeView.setText(pos(state.gps.lat, "N", "S")); +// mLongitudeView.setText(pos(state.gps.lon, "W", "E")); + } + +} diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java new file mode 100644 index 00000000..41776c10 --- /dev/null +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java @@ -0,0 +1,139 @@ +/* + * 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_1.*; + +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; + +public class TabPad extends Fragment implements AltosDroidTab { + AltosDroid mAltosDroid; + + private TextView mBatteryVoltageView; + private GoNoGoLights mBatteryLights; + private TextView mApogeeVoltageView; + private GoNoGoLights mApogeeLights; + private TextView mMainVoltageView; + private GoNoGoLights mMainLights; + private TextView mDataLoggingView; + private GoNoGoLights mDataLoggingLights; + private TextView mGPSLockedView; + private GoNoGoLights mGPSLockedLights; + private TextView mGPSReadyView; + private GoNoGoLights mGPSReadyLights; + private TextView mPadLatitudeView; + private TextView mPadLongitudeView; + private TextView mPadAltitudeView; + + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + mAltosDroid = (AltosDroid) activity; + mAltosDroid.registerTab(this); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + View v = inflater.inflate(R.layout.tab_pad, container, false); + mBatteryVoltageView = (TextView) v.findViewById(R.id.battery_voltage_value); + mBatteryLights = new GoNoGoLights((ImageView) v.findViewById(R.id.battery_redled), + (ImageView) v.findViewById(R.id.battery_greenled), + getResources()); + + 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()); + + mDataLoggingView = (TextView) v.findViewById(R.id.logging_value); + mDataLoggingLights = new GoNoGoLights((ImageView) v.findViewById(R.id.logging_redled), + (ImageView) v.findViewById(R.id.logging_greenled), + getResources()); + + mGPSLockedView = (TextView) v.findViewById(R.id.gps_locked_value); + mGPSLockedLights = new GoNoGoLights((ImageView) v.findViewById(R.id.gps_locked_redled), + (ImageView) v.findViewById(R.id.gps_locked_greenled), + getResources()); + + mGPSReadyView = (TextView) v.findViewById(R.id.gps_ready_value); + mGPSReadyLights = new GoNoGoLights((ImageView) v.findViewById(R.id.gps_ready_redled), + (ImageView) v.findViewById(R.id.gps_ready_greenled), + getResources()); + + mPadLatitudeView = (TextView) v.findViewById(R.id.pad_lat_value); + mPadLongitudeView = (TextView) v.findViewById(R.id.pad_lon_value); + mPadAltitudeView = (TextView) v.findViewById(R.id.pad_alt_value); + return v; + } + + @Override + public void onDestroy() { + super.onDestroy(); + mAltosDroid.unregisterTab(this); + mAltosDroid = null; + } + + public void update_ui(AltosState state) { + mBatteryVoltageView.setText(String.format("%4.2f V", state.battery)); + mBatteryLights.set(state.battery > 3.7); + + mApogeeVoltageView.setText(String.format("%4.2f V", state.drogue_sense)); + mApogeeLights.set(state.drogue_sense > 3.2); + + mMainVoltageView.setText(String.format("%4.2f V", state.main_sense)); + mMainLights.set(state.main_sense > 3.2); + + if (state.data.flight != 0) { + if (state.data.state <= AltosLib.ao_flight_pad) + mDataLoggingView.setText("Ready to record"); + else if (state.data.state < AltosLib.ao_flight_landed) + mDataLoggingView.setText("Recording data"); + else + mDataLoggingView.setText("Recorded data"); + } else { + mDataLoggingView.setText("Storage full"); + } + mDataLoggingLights.set(state.data.flight != 0); + + mGPSLockedView.setText(String.format("%4d sats", state.gps.nsat)); + mGPSLockedLights.set(state.gps.locked && state.gps.nsat >= 4); + + if (state.gps_ready) + mGPSReadyView.setText("Ready"); + else + mGPSReadyView.setText(String.format("Waiting %d", state.gps_waiting)); + mGPSReadyLights.set(state.gps_ready); + + mPadLatitudeView.setText(AltosDroid.pos(state.pad_lat, "N", "S")); + mPadLongitudeView.setText(AltosDroid.pos(state.pad_lon, "W", "E")); + mPadAltitudeView.setText(String.format("%4.0f m", state.pad_alt)); + } + +} diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabsAdapter.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabsAdapter.java new file mode 100644 index 00000000..a4758c37 --- /dev/null +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabsAdapter.java @@ -0,0 +1,133 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.altusmetrum.AltosDroid; + +import java.util.ArrayList; + +import android.content.Context; +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentActivity; +import android.support.v4.app.FragmentPagerAdapter; +import android.support.v4.view.ViewPager; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TabHost; +import android.widget.TabWidget; + + + +/** + * This is a helper class that implements the management of tabs and all + * details of connecting a ViewPager with associated TabHost. It relies on a + * trick. Normally a tab host has a simple API for supplying a View or + * Intent that each tab will show. This is not sufficient for switching + * between pages. So instead we make the content part of the tab host + * 0dp high (it is not shown) and the TabsAdapter supplies its own dummy + * view to show as the tab content. It listens to changes in tabs, and takes + * care of switch to the correct paged in the ViewPager whenever the selected + * tab changes. + */ +public class TabsAdapter extends FragmentPagerAdapter + implements TabHost.OnTabChangeListener, ViewPager.OnPageChangeListener { + private final Context mContext; + private final TabHost mTabHost; + private final ViewPager mViewPager; + private final ArrayList mTabs = new ArrayList(); + + static final class TabInfo { + private final String tag; + private final Class clss; + private final Bundle args; + + TabInfo(String _tag, Class _class, Bundle _args) { + tag = _tag; + clss = _class; + args = _args; + } + } + + static class DummyTabFactory implements TabHost.TabContentFactory { + private final Context mContext; + + public DummyTabFactory(Context context) { + mContext = context; + } + + public View createTabContent(String tag) { + View v = new View(mContext); + v.setMinimumWidth(0); + v.setMinimumHeight(0); + return v; + } + } + + public TabsAdapter(FragmentActivity activity, TabHost tabHost, ViewPager pager) { + super(activity.getSupportFragmentManager()); + mContext = activity; + mTabHost = tabHost; + mViewPager = pager; + mTabHost.setOnTabChangedListener(this); + mViewPager.setAdapter(this); + mViewPager.setOnPageChangeListener(this); + } + + public void addTab(TabHost.TabSpec tabSpec, Class clss, Bundle args) { + tabSpec.setContent(new DummyTabFactory(mContext)); + String tag = tabSpec.getTag(); + + TabInfo info = new TabInfo(tag, clss, args); + mTabs.add(info); + mTabHost.addTab(tabSpec); + notifyDataSetChanged(); + } + + @Override + public int getCount() { + return mTabs.size(); + } + + @Override + public Fragment getItem(int position) { + TabInfo info = mTabs.get(position); + return Fragment.instantiate(mContext, info.clss.getName(), info.args); + } + + public void onTabChanged(String tabId) { + int position = mTabHost.getCurrentTab(); + mViewPager.setCurrentItem(position); + } + + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + } + + public void onPageSelected(int position) { + // Unfortunately when TabHost changes the current tab, it kindly + // also takes care of putting focus on it when not in touch mode. + // The jerk. + // This hack tries to prevent this from pulling focus out of our + // ViewPager. + TabWidget widget = mTabHost.getTabWidget(); + int oldFocusability = widget.getDescendantFocusability(); + widget.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); + mTabHost.setCurrentTab(position); + widget.setDescendantFocusability(oldFocusability); + } + + public void onPageScrollStateChanged(int state) { + } +} -- cgit v1.2.3 From 2a81d637308e680b99d7218ba9e03c9ade6626f1 Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Thu, 7 Mar 2013 21:33:27 +1300 Subject: altosdroid: implement tabs interface Signed-off-by: Mike Beattie --- altosdroid/res/layout/altosdroid.xml | 528 +++++++-------------- .../src/org/altusmetrum/AltosDroid/AltosDroid.java | 54 +-- 2 files changed, 206 insertions(+), 376 deletions(-) diff --git a/altosdroid/res/layout/altosdroid.xml b/altosdroid/res/layout/altosdroid.xml index dd277ffb..ce812414 100644 --- a/altosdroid/res/layout/altosdroid.xml +++ b/altosdroid/res/layout/altosdroid.xml @@ -15,352 +15,182 @@ with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index 625a2eee..2777a4d4 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -33,18 +33,21 @@ import android.os.Handler; import android.os.Message; import android.os.Messenger; import android.os.RemoteException; +import android.support.v4.app.FragmentActivity; +import android.support.v4.view.ViewPager; import android.util.Log; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.Window; +import android.widget.TabHost; import android.widget.TextView; import android.widget.Toast; import android.app.AlertDialog; import org.altusmetrum.altoslib_1.*; -public class AltosDroid extends Activity { +public class AltosDroid extends FragmentActivity { // Debugging private static final String TAG = "AltosDroid"; private static final boolean D = true; @@ -66,18 +69,16 @@ public class AltosDroid extends Activity { private TextView mSerialView; private TextView mFlightView; private TextView mStateView; - private TextView mSpeedView; - private TextView mAccelView; - private TextView mRangeView; - private TextView mHeightView; - private TextView mElevationView; - private TextView mBearingView; - private TextView mLatitudeView; - private TextView mLongitudeView; + private TextView mAgeView; // field to display the version at the bottom of the screen private TextView mVersion; + // Tabs + TabHost mTabHost; + ViewPager mViewPager; + TabsAdapter mTabsAdapter; + // Service private boolean mIsBound = false; private Messenger mService = null; @@ -181,19 +182,10 @@ public class AltosDroid extends Activity { void update_ui(AltosState state) { mCallsignView.setText(state.data.callsign); - mRSSIView.setText(String.format("%d", state.data.rssi)); mSerialView.setText(String.format("%d", state.data.serial)); mFlightView.setText(String.format("%d", state.data.flight)); mStateView.setText(state.data.state()); - mSpeedView.setText(String.format("%6.0f m/s", state.speed())); - mAccelView.setText(String.format("%6.0f m/s²", state.acceleration)); - mRangeView.setText(String.format("%6.0f m", state.range)); - mHeightView.setText(String.format("%6.0f m", state.height)); - mElevationView.setText(String.format("%3.0f°", state.elevation)); - if (state.from_pad != null) - mBearingView.setText(String.format("%3.0f°", state.from_pad.bearing)); - mLatitudeView.setText(pos(state.gps.lat, "N", "S")); - mLongitudeView.setText(pos(state.gps.lon, "W", "E")); + mRSSIView.setText(String.format("%d", state.data.rssi)); mAltosVoice.tell(state); } @@ -233,6 +225,21 @@ public class AltosDroid extends Activity { setContentView(R.layout.altosdroid); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title); + mTabHost = (TabHost)findViewById(android.R.id.tabhost); + mTabHost.setup(); + + mViewPager = (ViewPager)findViewById(R.id.pager); + mViewPager.setOffscreenPageLimit(4); + + mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager); + + mTabsAdapter.addTab(mTabHost.newTabSpec("pad").setIndicator("Pad"), TabPad.class, null); + mTabsAdapter.addTab(mTabHost.newTabSpec("ascent").setIndicator("Ascent"), TabAscent.class, null); + mTabsAdapter.addTab(mTabHost.newTabSpec("descent").setIndicator("Descent"), TabDescent.class, null); + mTabsAdapter.addTab(mTabHost.newTabSpec("landed").setIndicator("Landed"), TabLanded.class, null); + mTabsAdapter.addTab(mTabHost.newTabSpec("map").setIndicator("Map"), TabMap.class, null); + + // Set up the custom title mTitle = (TextView) findViewById(R.id.title_left_text); mTitle.setText(R.string.app_name); @@ -249,14 +256,7 @@ public class AltosDroid extends Activity { mSerialView = (TextView) findViewById(R.id.serial_value); mFlightView = (TextView) findViewById(R.id.flight_value); mStateView = (TextView) findViewById(R.id.state_value); - mSpeedView = (TextView) findViewById(R.id.speed_value); - mAccelView = (TextView) findViewById(R.id.accel_value); - mRangeView = (TextView) findViewById(R.id.range_value); - mHeightView = (TextView) findViewById(R.id.height_value); - mElevationView = (TextView) findViewById(R.id.elevation_value); - mBearingView = (TextView) findViewById(R.id.bearing_value); - mLatitudeView = (TextView) findViewById(R.id.latitude_value); - mLongitudeView = (TextView) findViewById(R.id.longitude_value); + mAgeView = (TextView) findViewById(R.id.age_value); mAltosVoice = new AltosVoice(this); } -- cgit v1.2.3 From 86b742743b26693cf8e56034d4ea68ff277931c1 Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Thu, 7 Mar 2013 21:35:43 +1300 Subject: altosdroid: implement UI updating on tabs Signed-off-by: Mike Beattie --- altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index 2777a4d4..8ddba9bd 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -18,6 +18,7 @@ package org.altusmetrum.AltosDroid; import java.lang.ref.WeakReference; +import java.util.ArrayList; import android.app.Activity; import android.bluetooth.BluetoothAdapter; @@ -78,6 +79,7 @@ public class AltosDroid extends FragmentActivity { TabHost mTabHost; ViewPager mViewPager; TabsAdapter mTabsAdapter; + ArrayList mTabs = new ArrayList(); // Service private boolean mIsBound = false; @@ -175,9 +177,11 @@ public class AltosDroid extends FragmentActivity { } public void registerTab(AltosDroidTab mTab) { + mTabs.add(mTab); } public void unregisterTab(AltosDroidTab mTab) { + mTabs.remove(mTab); } void update_ui(AltosState state) { @@ -187,6 +191,9 @@ public class AltosDroid extends FragmentActivity { mStateView.setText(state.data.state()); mRSSIView.setText(String.format("%d", state.data.rssi)); + for (AltosDroidTab mTab : mTabs) + mTab.update_ui(state); + mAltosVoice.tell(state); } -- cgit v1.2.3 From ecfc568574ababd23b2c4dc1323cb7265c097933 Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Thu, 7 Mar 2013 21:37:22 +1300 Subject: altosdroid: implement Age field updating Signed-off-by: Mike Beattie --- .../src/org/altusmetrum/AltosDroid/AltosDroid.java | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index 8ddba9bd..2f98b64b 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -19,6 +19,8 @@ package org.altusmetrum.AltosDroid; import java.lang.ref.WeakReference; import java.util.ArrayList; +import java.util.Timer; +import java.util.TimerTask; import android.app.Activity; import android.bluetooth.BluetoothAdapter; @@ -56,6 +58,7 @@ public class AltosDroid extends FragmentActivity { // Message types received by our Handler public static final int MSG_STATE_CHANGE = 1; public static final int MSG_TELEMETRY = 2; + public static final int MSG_UPDATE_AGE = 3; // Intent request codes private static final int REQUEST_CONNECT_DEVICE = 1; @@ -81,6 +84,10 @@ public class AltosDroid extends FragmentActivity { TabsAdapter mTabsAdapter; ArrayList mTabs = new ArrayList(); + // Timer and Saved flight state for Age calculation + private Timer timer = new Timer(); + AltosState saved_state; + // Service private boolean mIsBound = false; private Messenger mService = null; @@ -130,6 +137,11 @@ public class AltosDroid extends FragmentActivity { case MSG_TELEMETRY: ad.update_ui((AltosState) msg.obj); break; + case MSG_UPDATE_AGE: + if (ad.saved_state != null) { + ad.mAgeView.setText(String.format("%d", (System.currentTimeMillis() - ad.saved_state.report_time + 500) / 1000)); + } + break; } } }; @@ -185,6 +197,8 @@ public class AltosDroid extends FragmentActivity { } void update_ui(AltosState state) { + saved_state = state; + mCallsignView.setText(state.data.callsign); mSerialView.setText(String.format("%d", state.data.serial)); mFlightView.setText(String.format("%d", state.data.flight)); @@ -197,6 +211,13 @@ public class AltosDroid extends FragmentActivity { mAltosVoice.tell(state); } + private void onTimerTick() { + try { + mMessenger.send(Message.obtain(null, MSG_UPDATE_AGE)); + } catch (RemoteException e) { + } + } + static String pos(double p, String pos, String neg) { String h = pos; if (p < 0) { @@ -265,6 +286,8 @@ public class AltosDroid extends FragmentActivity { mStateView = (TextView) findViewById(R.id.state_value); mAgeView = (TextView) findViewById(R.id.age_value); + timer.scheduleAtFixedRate(new TimerTask(){ public void run() {onTimerTick();}}, 1000L, 100L); + mAltosVoice = new AltosVoice(this); } -- cgit v1.2.3 From e0d9128b7219b4c8ee68245a44b3428e796ca2f1 Mon Sep 17 00:00:00 2001 From: Mike Beattie Date: Thu, 7 Mar 2013 21:37:51 +1300 Subject: altosdroid: Auto tab changing Signed-off-by: Mike Beattie --- .../src/org/altusmetrum/AltosDroid/AltosDroid.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index 2f98b64b..63043abd 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -197,6 +197,22 @@ public class AltosDroid extends FragmentActivity { } void update_ui(AltosState state) { + if (saved_state != null) { + if (saved_state.state != state.state) { + String currentTab = mTabHost.getCurrentTabTag(); + switch (state.state) { + case AltosLib.ao_flight_boost: + if (currentTab.equals("pad")) mTabHost.setCurrentTabByTag("ascent"); + break; + case AltosLib.ao_flight_drogue: + if (currentTab.equals("ascent")) mTabHost.setCurrentTabByTag("descent"); + break; + case AltosLib.ao_flight_landed: + if (currentTab.equals("descent")) mTabHost.setCurrentTabByTag("landed"); + break; + } + } + } saved_state = state; mCallsignView.setText(state.data.callsign); -- cgit v1.2.3