Merge remote-tracking branch 'mjb/altosdroid'
authorKeith Packard <keithp@keithp.com>
Sun, 10 Mar 2013 18:43:06 +0000 (11:43 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 10 Mar 2013 18:43:06 +0000 (11:43 -0700)
.gitignore
altosdroid/Makefile.am
altosdroid/res/drawable/pad.png [new file with mode: 0644]
altosdroid/res/drawable/rocket.png [new file with mode: 0644]
altosdroid/res/layout/altosdroid.xml
altosdroid/res/layout/tab_map.xml
altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java
altosdroid/src/org/altusmetrum/AltosDroid/AltosViewPager.java [new file with mode: 0644]
altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java
configure.ac

index b7b8fda159f4ed74050b357331a2cee6d19547e7..6ae2b864a6c0b7c74541ee0ce92ee050f663da08 100644 (file)
@@ -30,6 +30,7 @@ ao-tools/ao-bitbang/ao-bitbang
 ao-tools/ao-dbg/ao-dbg
 ao-tools/ao-dumplog/ao-dumplog
 ao-tools/ao-eeprom/ao-eeprom
+ao-tools/ao-edit-telem/ao-edit-telem
 ao-tools/ao-list/ao-list
 ao-tools/ao-load/ao-load
 ao-tools/ao-postflight/ao-postflight
index 3dbabdd7361603595e11c9becdb538dd077a528d..0473c17a85cad887e79b4757eedb67f5db37a8e2 100644 (file)
@@ -80,7 +80,7 @@ release: bin/AltosDroid-release-unsigned.apk
           bin/AltosDroid-release-signed.apk \
           bin/AltosDroid-release.apk
 
-clean: $(GOOGLE_PLAY_SERVICES_LIB)
+clean-local: $(GOOGLE_PLAY_SERVICES_LIB)
        ant clean
        rm -rf $(EXT_LIBDIR)
        rm -f $(DRAWABLES)
@@ -88,7 +88,8 @@ clean: $(GOOGLE_PLAY_SERVICES_LIB)
 
 else
 
-clean:
+clean-local:
 
 endif
 
+clean: clean-local
diff --git a/altosdroid/res/drawable/pad.png b/altosdroid/res/drawable/pad.png
new file mode 100644 (file)
index 0000000..b2e65c8
Binary files /dev/null and b/altosdroid/res/drawable/pad.png differ
diff --git a/altosdroid/res/drawable/rocket.png b/altosdroid/res/drawable/rocket.png
new file mode 100644 (file)
index 0000000..7e62f6c
Binary files /dev/null and b/altosdroid/res/drawable/rocket.png differ
index ce812414232ad42d681478dd78c2a98fb219317e..364f6ba6d62677b370c0b1eef289ee8f949064b8 100644 (file)
                                android:layout_height="0dp"
                                android:layout_weight="0" />
 
-                       <android.support.v4.view.ViewPager
+                       <org.altusmetrum.AltosDroid.AltosViewPager
                                android:id="@+id/pager"
                                android:layout_width="match_parent"
                                android:layout_height="0dp"
index 4737fae09980d834e628abf3ebf30a4580a2c473..b9f4e69e7267d3d48dea9fca2d307ac0bf77cddc 100644 (file)
      with this program; if not, write to the Free Software Foundation, Inc.,
      59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 -->
-<fragment xmlns:android="http://schemas.android.com/apk/res/android"
-       android:id="@+id/map"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
-       class="com.google.android.gms.maps.SupportMapFragment"/>
+       android:orientation="vertical" >
+
+       <LinearLayout
+           android:id="@+id/map"
+               android:orientation="horizontal"
+               android:layout_width="fill_parent"
+               android:layout_height="0dp"
+               android:layout_weight="1">
+
+       </LinearLayout>
+
+       <LinearLayout
+               xmlns:android="http://schemas.android.com/apk/res/android"
+               android:layout_width="fill_parent"
+               android:layout_height="wrap_content"
+               android:baselineAligned="true"
+               android:orientation="horizontal" >
+
+               <RelativeLayout
+                       android:layout_width="0dp"
+                       android:layout_height="wrap_content"
+                       android:layout_weight="1"
+                       android:paddingTop="5dp" >
+
+                       <TextView
+                               android:id="@+id/distance_label"
+                               android:layout_width="wrap_content"
+                               android:layout_height="wrap_content"
+                               android:text="@string/distance_label" />
+
+                       <TextView
+                               android:id="@+id/distance_value"
+                               android:layout_width="wrap_content"
+                               android:layout_height="wrap_content"
+                               android:layout_alignParentRight="true"
+                               android:layout_below="@+id/distance_label"
+                               android:text=""
+                               android:textAppearance="?android:attr/textAppearanceLarge" />
+               </RelativeLayout>
+
+               <RelativeLayout
+                       android:layout_width="0dp"
+                       android:layout_height="wrap_content"
+                       android:layout_weight="1"
+                       android:paddingTop="5dp" >
+
+                       <TextView
+                               android:id="@+id/bearing_label"
+                               android:layout_width="wrap_content"
+                               android:layout_height="wrap_content"
+                               android:text="@string/bearing_label" />
+
+                       <TextView
+                               android:id="@+id/bearing_value"
+                               android:layout_width="wrap_content"
+                               android:layout_height="wrap_content"
+                               android:layout_alignParentRight="true"
+                               android:layout_below="@+id/bearing_label"
+                               android:text=""
+                               android:textAppearance="?android:attr/textAppearanceLarge" />
+               </RelativeLayout>
+
+       </LinearLayout>
+
+       <LinearLayout
+               xmlns:android="http://schemas.android.com/apk/res/android"
+               android:layout_width="fill_parent"
+               android:layout_height="wrap_content"
+               android:baselineAligned="true"
+               android:orientation="horizontal" >
+
+               <RelativeLayout
+                       android:layout_width="0dp"
+                       android:layout_height="wrap_content"
+                       android:layout_weight="1"
+                       android:paddingTop="5dp" >
+
+                       <TextView
+                               android:id="@+id/lat_label"
+                               android:layout_width="wrap_content"
+                               android:layout_height="wrap_content"
+                               android:text="@string/latitude_label" />
+
+                       <TextView
+                               android:id="@+id/lat_value"
+                               android:layout_width="wrap_content"
+                               android:layout_height="wrap_content"
+                               android:layout_alignParentRight="true"
+                               android:layout_below="@id/lat_label"
+                               android:text=""
+                               android:textAppearance="?android:attr/textAppearanceLarge" />
+               </RelativeLayout>
+
+               <RelativeLayout
+                       android:layout_width="0dp"
+                       android:layout_height="wrap_content"
+                       android:layout_weight="1"
+                       android:paddingTop="5dp" >
+
+                       <TextView
+                               android:id="@+id/lon_label"
+                               android:layout_width="wrap_content"
+                               android:layout_height="wrap_content"
+                               android:text="@string/longitude_label" />
+
+                       <TextView
+                               android:id="@+id/lon_value"
+                               android:layout_width="wrap_content"
+                               android:layout_height="wrap_content"
+                               android:layout_alignParentRight="true"
+                               android:layout_below="@id/lon_label"
+                               android:text=""
+                               android:textAppearance="?android:attr/textAppearanceLarge" />
+               </RelativeLayout>
+       </LinearLayout>
+</LinearLayout>
\ No newline at end of file
index 63043abd503468e9e1730cf5ebbcd0290f45a8c8..c9ce46a0d0c8487c075d6c95e6a8b6a845e32657 100644 (file)
@@ -80,7 +80,7 @@ public class AltosDroid extends FragmentActivity {
 
        // Tabs
        TabHost     mTabHost;
-       ViewPager   mViewPager;
+       AltosViewPager   mViewPager;
        TabsAdapter mTabsAdapter;
        ArrayList<AltosDroidTab> mTabs = new ArrayList<AltosDroidTab>();
 
@@ -272,7 +272,7 @@ public class AltosDroid extends FragmentActivity {
                mTabHost = (TabHost)findViewById(android.R.id.tabhost);
                mTabHost.setup();
 
-               mViewPager = (ViewPager)findViewById(R.id.pager);
+               mViewPager = (AltosViewPager)findViewById(R.id.pager);
                mViewPager.setOffscreenPageLimit(4);
 
                mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager);
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosViewPager.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosViewPager.java
new file mode 100644 (file)
index 0000000..ebddc26
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright © 2013 Mike Beattie <mike@ethernal.org>
+ *
+ * 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.Context;
+import android.support.v4.view.ViewPager;
+import android.util.AttributeSet;
+import android.view.View;
+
+public class AltosViewPager extends ViewPager {
+
+    public AltosViewPager(Context context) {
+        super(context);
+    }
+
+    public AltosViewPager(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    @Override
+    protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
+        if(v.getClass().getPackage().getName().startsWith("maps.")){
+            return true;
+        }
+        return super.canScroll(v, checkV, dx, x, y);
+    }
+
+}
\ No newline at end of file
index b30b4694d069e04e8d81112dbfa3e477fe59458c..8fc8f59278ac2c59062c8bcb80d1a27a15179e5c 100644 (file)
 
 package org.altusmetrum.AltosDroid;
 
-import org.altusmetrum.altoslib_1.AltosState;
+import java.util.Arrays;
 
+import org.altusmetrum.altoslib_1.*;
+
+import com.google.android.gms.maps.CameraUpdateFactory;
 import com.google.android.gms.maps.GoogleMap;
+import com.google.android.gms.maps.SupportMapFragment;
+import com.google.android.gms.maps.model.BitmapDescriptorFactory;
+import com.google.android.gms.maps.model.LatLng;
+import com.google.android.gms.maps.model.Marker;
+import com.google.android.gms.maps.model.MarkerOptions;
+import com.google.android.gms.maps.model.Polyline;
+import com.google.android.gms.maps.model.PolylineOptions;
 
 import android.app.Activity;
+import android.graphics.Color;
 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;
+import android.widget.TextView;
 
 public class TabMap extends Fragment implements AltosDroidTab {
        AltosDroid mAltosDroid;
 
+       private SupportMapFragment mMapFragment;
        private GoogleMap mMap;
+       private boolean mapLoaded = false;
+
+       private Marker mRocketMarker;
+       private Marker mPadMarker;
+       private Polyline mPolyline;
 
+       private TextView mDistanceView;
+       private TextView mBearingView;
+       private TextView mLatitudeView;
+       private TextView mLongitudeView;
 
        @Override
        public void onAttach(Activity activity) {
@@ -42,12 +64,36 @@ public class TabMap extends Fragment implements AltosDroidTab {
                mAltosDroid.registerTab(this);
        }
 
+       @Override
+       public void onCreate(Bundle savedInstanceState) {
+               super.onCreate(savedInstanceState);
+
+               mMapFragment = new SupportMapFragment() {
+                       @Override
+                       public void onActivityCreated(Bundle savedInstanceState) {
+                               super.onActivityCreated(savedInstanceState);
+                               setupMap();
+                       }
+               };
+
+       }
+
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
                View v = inflater.inflate(R.layout.tab_map, container, false);
+               mDistanceView  = (TextView)v.findViewById(R.id.distance_value);
+               mBearingView   = (TextView)v.findViewById(R.id.bearing_value);
+               mLatitudeView  = (TextView)v.findViewById(R.id.lat_value);
+               mLongitudeView = (TextView)v.findViewById(R.id.lon_value);
                return v;
        }
 
+       @Override
+       public void onActivityCreated(Bundle savedInstanceState) {
+               super.onActivityCreated(savedInstanceState);
+               getChildFragmentManager().beginTransaction().add(R.id.map, mMapFragment).commit();
+       }
+
        @Override
        public void onDestroyView() {
                super.onDestroyView();
@@ -61,12 +107,58 @@ public class TabMap extends Fragment implements AltosDroidTab {
                //ft.commit();
        }
 
+       private void setupMap() {
+               mMap = mMapFragment.getMap();
+               if (mMap != null) {
+                       mMap.setMyLocationEnabled(true);
+                       mMap.getUiSettings().setTiltGesturesEnabled(false);
+                       mMap.getUiSettings().setZoomControlsEnabled(false);
+                       mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(40.8,-104.7),8));
+
+                       mRocketMarker = mMap.addMarker(
+                                       // From: http://mapicons.nicolasmollet.com/markers/industry/military/missile-2/
+                                       new MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.rocket))
+                                                          .position(new LatLng(0,0))
+                                                          .visible(false)
+                                       );
+
+                       mPadMarker = mMap.addMarker(
+                                       new MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.pad))
+                                                          .position(new LatLng(0,0))
+                                                          .visible(false)
+                                       );
+
+                       mPolyline = mMap.addPolyline(
+                                       new PolylineOptions().add(new LatLng(0,0), new LatLng(0,0))
+                                                            .width(3)
+                                                            .color(Color.BLUE)
+                                                            .visible(false)
+                                       );
+
+                       mapLoaded = true;
+               }
+       }
+
        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"));
+               if (state.from_pad != null) {
+                       mDistanceView.setText(String.format("%6.0f m", state.from_pad.distance));
+                       mBearingView.setText(String.format("%3.0f°", state.from_pad.bearing));
+               }
+               mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
+               mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E"));
+
+               if (mapLoaded) {
+                       mRocketMarker.setPosition(new LatLng(state.gps.lat, state.gps.lon));
+                       mRocketMarker.setVisible(true);
+
+                       mPolyline.setPoints(Arrays.asList(new LatLng(state.pad_lat, state.pad_lon), new LatLng(state.gps.lat, state.gps.lon)));
+                       mPolyline.setVisible(true);
+
+                       if (state.state == AltosLib.ao_flight_pad) {
+                               mPadMarker.setPosition(new LatLng(state.pad_lat, state.pad_lon));
+                               mPadMarker.setVisible(true);
+                       }
+               }
        }
 
 }
index f9a892df4c8a26121716d287f1900bf505bcd994..977678f39d740e932a4eb72c921b0200c943cc5a 100644 (file)
@@ -86,10 +86,8 @@ AC_ARG_WITH(android, AS_HELP_STRING([--with-android=PATH],
        [Set android SDK path (default searches in a variety of places)]),
        [ANDROID_SDK=$withval], [ANDROID_SDK=${ANDROID_SDK:-auto}])
 
-echo ANDROID_SDK set to $ANDROID_SDK
-
 if test "x$ANDROID_SDK" = "xauto"; then
-       AC_MSG_CHECKING([Android SDK files])
+       AC_MSG_CHECKING([Android SDK])
        for sdk in ../android/android-sdk-linux ../android/android-sdk ../android-sdk ../android-sdk-linux $HOME/android; do
                if test "x$ANDROID_SDK" = "xauto"; then
                        SDK="$sdk"
@@ -104,6 +102,48 @@ if test "x$ANDROID_SDK" = "xauto"; then
        fi
        AC_MSG_RESULT([$ANDROID_SDK])
 fi
+if test "x$ANDROID_SDK" != "xno"; then
+       AC_MSG_CHECKING([Android SDK version])
+       SDK_VERSION=`grep -i '^Pkg.Revision=' $ANDROID_SDK/tools/source.properties | cut -f2- -d= | sed s/^r//`
+       SDK_MAJOR_VERSION="`echo $SDK_VERSION | sed 's/[[^0-9]].*//'`"
+       if test "$SDK_MAJOR_VERSION" -lt 17 ; then
+               AC_MSG_NOTICE([SDK version $SDK_VERSION is too old. Need >= r17])
+               ANDROID_SDK=no
+       else
+               AC_MSG_RESULT([$SDK_VERSION])
+       fi
+fi
+if test "x$ANDROID_SDK" != "xno"; then
+       AC_MSG_CHECKING([Android SDK API Level])
+       if test -f "$ANDROID_SDK/platforms/android-10/source.properties"; then
+               API_LEVEL=`sed -ne 's/^AndroidVersion.ApiLevel=//p' $ANDROID_SDK/platforms/android-10/source.properties`
+               if test "$API_LEVEL" = "10"; then
+                       AC_MSG_RESULT([$API_LEVEL])
+               else
+                       AC_MSG_NOTICE([API Level 10 not installed correctly.])
+                       ANDROID_SDK=no
+               fi
+       else
+               AC_MSG_NOTICE([API Level 10 not installed, but is required.])
+               ANDROID_SDK=no
+       fi
+fi
+if test "x$ANDROID_SDK" != "xno"; then
+       AC_MSG_CHECKING([Android SDK required extras])
+       if test -f "$ANDROID_SDK/extras/android/support/source.properties"; then
+               ANDROID_SUPPORT_LIB_NAME=`sed -ne 's/^Extra.NameDisplay=//p' $ANDROID_SDK/extras/android/support/source.properties`
+               if test -f "$ANDROID_SDK/extras/google/google_play_services/source.properties"; then
+                       GOOGLE_PLAY_SERVICES_NAME=`sed -ne 's/^Extra.NameDisplay=//p' $ANDROID_SDK/extras/google/google_play_services/source.properties`
+                       AC_MSG_RESULT([$ANDROID_SUPPORT_LIB_NAME, $GOOGLE_PLAY_SERVICES_NAME])
+               else
+                       AC_MSG_NOTICE([Google Play Services library not installed.])
+                       ANDROID_SDK=no
+               fi
+       else
+               AC_MSG_NOTICE([Android Support Library not installed.])
+               ANDROID_SDK=no
+       fi
+fi
 
 AM_CONDITIONAL([ANDROID], [test x$ANDROID_SDK != xno])