updated the manifest to reflect com.TwentyCodes.android.location as the main package

Created the abstract class MapFragmentBase.java to be used as a template for creating new mapfragments.

Created UserOverlayMapFragment.java & SkyHookUserOverlayMapFragment.java. these two mapfragments each maintain the mapview and its respected user overlay, allowing for simpler implmention
This commit is contained in:
2012-01-12 15:20:42 +00:00
parent 1a858f1335
commit 51e03d9d9d
48 changed files with 381 additions and 70 deletions

View File

@@ -8,5 +8,6 @@
<attribute name="javadoc_location" value="http://tcdevsvn1/ShyHookdocumentation"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="/app/android-sdk-linux_86/extras/android-support-v4-r6-googlemaps.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

View File

@@ -1,23 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.TwentyCodes.android.SkyHook"
android:versionName="0.1.1" android:versionCode="11">
<application android:label="@string/app_name">
<service android:exported="true" android:enabled="true" android:process=":locationservice" android:name="SkyHookService"></service>
<receiver android:enabled="true" android:exported="true" android:process=":startinglocationservice" android:name="com.TwentyCodes.android.location.ServiceWakeUpReceiver"></receiver>
package="com.TwentyCodes.android.location"
android:versionCode="11"
android:versionName="0.1.1" >
<application android:label="@string/app_name" >
<service
android:name="SkyHookService"
android:enabled="true"
android:exported="true"
android:process=":locationservice" >
</service>
<service android:name="com.TwentyCodes.android.location.LocationService" android:process=":locationservice" android:enabled="true" android:exported="true"></service>
<receiver
android:name="com.TwentyCodes.android.location.ServiceWakeUpReceiver"
android:enabled="true"
android:exported="true"
android:process=":startinglocationservice" >
</receiver>
<activity android:name="Splash"></activity>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CONTROL_LOCATION_UPDATES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
</manifest>
<service
android:name="com.TwentyCodes.android.location.LocationService"
android:enabled="true"
android:exported="true"
android:process=":locationservice" >
</service>
<activity android:name="Splash" >
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CONTROL_LOCATION_UPDATES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" >
</uses-permission>
</manifest>

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 898 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 760 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 751 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 466 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 776 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 527 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 417 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 473 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 276 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 664 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 567 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 608 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 359 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 949 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 943 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 579 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 825 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -1,50 +0,0 @@
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package com.TwentyCodes.android.SkyHook;
public final class R {
public static final class attr {
}
public static final class drawable {
public static int compass=0x7f020000;
public static int compass_lrg=0x7f020001;
public static int compass_med=0x7f020002;
public static int compass_sm=0x7f020003;
public static int logoidea3=0x7f020004;
public static int map_action_bar=0x7f020005;
public static int map_mode_action_bar=0x7f020006;
public static int mark_my_location_action_bar=0x7f020007;
public static int my_location_action_bar=0x7f020008;
public static int nav_action_bar=0x7f020009;
public static int needle=0x7f02000a;
public static int needle_lrg=0x7f02000b;
public static int needle_med=0x7f02000c;
public static int needle_sm=0x7f02000d;
public static int skyhook_logo=0x7f02000e;
public static int skyhook_logo_alpha=0x7f02000f;
public static int skyhook_logo_alpha_small=0x7f020010;
public static int tc_logo_complete=0x7f020011;
public static int user=0x7f020012;
public static int user_arrow_animation_1=0x7f020013;
public static int user_arrow_animation_2=0x7f020014;
public static int user_arrow_animation_3=0x7f020015;
}
public static final class id {
public static int skyhook_img=0x7f050000;
public static int tc_img=0x7f050002;
public static int text=0x7f050001;
}
public static final class layout {
public static int powered_by_skyhook=0x7f030000;
}
public static final class string {
public static int app_name=0x7f040000;
public static int gps_fix=0x7f040001;
public static int sorry_theres_trouble=0x7f040002;
}
}

Binary file not shown.

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
ricky beta release 0rKmsWMM0D-IRAEgcSZEqwZCs_8AUwxjYjj0bnA
ricky 0rKmsWMM0D-LWOndcfwrmW-S0OXlnQl2SJCMeTg
TWENTYCODES 0rKmsWMM0D-K15bEM_kwabPbNhsn4dp4rcq2q5Q
-->
<com.TwentyCodes.android.location.MapView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:apiKey="0rKmsWMM0D-LWOndcfwrmW-S0OXlnQl2SJCMeTg" />

View File

@@ -0,0 +1,127 @@
/**
* UserOverlayMapFragmentBase.java
* @date Jan 12, 2012
* @author ricky barrette
* @author Twenty Codes, LLC
*/
package com.TwentyCodes.android.SkyHook;
import com.TwentyCodes.android.location.CompassListener;
import com.TwentyCodes.android.location.GeoPointLocationListener;
import com.TwentyCodes.android.location.MapFragmentBase;
import com.TwentyCodes.android.location.MapView;
import com.google.android.maps.GeoPoint;
/**
* This is a MapFragment that maintains the SkyHookUserOverlay
*
* TODO acquiring gps dialog
* @author ricky barrette
*/
public class SkyHoookUserOverlayMapFragment extends MapFragmentBase implements GeoPointLocationListener, CompassListener{
private SkyHookUserOverlay mUserOverlay;
private GeoPointLocationListener mGeoPointLocationListener;
private CompassListener mCompassListener;
/**
* Creates a new UserOverlayMapFragment
* @author ricky barrette
*/
public SkyHoookUserOverlayMapFragment() {
super();
}
/**
* @return the users current location
* @author ricky barrette
*/
public GeoPoint getUserLocation() {
return mUserOverlay.getUserLocation();
}
/**
* Called when the compass is updated
* (non-Javadoc)
* @see com.TwentyCodes.android.location.CompassListener#onCompassUpdate(float)
*/
@Override
public void onCompassUpdate(float bearing) {
if(mCompassListener != null)
mCompassListener.onCompassUpdate(bearing);
}
/**
* Called when has a location to report
* @author ricky barrette
*/
@Override
public void onLocationChanged(GeoPoint point, int accuracy) {
if(mGeoPointLocationListener != null)
mGeoPointLocationListener.onLocationChanged(point, accuracy);
}
/**
* (non-Javadoc)
* @see com.TwentyCodes.android.location.MapFragmentBase#onMapViewCreate(com.TwentyCodes.android.location.MapView)
*/
@Override
public void onMapViewCreate(MapView map) {
mUserOverlay = new SkyHookUserOverlay(map, this.getActivity().getApplicationContext());
mUserOverlay.registerListener(this);
mUserOverlay.setCompassListener(this);
mUserOverlay.enableCompass();
mUserOverlay.disableGPSDialog();
mUserOverlay.followUser(true);
map.getOverlays().add(mUserOverlay);
}
/**
* (non-Javadoc)
* @see com.TwentyCodes.android.location.MapFragmentBase#onPause()
*/
@Override
public void onPause() {
mUserOverlay.disableMyLocation();
removeOverlay(mUserOverlay);
super.onPause();
}
/**
* (non-Javadoc)
* @see com.TwentyCodes.android.location.MapFragmentBase#onResume()
*/
@Override
public void onResume() {
if(mUserOverlay != null)
mUserOverlay.enableMyLocation();
super.onResume();
}
/**
* @param listener
* @author ricky barrette
*/
public void setCompassListener(CompassListener listener){
mCompassListener = listener;
}
/**
* Sets the destination for the compass to point to
* @param destination
* @author ricky barrette
*/
public void setDestination(GeoPoint destination){
mUserOverlay.setDestination(destination);
}
/**
* @param listener
* @author ricky barrette
*/
public void setGeoPointLocationListener(GeoPointLocationListener listener){
mGeoPointLocationListener = listener;
}
}

View File

@@ -5,6 +5,8 @@
*/
package com.TwentyCodes.android.SkyHook;
import com.TwentyCodes.android.location.R;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;

View File

@@ -15,7 +15,7 @@ import android.graphics.Matrix;
import android.graphics.Point;
import android.util.TypedValue;
import com.TwentyCodes.android.SkyHook.R;
import com.TwentyCodes.android.location.R;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;

View File

@@ -0,0 +1,75 @@
/**
* MapFragment.java
* @date Jan 7, 2012
* @author ricky barrette
* @author Twenty Codes, LLC
*/
package com.TwentyCodes.android.location;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.maps.GeoPoint;
/**
* This map fragment will maintain a map view and all its functions
*
* @author ricky barrette
*/
public abstract class MapFragmentBase extends Fragment {
private MapView mMapView;
/**
* Creates a new MapFragment
* @author ricky barrette
*/
public MapFragmentBase() {
super();
}
/**
* Called when the fragment view is first created
* (non-Javadoc)
* @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.map_fragment, container, false);
mMapView = (MapView) view.findViewById(R.id.mapview);
mMapView.setClickable(true);
onMapViewCreate(mMapView);
return view;
}
/**
* Called when the mapview has been initialized. here you want to init and add your custom overlays
* @param map
* @author ricky barrette
*/
public abstract void onMapViewCreate(MapView map);
/**
* Removes an overlay from the mapview
* @param overlay
* @author ricky barrette
*/
protected void removeOverlay(Object overlay){
mMapView.getOverlays().remove(overlay);
}
/**
* Sets the center of the map to the provided point
* @param point
* @author ricky barrette
*/
public void setMapCenter(GeoPoint point){
mMapView.getController().setCenter(point);
}
}

View File

@@ -22,7 +22,7 @@ import android.os.Handler;
import android.os.SystemClock;
import android.util.Log;
import com.TwentyCodes.android.SkyHook.R;
import com.TwentyCodes.android.location.R;
import com.TwentyCodes.android.debug.Debug;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;

View File

@@ -0,0 +1,123 @@
/**
* UserOverlayMapFragment.java
* @date Jan 12, 2012
* @author ricky barrette
* @author Twenty Codes, LLC
*/
package com.TwentyCodes.android.location;
import com.google.android.maps.GeoPoint;
/**
* This is a MapFragment that maintains the UserOverlay
*
* TODO acquiring gps dialog
* @author ricky barrette
*/
public class UserOverlayMapFragment extends MapFragmentBase implements GeoPointLocationListener, CompassListener{
private UserOverlay mUserOverlay;
private GeoPointLocationListener mGeoPointLocationListener;
private CompassListener mCompassListener;
/**
* Creates a new UserOverlayMapFragment
* @author ricky barrette
*/
public UserOverlayMapFragment() {
super();
}
/**
* @return the users current location
* @author ricky barrette
*/
public GeoPoint getUserLocation() {
return mUserOverlay.getUserLocation();
}
/**
* Called when the compass is updated
* (non-Javadoc)
* @see com.TwentyCodes.android.location.CompassListener#onCompassUpdate(float)
*/
@Override
public void onCompassUpdate(float bearing) {
if(mCompassListener != null)
mCompassListener.onCompassUpdate(bearing);
}
/**
* Called when skyhook has a location to report
* @author ricky barrette
*/
@Override
public void onLocationChanged(GeoPoint point, int accuracy) {
if(mGeoPointLocationListener != null)
mGeoPointLocationListener.onLocationChanged(point, accuracy);
}
/**
* (non-Javadoc)
* @see com.TwentyCodes.android.location.MapFragmentBase#onMapViewCreate(com.TwentyCodes.android.location.MapView)
*/
@Override
public void onMapViewCreate(MapView map) {
mUserOverlay = new UserOverlay(map, this.getActivity().getApplicationContext());
mUserOverlay.registerListener(this);
mUserOverlay.setCompassListener(this);
mUserOverlay.enableCompass();
mUserOverlay.disableGPSDialog();
mUserOverlay.followUser(true);
map.getOverlays().add(mUserOverlay);
}
/**
* (non-Javadoc)
* @see com.TwentyCodes.android.location.MapFragmentBase#onPause()
*/
@Override
public void onPause() {
mUserOverlay.disableMyLocation();
removeOverlay(mUserOverlay);
super.onPause();
}
/**
* (non-Javadoc)
* @see com.TwentyCodes.android.location.MapFragmentBase#onResume()
*/
@Override
public void onResume() {
if(mUserOverlay != null)
mUserOverlay.enableMyLocation();
super.onResume();
}
/**
* @param listener
* @author ricky barrette
*/
public void setCompassListener(CompassListener listener){
mCompassListener = listener;
}
/**
* Sets the destination for the compass to point to
* @param destination
* @author ricky barrette
*/
public void setDestination(GeoPoint destination){
mUserOverlay.setDestination(destination);
}
/**
* @param listener
* @author ricky barrette
*/
public void setGeoPointLocationListener(GeoPointLocationListener listener){
mGeoPointLocationListener = listener;
}
}