diff options
| -rw-r--r-- | altosdroid/res/layout/tab_map.xml | 340 | ||||
| -rw-r--r-- | altosdroid/res/layout/tab_map_offline.xml | 199 | ||||
| -rw-r--r-- | altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java | 1 | ||||
| -rw-r--r-- | altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java | 251 | ||||
| -rw-r--r-- | altosdroid/src/org/altusmetrum/AltosDroid/TabMapOffline.java | 172 | 
5 files changed, 255 insertions, 708 deletions
| diff --git a/altosdroid/res/layout/tab_map.xml b/altosdroid/res/layout/tab_map.xml index b4c97f91..2388a20b 100644 --- a/altosdroid/res/layout/tab_map.xml +++ b/altosdroid/res/layout/tab_map.xml @@ -20,168 +20,180 @@  	android:layout_height="match_parent"  	android:orientation="vertical" > -  	<LinearLayout -	    android:id="@+id/map" -	    android:orientation="horizontal" -	    android:layout_width="fill_parent" -	    android:layout_height="fill_parent" -	    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:paddingRight="4dp" -				android:text="@string/distance_label" /> - -			<TextView -				android:id="@+id/distance_value" -				android:layout_width="wrap_content" -				android:layout_height="wrap_content" -				android:layout_toRightOf="@+id/distance_label" -				android:text="" -				android:textAppearance="?android:attr/textAppearanceSmall" /> -		</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:paddingRight="4dp" -				android:text="@string/bearing_label" /> - -			<TextView -				android:id="@+id/bearing_value" -				android:layout_width="wrap_content" -				android:layout_height="wrap_content" -				android:layout_toRightOf="@+id/bearing_label" -				android:text="" -				android:textAppearance="?android:attr/textAppearanceSmall" /> -		</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/target_lat_label" -				android:layout_width="wrap_content" -				android:layout_height="wrap_content" -				android:paddingRight="4dp" -				android:text="@string/target_latitude_label" /> - -			<TextView -				android:id="@+id/target_lat_value" -				android:layout_width="wrap_content" -				android:layout_height="wrap_content" -				android:layout_toRightOf="@id/target_lat_label" -				android:text="" -				android:textAppearance="?android:attr/textAppearanceSmall" /> -		</RelativeLayout> - -		<RelativeLayout -			android:layout_width="0dp" -			android:layout_height="wrap_content" -			android:layout_weight="1" -			android:paddingTop="5dp" > - -			<TextView -				android:id="@+id/target_lon_label" -				android:layout_width="wrap_content" -				android:layout_height="wrap_content" -				android:paddingRight="4dp" -				android:text="@string/target_longitude_label" /> - -			<TextView -				android:id="@+id/target_lon_value" -				android:layout_width="wrap_content" -				android:layout_height="wrap_content" -				android:layout_toRightOf="@id/target_lon_label" -				android:text="" -				android:textAppearance="?android:attr/textAppearanceSmall" /> -		</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/receiver_lat_label" -				android:layout_width="wrap_content" -				android:layout_height="wrap_content" -				android:paddingRight="4dp" -				android:text="@string/receiver_latitude_label" /> - -			<TextView -				android:id="@+id/receiver_lat_value" -				android:layout_width="wrap_content" -				android:layout_height="wrap_content" -				android:layout_toRightOf="@id/receiver_lat_label" -				android:text="" -				android:textAppearance="?android:attr/textAppearanceSmall" /> -		</RelativeLayout> - -		<RelativeLayout -			android:layout_width="0dp" -			android:layout_height="wrap_content" -			android:layout_weight="1" -			android:paddingTop="5dp" > - -			<TextView -				android:id="@+id/receiver_lon_label" -				android:layout_width="wrap_content" -				android:layout_height="wrap_content" -				android:paddingRight="4dp" -				android:text="@string/receiver_longitude_label" /> - -			<TextView -				android:id="@+id/receiver_lon_value" -				android:layout_width="wrap_content" -				android:layout_height="wrap_content" -				android:layout_toRightOf="@id/receiver_lon_label" -				android:text="" -				android:textAppearance="?android:attr/textAppearanceSmall" /> -		</RelativeLayout> -	</LinearLayout> +  <FrameLayout +      android:layout_width="fill_parent" +      android:layout_height="wrap_content" +      android:baselineAligned="true" +      android:orientation="horizontal" +      android:layout_weight="1"> +    <LinearLayout +	android:id="@+id/map_online" +	android:orientation="horizontal" +	android:layout_width="fill_parent" +	android:layout_height="fill_parent" +	android:layout_weight="1"> +    </LinearLayout> +    <org.altusmetrum.AltosDroid.AltosMapOffline android:id="@+id/map_offline" +						android:layout_width="fill_parent" +						android:layout_height="wrap_content" +						android:layout_weight="1" +						/> +  </FrameLayout> +   +  <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:paddingRight="4dp" +	  android:text="@string/distance_label" /> + +      <TextView +	  android:id="@+id/distance_value" +	  android:layout_width="wrap_content" +	  android:layout_height="wrap_content" +	  android:layout_toRightOf="@id/distance_label" +	  android:text="" +	  android:textAppearance="?android:attr/textAppearanceSmall" /> +    </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:paddingRight="4dp" +	  android:text="@string/bearing_label" /> + +      <TextView +	  android:id="@+id/bearing_value" +	  android:layout_width="wrap_content" +	  android:layout_height="wrap_content" +	  android:layout_toRightOf="@id/bearing_label" +	  android:text="" +	  android:textAppearance="?android:attr/textAppearanceSmall" /> +    </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/target_lat_label" +	  android:layout_width="wrap_content" +	  android:layout_height="wrap_content" +	  android:paddingRight="4dp" +	  android:text="@string/target_latitude_label" /> + +      <TextView +	  android:id="@+id/target_lat_value" +	  android:layout_width="wrap_content" +	  android:layout_height="wrap_content" +	  android:layout_toRightOf="@id/target_lat_label" +	  android:text="" +	  android:textAppearance="?android:attr/textAppearanceSmall" /> +    </RelativeLayout> + +    <RelativeLayout +	android:layout_width="0dp" +	android:layout_height="wrap_content" +	android:layout_weight="1" +	android:paddingTop="5dp" > + +      <TextView +	  android:id="@+id/target_lon_label" +	  android:layout_width="wrap_content" +	  android:layout_height="wrap_content" +	  android:paddingRight="4dp" +	  android:text="@string/target_longitude_label" /> + +      <TextView +	  android:id="@+id/target_lon_value" +	  android:layout_width="wrap_content" +	  android:layout_height="wrap_content" +	  android:layout_toRightOf="@id/target_lon_label" +	  android:text="" +	  android:textAppearance="?android:attr/textAppearanceSmall" /> +    </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/receiver_lat_label" +	  android:layout_width="wrap_content" +	  android:layout_height="wrap_content" +	  android:paddingRight="4dp" +	  android:text="@string/receiver_latitude_label" /> + +      <TextView +	  android:id="@+id/receiver_lat_value" +	  android:layout_width="wrap_content" +	  android:layout_height="wrap_content" +	  android:layout_toRightOf="@id/receiver_lat_label" +	  android:text="" +	  android:textAppearance="?android:attr/textAppearanceSmall" /> +    </RelativeLayout> + +    <RelativeLayout +	android:layout_width="0dp" +	android:layout_height="wrap_content" +	android:layout_weight="1" +	android:paddingTop="5dp" > + +      <TextView +	  android:id="@+id/receiver_lon_label" +	  android:layout_width="wrap_content" +	  android:layout_height="wrap_content" +	  android:paddingRight="4dp" +	  android:text="@string/receiver_longitude_label" /> + +      <TextView +	  android:id="@+id/receiver_lon_value" +	  android:layout_width="wrap_content" +	  android:layout_height="wrap_content" +	  android:layout_toRightOf="@id/receiver_lon_label" +	  android:text="" +	  android:textAppearance="?android:attr/textAppearanceSmall" /> +    </RelativeLayout> +  </LinearLayout>  </LinearLayout> diff --git a/altosdroid/res/layout/tab_map_offline.xml b/altosdroid/res/layout/tab_map_offline.xml deleted file mode 100644 index 1b0f28a7..00000000 --- a/altosdroid/res/layout/tab_map_offline.xml +++ /dev/null @@ -1,199 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- -     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. ---> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" -	android:layout_width="match_parent" -	android:layout_height="match_parent" -	android:orientation="vertical" > - -  <FrameLayout -      android:layout_width="fill_parent" -      android:layout_height="wrap_content" -      android:baselineAligned="true" -      android:orientation="horizontal" -      android:layout_weight="1"> -    <LinearLayout -	android:id="@+id/map_online" -	android:orientation="horizontal" -	android:layout_width="fill_parent" -	android:layout_height="fill_parent" -	android:layout_weight="1"> -    </LinearLayout> -    <org.altusmetrum.AltosDroid.AltosMapOffline android:id="@+id/map_view_offline" -						android:layout_width="fill_parent" -						android:layout_height="wrap_content" -						android:layout_weight="1" -						/> -  </FrameLayout> -   -  <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_offline" -	  android:layout_width="wrap_content" -	  android:layout_height="wrap_content" -	  android:paddingRight="4dp" -	  android:text="@string/distance_label" /> - -      <TextView -	  android:id="@+id/distance_value_offline" -	  android:layout_width="wrap_content" -	  android:layout_height="wrap_content" -	  android:layout_toRightOf="@id/distance_label_offline" -	  android:text="" -	  android:textAppearance="?android:attr/textAppearanceSmall" /> -    </RelativeLayout> - -    <RelativeLayout -	android:layout_width="0dp" -	android:layout_height="wrap_content" -	android:layout_weight="1" -	android:paddingTop="5dp" > - -      <TextView -	  android:id="@+id/bearing_label_offline" -	  android:layout_width="wrap_content" -	  android:layout_height="wrap_content" -	  android:paddingRight="4dp" -	  android:text="@string/bearing_label" /> - -      <TextView -	  android:id="@+id/bearing_value_offline" -	  android:layout_width="wrap_content" -	  android:layout_height="wrap_content" -	  android:layout_toRightOf="@id/bearing_label_offline" -	  android:text="" -	  android:textAppearance="?android:attr/textAppearanceSmall" /> -    </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/target_lat_label_offline" -	  android:layout_width="wrap_content" -	  android:layout_height="wrap_content" -	  android:paddingRight="4dp" -	  android:text="@string/target_latitude_label" /> - -      <TextView -	  android:id="@+id/target_lat_value_offline" -	  android:layout_width="wrap_content" -	  android:layout_height="wrap_content" -	  android:layout_toRightOf="@id/target_lat_label_offline" -	  android:text="" -	  android:textAppearance="?android:attr/textAppearanceSmall" /> -    </RelativeLayout> - -    <RelativeLayout -	android:layout_width="0dp" -	android:layout_height="wrap_content" -	android:layout_weight="1" -	android:paddingTop="5dp" > - -      <TextView -	  android:id="@+id/target_lon_label_offline" -	  android:layout_width="wrap_content" -	  android:layout_height="wrap_content" -	  android:paddingRight="4dp" -	  android:text="@string/target_longitude_label" /> - -      <TextView -	  android:id="@+id/target_lon_value_offline" -	  android:layout_width="wrap_content" -	  android:layout_height="wrap_content" -	  android:layout_toRightOf="@id/target_lon_label_offline" -	  android:text="" -	  android:textAppearance="?android:attr/textAppearanceSmall" /> -    </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/receiver_lat_label_offline" -	  android:layout_width="wrap_content" -	  android:layout_height="wrap_content" -	  android:paddingRight="4dp" -	  android:text="@string/receiver_latitude_label" /> - -      <TextView -	  android:id="@+id/receiver_lat_value_offline" -	  android:layout_width="wrap_content" -	  android:layout_height="wrap_content" -	  android:layout_toRightOf="@id/receiver_lat_label_offline" -	  android:text="" -	  android:textAppearance="?android:attr/textAppearanceSmall" /> -    </RelativeLayout> - -    <RelativeLayout -	android:layout_width="0dp" -	android:layout_height="wrap_content" -	android:layout_weight="1" -	android:paddingTop="5dp" > - -      <TextView -	  android:id="@+id/receiver_lon_label_offline" -	  android:layout_width="wrap_content" -	  android:layout_height="wrap_content" -	  android:paddingRight="4dp" -	  android:text="@string/receiver_longitude_label" /> - -      <TextView -	  android:id="@+id/receiver_lon_value_offline" -	  android:layout_width="wrap_content" -	  android:layout_height="wrap_content" -	  android:layout_toRightOf="@id/receiver_lon_label_offline" -	  android:text="" -	  android:textAppearance="?android:attr/textAppearanceSmall" /> -    </RelativeLayout> -  </LinearLayout> -</LinearLayout> diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java index 426e2e84..f6645105 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java @@ -536,7 +536,6 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener {  		mTabsAdapter.addTab(mTabHost.newTabSpec("descent").setIndicator(create_tab_view("Descent")), TabDescent.class, null);  		mTabsAdapter.addTab(mTabHost.newTabSpec("landed").setIndicator(create_tab_view("Landed")), TabLanded.class, null);  		mTabsAdapter.addTab(mTabHost.newTabSpec("map").setIndicator(create_tab_view("Map")), TabMap.class, null); -		mTabsAdapter.addTab(mTabHost.newTabSpec("offmap").setIndicator(create_tab_view("OffMap")), TabMapOffline.class, null);  		// Display the Version  		mVersion = (TextView) findViewById(R.id.version); diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java index ee52d637..9c39e105 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java @@ -18,40 +18,23 @@  package org.altusmetrum.AltosDroid;  import java.util.*; +import java.io.*;  import org.altusmetrum.altoslib_7.*; -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.graphics.*;  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; +import android.support.v4.app.FragmentTransaction; +import android.view.*; +import android.widget.*;  import android.location.Location; +import android.content.*;  public class TabMap extends AltosDroidTab { -	private SupportMapFragment mMapFragment; -	private GoogleMap mMap; -	private boolean mapLoaded = false; -	private HashMap<Integer,Marker> rockets = new HashMap<Integer,Marker>(); -	private Marker mPadMarker; -	private boolean pad_set; -	private Polyline mPolyline; +	AltosLatLon	here;  	private TextView mDistanceView;  	private TextView mBearingView; @@ -59,135 +42,67 @@ public class TabMap extends AltosDroidTab {  	private TextView mTargetLongitudeView;  	private TextView mReceiverLatitudeView;  	private TextView mReceiverLongitudeView; +	private AltosMapOffline map_offline; +	private AltosMapOnline map_online; +	private View view; +	private int map_source; -	private double mapAccuracy = -1; - -	private AltosLatLon my_position = null; -	private AltosLatLon target_position = null; - -	private Bitmap rocket_bitmap(String text) { - -		/* From: http://mapicons.nicolasmollet.com/markers/industry/military/missile-2/ -		 */ -		Bitmap orig_bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.rocket); -		Bitmap bitmap = orig_bitmap.copy(Bitmap.Config.ARGB_8888, true); - -		Canvas canvas = new Canvas(bitmap); -		Paint paint = new Paint(); -		paint.setTextSize(40); -		paint.setColor(0xff000000); - -		Rect	bounds = new Rect(); -		paint.getTextBounds(text, 0, text.length(), bounds); - -		int	width = bounds.right - bounds.left; -		int	height = bounds.bottom - bounds.top; - -		float x = bitmap.getWidth() / 2.0f - width / 2.0f; -		float y = bitmap.getHeight() / 2.0f - height / 2.0f; - -		AltosDebug.debug("map label x %f y %f\n", x, y); - -		canvas.drawText(text, 0, text.length(), x, y, paint); -		return bitmap; -	} - -	private Marker rocket_marker(int serial, double lat, double lon) { -		Bitmap	bitmap = rocket_bitmap(String.format("%d", serial)); - -		return mMap.addMarker(new MarkerOptions() -				      .icon(BitmapDescriptorFactory.fromBitmap(bitmap)) -				      .position(new LatLng(lat, lon)) -				      .visible(true)); +	@Override +	public void onAttach(Activity activity) { +		super.onAttach(activity);  	}  	@Override  	public void onCreate(Bundle savedInstanceState) {  		super.onCreate(savedInstanceState); +	} -		mMapFragment = new SupportMapFragment() { -			@Override -			public void onActivityCreated(Bundle savedInstanceState) { -				super.onActivityCreated(savedInstanceState); -				setupMap(); -			} -		}; +	private void make_offline_map() { +	} + +	private void make_online_map() { +		map_online = new AltosMapOnline(view.getContext()); +		map_online.onCreateView(altos_droid.map_type);  	}  	@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); -		mTargetLatitudeView  = (TextView)v.findViewById(R.id.target_lat_value); -		mTargetLongitudeView = (TextView)v.findViewById(R.id.target_lon_value); -		mReceiverLatitudeView  = (TextView)v.findViewById(R.id.receiver_lat_value); -		mReceiverLongitudeView = (TextView)v.findViewById(R.id.receiver_lon_value); -		return v; +		view = inflater.inflate(R.layout.tab_map, container, false); +		int map_source = AltosDroidPreferences.map_source(); + +		mDistanceView  = (TextView)view.findViewById(R.id.distance_value); +		mBearingView   = (TextView)view.findViewById(R.id.bearing_value); +		mTargetLatitudeView  = (TextView)view.findViewById(R.id.target_lat_value); +		mTargetLongitudeView = (TextView)view.findViewById(R.id.target_lon_value); +		mReceiverLatitudeView  = (TextView)view.findViewById(R.id.receiver_lat_value); +		mReceiverLongitudeView = (TextView)view.findViewById(R.id.receiver_lon_value); +		map_offline = (AltosMapOffline)view.findViewById(R.id.map_offline); +		map_offline.onCreateView(altos_droid.map_type); +		map_online = new AltosMapOnline(view.getContext()); +		map_online.onCreateView(altos_droid.map_type); +		set_map_source(AltosDroidPreferences.map_source()); +		return view;  	}  	@Override  	public void onActivityCreated(Bundle savedInstanceState) {  		super.onActivityCreated(savedInstanceState); -		getChildFragmentManager().beginTransaction().add(R.id.map, mMapFragment).commit(); -	} - -	private void setupMap() { -		mMap = mMapFragment.getMap(); -		if (mMap != null) { -			set_map_type(altos_droid.map_type); -			mMap.setMyLocationEnabled(true); -			mMap.getUiSettings().setTiltGesturesEnabled(false); -			mMap.getUiSettings().setZoomControlsEnabled(false); - -			Bitmap label_bitmap = rocket_bitmap("hello"); - -			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(20) -					                     .color(Color.BLUE) -					                     .visible(false) -					); - -			mapLoaded = true; -		} +		if (map_online != null) +			getChildFragmentManager().beginTransaction().add(R.id.map_online, map_online.mMapFragment).commit();  	} -	private void center(double lat, double lon, double accuracy) { -		if (mapAccuracy < 0 || accuracy < mapAccuracy/10) { -			mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lon),14)); -			mapAccuracy = accuracy; -		} +	@Override +	public void onDestroyView() { +		super.onDestroyView();  	}  	public String tab_name() { return "map"; } -	private void set_rocket(int serial, AltosState state) { -		Marker	marker; - -		if (state.gps == null || state.gps.lat == AltosLib.MISSING) -			return; - -		if (rockets.containsKey(serial)) { -			marker = rockets.get(serial); -			marker.setPosition(new LatLng(state.gps.lat, state.gps.lon)); -		} else { -			marker = rocket_marker(serial, state.gps.lat, state.gps.lon); -			rockets.put(serial, marker); -			marker.setVisible(true); -		} -	} - -	private void remove_rocket(int serial) { -		Marker marker = rockets.get(serial); -		marker.remove(); -		rockets.remove(serial); +	private void center(double lat, double lon, double accuracy) { +		if (map_offline != null) +			map_offline.center(lat, lon, accuracy); +		if (map_online != null) +			map_online.center(lat, lon, accuracy);  	}  	public void show(TelemetryState telem_state, AltosState state, AltosGreatCircle from_receiver, Location receiver) { @@ -196,67 +111,59 @@ public class TabMap extends AltosDroidTab {  			set_value(mDistanceView, AltosConvert.distance, 6, from_receiver.distance);  		} -		if (telem_state != null) { -			for (int serial : rockets.keySet()) { -				if (!telem_state.states.containsKey(serial)) -					remove_rocket(serial); -			} - -			for (int serial : telem_state.states.keySet()) { -				set_rocket(serial, telem_state.states.get(serial)); -			} -		} -  		if (state != null) { -			if (mapLoaded) { -				if (!pad_set && state.pad_lat != AltosLib.MISSING) { -					pad_set = true; -					mPadMarker.setPosition(new LatLng(state.pad_lat, state.pad_lon)); -					mPadMarker.setVisible(true); -				} -			}  			if (state.gps != null) { - -				target_position = new AltosLatLon(state.gps.lat, state.gps.lon); -  				mTargetLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));  				mTargetLongitudeView.setText(AltosDroid.pos(state.gps.lon, "E", "W")); -				if (state.gps.locked && state.gps.nsat >= 4) -					center (state.gps.lat, state.gps.lon, 10);  			}  		}  		if (receiver != null) {  			double accuracy; +			here = new AltosLatLon(receiver.getLatitude(), receiver.getLongitude());  			if (receiver.hasAccuracy())  				accuracy = receiver.getAccuracy();  			else  				accuracy = 1000; - -			my_position = new AltosLatLon(receiver.getLatitude(), receiver.getLongitude()); -			mReceiverLatitudeView.setText(AltosDroid.pos(my_position.lat, "N", "S")); -			mReceiverLongitudeView.setText(AltosDroid.pos(my_position.lon, "E", "W")); -			center (my_position.lat, my_position.lon, accuracy); +			mReceiverLatitudeView.setText(AltosDroid.pos(here.lat, "N", "S")); +			mReceiverLongitudeView.setText(AltosDroid.pos(here.lon, "E", "W")); +			center (here.lat, here.lon, accuracy);  		} - -		if (my_position != null && target_position != null) { -			mPolyline.setPoints(Arrays.asList(new LatLng(my_position.lat, my_position.lon), new LatLng(target_position.lat, target_position.lon))); -			mPolyline.setVisible(true); +		if (map_source == AltosDroidPreferences.MAP_SOURCE_OFFLINE) { +			if (map_offline != null) +				map_offline.show(telem_state, state, from_receiver, receiver); +		} else { +			if (map_online != null) +				map_online.show(telem_state, state, from_receiver, receiver);  		} -  	} +	@Override  	public void set_map_type(int map_type) { -		if (mMap != null) { -			if (map_type == AltosMap.maptype_hybrid) -				mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID); -			else if (map_type == AltosMap.maptype_satellite) -				mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE); -			else if (map_type == AltosMap.maptype_terrain) -				mMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN); -			else -				mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); +		if (map_offline != null) +			map_offline.set_map_type(map_type); +		if (map_online != null) +			map_online.set_map_type(map_type); +	} + +	@Override +	public void set_map_source(int map_source) { +		this.map_source = map_source; +		if (map_source == AltosDroidPreferences.MAP_SOURCE_OFFLINE) { +			if (map_online != null) +				map_online.set_visible(false); +			if (map_offline != null) { +				map_offline.set_visible(true); +				map_offline.show(last_telem_state, last_state, last_from_receiver, last_receiver); +			} +		} else { +			if (map_offline != null) +				map_offline.set_visible(false); +			if (map_online != null) { +				map_online.set_visible(true); +				map_online.show(last_telem_state, last_state, last_from_receiver, last_receiver); +			}  		}  	} diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabMapOffline.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabMapOffline.java deleted file mode 100644 index 26e04c83..00000000 --- a/altosdroid/src/org/altusmetrum/AltosDroid/TabMapOffline.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * 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 java.util.*; -import java.io.*; - -import org.altusmetrum.altoslib_7.*; - -import android.app.Activity; -import android.graphics.*; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentTransaction; -import android.view.*; -import android.widget.*; -import android.location.Location; -import android.content.*; - -public class TabMapOffline extends AltosDroidTab { - -	AltosLatLon	here; - -	private TextView mDistanceView; -	private TextView mBearingView; -	private TextView mTargetLatitudeView; -	private TextView mTargetLongitudeView; -	private TextView mReceiverLatitudeView; -	private TextView mReceiverLongitudeView; -	private AltosMapOffline map_offline; -	private AltosMapOnline map_online; -	private View view; -	private int map_source; - -	@Override -	public void onAttach(Activity activity) { -		super.onAttach(activity); -	} - -	@Override -	public void onCreate(Bundle savedInstanceState) { -		super.onCreate(savedInstanceState); -	} - -	private void make_offline_map() { -	} - -	private void make_online_map() { -		map_online = new AltosMapOnline(view.getContext()); -		map_online.onCreateView(altos_droid.map_type); -	} - -	@Override -	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { -		view = inflater.inflate(R.layout.tab_map_offline, container, false); -		int map_source = AltosDroidPreferences.map_source(); - -		mDistanceView  = (TextView)view.findViewById(R.id.distance_value_offline); -		mBearingView   = (TextView)view.findViewById(R.id.bearing_value_offline); -		mTargetLatitudeView  = (TextView)view.findViewById(R.id.target_lat_value_offline); -		mTargetLongitudeView = (TextView)view.findViewById(R.id.target_lon_value_offline); -		mReceiverLatitudeView  = (TextView)view.findViewById(R.id.receiver_lat_value_offline); -		mReceiverLongitudeView = (TextView)view.findViewById(R.id.receiver_lon_value_offline); -		map_offline = (AltosMapOffline)view.findViewById(R.id.map_view_offline); -		map_offline.onCreateView(altos_droid.map_type); -		map_online = new AltosMapOnline(view.getContext()); -		map_online.onCreateView(altos_droid.map_type); -		set_map_source(AltosDroidPreferences.map_source()); -		return view; -	} - -	@Override -	public void onActivityCreated(Bundle savedInstanceState) { -		super.onActivityCreated(savedInstanceState); -		if (map_online != null) -			getChildFragmentManager().beginTransaction().add(R.id.map_online, map_online.mMapFragment).commit(); -	} - -	@Override -	public void onDestroyView() { -		super.onDestroyView(); -	} - -	public String tab_name() { return "offmap"; } - -	private void center(double lat, double lon, double accuracy) { -		if (map_offline != null) -			map_offline.center(lat, lon, accuracy); -		if (map_online != null) -			map_online.center(lat, lon, accuracy); -	} - -	public void show(TelemetryState telem_state, AltosState state, AltosGreatCircle from_receiver, Location receiver) { -		if (from_receiver != null) { -			mBearingView.setText(String.format("%3.0f°", from_receiver.bearing)); -			set_value(mDistanceView, AltosConvert.distance, 6, from_receiver.distance); -		} - -		if (state != null) { -			if (state.gps != null) { -				mTargetLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S")); -				mTargetLongitudeView.setText(AltosDroid.pos(state.gps.lon, "E", "W")); -			} -		} - -		if (receiver != null) { -			double accuracy; - -			here = new AltosLatLon(receiver.getLatitude(), receiver.getLongitude()); -			if (receiver.hasAccuracy()) -				accuracy = receiver.getAccuracy(); -			else -				accuracy = 1000; -			mReceiverLatitudeView.setText(AltosDroid.pos(here.lat, "N", "S")); -			mReceiverLongitudeView.setText(AltosDroid.pos(here.lon, "E", "W")); -			center (here.lat, here.lon, accuracy); -		} -		if (map_source == AltosDroidPreferences.MAP_SOURCE_OFFLINE) { -			if (map_offline != null) -				map_offline.show(telem_state, state, from_receiver, receiver); -		} else { -			if (map_online != null) -				map_online.show(telem_state, state, from_receiver, receiver); -		} -	} - -	@Override -	public void set_map_type(int map_type) { -		if (map_offline != null) -			map_offline.set_map_type(map_type); -		if (map_online != null) -			map_online.set_map_type(map_type); -	} - -	@Override -	public void set_map_source(int map_source) { -		this.map_source = map_source; -		if (map_source == AltosDroidPreferences.MAP_SOURCE_OFFLINE) { -			if (map_online != null) -				map_online.set_visible(false); -			if (map_offline != null) { -				map_offline.set_visible(true); -				map_offline.show(last_telem_state, last_state, last_from_receiver, last_receiver); -			} -		} else { -			if (map_offline != null) -				map_offline.set_visible(false); -			if (map_online != null) { -				map_online.set_visible(true); -				map_online.show(last_telem_state, last_state, last_from_receiver, last_receiver); -			} -		} -	} - -	public TabMapOffline() { -	} -} | 
