diff options
author | Keith Packard <keithp@keithp.com> | 2013-03-10 11:43:06 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2013-03-10 11:43:06 -0700 |
commit | 90ee11542b111befa0e96e27292dc548e5c37396 (patch) | |
tree | 088785d41e4aa3216489277ff5901c1b04f612e8 | |
parent | 97efce5f7ff227aaa8990529217d3d10db3443dc (diff) | |
parent | d7973de32adff5402844cc1e1da3eced05265074 (diff) |
Merge remote-tracking branch 'mjb/altosdroid'
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | altosdroid/Makefile.am | 5 | ||||
-rw-r--r-- | altosdroid/res/drawable/pad.png | bin | 0 -> 584 bytes | |||
-rw-r--r-- | altosdroid/res/drawable/rocket.png | bin | 0 -> 1286 bytes | |||
-rw-r--r-- | altosdroid/res/layout/altosdroid.xml | 2 | ||||
-rw-r--r-- | altosdroid/res/layout/tab_map.xml | 120 | ||||
-rw-r--r-- | altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java | 4 | ||||
-rw-r--r-- | altosdroid/src/org/altusmetrum/AltosDroid/AltosViewPager.java | 43 | ||||
-rw-r--r-- | altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java | 104 | ||||
-rw-r--r-- | configure.ac | 46 |
10 files changed, 308 insertions, 17 deletions
@@ -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 diff --git a/altosdroid/Makefile.am b/altosdroid/Makefile.am index 3dbabdd7..0473c17a 100644 --- a/altosdroid/Makefile.am +++ b/altosdroid/Makefile.am @@ -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 Binary files differnew file mode 100644 index 00000000..b2e65c8a --- /dev/null +++ b/altosdroid/res/drawable/pad.png diff --git a/altosdroid/res/drawable/rocket.png b/altosdroid/res/drawable/rocket.png Binary files differnew file mode 100644 index 00000000..7e62f6c4 --- /dev/null +++ b/altosdroid/res/drawable/rocket.png diff --git a/altosdroid/res/layout/altosdroid.xml b/altosdroid/res/layout/altosdroid.xml index ce812414..364f6ba6 100644 --- a/altosdroid/res/layout/altosdroid.xml +++ b/altosdroid/res/layout/altosdroid.xml @@ -176,7 +176,7 @@ 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" diff --git a/altosdroid/res/layout/tab_map.xml b/altosdroid/res/layout/tab_map.xml index 4737fae0..b9f4e69e 100644 --- a/altosdroid/res/layout/tab_map.xml +++ b/altosdroid/res/layout/tab_map.xml @@ -15,8 +15,122 @@ 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 diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index 63043abd..c9ce46a0 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -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 index 00000000..ebddc266 --- /dev/null +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosViewPager.java @@ -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 diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java index b30b4694..8fc8f592 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java @@ -17,23 +17,45 @@ 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) { @@ -43,12 +65,36 @@ public class TabMap extends Fragment implements AltosDroidTab { } @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); + } + } } } diff --git a/configure.ac b/configure.ac index f9a892df..977678f3 100644 --- a/configure.ac +++ b/configure.ac @@ -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]) |