Cleaned up code

This commit is contained in:
2012-07-22 09:36:54 -04:00
parent 6fcc65a605
commit fee38864a7
29 changed files with 984 additions and 703 deletions

View File

@@ -22,7 +22,9 @@ import com.skyhookwireless.wps.WPSReturnCode;
import com.skyhookwireless.wps.XPS; import com.skyhookwireless.wps.XPS;
/** /**
* this calls will be used to create skyhook object that uses an listener interface to interact with the rest of location ringer * this calls will be used to create skyhook object that uses an listener
* interface to interact with the rest of location ringer
*
* @author ricky barrette * @author ricky barrette
*/ */
public class SkyHook implements GeoPointLocationListener { public class SkyHook implements GeoPointLocationListener {
@@ -45,6 +47,7 @@ public class SkyHook implements GeoPointLocationListener{
return WPSContinuation.WPS_CONTINUE; return WPSContinuation.WPS_CONTINUE;
} }
} }
public static final String TAG = "Skyhook"; public static final String TAG = "Skyhook";
public static final String USERNAME = "cjyh95q32gsc"; public static final String USERNAME = "cjyh95q32gsc";
public static final String USERNAME_FOR_TESTING = "twentycodes"; public static final String USERNAME_FOR_TESTING = "twentycodes";
@@ -71,8 +74,8 @@ public class SkyHook implements GeoPointLocationListener{
private boolean isFirstFix; private boolean isFirstFix;
/* /*
* this runnable will be used to check if we have location from skyhook, * this runnable will be used to check if we have location from skyhook, if
* if we dont, then we will us android's location services to fall back on. * we dont, then we will us android's location services to fall back on.
*/ */
private final Runnable mFallBack = new Runnable() { private final Runnable mFallBack = new Runnable() {
@Override @Override
@@ -116,6 +119,7 @@ public class SkyHook implements GeoPointLocationListener{
/** /**
* Constructors a new skyhook object * Constructors a new skyhook object
*
* @param context * @param context
* @author ricky barrette * @author ricky barrette
*/ */
@@ -131,8 +135,10 @@ public class SkyHook implements GeoPointLocationListener{
/** /**
* Constructors a new skyhook object * Constructors a new skyhook object
*
* @param context * @param context
* @param period between location updates in milliseconds * @param period
* between location updates in milliseconds
* @author ricky barrette * @author ricky barrette
*/ */
public SkyHook(final Context context, final long period) { public SkyHook(final Context context, final long period) {
@@ -141,8 +147,10 @@ public class SkyHook implements GeoPointLocationListener{
} }
/** /**
* request current user location, note that the listeners onLocationChanged() will be call multiple times. * request current user location, note that the listeners
* updates will stop once an accurate location is determined. * onLocationChanged() will be call multiple times. updates will stop once
* an accurate location is determined.
*
* @author Ricky Barrette * @author Ricky Barrette
*/ */
public void getLoctaion() { public void getLoctaion() {
@@ -155,6 +163,7 @@ public class SkyHook implements GeoPointLocationListener{
/** /**
* Attempts to register the the listener for periodic updates * Attempts to register the the listener for periodic updates
*
* @author Ricky Barrette * @author Ricky Barrette
*/ */
public void getUpdates() { public void getUpdates() {
@@ -186,9 +195,10 @@ public class SkyHook implements GeoPointLocationListener{
} }
/** /**
* called from our skyhook to android fall back class * called from our skyhook to android fall back class (non-Javadoc)
* (non-Javadoc) *
* @see com.TwentyCodes.android.location.GeoPointLocationListener#onLocationChanged(com.google.android.maps.GeoPoint, int) * @see com.TwentyCodes.android.location.GeoPointLocationListener#onLocationChanged(com.google.android.maps.GeoPoint,
* int)
* @author ricky barrette * @author ricky barrette
*/ */
@Override @Override
@@ -199,9 +209,10 @@ public class SkyHook implements GeoPointLocationListener{
} }
/** /**
* Removes any current registration for location updates of the current activity * Removes any current registration for location updates of the current
* with the given LocationListener. Following this call, updates will no longer * activity with the given LocationListener. Following this call, updates
* occur for this listener. * will no longer occur for this listener.
*
* @param listener * @param listener
* @author ricky barrette * @author ricky barrette
*/ */
@@ -222,9 +233,10 @@ public class SkyHook implements GeoPointLocationListener{
} }
/** /**
* Used for receiving notifications from SkyHook when * Used for receiving notifications from SkyHook when the location has
* the location has changed. These methods are called if the * changed. These methods are called if the LocationListener has been
* LocationListener has been registered with the location manager service using the method. * registered with the location manager service using the method.
*
* @param listener * @param listener
* @author ricky barrette * @author ricky barrette
*/ */
@@ -265,9 +277,11 @@ public class SkyHook implements GeoPointLocationListener{
hasLocation = false; hasLocation = false;
/* /*
* check to see if the error returned is an WPS_ERROR_UNAUTHORIZED * check to see if the error returned is an
* then check to see if this is the second occurrence of WPS_ERROR_UNAUTHORIZED, * WPS_ERROR_UNAUTHORIZED then check to see if this is
* if so we will stop skyhook's services to cut down the work load * the second occurrence of WPS_ERROR_UNAUTHORIZED, if
* so we will stop skyhook's services to cut down the
* work load
*/ */
if (code == WPSReturnCode.WPS_ERROR_UNAUTHORIZED) { if (code == WPSReturnCode.WPS_ERROR_UNAUTHORIZED) {
if (isUnauthorized) { if (isUnauthorized) {
@@ -278,10 +292,10 @@ public class SkyHook implements GeoPointLocationListener{
isUnauthorized = true; isUnauthorized = true;
} }
/* /*
* check to see if we already have a fall back Scheduled * check to see if we already have a fall back Scheduled
* if we dont, and there is not fallback already in place, then schedule one * if we dont, and there is not fallback already in
* place, then schedule one
*/ */
if (!isFallBackScheduled && mSkyHookFallback == null && isEnabled) { if (!isFallBackScheduled && mSkyHookFallback == null && isEnabled) {
Log.d(TAG, "scheduling fallback"); Log.d(TAG, "scheduling fallback");

View File

@@ -17,12 +17,14 @@ import com.skyhookwireless.wps.XPS;
/** /**
* this class will be used to register new users with skyhook * this class will be used to register new users with skyhook
*
* @author ricky barrette * @author ricky barrette
*/ */
public class SkyHookRegistration { public class SkyHookRegistration {
/** /**
* returns the users username * returns the users username
*
* @param context * @param context
* @return * @return
* @author ricky barrette * @author ricky barrette
@@ -45,6 +47,7 @@ public class SkyHookRegistration{
return null; return null;
} }
private final XPS mXps; private final XPS mXps;
private final Context mContext; private final Context mContext;
@@ -58,7 +61,9 @@ public class SkyHookRegistration{
* attempts to register the user by their cell # * attempts to register the user by their cell #
* *
* TODO hash cell number for privacy * TODO hash cell number for privacy
* @param listener for call back methods *
* @param listener
* for call back methods
* @author ricky barrette * @author ricky barrette
*/ */
public void registerNewUser(final RegistrationCallback listener) { public void registerNewUser(final RegistrationCallback listener) {

View File

@@ -26,12 +26,17 @@ import com.skyhookwireless.wps.WPSContinuation;
import com.skyhookwireless.wps.WPSReturnCode; import com.skyhookwireless.wps.WPSReturnCode;
/** /**
* This service class will be used broadcast the users location either one time, or periodically. * This service class will be used broadcast the users location either one time,
* To use as a one shot location service: * or periodically. To use as a one shot location service: <blockquote>
* <blockquote><pre>PendingIntent pendingIntent = PendingIntent.getService(context, 0, SkyHookService.startService(context), 0); *
* <pre>
* PendingIntent pendingIntent = PendingIntent.getService(context, 0, SkyHookService.startService(context), 0);
* or * or
* Intent service = new Intent(context, SkyHookService.class); * Intent service = new Intent(context, SkyHookService.class);
* context.startService(service);<pre></bloackquote> * context.startService(service);
*
* <pre>
* </bloackquote>
* To use as a recurring service: * To use as a recurring service:
* <blockquote>SkyHookService.startService(this, (60000 * Integer.parseInt(ringer.getString(UPDATE_INTVERVAL , "5")))).run();</bloackquote> * <blockquote>SkyHookService.startService(this, (60000 * Integer.parseInt(ringer.getString(UPDATE_INTVERVAL , "5")))).run();</bloackquote>
* @author ricky barrette * @author ricky barrette
@@ -40,8 +45,10 @@ public class SkyHookService extends Service implements GeoPointLocationListener,
public static final String TAG = "SkyHookService"; public static final String TAG = "SkyHookService";
public static final int REQUEST_CODE = 32741942; public static final int REQUEST_CODE = 32741942;
/** /**
* a convince method for getting an intent to start the service * a convince method for getting an intent to start the service
*
* @param context * @param context
* @return a intent that will be used to start the service * @return a intent that will be used to start the service
* @author ricky barrette * @author ricky barrette
@@ -49,8 +56,11 @@ public class SkyHookService extends Service implements GeoPointLocationListener,
public static Intent getStartServiceIntent(final Context context) { public static Intent getStartServiceIntent(final Context context) {
return new Intent(context, SkyHookService.class); return new Intent(context, SkyHookService.class);
} }
/** /**
* a convince method for stopping the service and removing its que from the alarm manager * a convince method for stopping the service and removing its que from the
* alarm manager
*
* @param context * @param context
* @return a runnable that will stop the service * @return a runnable that will stop the service
* @author ricky barrette * @author ricky barrette
@@ -60,10 +70,12 @@ public class SkyHookService extends Service implements GeoPointLocationListener,
@Override @Override
public void run() { public void run() {
context.stopService(new Intent(context, SkyHookService.class)); context.stopService(new Intent(context, SkyHookService.class));
((AlarmManager) context.getSystemService(Context.ALARM_SERVICE)).cancel(PendingIntent.getService(context, REQUEST_CODE, new Intent(context, SkyHookService.class), 0)); ((AlarmManager) context.getSystemService(Context.ALARM_SERVICE)).cancel(PendingIntent.getService(context, REQUEST_CODE, new Intent(context,
SkyHookService.class), 0));
} }
}; };
} }
private SkyHook mSkyhook; private SkyHook mSkyhook;
protected long mPeriod = -1; protected long mPeriod = -1;
private GeoPoint mLocation; private GeoPoint mLocation;
@@ -93,6 +105,7 @@ public class SkyHookService extends Service implements GeoPointLocationListener,
/** /**
* converts skyhook's location object into android's location object * converts skyhook's location object into android's location object
*
* @return converted location * @return converted location
* @author ricky barrette * @author ricky barrette
*/ */
@@ -111,15 +124,18 @@ public class SkyHookService extends Service implements GeoPointLocationListener,
} }
/* /*
* I believe that this method is no longer needed as we are not supporting pre 2.1 * I believe that this method is no longer needed as we are not supporting
* pre 2.1
*/ */
// /** // /**
// * To keep backwards compatibility we override onStart which is the equivalent of onStartCommand in pre android 2.x // * To keep backwards compatibility we override onStart which is the
// equivalent of onStartCommand in pre android 2.x
// * @author ricky barrette // * @author ricky barrette
// */ // */
// @Override // @Override
// public void onStart(Intent intent, int startId) { // public void onStart(Intent intent, int startId) {
// Log.i(SkyHook.TAG, "onStart.Service started with start id of: " + startId); // Log.i(SkyHook.TAG, "onStart.Service started with start id of: " +
// startId);
// parseIntent(intent); // parseIntent(intent);
// this.mSkyhook.getUpdates(); // this.mSkyhook.getUpdates();
// } // }
@@ -138,6 +154,7 @@ public class SkyHookService extends Service implements GeoPointLocationListener,
/** /**
* (non-Javadoc) * (non-Javadoc)
*
* @see android.app.Service#onBind(android.content.Intent) * @see android.app.Service#onBind(android.content.Intent)
* @param arg0 * @param arg0
* @return * @return
@@ -155,8 +172,8 @@ public class SkyHookService extends Service implements GeoPointLocationListener,
mSkyhook.setLocationListener(this); mSkyhook.setLocationListener(this);
/* /*
* fail safe * fail safe this will stop the service after the maximum running time,
* this will stop the service after the maximum running time, if location has not been reported * if location has not been reported
*/ */
new Handler().postDelayed(new Runnable() { new Handler().postDelayed(new Runnable() {
@Override @Override
@@ -167,8 +184,8 @@ public class SkyHookService extends Service implements GeoPointLocationListener,
} }
/** /**
* aborts location services * aborts location services (non-Javadoc)
* (non-Javadoc) *
* @see android.app.Service#onDestroy() * @see android.app.Service#onDestroy()
* @author Ricky Barrette * @author Ricky Barrette
*/ */
@@ -193,18 +210,19 @@ public class SkyHookService extends Service implements GeoPointLocationListener,
mLocation = point; mLocation = point;
mAccuracy = accuracy; mAccuracy = accuracy;
/* /*
* fail safe * fail safe if the accuracy is greater than the minimum required
* if the accuracy is greater than the minimum required accuracy * accuracy then continue else stop to report location
* then continue
* else stop to report location
*/ */
if(accuracy < (mRequiredAccuracy > -1 ? mRequiredAccuracy : LocationLibraryConstants.MINIMUM_REQUIRED_ACCURACY) || LocationLibraryConstants.REPORT_FIRST_LOCATION) if (accuracy < (mRequiredAccuracy > -1 ? mRequiredAccuracy : LocationLibraryConstants.MINIMUM_REQUIRED_ACCURACY)
|| LocationLibraryConstants.REPORT_FIRST_LOCATION)
this.stopSelf(mStartID); this.stopSelf(mStartID);
} }
/** /**
* This method is called when startService is called. only used in 2.x android. * This method is called when startService is called. only used in 2.x
* android.
*
* @author ricky barrette * @author ricky barrette
*/ */
@Override @Override
@@ -236,6 +254,7 @@ public class SkyHookService extends Service implements GeoPointLocationListener,
/** /**
* registers our Receiver the starts the service with the alarm manager * registers our Receiver the starts the service with the alarm manager
*
* @author ricky barrette * @author ricky barrette
*/ */
private void registerWakeUp() { private void registerWakeUp() {

View File

@@ -8,12 +8,14 @@ package com.TwentyCodes.android.debug;
/** /**
* This class will be used to enable and disable debugging features * This class will be used to enable and disable debugging features
*
* @author ricky barrette * @author ricky barrette
*/ */
public class Debug { public class Debug {
/** /**
* Sets the logging level for this library * Sets the logging level for this library
*
* @author ricky barrette * @author ricky barrette
*/ */
public static final boolean DEBUG = false; public static final boolean DEBUG = false;

View File

@@ -12,6 +12,7 @@ import android.location.LocationManager;
/** /**
* This class will be used to set the Location Library Constants * This class will be used to set the Location Library Constants
*
* @author ricky barrette * @author ricky barrette
*/ */
public final class LocationLibraryConstants { public final class LocationLibraryConstants {
@@ -23,31 +24,37 @@ public final class LocationLibraryConstants {
} }
/** /**
* Sets the default SkyHook Registration Behavior used by SkyHookRegistration.getUserName() * Sets the default SkyHook Registration Behavior used by
* SkyHookRegistration.getUserName()
*
* @author ricky barrette * @author ricky barrette
*/ */
public static final SkyHookRegistrationBehavior DEFAULT_REGISTRATION_BEHAVIOR = SkyHookRegistrationBehavior.NORMAL; public static final SkyHookRegistrationBehavior DEFAULT_REGISTRATION_BEHAVIOR = SkyHookRegistrationBehavior.NORMAL;
/** /**
* Sets the default compass sensor update interval * Sets the default compass sensor update interval
*
* @author ricky barrette * @author ricky barrette
*/ */
public static final int COMPASS_UPDATE_INTERVAL = SensorManager.SENSOR_DELAY_NORMAL; public static final int COMPASS_UPDATE_INTERVAL = SensorManager.SENSOR_DELAY_NORMAL;
/** /**
* The maximum running time for a single shot location service * The maximum running time for a single shot location service
*
* @author ricky barrette * @author ricky barrette
*/ */
public static final long MAX_LOCATION_SERVICE_RUN_TIME = 60000l; public static final long MAX_LOCATION_SERVICE_RUN_TIME = 60000l;
/** /**
* Forces single shot location services to return the first location * Forces single shot location services to return the first location
*
* @author ricky barrette * @author ricky barrette
*/ */
public static final boolean REPORT_FIRST_LOCATION = false; public static final boolean REPORT_FIRST_LOCATION = false;
/** /**
* Minimum Required accuracy to report * Minimum Required accuracy to report
*
* @author ricky barrette * @author ricky barrette
*/ */
public static final int MINIMUM_REQUIRED_ACCURACY = 100; public static final int MINIMUM_REQUIRED_ACCURACY = 100;
@@ -61,7 +68,8 @@ public final class LocationLibraryConstants {
public static final String INTENT_EXTRA_LOCATION_CHANGED = LocationManager.KEY_LOCATION_CHANGED; public static final String INTENT_EXTRA_LOCATION_CHANGED = LocationManager.KEY_LOCATION_CHANGED;
/** /**
* Used to tell the service how frequently it needs to run. This is required if you want a multishot service * Used to tell the service how frequently it needs to run. This is required
* if you want a multishot service
*/ */
public static final String INTENT_EXTRA_PERIOD_BETWEEN_UPDATES = "period_beween_updates"; public static final String INTENT_EXTRA_PERIOD_BETWEEN_UPDATES = "period_beween_updates";
@@ -71,7 +79,8 @@ public final class LocationLibraryConstants {
public static final String INTENT_EXTRA_REQUIRED_ACCURACY = "required_accuracy"; public static final String INTENT_EXTRA_REQUIRED_ACCURACY = "required_accuracy";
/** /**
* used if the INTENT_EXTRA_PERIOD_BETWEEN_UPDATES is present, but contains no data * used if the INTENT_EXTRA_PERIOD_BETWEEN_UPDATES is present, but contains
* no data
*/ */
public static final long FAIL_SAFE_UPDATE_INVERVAL = AlarmManager.INTERVAL_FIFTEEN_MINUTES; public static final long FAIL_SAFE_UPDATE_INVERVAL = AlarmManager.INTERVAL_FIFTEEN_MINUTES;
} }

View File

@@ -8,6 +8,7 @@ package com.TwentyCodes.android.debug;
/** /**
* This enum will be used to select the testing level * This enum will be used to select the testing level
*
* @author ricky barrette * @author ricky barrette
*/ */
public enum SkyHookRegistrationBehavior { public enum SkyHookRegistrationBehavior {
@@ -18,7 +19,8 @@ public enum SkyHookRegistrationBehavior {
NORMAL, NORMAL,
/** /**
* Used to force SkyHookRegistration.getUserName to return the testing user name * Used to force SkyHookRegistration.getUserName to return the testing user
* name
*/ */
USE_TESTING_USERNAME, USE_TESTING_USERNAME,

View File

@@ -31,6 +31,7 @@ public abstract class BaseMapFragment extends Fragment {
/** /**
* Creates a new MapFragment * Creates a new MapFragment
*
* @author ricky barrette * @author ricky barrette
*/ */
public BaseMapFragment() { public BaseMapFragment() {
@@ -43,6 +44,7 @@ public abstract class BaseMapFragment extends Fragment {
/** /**
* changes the map mode * changes the map mode
*
* @author ricky barrette * @author ricky barrette
*/ */
public void changeMapMode() { public void changeMapMode() {
@@ -51,6 +53,7 @@ public abstract class BaseMapFragment extends Fragment {
/** /**
* Disables the Acquiring GPS dialog * Disables the Acquiring GPS dialog
*
* @author ricky barrette * @author ricky barrette
*/ */
public void disableGPSProgess() { public void disableGPSProgess() {
@@ -78,6 +81,7 @@ public abstract class BaseMapFragment extends Fragment {
/** /**
* Forces the map to redraw * Forces the map to redraw
*
* @author ricky barrette * @author ricky barrette
*/ */
public void invalidate() { public void invalidate() {
@@ -101,9 +105,10 @@ public abstract class BaseMapFragment extends Fragment {
} }
/** /**
* Called when the fragment view is first created * Called when the fragment view is first created (non-Javadoc)
* (non-Javadoc) *
* @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle) * @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater,
* android.view.ViewGroup, android.os.Bundle)
*/ */
@Override @Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
@@ -120,7 +125,9 @@ public abstract class BaseMapFragment extends Fragment {
} }
/** /**
* Called when the mapview has been initialized. here you want to init and add your custom overlays * Called when the mapview has been initialized. here you want to init and
* add your custom overlays
*
* @param map * @param map
* @author ricky barrette * @author ricky barrette
*/ */
@@ -128,6 +135,7 @@ public abstract class BaseMapFragment extends Fragment {
/** /**
* Removes an overlay from the mapview * Removes an overlay from the mapview
*
* @param overlay * @param overlay
* @author ricky barrette * @author ricky barrette
*/ */
@@ -137,6 +145,7 @@ public abstract class BaseMapFragment extends Fragment {
/** /**
* Enables or disables the built in zoom controls * Enables or disables the built in zoom controls
*
* @param isShowing * @param isShowing
* @author ricky barrette * @author ricky barrette
*/ */
@@ -146,6 +155,7 @@ public abstract class BaseMapFragment extends Fragment {
/** /**
* Sets where or not the map view is interactive * Sets where or not the map view is interactive
*
* @param isClickable * @param isClickable
* @author ricky barrette * @author ricky barrette
*/ */
@@ -155,6 +165,7 @@ public abstract class BaseMapFragment extends Fragment {
/** /**
* Sets double tap zoom * Sets double tap zoom
*
* @param isDoubleTapZoonEnabled * @param isDoubleTapZoonEnabled
* @author ricky barrette * @author ricky barrette
*/ */
@@ -164,6 +175,7 @@ public abstract class BaseMapFragment extends Fragment {
/** /**
* Sets the center of the map to the provided point * Sets the center of the map to the provided point
*
* @param point * @param point
* @author ricky barrette * @author ricky barrette
*/ */
@@ -176,6 +188,7 @@ public abstract class BaseMapFragment extends Fragment {
/** /**
* Sets the view of the map. true is sat, false is map * Sets the view of the map. true is sat, false is map
*
* @param isSat * @param isSat
* @author ricky barrette * @author ricky barrette
*/ */
@@ -185,6 +198,7 @@ public abstract class BaseMapFragment extends Fragment {
/** /**
* Sets the zoom level of the map * Sets the zoom level of the map
*
* @param zoom * @param zoom
* @author ricky barrette * @author ricky barrette
*/ */

View File

@@ -17,26 +17,30 @@ import com.TwentyCodes.android.location.R;
import com.TwentyCodes.android.overlays.DirectionsOverlay; import com.TwentyCodes.android.overlays.DirectionsOverlay;
/** /**
* this is a custom listview adaptor that wills a listview that has 2 textviews in each row. * this is a custom listview adaptor that wills a listview that has 2 textviews
* in each row.
*
* @author ricky barrette * @author ricky barrette
*/ */
public class DirectionsAdapter extends BaseAdapter { public class DirectionsAdapter extends BaseAdapter {
/** /**
* this class will hold the TextViews * this class will hold the TextViews
*
* @author ricky barrette * @author ricky barrette
*/ */
class ViewHolder { class ViewHolder {
TextView text; TextView text;
TextView text2; TextView text2;
} }
private final LayoutInflater mInflater;
private final LayoutInflater mInflater;
private final DirectionsOverlay mDirections; private final DirectionsOverlay mDirections;
/** /**
* Creates a new DirectionsAdapter * Creates a new DirectionsAdapter
*
* @author ricky barrette * @author ricky barrette
*/ */
public DirectionsAdapter(final Context context, final DirectionsOverlay directions) { public DirectionsAdapter(final Context context, final DirectionsOverlay directions) {
@@ -46,6 +50,7 @@ public class DirectionsAdapter extends BaseAdapter {
/** /**
* returns the size of the main list * returns the size of the main list
*
* @see android.widget.Adapter#getCount() * @see android.widget.Adapter#getCount()
* @return * @return
* @author ricky barrette * @author ricky barrette
@@ -57,6 +62,7 @@ public class DirectionsAdapter extends BaseAdapter {
/** /**
* (non-Javadoc) * (non-Javadoc)
*
* @see android.widget.Adapter#getItem(int) * @see android.widget.Adapter#getItem(int)
* @param position * @param position
* @return * @return
@@ -69,6 +75,7 @@ public class DirectionsAdapter extends BaseAdapter {
/** /**
* returns the current position in the list * returns the current position in the list
*
* @see android.widget.Adapter#getItemId(int) * @see android.widget.Adapter#getItemId(int)
* @param position * @param position
* @return * @return
@@ -81,7 +88,9 @@ public class DirectionsAdapter extends BaseAdapter {
/** /**
* inflates the row from xml, and sets the textviews to their intended vales * inflates the row from xml, and sets the textviews to their intended vales
* @see android.widget.Adapter#getView(int, android.view.View, android.view.ViewGroup) *
* @see android.widget.Adapter#getView(int, android.view.View,
* android.view.ViewGroup)
* @param position * @param position
* @param convertView * @param convertView
* @param parent * @param parent

View File

@@ -17,20 +17,23 @@ import com.TwentyCodes.android.overlays.DirectionsOverlay;
import com.google.android.maps.GeoPoint; import com.google.android.maps.GeoPoint;
/** /**
* This fragment will be used to display directions to the user. * This fragment will be used to display directions to the user. When a specific
* When a specific direction is clicked, the corrispoding geopoint is returned via listener * direction is clicked, the corrispoding geopoint is returned via listener
*
* @author ricky barrette * @author ricky barrette
*/ */
public class DirectionsListFragment extends ListFragment { public class DirectionsListFragment extends ListFragment {
/** /**
* A simple interfrace for a directions list fragment * A simple interfrace for a directions list fragment
*
* @author ricky barrette * @author ricky barrette
*/ */
public interface OnDirectionSelectedListener { public interface OnDirectionSelectedListener {
/** /**
* Called when the user selects a direction from a directions list * Called when the user selects a direction from a directions list
*
* @param point * @param point
* @author ricky barrette * @author ricky barrette
*/ */
@@ -43,6 +46,7 @@ public class DirectionsListFragment extends ListFragment {
/** /**
* Creates a new Directions List Fragment * Creates a new Directions List Fragment
*
* @author ricky barrette * @author ricky barrette
*/ */
public DirectionsListFragment() { public DirectionsListFragment() {
@@ -51,6 +55,7 @@ public class DirectionsListFragment extends ListFragment {
/** /**
* Creates a new Directions List Fragment * Creates a new Directions List Fragment
*
* @param listener * @param listener
* @author ricky barrette * @author ricky barrette
*/ */
@@ -61,6 +66,7 @@ public class DirectionsListFragment extends ListFragment {
/** /**
* Deletes all content in the listview * Deletes all content in the listview
*
* @author ricky barrette * @author ricky barrette
*/ */
public void clear() { public void clear() {
@@ -68,10 +74,12 @@ public class DirectionsListFragment extends ListFragment {
} }
/** /**
* Called when a list item is clicked. * Called when a list item is clicked. Checks to see if the list item is a
* Checks to see if the list item is a direction, if to it reports the selected direction's geopoint to the listener * direction, if to it reports the selected direction's geopoint to the
* (non-Javadoc) * listener (non-Javadoc)
* @see android.widget.AdapterView.OnItemClickListener#onItemClick(android.widget.AdapterView, android.view.View, int, long) *
* @see android.widget.AdapterView.OnItemClickListener#onItemClick(android.widget.AdapterView,
* android.view.View, int, long)
*/ */
@Override @Override
public void onListItemClick(final ListView l, final View w, final int position, final long id) { public void onListItemClick(final ListView l, final View w, final int position, final long id) {
@@ -82,6 +90,7 @@ public class DirectionsListFragment extends ListFragment {
/** /**
* (non-Javadoc) * (non-Javadoc)
*
* @see android.support.v4.app.Fragment#onStart() * @see android.support.v4.app.Fragment#onStart()
*/ */
@Override @Override
@@ -92,6 +101,7 @@ public class DirectionsListFragment extends ListFragment {
/** /**
* Displays the directions from the provided DirectionsOverlay object * Displays the directions from the provided DirectionsOverlay object
*
* @param directions * @param directions
* @author ricky barrette * @author ricky barrette
*/ */
@@ -102,6 +112,7 @@ public class DirectionsListFragment extends ListFragment {
/** /**
* Sets the text to be displayed while the list is empty * Sets the text to be displayed while the list is empty
*
* @param text * @param text
* @author ricky barrette * @author ricky barrette
*/ */

View File

@@ -16,6 +16,7 @@ import com.google.android.maps.GeoPoint;
* This is a MapFragment that maintains the SkyHookUserOverlay * This is a MapFragment that maintains the SkyHookUserOverlay
* *
* TODO acquiring gps dialog * TODO acquiring gps dialog
*
* @author ricky barrette * @author ricky barrette
*/ */
public class SkyHoookUserOverlayMapFragment extends BaseMapFragment implements GeoPointLocationListener, CompassListener { public class SkyHoookUserOverlayMapFragment extends BaseMapFragment implements GeoPointLocationListener, CompassListener {
@@ -26,6 +27,7 @@ public class SkyHoookUserOverlayMapFragment extends BaseMapFragment implements G
/** /**
* Creates a new UserOverlayMapFragment * Creates a new UserOverlayMapFragment
*
* @author ricky barrette * @author ricky barrette
*/ */
public SkyHoookUserOverlayMapFragment() { public SkyHoookUserOverlayMapFragment() {
@@ -34,6 +36,7 @@ public class SkyHoookUserOverlayMapFragment extends BaseMapFragment implements G
/** /**
* Tells the useroverlay to pan the map to follow the user * Tells the useroverlay to pan the map to follow the user
*
* @param followUser * @param followUser
* @author ricky barrette * @author ricky barrette
*/ */
@@ -58,8 +61,8 @@ public class SkyHoookUserOverlayMapFragment extends BaseMapFragment implements G
} }
/** /**
* Called when the compass is updated * Called when the compass is updated (non-Javadoc)
* (non-Javadoc) *
* @see com.TwentyCodes.android.location.CompassListener#onCompassUpdate(float) * @see com.TwentyCodes.android.location.CompassListener#onCompassUpdate(float)
*/ */
@Override @Override
@@ -76,6 +79,7 @@ public class SkyHoookUserOverlayMapFragment extends BaseMapFragment implements G
/** /**
* Called when has a location to report * Called when has a location to report
*
* @author ricky barrette * @author ricky barrette
*/ */
@Override @Override
@@ -86,6 +90,7 @@ public class SkyHoookUserOverlayMapFragment extends BaseMapFragment implements G
/** /**
* (non-Javadoc) * (non-Javadoc)
*
* @see com.TwentyCodes.android.fragments.BaseMapFragment#onMapViewCreate(com.TwentyCodes.android.location.MapView) * @see com.TwentyCodes.android.fragments.BaseMapFragment#onMapViewCreate(com.TwentyCodes.android.location.MapView)
*/ */
@Override @Override
@@ -101,6 +106,7 @@ public class SkyHoookUserOverlayMapFragment extends BaseMapFragment implements G
/** /**
* (non-Javadoc) * (non-Javadoc)
*
* @see com.TwentyCodes.android.fragments.BaseMapFragment#onPause() * @see com.TwentyCodes.android.fragments.BaseMapFragment#onPause()
*/ */
@Override @Override
@@ -112,6 +118,7 @@ public class SkyHoookUserOverlayMapFragment extends BaseMapFragment implements G
/** /**
* (non-Javadoc) * (non-Javadoc)
*
* @see com.TwentyCodes.android.fragments.BaseMapFragment#onResume() * @see com.TwentyCodes.android.fragments.BaseMapFragment#onResume()
*/ */
@Override @Override
@@ -125,6 +132,7 @@ public class SkyHoookUserOverlayMapFragment extends BaseMapFragment implements G
/** /**
* reorders the overlays to the UserOverlay always on top * reorders the overlays to the UserOverlay always on top
*
* @author ricky barrette * @author ricky barrette
*/ */
public void reorderOverlays() { public void reorderOverlays() {
@@ -153,6 +161,7 @@ public class SkyHoookUserOverlayMapFragment extends BaseMapFragment implements G
/** /**
* Sets the destination for the compass to point to * Sets the destination for the compass to point to
*
* @param destination * @param destination
* @author ricky barrette * @author ricky barrette
*/ */

View File

@@ -16,6 +16,7 @@ import com.google.android.maps.GeoPoint;
* This is a MapFragment that maintains the UserOverlay * This is a MapFragment that maintains the UserOverlay
* *
* TODO acquiring gps dialog * TODO acquiring gps dialog
*
* @author ricky barrette * @author ricky barrette
*/ */
public class UserOverlayMapFragment extends BaseMapFragment implements GeoPointLocationListener, CompassListener { public class UserOverlayMapFragment extends BaseMapFragment implements GeoPointLocationListener, CompassListener {
@@ -26,6 +27,7 @@ public class UserOverlayMapFragment extends BaseMapFragment implements GeoPointL
/** /**
* Creates a new UserOverlayMapFragment * Creates a new UserOverlayMapFragment
*
* @author ricky barrette * @author ricky barrette
*/ */
public UserOverlayMapFragment() { public UserOverlayMapFragment() {
@@ -34,6 +36,7 @@ public class UserOverlayMapFragment extends BaseMapFragment implements GeoPointL
/** /**
* Tells the useroverlay to pan the map to follow the user * Tells the useroverlay to pan the map to follow the user
*
* @param followUser * @param followUser
* @author ricky barrette * @author ricky barrette
*/ */
@@ -58,8 +61,8 @@ public class UserOverlayMapFragment extends BaseMapFragment implements GeoPointL
} }
/** /**
* Called when the compass is updated * Called when the compass is updated (non-Javadoc)
* (non-Javadoc) *
* @see com.TwentyCodes.android.location.CompassListener#onCompassUpdate(float) * @see com.TwentyCodes.android.location.CompassListener#onCompassUpdate(float)
*/ */
@Override @Override
@@ -76,6 +79,7 @@ public class UserOverlayMapFragment extends BaseMapFragment implements GeoPointL
/** /**
* Called when skyhook has a location to report * Called when skyhook has a location to report
*
* @author ricky barrette * @author ricky barrette
*/ */
@Override @Override
@@ -86,6 +90,7 @@ public class UserOverlayMapFragment extends BaseMapFragment implements GeoPointL
/** /**
* (non-Javadoc) * (non-Javadoc)
*
* @see com.TwentyCodes.android.fragments.BaseMapFragment#onMapViewCreate(com.TwentyCodes.android.location.MapView) * @see com.TwentyCodes.android.fragments.BaseMapFragment#onMapViewCreate(com.TwentyCodes.android.location.MapView)
*/ */
@Override @Override
@@ -101,6 +106,7 @@ public class UserOverlayMapFragment extends BaseMapFragment implements GeoPointL
/** /**
* (non-Javadoc) * (non-Javadoc)
*
* @see com.TwentyCodes.android.fragments.BaseMapFragment#onPause() * @see com.TwentyCodes.android.fragments.BaseMapFragment#onPause()
*/ */
@Override @Override
@@ -112,6 +118,7 @@ public class UserOverlayMapFragment extends BaseMapFragment implements GeoPointL
/** /**
* (non-Javadoc) * (non-Javadoc)
*
* @see com.TwentyCodes.android.fragments.BaseMapFragment#onResume() * @see com.TwentyCodes.android.fragments.BaseMapFragment#onResume()
*/ */
@Override @Override
@@ -125,6 +132,7 @@ public class UserOverlayMapFragment extends BaseMapFragment implements GeoPointL
/** /**
* reorders the overlays to the UserOverlay always on top * reorders the overlays to the UserOverlay always on top
*
* @author ricky barrette * @author ricky barrette
*/ */
public void reorderOverlays() { public void reorderOverlays() {
@@ -153,6 +161,7 @@ public class UserOverlayMapFragment extends BaseMapFragment implements GeoPointL
/** /**
* Sets the destination for the compass to point to * Sets the destination for the compass to point to
*
* @param destination * @param destination
* @author ricky barrette * @author ricky barrette
*/ */

View File

@@ -18,7 +18,9 @@ import com.TwentyCodes.android.debug.Debug;
import com.google.android.maps.GeoPoint; import com.google.android.maps.GeoPoint;
/** /**
* This class will be used for gathering location using android's location services * This class will be used for gathering location using android's location
* services
*
* @author ricky barrette * @author ricky barrette
*/ */
public class AndroidGPS implements LocationListener { public class AndroidGPS implements LocationListener {
@@ -31,6 +33,7 @@ public class AndroidGPS implements LocationListener {
/** /**
* Creates a new SkyHookFallback * Creates a new SkyHookFallback
*
* @author ricky barrette * @author ricky barrette
*/ */
public AndroidGPS(final Context context) { public AndroidGPS(final Context context) {
@@ -40,6 +43,7 @@ public class AndroidGPS implements LocationListener {
/** /**
* Remove updates from androids location services * Remove updates from androids location services
*
* @author ricky barrette * @author ricky barrette
*/ */
public void disableLocationUpdates() { public void disableLocationUpdates() {
@@ -52,6 +56,7 @@ public class AndroidGPS implements LocationListener {
/** /**
* request periodic location updates from androids location services * request periodic location updates from androids location services
*
* @author ricky barrette * @author ricky barrette
*/ */
public void enableLocationUpdates(final GeoPointLocationListener listener) { public void enableLocationUpdates(final GeoPointLocationListener listener) {
@@ -65,6 +70,7 @@ public class AndroidGPS implements LocationListener {
/** /**
* Attempts to enable periodic location updates * Attempts to enable periodic location updates
*
* @param listener * @param listener
* @author ricky barrette * @author ricky barrette
*/ */
@@ -79,6 +85,7 @@ public class AndroidGPS implements LocationListener {
/** /**
* (non-Javadoc) * (non-Javadoc)
*
* @see android.location.LocationListener#onLocationChanged(android.location.Location) * @see android.location.LocationListener#onLocationChanged(android.location.Location)
* @param location * @param location
* @author ricky barrette * @author ricky barrette
@@ -98,6 +105,7 @@ public class AndroidGPS implements LocationListener {
/** /**
* (non-Javadoc) * (non-Javadoc)
*
* @see android.location.LocationListener#onProviderDisabled(java.lang.String) * @see android.location.LocationListener#onProviderDisabled(java.lang.String)
* @param arg0 * @param arg0
* @author ricky barrette * @author ricky barrette
@@ -110,6 +118,7 @@ public class AndroidGPS implements LocationListener {
/** /**
* (non-Javadoc) * (non-Javadoc)
*
* @see android.location.LocationListener#onProviderEnabled(java.lang.String) * @see android.location.LocationListener#onProviderEnabled(java.lang.String)
* @param arg0 * @param arg0
* @author ricky barrette * @author ricky barrette
@@ -121,7 +130,9 @@ public class AndroidGPS implements LocationListener {
/** /**
* (non-Javadoc) * (non-Javadoc)
* @see android.location.LocationListener#onStatusChanged(java.lang.String, int, android.os.Bundle) *
* @see android.location.LocationListener#onStatusChanged(java.lang.String,
* int, android.os.Bundle)
* @param arg0 * @param arg0
* @param arg1 * @param arg1
* @param arg2 * @param arg2
@@ -134,6 +145,7 @@ public class AndroidGPS implements LocationListener {
/** /**
* Request updates from android location services * Request updates from android location services
*
* @author ricky barrette * @author ricky barrette
*/ */
private void requestUpdates() { private void requestUpdates() {

View File

@@ -12,7 +12,9 @@ import android.location.Location;
import android.location.LocationManager; import android.location.LocationManager;
/** /**
* this abstract class will be used as a for classes wishing to be a receiver of location updates from the location services * this abstract class will be used as a for classes wishing to be a receiver of
* location updates from the location services
*
* @author ricky barrette * @author ricky barrette
*/ */
public abstract class BaseLocationReceiver extends BroadcastReceiver { public abstract class BaseLocationReceiver extends BroadcastReceiver {
@@ -21,6 +23,7 @@ public abstract class BaseLocationReceiver extends BroadcastReceiver {
/** /**
* called when a location update is received * called when a location update is received
*
* @param parcelableExtra * @param parcelableExtra
* @author ricky barrette * @author ricky barrette
*/ */
@@ -28,7 +31,9 @@ public abstract class BaseLocationReceiver extends BroadcastReceiver {
/** /**
* (non-Javadoc) * (non-Javadoc)
* @see android.content.BroadcastReceiver#onReceive(android.content.Context, android.content.Intent) *
* @see android.content.BroadcastReceiver#onReceive(android.content.Context,
* android.content.Intent)
*/ */
@Override @Override
public void onReceive(final Context context, final Intent intent) { public void onReceive(final Context context, final Intent intent) {

View File

@@ -25,18 +25,21 @@ import com.TwentyCodes.android.debug.LocationLibraryConstants;
/** /**
* A simple convince class that accesses the compass sensor on another thread * A simple convince class that accesses the compass sensor on another thread
*
* @author ricky barrette * @author ricky barrette
*/ */
public class CompassSensor { public class CompassSensor {
/** /**
* A simple listener interface to get updates from CompassSensor * A simple listener interface to get updates from CompassSensor
*
* @author ricky barrette * @author ricky barrette
*/ */
public interface CompassListener { public interface CompassListener {
/** /**
* Called when there is an update from the Compass Sensor * Called when there is an update from the Compass Sensor
*
* @param bearing * @param bearing
* @author ricky barrette * @author ricky barrette
*/ */
@@ -73,6 +76,7 @@ public class CompassSensor{
private final float[] mOrientVals = new float[3]; private final float[] mOrientVals = new float[3];
private double mAzimuth = 0; private double mAzimuth = 0;
// double mPitch = 0; // double mPitch = 0;
// double mRoll = 0; // double mRoll = 0;
// private float mInclination; // private float mInclination;
@@ -124,19 +128,27 @@ public class CompassSensor{
// switch (mDisplay.getOrientation()){ // switch (mDisplay.getOrientation()){
// case Surface.ROTATION_0: // case Surface.ROTATION_0:
// Log.v(TAG , "0"); // Log.v(TAG , "0");
// // SensorManager.remapCoordinateSystem(mRotationMatrix, SensorManager.AXIS_X, SensorManager.AXIS_Y, mRemapedRotationMatrix); // // SensorManager.remapCoordinateSystem(mRotationMatrix,
// SensorManager.AXIS_X, SensorManager.AXIS_Y,
// mRemapedRotationMatrix);
// break; // break;
// case Surface.ROTATION_90: // case Surface.ROTATION_90:
// Log.v(TAG , "90"); // Log.v(TAG , "90");
// // SensorManager.remapCoordinateSystem(mRotationMatrix, SensorManager.AXIS_X, SensorManager.AXIS_Y, mRemapedRotationMatrix); // // SensorManager.remapCoordinateSystem(mRotationMatrix,
// SensorManager.AXIS_X, SensorManager.AXIS_Y,
// mRemapedRotationMatrix);
// break; // break;
// case Surface.ROTATION_180: // case Surface.ROTATION_180:
// Log.v(TAG , "180"); // Log.v(TAG , "180");
// // SensorManager.remapCoordinateSystem(mRotationMatrix, SensorManager.AXIS_MINUS_X, SensorManager.AXIS_MINUS_Y, mRemapedRotationMatrix); // // SensorManager.remapCoordinateSystem(mRotationMatrix,
// SensorManager.AXIS_MINUS_X, SensorManager.AXIS_MINUS_Y,
// mRemapedRotationMatrix);
// break; // break;
// case Surface.ROTATION_270: // case Surface.ROTATION_270:
// Log.v(TAG , "270"); // Log.v(TAG , "270");
// // SensorManager.remapCoordinateSystem(mRotationMatrix, SensorManager.AXIS_MINUS_X, SensorManager.AXIS_Y, mRemapedRotationMatrix); // // SensorManager.remapCoordinateSystem(mRotationMatrix,
// SensorManager.AXIS_MINUS_X, SensorManager.AXIS_Y,
// mRemapedRotationMatrix);
// break; // break;
// } // }
@@ -179,6 +191,7 @@ public class CompassSensor{
/** /**
* Creates a new CompassSensor * Creates a new CompassSensor
*
* @author ricky barrette * @author ricky barrette
*/ */
public CompassSensor(final Context context) { public CompassSensor(final Context context) {
@@ -189,6 +202,7 @@ public class CompassSensor{
/** /**
* Disables compass updates * Disables compass updates
*
* @author ricky barrette * @author ricky barrette
*/ */
public void disable() { public void disable() {
@@ -198,6 +212,7 @@ public class CompassSensor{
/** /**
* Attempts to register the listener for compass updates * Attempts to register the listener for compass updates
*
* @param listener * @param listener
* @author ricky barrette * @author ricky barrette
*/ */
@@ -208,26 +223,30 @@ public class CompassSensor{
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
// Register this class as a listener for the accelerometer sensor // Register this class as a listener for the
mSensorManager.registerListener(mCallBack, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), LocationLibraryConstants.COMPASS_UPDATE_INTERVAL); // accelerometer sensor
mSensorManager.registerListener(mCallBack, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
LocationLibraryConstants.COMPASS_UPDATE_INTERVAL);
// ...and the orientation sensor // ...and the orientation sensor
mSensorManager.registerListener(mCallBack, mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD), LocationLibraryConstants.COMPASS_UPDATE_INTERVAL); mSensorManager.registerListener(mCallBack, mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD),
LocationLibraryConstants.COMPASS_UPDATE_INTERVAL);
} }
}).start(); }).start();
} }
} }
/** /**
* Updates the Geomagnetic Field Declination based off of the provided location * Updates the Geomagnetic Field Declination based off of the provided
* @param location last known (lat,lon,altitude), null will reset * location
*
* @param location
* last known (lat,lon,altitude), null will reset
* @author ricky barrette * @author ricky barrette
*/ */
public void setDeclination(final Location location) { public void setDeclination(final Location location) {
if (location != null) { if (location != null) {
final GeomagneticField geomagneticField = new GeomagneticField(Double.valueOf(location.getLatitude()).floatValue(), final GeomagneticField geomagneticField = new GeomagneticField(Double.valueOf(location.getLatitude()).floatValue(), Double.valueOf(location.getLongitude())
Double.valueOf(location.getLongitude()).floatValue(), .floatValue(), Double.valueOf(location.getAltitude()).floatValue(), System.currentTimeMillis());
Double.valueOf(location.getAltitude()).floatValue(),
System.currentTimeMillis());
mDelination = geomagneticField.getDeclination(); mDelination = geomagneticField.getDeclination();
} else } else
mDelination = 0; mDelination = 0;

View File

@@ -8,13 +8,16 @@ package com.TwentyCodes.android.location;
import com.google.android.maps.GeoPoint; import com.google.android.maps.GeoPoint;
/** /**
* this interface will be used to interface with skyhook sdk with the rest of the application * this interface will be used to interface with skyhook sdk with the rest of
* the application
*
* @author ricky barrette * @author ricky barrette
*/ */
public interface GeoPointLocationListener { public interface GeoPointLocationListener {
/** /**
* Called when first fix is aquired * Called when first fix is aquired
*
* @param isFirstFix * @param isFirstFix
* @author ricky barrette * @author ricky barrette
*/ */
@@ -22,6 +25,7 @@ public interface GeoPointLocationListener {
/** /**
* Called when the location has changed * Called when the location has changed
*
* @param point * @param point
* @param accuracy * @param accuracy
* @author ricky barrette * @author ricky barrette

View File

@@ -31,6 +31,7 @@ import com.google.android.maps.MapView;
/** /**
* This class contains common tools for computing common geological problems * This class contains common tools for computing common geological problems
*
* @author ricky barrette * @author ricky barrette
* @author Google Inc. * @author Google Inc.
*/ */
@@ -40,12 +41,19 @@ public class GeoUtils {
public static final double MILLION = 1000000; public static final double MILLION = 1000000;
/** /**
* computes the bearing of lat2/lon2 in relationship from lat1/lon1 in degrees East * computes the bearing of lat2/lon2 in relationship from lat1/lon1 in
* @param lat1 source lat * degrees East
* @param lon1 source lon *
* @param lat2 destination lat * @param lat1
* @param lon2 destination lon * source lat
* @return the bearing of lat2/lon2 in relationship from lat1/lon1 in degrees East of true north * @param lon1
* source lon
* @param lat2
* destination lat
* @param lon2
* destination lon
* @return the bearing of lat2/lon2 in relationship from lat1/lon1 in
* degrees East of true north
* @author Google Inc. * @author Google Inc.
*/ */
public static double bearing(final double lat1, final double lon1, final double lat2, final double lon2) { public static double bearing(final double lat1, final double lon1, final double lat2, final double lon2) {
@@ -58,9 +66,13 @@ public class GeoUtils {
} }
/** /**
* computes the bearing of lat2/lon2 in relationship from lat1/lon1 in degrees East of true north * computes the bearing of lat2/lon2 in relationship from lat1/lon1 in
* @param p1 source geopoint * degrees East of true north
* @param p2 destination geopoint *
* @param p1
* source geopoint
* @param p2
* destination geopoint
* @return the bearing of p2 in relationship from p1 in degrees East * @return the bearing of p2 in relationship from p1 in degrees East
* @author Google Inc. * @author Google Inc.
*/ */
@@ -73,11 +85,17 @@ public class GeoUtils {
} }
/** /**
* Calculates the bearing from the user location to the destination location, or returns the bearing for north if there is no destination. * Calculates the bearing from the user location to the destination
* This method is awesome for making a compass point toward the destination rather than North. * location, or returns the bearing for north if there is no destination.
* @param user location * This method is awesome for making a compass point toward the destination
* @param dest location * rather than North.
* @param bearing Degrees East from compass *
* @param user
* location
* @param dest
* location
* @param bearing
* Degrees East from compass
* @return Degrees East of dest location * @return Degrees East of dest location
* @author ricky barrette * @author ricky barrette
*/ */
@@ -97,11 +115,14 @@ public class GeoUtils {
} }
/** /**
* Calculates a geopoint x meters away of the geopoint supplied. The new geopoint * Calculates a geopoint x meters away of the geopoint supplied. The new
* shares the same latitude as geopoint point, this way they are on the same latitude arc. * geopoint shares the same latitude as geopoint point, this way they are on
* the same latitude arc.
* *
* @param point central geopoint * @param point
* @param distance in meters from the geopoint * central geopoint
* @param distance
* in meters from the geopoint
* @return geopoint that is x meters away from the geopoint supplied * @return geopoint that is x meters away from the geopoint supplied
* @author ricky barrette * @author ricky barrette
*/ */
@@ -114,34 +135,45 @@ public class GeoUtils {
final double lon1Rad = Math.toRadians(point.getLongitudeE6() / 1e6); final double lon1Rad = Math.toRadians(point.getLongitudeE6() / 1e6);
/* /*
* kilometers = acos(sin(lat1Rad)sin(lat2Rad)+cos(lat1Rad)cos(lat2Rad)cos(lon2Rad-lon1Rad)6371 * kilometers =
* acos(sin(lat1Rad)sin(lat2Rad)+cos(lat1Rad)cos(lat2Rad)cos
* (lon2Rad-lon1Rad)6371
* *
* we are solving this equation for lon2Rad * we are solving this equation for lon2Rad
* *
* lon2Rad = lon1Rad+acos(cos(meters/6371)sec(lat1Rad)sec(lat2Rad)-tan(lat1Rad)tan(lat2Rad)) * lon2Rad =
* lon1Rad+acos(cos(meters/6371)sec(lat1Rad)sec(lat2Rad)-tan(lat1Rad
* )tan(lat2Rad))
* *
* NOTE: sec(x) = 1/cos(x) * NOTE: sec(x) = 1/cos(x)
* *
* NOTE: that lat2Rad is = lat1Rad because we want to keep the new geopoint on the same lat arc * NOTE: that lat2Rad is = lat1Rad because we want to keep the new
* therefore i saw no need to create a new variable for lat2Rad, * geopoint on the same lat arc therefore i saw no need to create a new
* and simply inputed lat1Rad in place of lat2Rad in the equation * variable for lat2Rad, and simply inputed lat1Rad in place of lat2Rad
* in the equation
* *
* NOTE: this equation has be tested in the field against another gps device, and the distanceKm() from google * NOTE: this equation has be tested in the field against another gps
* and has been proven to be damn close * device, and the distanceKm() from google and has been proven to be
* damn close
*/ */
final double lon2Rad = lon1Rad + Math.acos( Math.cos(distance/6371) * (1 / Math.cos(lat1Rad)) final double lon2Rad = lon1Rad + Math.acos(Math.cos(distance / 6371) * (1 / Math.cos(lat1Rad)) * (1 / Math.cos(lat1Rad)) - Math.tan(lat1Rad) * Math.tan(lat1Rad));
* (1 / Math.cos(lat1Rad)) - Math.tan(lat1Rad) * Math.tan(lat1Rad));
// return a geopoint that is x meters away from the geopoint supplied // return a geopoint that is x meters away from the geopoint supplied
return new GeoPoint(point.getLatitudeE6(), (int) (Math.toDegrees(lon2Rad) * 1e6)); return new GeoPoint(point.getLatitudeE6(), (int) (Math.toDegrees(lon2Rad) * 1e6));
} }
/** /**
* computes the distance between to lat1/lon1 and lat2/lon2 based on the curve of the earth * computes the distance between to lat1/lon1 and lat2/lon2 based on the
* @param lat1 source lat * curve of the earth
* @param lon1 source lon *
* @param lat2 destination lat * @param lat1
* @param lon2 destination lon * source lat
* @param lon1
* source lon
* @param lat2
* destination lat
* @param lon2
* destination lon
* @return the distance between to lat1/lon1 and lat2/lon2 * @return the distance between to lat1/lon1 and lat2/lon2
* @author Google Inc. * @author Google Inc.
*/ */
@@ -153,7 +185,9 @@ public class GeoUtils {
} }
/** /**
* computes the distance between to p1 and p2 based on the curve of the earth * computes the distance between to p1 and p2 based on the curve of the
* earth
*
* @param p1 * @param p1
* @param p2 * @param p2
* @return the distance between to p1 and p2 * @return the distance between to p1 and p2
@@ -173,8 +207,11 @@ public class GeoUtils {
/** /**
* Converts distance into a human readbale string * Converts distance into a human readbale string
* @param distance in kilometers *
* @param returnMetric true if metric, false for US * @param distance
* in kilometers
* @param returnMetric
* true if metric, false for US
* @return string distance * @return string distance
* @author ricky barrette * @author ricky barrette
*/ */
@@ -198,18 +235,26 @@ public class GeoUtils {
} }
/** /**
* a convince method for testing if 2 circles on the the surface of the earth intersect. * a convince method for testing if 2 circles on the the surface of the
* we will use this method to test if the users accuracy circle intersects a marked locaton's radius * earth intersect. we will use this method to test if the users accuracy
* if ( (accuracyCircleRadius + locationRadius) - fudgeFactor) > acos(sin(lat1Rad)sin(lat2Rad)+cos(lat1Rad)cos(lat2Rad)cos(lon2Rad-lon1Rad)6371 * circle intersects a marked locaton's radius if ( (accuracyCircleRadius +
* locationRadius) - fudgeFactor) >
* acos(sin(lat1Rad)sin(lat2Rad)+cos(lat1Rad
* )cos(lat2Rad)cos(lon2Rad-lon1Rad)6371
*
* @param userPoint * @param userPoint
* @param accuracyRadius in KM * @param accuracyRadius
* in KM
* @param locationPoint * @param locationPoint
* @param locationRadius in KM * @param locationRadius
* @param fudgeFactor how many KM the circles have to intersect * in KM
* @param fudgeFactor
* how many KM the circles have to intersect
* @return true if the circles intersect * @return true if the circles intersect
* @author ricky barrette * @author ricky barrette
*/ */
public static boolean isIntersecting(final GeoPoint userPoint, final float accuracyRadius, final GeoPoint locationPoint, final float locationRadius, final float fudgeFactor){ public static boolean isIntersecting(final GeoPoint userPoint, final float accuracyRadius, final GeoPoint locationPoint, final float locationRadius,
final float fudgeFactor) {
if (accuracyRadius + locationRadius - fudgeFactor > distanceKm(locationPoint, userPoint)) if (accuracyRadius + locationRadius - fudgeFactor > distanceKm(locationPoint, userPoint))
return true; return true;
return false; return false;
@@ -217,6 +262,7 @@ public class GeoUtils {
/** /**
* determines when the specified point is off the map * determines when the specified point is off the map
*
* @param point * @param point
* @return true is the point is off the map * @return true is the point is off the map
* @author ricky barrette * @author ricky barrette
@@ -237,8 +283,11 @@ public class GeoUtils {
/** /**
* computes a geopoint the is the central geopoint between p1 and p1 * computes a geopoint the is the central geopoint between p1 and p1
* @param p1 first geopoint *
* @param p2 second geopoint * @param p1
* first geopoint
* @param p2
* second geopoint
* @return a MidPoint object * @return a MidPoint object
* @author ricky barrette * @author ricky barrette
*/ */
@@ -272,6 +321,7 @@ public class GeoUtils {
/** /**
* converts radians to bearing * converts radians to bearing
*
* @param rad * @param rad
* @return bearing * @return bearing
* @author Google Inc. * @author Google Inc.

View File

@@ -25,15 +25,19 @@ import com.TwentyCodes.android.debug.Debug;
import com.TwentyCodes.android.debug.LocationLibraryConstants; import com.TwentyCodes.android.debug.LocationLibraryConstants;
/** /**
* This service class will be used broadcast the users location either one time, or periodically. * This service class will be used broadcast the users location either one time,
* or periodically.
*
* @author ricky barrette * @author ricky barrette
*/ */
public class LocationService extends Service implements LocationListener { public class LocationService extends Service implements LocationListener {
public static final String TAG = "LocationService"; public static final String TAG = "LocationService";
private static final int REQUEST_CODE = 7893749; private static final int REQUEST_CODE = 7893749;
/** /**
* a convince method for getting an intent to start the service * a convince method for getting an intent to start the service
*
* @param context * @param context
* @return a intent that will start the service * @return a intent that will start the service
* @author ricky barrette * @author ricky barrette
@@ -41,8 +45,10 @@ public class LocationService extends Service implements LocationListener {
public static Intent getStartServiceIntent(final Context context) { public static Intent getStartServiceIntent(final Context context) {
return new Intent(context, LocationService.class); return new Intent(context, LocationService.class);
} }
/** /**
* a convince method for stopping the service and removing it's alarm * a convince method for stopping the service and removing it's alarm
*
* @param context * @param context
* @return a runnable that will stop the service * @return a runnable that will stop the service
* @author ricky barrette * @author ricky barrette
@@ -52,10 +58,12 @@ public class LocationService extends Service implements LocationListener {
@Override @Override
public void run() { public void run() {
context.stopService(new Intent(context, LocationService.class)); context.stopService(new Intent(context, LocationService.class));
((AlarmManager) context.getSystemService(Context.ALARM_SERVICE)).cancel(PendingIntent.getService(context, REQUEST_CODE, new Intent(context, LocationService.class), 0)); ((AlarmManager) context.getSystemService(Context.ALARM_SERVICE)).cancel(PendingIntent.getService(context, REQUEST_CODE, new Intent(context,
LocationService.class), 0));
} }
}; };
} }
private WakeLock mWakeLock; private WakeLock mWakeLock;
protected long mPeriod = -1; protected long mPeriod = -1;
private Location mLocation; private Location mLocation;
@@ -63,11 +71,11 @@ public class LocationService extends Service implements LocationListener {
private AndroidGPS mLocationManager; private AndroidGPS mLocationManager;
private int mRequiredAccuracy; private int mRequiredAccuracy;
private Intent mIntent; private Intent mIntent;
/* /*
* this runnable will be qued when the service is created. this will be used as a fail safe * this runnable will be qued when the service is created. this will be used
* as a fail safe
*/ */
private final Runnable failSafe = new Runnable() { private final Runnable failSafe = new Runnable() {
@Override @Override
@@ -77,8 +85,9 @@ public class LocationService extends Service implements LocationListener {
}; };
/** /**
* broadcasts location to anything listening for updates, * broadcasts location to anything listening for updates, since this is the
* since this is the last function of the service, we call finish()u * last function of the service, we call finish()u
*
* @author ricky barrette * @author ricky barrette
*/ */
private void broadcastLocation() { private void broadcastLocation() {
@@ -97,6 +106,7 @@ public class LocationService extends Service implements LocationListener {
/** /**
* (non-Javadoc) * (non-Javadoc)
*
* @see android.app.Service#onBind(android.content.Intent) * @see android.app.Service#onBind(android.content.Intent)
* @param arg0 * @param arg0
* @return * @return
@@ -109,8 +119,9 @@ public class LocationService extends Service implements LocationListener {
} }
/** /**
* called when the service is created. this will initialize the location manager, and acquire a wakelock * called when the service is created. this will initialize the location
* (non-Javadoc) * manager, and acquire a wakelock (non-Javadoc)
*
* @see android.app.Service#onCreate() * @see android.app.Service#onCreate()
* @author ricky barrette * @author ricky barrette
*/ */
@@ -122,16 +133,17 @@ public class LocationService extends Service implements LocationListener {
mWakeLock.acquire(); mWakeLock.acquire();
/* /*
* que the fail safe runnable to kill the report location and kill it self after the MAX_RUN_TIME has been meet * que the fail safe runnable to kill the report location and kill it
* self after the MAX_RUN_TIME has been meet
*/ */
new Handler().postDelayed(failSafe, LocationLibraryConstants.MAX_LOCATION_SERVICE_RUN_TIME); new Handler().postDelayed(failSafe, LocationLibraryConstants.MAX_LOCATION_SERVICE_RUN_TIME);
super.onCreate(); super.onCreate();
} }
/** /**
* called when the service is destroyed. * called when the service is destroyed. this will remove any wakelock or
* this will remove any wakelock or location service running, and register to be waken back up * location service running, and register to be waken back up (non-Javadoc)
* (non-Javadoc) *
* @see android.app.Service#onDestroy() * @see android.app.Service#onDestroy()
* @author ricky barrette * @author ricky barrette
*/ */
@@ -150,7 +162,8 @@ public class LocationService extends Service implements LocationListener {
if (Debug.DEBUG) if (Debug.DEBUG)
Log.d(TAG, "got location +- " + location.getAccuracy() + "m"); Log.d(TAG, "got location +- " + location.getAccuracy() + "m");
mLocation = location; mLocation = location;
if(location.getAccuracy() <= (mRequiredAccuracy > -1 ? mRequiredAccuracy : LocationLibraryConstants.MINIMUM_REQUIRED_ACCURACY) || LocationLibraryConstants.REPORT_FIRST_LOCATION) if (location.getAccuracy() <= (mRequiredAccuracy > -1 ? mRequiredAccuracy : LocationLibraryConstants.MINIMUM_REQUIRED_ACCURACY)
|| LocationLibraryConstants.REPORT_FIRST_LOCATION)
stopSelf(mStartId); stopSelf(mStartId);
} }
@@ -167,7 +180,9 @@ public class LocationService extends Service implements LocationListener {
} }
/** /**
* This method is called when startService is called. only used in 2.x android. * This method is called when startService is called. only used in 2.x
* android.
*
* @author ricky barrette * @author ricky barrette
*/ */
@Override @Override
@@ -205,6 +220,7 @@ public class LocationService extends Service implements LocationListener {
/** /**
* registers this service to be waken up by android's alarm manager * registers this service to be waken up by android's alarm manager
*
* @author ricky barrette * @author ricky barrette
*/ */
private void registerwakeUp() { private void registerwakeUp() {

View File

@@ -14,7 +14,9 @@ import android.view.MotionEvent;
import com.TwentyCodes.android.debug.Debug; import com.TwentyCodes.android.debug.Debug;
/** /**
* We use this MapView Because it has double tap zoom capability and exception handling * We use this MapView Because it has double tap zoom capability and exception
* handling
*
* @author ricky barrette * @author ricky barrette
*/ */
public class MapView extends com.google.android.maps.MapView { public class MapView extends com.google.android.maps.MapView {
@@ -52,8 +54,8 @@ public class MapView extends com.google.android.maps.MapView {
} }
/** /**
* We will override the draw method to help prevent issues * We will override the draw method to help prevent issues (non-Javadoc)
* (non-Javadoc) *
* @see android.view.View#draw(android.graphics.Canvas) * @see android.view.View#draw(android.graphics.Canvas)
* @author ricky barrette * @author ricky barrette
*/ */
@@ -63,8 +65,7 @@ public class MapView extends com.google.android.maps.MapView {
if (getZoomLevel() >= 21) if (getZoomLevel() >= 21)
getController().setZoom(20); getController().setZoom(20);
super.draw(canvas); super.draw(canvas);
} } catch (final Exception ex) {
catch(final Exception ex) {
// getController().setCenter(this.getMapCenter()); // getController().setCenter(this.getMapCenter());
// getController().setZoom(this.getZoomLevel() - 2); // getController().setZoom(this.getZoomLevel() - 2);
if (Debug.DEBUG) if (Debug.DEBUG)
@@ -99,7 +100,8 @@ public class MapView extends com.google.android.maps.MapView {
} }
/** /**
* @param isDoubleTapZoonEnabled the isDoubleTapZoonEnabled to set * @param isDoubleTapZoonEnabled
* the isDoubleTapZoonEnabled to set
* @author ricky barrette * @author ricky barrette
*/ */
public void setDoubleTapZoonEnabled(final boolean isDoubleTapZoonEnabled) { public void setDoubleTapZoonEnabled(final boolean isDoubleTapZoonEnabled) {

View File

@@ -8,7 +8,9 @@ package com.TwentyCodes.android.location;
import com.google.android.maps.GeoPoint; import com.google.android.maps.GeoPoint;
/** /**
* This MidPoint object will hold the information form the calculations performed by GeoUtils.midPoint(). * This MidPoint object will hold the information form the calculations
* performed by GeoUtils.midPoint().
*
* @author ricky barrette * @author ricky barrette
*/ */
public class MidPoint { public class MidPoint {
@@ -21,6 +23,7 @@ public class MidPoint {
/** /**
* Creates a new MidPoint * Creates a new MidPoint
*
* @author ricky barrette * @author ricky barrette
*/ */
public MidPoint(final GeoPoint midPoint, final int minLatitude, final int minLongitude, final int maxLatitude, final int maxLongitude) { public MidPoint(final GeoPoint midPoint, final int minLatitude, final int minLongitude, final int maxLatitude, final int maxLongitude) {
@@ -33,6 +36,7 @@ public class MidPoint {
/** /**
* returns the calculated midpoint * returns the calculated midpoint
*
* @return * @return
* @author ricky barrette * @author ricky barrette
*/ */
@@ -42,6 +46,7 @@ public class MidPoint {
/** /**
* zooms the provided map view to the span of this mid point * zooms the provided map view to the span of this mid point
*
* @param mMapView * @param mMapView
* @author ricky barrette * @author ricky barrette
*/ */

View File

@@ -3,7 +3,9 @@ package com.TwentyCodes.android.location;
import com.google.android.maps.GeoPoint; import com.google.android.maps.GeoPoint;
/** /**
* This interface will be used to pass the selected location from the dialogs to the listening instance * This interface will be used to pass the selected location from the dialogs to
* the listening instance
*
* @author ricky barrette * @author ricky barrette
*/ */
public interface OnLocationSelectedListener { public interface OnLocationSelectedListener {

View File

@@ -15,12 +15,14 @@ import com.TwentyCodes.android.debug.LocationLibraryConstants;
/** /**
* A convenience class for requesting passive location updates * A convenience class for requesting passive location updates
*
* @author ricky barrette * @author ricky barrette
*/ */
public class PassiveLocationListener { public class PassiveLocationListener {
/** /**
* A convenience method for requesting passive location updates * A convenience method for requesting passive location updates
*
* @param context * @param context
* @param receiverIntent * @param receiverIntent
* @author ricky barrette * @author ricky barrette

View File

@@ -26,8 +26,9 @@ import android.util.Log;
import com.TwentyCodes.android.debug.Debug; import com.TwentyCodes.android.debug.Debug;
/** /**
* Due to this bug http://code.google.com/p/android/issues/detail?id=8816 google's Geocoder class does not function in android 2.2+. * Due to this bug http://code.google.com/p/android/issues/detail?id=8816
* I found this source in one of the comments mentioning that it is a work around. * google's Geocoder class does not function in android 2.2+. I found this
* source in one of the comments mentioning that it is a work around.
* *
* @author ricky barrette * @author ricky barrette
*/ */
@@ -37,7 +38,9 @@ public class ReverseGeocoder {
/** /**
* Performs a google maps search for the address * Performs a google maps search for the address
* @param address to search *
* @param address
* to search
* @return JSON Array of google place marks * @return JSON Array of google place marks
* @throws IOException * @throws IOException
* @throws JSONException * @throws JSONException
@@ -68,6 +71,7 @@ public class ReverseGeocoder {
/** /**
* Performs a google maps search for the closest address to the location * Performs a google maps search for the closest address to the location
*
* @param lat * @param lat
* @param lon * @param lon
* @return string address, or lat, lon if search fails * @return string address, or lat, lon if search fails
@@ -96,7 +100,6 @@ public class ReverseGeocoder {
if (Debug.DEBUG) if (Debug.DEBUG)
Log.d(TAG, response.toString()); Log.d(TAG, response.toString());
JSONArray responseArray = null; JSONArray responseArray = null;
try { try {
responseArray = new JSONObject(response.toString()).getJSONArray("Placemark"); responseArray = new JSONObject(response.toString()).getJSONArray("Placemark");
@@ -119,6 +122,7 @@ public class ReverseGeocoder {
/** /**
* Performs a google maps search for the address * Performs a google maps search for the address
*
* @param location * @param location
* @return JSON Array on google place marks nearby * @return JSON Array on google place marks nearby
* @author ricky barrette * @author ricky barrette

View File

@@ -30,12 +30,14 @@ import com.google.android.maps.Projection;
/** /**
* This class will be used to build user overlays * This class will be used to build user overlays
*
* @author ricky barrette * @author ricky barrette
*/ */
public abstract class BaseUserOverlay extends Overlay implements GeoPointLocationListener, CompassListener { public abstract class BaseUserOverlay extends Overlay implements GeoPointLocationListener, CompassListener {
/** /**
* This thread is responsible for animating the user icon * This thread is responsible for animating the user icon
*
* @author ricky barrette * @author ricky barrette
*/ */
public class AnimationThread extends Thread { public class AnimationThread extends Thread {
@@ -47,8 +49,8 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
} }
/** /**
* Main method of this animation thread * Main method of this animation thread (non-Javadoc)
* (non-Javadoc) *
* @see java.lang.Thread#run() * @see java.lang.Thread#run()
*/ */
@Override @Override
@@ -121,6 +123,7 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
/** /**
* Construct a new UserOverlay * Construct a new UserOverlay
*
* @param mapView * @param mapView
* @param context * @param context
* @author ricky barrette * @author ricky barrette
@@ -135,6 +138,7 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
/** /**
* Construct a new UserOverlayTODO Auto-generated method stub * Construct a new UserOverlayTODO Auto-generated method stub
*
* @param mapView * @param mapView
* @param context * @param context
* @param followUser * @param followUser
@@ -147,6 +151,7 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
/** /**
* Disables the compass * Disables the compass
*
* @author ricky barrette * @author ricky barrette
*/ */
public final void disableCompass() { public final void disableCompass() {
@@ -156,6 +161,7 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
/** /**
* Stops location updates and removes the overlay from view * Stops location updates and removes the overlay from view
*
* @author ricky barrette * @author ricky barrette
*/ */
public final void disableMyLocation() { public final void disableMyLocation() {
@@ -169,9 +175,11 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
} }
/** /**
* we override this methods so we can provide a drawable and a location to draw on the canvas. * we override this methods so we can provide a drawable and a location to
* (non-Javadoc) * draw on the canvas. (non-Javadoc)
* @see com.google.android.maps.Overlay#draw(android.graphics.Canvas, com.google.android.maps.MapView, boolean) *
* @see com.google.android.maps.Overlay#draw(android.graphics.Canvas,
* com.google.android.maps.MapView, boolean)
* @param canvas * @param canvas
* @param mapView * @param mapView
* @param shadow * @param shadow
@@ -189,7 +197,8 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
canvas = drawAccuracyCircle(center, left, canvas); canvas = drawAccuracyCircle(center, left, canvas);
canvas = drawUser(center, mBearing, canvas); canvas = drawUser(center, mBearing, canvas);
/* /*
* the following log is used to demonstrate if the leftGeo point is the correct * the following log is used to demonstrate if the leftGeo point is
* the correct
*/ */
if (Debug.DEBUG) if (Debug.DEBUG)
Log.d(TAG, GeoUtils.distanceKm(mPoint, leftGeo) * 1000 + "m"); Log.d(TAG, GeoUtils.distanceKm(mPoint, leftGeo) * 1000 + "m");
@@ -199,9 +208,13 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
/** /**
* draws an accuracy circle onto the canvas supplied * draws an accuracy circle onto the canvas supplied
* @param center point of the circle *
* @param left point of the circle * @param center
* @param canvas to be drawn on * point of the circle
* @param left
* point of the circle
* @param canvas
* to be drawn on
* @return modified canvas * @return modified canvas
* @author ricky barrette * @author ricky barrette
*/ */
@@ -230,8 +243,7 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
canvas.drawCircle(center.x, center.y, circleRadius, paint); canvas.drawCircle(center.x, center.y, circleRadius, paint);
/* /*
* for testing * for testing draw a dot over the left geopoint
* draw a dot over the left geopoint
*/ */
if (Debug.DEBUG) { if (Debug.DEBUG) {
paint.setColor(Color.RED); paint.setColor(Color.RED);
@@ -243,10 +255,15 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
} }
/** /**
* draws user arrow that points north based on bearing onto the supplied canvas * draws user arrow that points north based on bearing onto the supplied
* @param point to draw user arrow on * canvas
* @param bearing of the device *
* @param canvas to draw on * @param point
* to draw user arrow on
* @param bearing
* of the device
* @param canvas
* to draw on
* @return modified canvas * @return modified canvas
* @author ricky barrette * @author ricky barrette
*/ */
@@ -254,25 +271,14 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
final Bitmap user = BitmapFactory.decodeResource(mContext.getResources(), mUserArrow); final Bitmap user = BitmapFactory.decodeResource(mContext.getResources(), mUserArrow);
final Matrix matrix = new Matrix(); final Matrix matrix = new Matrix();
matrix.postRotate(bearing); matrix.postRotate(bearing);
final Bitmap rotatedBmp = Bitmap.createBitmap( final Bitmap rotatedBmp = Bitmap.createBitmap(user, 0, 0, user.getWidth(), user.getHeight(), matrix, true);
user, canvas.drawBitmap(rotatedBmp, point.x - rotatedBmp.getWidth() / 2, point.y - rotatedBmp.getHeight() / 2, null);
0, 0,
user.getWidth(),
user.getHeight(),
matrix,
true
);
canvas.drawBitmap(
rotatedBmp,
point.x - rotatedBmp.getWidth() / 2,
point.y - rotatedBmp.getHeight() / 2,
null
);
return canvas; return canvas;
} }
/** /**
* Enables the compass * Enables the compass
*
* @author ricky barrette * @author ricky barrette
*/ */
public void enableCompass() { public void enableCompass() {
@@ -284,6 +290,7 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
/** /**
* Attempts to enable MyLocation, registering for updates from provider * Attempts to enable MyLocation, registering for updates from provider
*
* @author ricky barrette * @author ricky barrette
*/ */
public void enableMyLocation() { public void enableMyLocation() {
@@ -305,6 +312,7 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
/** /**
* Allows the map to follow the user * Allows the map to follow the user
*
* @param followUser * @param followUser
* @author ricky barrette * @author ricky barrette
*/ */
@@ -324,6 +332,7 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
/** /**
* returns the users current bearing * returns the users current bearing
*
* @return * @return
* @author ricky barrette * @author ricky barrette
*/ */
@@ -333,6 +342,7 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
/** /**
* returns the users current location * returns the users current location
*
* @return * @return
* @author ricky barrette * @author ricky barrette
*/ */
@@ -349,9 +359,11 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
} }
/** /**
* called when the SkyHook location changes, this mthod is resposiable for updating the overlay location and accuracy circle. * called when the SkyHook location changes, this mthod is resposiable for
* (non-Javadoc) * updating the overlay location and accuracy circle. (non-Javadoc)
* @see com.TwentyCodes.android.SkyHook.GeoPointLocationListener.location.LocationListener#onLocationChanged(com.google.android.maps.GeoPoint, float) *
* @see com.TwentyCodes.android.SkyHook.GeoPointLocationListener.location.LocationListener#onLocationChanged(com.google.android.maps.GeoPoint,
* float)
* @param point * @param point
* @param accuracy * @param accuracy
* @author ricky barrette * @author ricky barrette
@@ -363,8 +375,8 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
mCompass.setLocation(point); mCompass.setLocation(point);
/* /*
* if this is the first fix * if this is the first fix set map center the users location, and zoom
* set map center the users location, and zoom to the max zoom level * to the max zoom level
*/ */
if (point != null && isFistFix) { if (point != null && isFistFix) {
mMapView.getController().setCenter(point); mMapView.getController().setCenter(point);
@@ -386,19 +398,24 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
} }
/** /**
* Called when disableMyLocation is called. This is where you want to disable any location updates from your provider * Called when disableMyLocation is called. This is where you want to
* disable any location updates from your provider
*
* @author ricky barrette * @author ricky barrette
*/ */
public abstract void onMyLocationDisabled(); public abstract void onMyLocationDisabled();
/** /**
* Called when the enableMyLocation() is called. This is where you want to ask your location provider for updates * Called when the enableMyLocation() is called. This is where you want to
* ask your location provider for updates
*
* @author ricky barrette * @author ricky barrette
*/ */
public abstract void onMyLocationEnabled(); public abstract void onMyLocationEnabled();
/** /**
* pans the map view if the user is off screen. * pans the map view if the user is off screen.
*
* @author ricky barrette * @author ricky barrette
*/ */
private void panToUserIfOffMap(final GeoPoint user) { private void panToUserIfOffMap(final GeoPoint user) {
@@ -410,8 +427,8 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
final double whichIsGreater = distanceLat > distanceLon ? distanceLat : distanceLon; final double whichIsGreater = distanceLat > distanceLon ? distanceLat : distanceLon;
/** /**
* if the user is one the map, keep them their * if the user is one the map, keep them their else don't pan to user
* else don't pan to user unless they pan pack to them * unless they pan pack to them
*/ */
if (!(distance > whichIsGreater)) if (!(distance > whichIsGreater))
if (distance > distanceLat || distance > distanceLon) if (distance > distanceLat || distance > distanceLon)
@@ -420,6 +437,7 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
/** /**
* Attempts to register the listener for location updates * Attempts to register the listener for location updates
*
* @param listener * @param listener
* @author Ricky Barrette * @author Ricky Barrette
*/ */
@@ -431,6 +449,7 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
/** /**
* Set the compass drawables and location * Set the compass drawables and location
*
* @param needleResId * @param needleResId
* @param backgroundResId * @param backgroundResId
* @param x * @param x
@@ -443,6 +462,7 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
/** /**
* Sets the CompassListener * Sets the CompassListener
*
* @param listener * @param listener
* @author ricky barrette * @author ricky barrette
*/ */
@@ -452,6 +472,7 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
/** /**
* Sets the destination for the compass * Sets the destination for the compass
*
* @author ricky barrette * @author ricky barrette
*/ */
public void setDestination(final GeoPoint destination) { public void setDestination(final GeoPoint destination) {
@@ -460,7 +481,9 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
} }
/** /**
* UnResgisters the listener. after this call you will no longer get location updates * UnResgisters the listener. after this call you will no longer get
* location updates
*
* @author Ricky Barrette * @author Ricky Barrette
*/ */
public void unRegisterListener() { public void unRegisterListener() {

View File

@@ -24,7 +24,9 @@ import com.google.android.maps.MapView;
import com.google.android.maps.Overlay; import com.google.android.maps.Overlay;
/** /**
* A Simple compass overlay that will be used to point towards a destination or north * A Simple compass overlay that will be used to point towards a destination or
* north
*
* @author ricky barrette * @author ricky barrette
*/ */
public class CompasOverlay extends Overlay implements CompassListener { public class CompasOverlay extends Overlay implements CompassListener {
@@ -43,6 +45,7 @@ public class CompasOverlay extends Overlay implements CompassListener {
/** /**
* Creates a new CompasOverlay * Creates a new CompasOverlay
*
* @author ricky barrette * @author ricky barrette
*/ */
public CompasOverlay(final Context context) { public CompasOverlay(final Context context) {
@@ -54,6 +57,7 @@ public class CompasOverlay extends Overlay implements CompassListener {
/** /**
* Creates a new CompasOverlay * Creates a new CompasOverlay
*
* @param context * @param context
* @param destination * @param destination
* @author ricky barrette * @author ricky barrette
@@ -65,12 +69,15 @@ public class CompasOverlay extends Overlay implements CompassListener {
/** /**
* Creates a new CompasOverlay * Creates a new CompasOverlay
*
* @param context * @param context
* @param destination * @param destination
* @param needleResId * @param needleResId
* @param backgroundResId * @param backgroundResId
* @param x dip * @param x
* @param y dip * dip
* @param y
* dip
* @author ricky barrette * @author ricky barrette
*/ */
public CompasOverlay(final Context context, final GeoPoint destination, final int needleResId, final int backgroundResId, final int x, final int y) { public CompasOverlay(final Context context, final GeoPoint destination, final int needleResId, final int backgroundResId, final int x, final int y) {
@@ -83,6 +90,7 @@ public class CompasOverlay extends Overlay implements CompassListener {
/** /**
* Creates a new CompasOverlay * Creates a new CompasOverlay
*
* @param context * @param context
* @param needleResId * @param needleResId
* @param backgroundResId * @param backgroundResId
@@ -96,6 +104,7 @@ public class CompasOverlay extends Overlay implements CompassListener {
/** /**
* Converts dip to px * Converts dip to px
*
* @param dip * @param dip
* @return px * @return px
* @author ricky barrette * @author ricky barrette
@@ -107,6 +116,7 @@ public class CompasOverlay extends Overlay implements CompassListener {
/** /**
* Disables the compass overlay * Disables the compass overlay
*
* @author ricky barrette * @author ricky barrette
*/ */
public void disable() { public void disable() {
@@ -117,43 +127,30 @@ public class CompasOverlay extends Overlay implements CompassListener {
/** /**
* (non-Javadoc) * (non-Javadoc)
* @see com.google.android.maps.Overlay#draw(android.graphics.Canvas, com.google.android.maps.MapView, boolean) *
* @see com.google.android.maps.Overlay#draw(android.graphics.Canvas,
* com.google.android.maps.MapView, boolean)
* @author ricky barrette * @author ricky barrette
*/ */
@Override @Override
public void draw(final Canvas canvas, final MapView mapView, final boolean shadow) { public void draw(final Canvas canvas, final MapView mapView, final boolean shadow) {
if (isEnabled) { if (isEnabled) {
//set the center of the compass in the top left corner of the screen // set the center of the compass in the top left corner of the
// screen
final Point point = new Point(); final Point point = new Point();
point.set(mX, mY); point.set(mX, mY);
// draw compass background // draw compass background
final Bitmap compass = BitmapFactory.decodeResource(mContext.getResources(), mBackgroundResId); final Bitmap compass = BitmapFactory.decodeResource(mContext.getResources(), mBackgroundResId);
canvas.drawBitmap(compass, canvas.drawBitmap(compass, point.x - compass.getWidth() / 2, point.y - compass.getHeight() / 2, null);
point.x - compass.getWidth() / 2,
point.y - compass.getHeight() / 2,
null
);
// draw the compass needle // draw the compass needle
final Bitmap arrowBitmap = BitmapFactory.decodeResource(mContext.getResources(), mNeedleResId); final Bitmap arrowBitmap = BitmapFactory.decodeResource(mContext.getResources(), mNeedleResId);
final Matrix matrix = new Matrix(); final Matrix matrix = new Matrix();
matrix.postRotate(GeoUtils.calculateBearing(mLocation, mDestination, mBearing)); matrix.postRotate(GeoUtils.calculateBearing(mLocation, mDestination, mBearing));
final Bitmap rotatedBmp = Bitmap.createBitmap( final Bitmap rotatedBmp = Bitmap.createBitmap(arrowBitmap, 0, 0, arrowBitmap.getWidth(), arrowBitmap.getHeight(), matrix, true);
arrowBitmap, canvas.drawBitmap(rotatedBmp, point.x - rotatedBmp.getWidth() / 2, point.y - rotatedBmp.getHeight() / 2, null);
0, 0,
arrowBitmap.getWidth(),
arrowBitmap.getHeight(),
matrix,
true
);
canvas.drawBitmap(
rotatedBmp,
point.x - rotatedBmp.getWidth() / 2,
point.y - rotatedBmp.getHeight() / 2,
null
);
mapView.invalidate(); mapView.invalidate();
} }
super.draw(canvas, mapView, shadow); super.draw(canvas, mapView, shadow);
@@ -161,6 +158,7 @@ public class CompasOverlay extends Overlay implements CompassListener {
/** /**
* Enables the compass overlay * Enables the compass overlay
*
* @author ricky barrette * @author ricky barrette
*/ */
public void enable() { public void enable() {
@@ -172,6 +170,7 @@ public class CompasOverlay extends Overlay implements CompassListener {
/** /**
* Enables the compass overlay * Enables the compass overlay
*
* @param listener * @param listener
* @author ricky barrette * @author ricky barrette
*/ */
@@ -199,6 +198,7 @@ public class CompasOverlay extends Overlay implements CompassListener {
/** /**
* Called from the compass Sensor to update the current bearing * Called from the compass Sensor to update the current bearing
* (non-Javadoc) * (non-Javadoc)
*
* @see com.TwentyCodes.android.location.CompassListener#onCompassUpdate(float) * @see com.TwentyCodes.android.location.CompassListener#onCompassUpdate(float)
* @author ricky barrette * @author ricky barrette
*/ */
@@ -224,8 +224,10 @@ public class CompasOverlay extends Overlay implements CompassListener {
/** /**
* @param needleResId * @param needleResId
* @param backgroundResId * @param backgroundResId
* @param x dip * @param x
* @param y dip * dip
* @param y
* dip
* @author ricky barrette * @author ricky barrette
*/ */
public void setDrawables(final int needleResId, final int backgroundResId, final int x, final int y) { public void setDrawables(final int needleResId, final int backgroundResId, final int x, final int y) {

View File

@@ -26,7 +26,9 @@ import com.TwentyCodes.android.location.MapView;
import com.google.android.maps.GeoPoint; import com.google.android.maps.GeoPoint;
/** /**
* This Overlay class will be used to display provided by the Google Directions API on a map * This Overlay class will be used to display provided by the Google Directions
* API on a map
*
* @author ricky barrette * @author ricky barrette
*/ */
public class DirectionsOverlay { public class DirectionsOverlay {
@@ -51,15 +53,19 @@ public class DirectionsOverlay {
/** /**
* Downloads and Creates a new DirectionsOverlay from the provided points * Downloads and Creates a new DirectionsOverlay from the provided points
* @param origin point *
* @param destination point * @param origin
* point
* @param destination
* point
* @author ricky barrette * @author ricky barrette
* @throws IOException * @throws IOException
* @throws ClientProtocolException * @throws ClientProtocolException
* @throws IllegalStateException * @throws IllegalStateException
* @throws JSONException * @throws JSONException
*/ */
public DirectionsOverlay(final MapView map, final GeoPoint origin, final GeoPoint destination, final OnDirectionsCompleteListener listener) throws IllegalStateException, ClientProtocolException, IOException, JSONException { public DirectionsOverlay(final MapView map, final GeoPoint origin, final GeoPoint destination, final OnDirectionsCompleteListener listener)
throws IllegalStateException, ClientProtocolException, IOException, JSONException {
mMapView = map; mMapView = map;
mListener = listener; mListener = listener;
final String json = downloadJSON(generateUrl(origin, destination)); final String json = downloadJSON(generateUrl(origin, destination));
@@ -68,6 +74,7 @@ public class DirectionsOverlay {
/** /**
* Creates a new DirectionsOverlay from the provided String JSON * Creates a new DirectionsOverlay from the provided String JSON
*
* @param json * @param json
* @throws JSONException * @throws JSONException
* @author ricky barrette * @author ricky barrette
@@ -80,9 +87,11 @@ public class DirectionsOverlay {
/** /**
* Deocodes googles polyline * Deocodes googles polyline
*
* @param encoded * @param encoded
* @return a list of geopoints representing the path * @return a list of geopoints representing the path
* @author Mark McClure http://facstaff.unca.edu/mcmcclur/googlemaps/encodepolyline/ * @author Mark McClure
* http://facstaff.unca.edu/mcmcclur/googlemaps/encodepolyline/
* @author ricky barrette * @author ricky barrette
* @throws JSONException * @throws JSONException
*/ */
@@ -124,7 +133,6 @@ public class DirectionsOverlay {
Log.d(TAG, "last = " + last.toString()); Log.d(TAG, "last = " + last.toString());
} }
if (last != null) if (last != null)
mPath.add(new PathOverlay(last, p, Color.RED)); mPath.add(new PathOverlay(last, p, Color.RED));
// else // else
@@ -137,6 +145,7 @@ public class DirectionsOverlay {
/** /**
* Downloads Google Directions JSON from the Internet * Downloads Google Directions JSON from the Internet
*
* @param url * @param url
* @return * @return
* @throws IllegalStateException * @throws IllegalStateException
@@ -157,10 +166,11 @@ public class DirectionsOverlay {
return response.toString(); return response.toString();
} }
/** /**
* Creates a new DirectionsOverlay from the json provided * Creates a new DirectionsOverlay from the json provided
* @param json of Google Directions API *
* @param json
* of Google Directions API
* @author ricky barrette * @author ricky barrette
* @return * @return
* @throws JSONException * @throws JSONException
@@ -185,8 +195,12 @@ public class DirectionsOverlay {
final JSONObject leg = route.getJSONArray("legs").getJSONObject(0); final JSONObject leg = route.getJSONArray("legs").getJSONObject(0);
getDistance(leg); getDistance(leg);
getDuration(leg); getDuration(leg);
// mMapView.getOverlays().add(new PathOverlay(getGeoPoint(leg.getJSONObject("start_location")), 12, Color.GREEN)); // mMapView.getOverlays().add(new
// mMapView.getOverlays().add(new PathOverlay(getGeoPoint(leg.getJSONObject("end_location")), 12, Color.RED)); // PathOverlay(getGeoPoint(leg.getJSONObject("start_location")), 12,
// Color.GREEN));
// mMapView.getOverlays().add(new
// PathOverlay(getGeoPoint(leg.getJSONObject("end_location")), 12,
// Color.RED));
leg.getString("start_address"); leg.getString("start_address");
leg.getString("end_address"); leg.getString("end_address");
@@ -215,7 +229,9 @@ public class DirectionsOverlay {
} }
// if(Debug.DEBUG) // if(Debug.DEBUG)
// mMapView.getOverlays().add(new PathOverlay(getGeoPoint(step.getJSONObject("start_location")), getGeoPoint(step.getJSONObject("end_location")), Color.MAGENTA)); // mMapView.getOverlays().add(new
// PathOverlay(getGeoPoint(step.getJSONObject("start_location")),
// getGeoPoint(step.getJSONObject("end_location")), Color.MAGENTA));
decodePoly(step); decodePoly(step);
@@ -247,15 +263,9 @@ public class DirectionsOverlay {
* @author ricky barrette * @author ricky barrette
*/ */
private String generateUrl(final GeoPoint origin, final GeoPoint destination) { private String generateUrl(final GeoPoint origin, final GeoPoint destination) {
return "http://maps.googleapis.com/maps/api/directions/json?&origin="+ return "http://maps.googleapis.com/maps/api/directions/json?&origin=" + Double.toString(origin.getLatitudeE6() / 1.0E6) + ","
Double.toString(origin.getLatitudeE6() / 1.0E6)+ + Double.toString(origin.getLongitudeE6() / 1.0E6) + "&destination=" + Double.toString(destination.getLatitudeE6() / 1.0E6) + ","
","+ + Double.toString(destination.getLongitudeE6() / 1.0E6) + "&sensor=true&mode=walking";
Double.toString(origin.getLongitudeE6() / 1.0E6)+
"&destination="+
Double.toString(destination.getLatitudeE6() / 1.0E6)+
","+
Double.toString(destination.getLongitudeE6() / 1.0E6)+
"&sensor=true&mode=walking";
} }
/** /**
@@ -312,6 +322,7 @@ public class DirectionsOverlay {
/** /**
* Converts a JSON location object into a GeoPoint * Converts a JSON location object into a GeoPoint
*
* @param point * @param point
* @return Geopoint parsed from the provided JSON Object * @return Geopoint parsed from the provided JSON Object
* @throws JSONException * @throws JSONException
@@ -347,9 +358,11 @@ public class DirectionsOverlay {
/** /**
* Removes the directions overlay from the map view * Removes the directions overlay from the map view
*
* @author ricky barrette * @author ricky barrette
*/ */
public void removePath() { public void removePath() {
if(mMapView.getOverlays().removeAll(mPath)); if (mMapView.getOverlays().removeAll(mPath))
;
} }
} }

View File

@@ -18,6 +18,7 @@ import com.google.android.maps.Projection;
/** /**
* This imutable overlay class is used to draw a path and points on a map * This imutable overlay class is used to draw a path and points on a map
*
* @author ricky barrette * @author ricky barrette
*/ */
public final class PathOverlay extends Overlay { public final class PathOverlay extends Overlay {
@@ -32,6 +33,7 @@ public final class PathOverlay extends Overlay {
/** /**
* Creates a new PathOverlay in path mode * Creates a new PathOverlay in path mode
*
* @author ricky barrette * @author ricky barrette
*/ */
public PathOverlay(final GeoPoint start, final GeoPoint end, final int color) { public PathOverlay(final GeoPoint start, final GeoPoint end, final int color) {
@@ -44,6 +46,7 @@ public final class PathOverlay extends Overlay {
/** /**
* Creates a new PathOverlay in point mode. This is used to draw end points. * Creates a new PathOverlay in point mode. This is used to draw end points.
*
* @param point * @param point
* @param radius * @param radius
* @param color * @param color
@@ -59,7 +62,8 @@ public final class PathOverlay extends Overlay {
/** /**
* *
* @param canvas canvas to be drawn on * @param canvas
* canvas to be drawn on
* @param mapView * @param mapView
* @param shadow * @param shadow
* @param when * @param when

View File

@@ -21,8 +21,9 @@ import com.google.android.maps.OverlayItem;
import com.google.android.maps.Projection; import com.google.android.maps.Projection;
/** /**
* This class will used to draw a radius of a specified size in a specified location, then inserted into * This class will used to draw a radius of a specified size in a specified
* an overlay list to be displayed a map * location, then inserted into an overlay list to be displayed a map
*
* @author ricky barrette * @author ricky barrette
*/ */
public class RadiusOverlay extends Overlay { public class RadiusOverlay extends Overlay {
@@ -36,16 +37,22 @@ public class RadiusOverlay extends Overlay{
/** /**
* Creates a new RadiusOverlay * Creates a new RadiusOverlay
*
* @author ricky barrette * @author ricky barrette
*/ */
public RadiusOverlay() { public RadiusOverlay() {
} }
/** /**
* Creates a new RadiusOverlay object that can be inserted into an overlay list. * Creates a new RadiusOverlay object that can be inserted into an overlay
* @param point center of radius geopoint * list.
* @param radius radius in meters *
* @param color desired color of the radius from Color API * @param point
* center of radius geopoint
* @param radius
* radius in meters
* @param color
* desired color of the radius from Color API
* @author ricky barrette * @author ricky barrette
*/ */
public RadiusOverlay(final GeoPoint point, final float radius, final int color) { public RadiusOverlay(final GeoPoint point, final float radius, final int color) {
@@ -56,7 +63,9 @@ public class RadiusOverlay extends Overlay{
/** /**
* draws a specific radius on the mapview that is handed to it * draws a specific radius on the mapview that is handed to it
* @param canvas canvas to be drawn on *
* @param canvas
* canvas to be drawn on
* @param mapView * @param mapView
* @param shadow * @param shadow
* @param when * @param when
@@ -70,9 +79,10 @@ public class RadiusOverlay extends Overlay{
final Projection projection = mapView.getProjection(); final Projection projection = mapView.getProjection();
/* /*
* Calculate a geopoint that is "radius" meters away from geopoint point and * Calculate a geopoint that is "radius" meters away from geopoint
* convert the given GeoPoint and leftGeo to onscreen pixel coordinates, * point and convert the given GeoPoint and leftGeo to onscreen
* relative to the top-left of the MapView that provided this Projection. * pixel coordinates, relative to the top-left of the MapView that
* provided this Projection.
*/ */
mRadiusPoint = GeoUtils.distanceFrom(mPoint, mRadius); mRadiusPoint = GeoUtils.distanceFrom(mPoint, mRadius);
projection.toPixels(mRadiusPoint, left); projection.toPixels(mRadiusPoint, left);
@@ -147,7 +157,8 @@ public class RadiusOverlay extends Overlay{
} }
/** /**
* @param radius in meters * @param radius
* in meters
* @author ricky barrette * @author ricky barrette
* @param radius * @param radius
*/ */

View File

@@ -11,7 +11,9 @@ import com.TwentyCodes.android.SkyHook.SkyHook;
import com.google.android.maps.MapView; import com.google.android.maps.MapView;
/** /**
* this class will be used to display the users location on the map using skyhook's call back methods * this class will be used to display the users location on the map using
* skyhook's call back methods
*
* @author ricky barrette * @author ricky barrette
*/ */
public class SkyHookUserOverlay extends BaseUserOverlay { public class SkyHookUserOverlay extends BaseUserOverlay {
@@ -25,6 +27,7 @@ public class SkyHookUserOverlay extends BaseUserOverlay{
/** /**
* Construct a new SkyHookUserOverlay * Construct a new SkyHookUserOverlay
*
* @param mapView * @param mapView
* @param context * @param context
* @param followUser * @param followUser
@@ -41,8 +44,8 @@ public class SkyHookUserOverlay extends BaseUserOverlay{
} }
/** /**
* Called when the location provider needs to be disabled * Called when the location provider needs to be disabled (non-Javadoc)
* (non-Javadoc) *
* @see com.TwentyCodes.android.overlays.BaseUserOverlay#onMyLocationDisabled() * @see com.TwentyCodes.android.overlays.BaseUserOverlay#onMyLocationDisabled()
*/ */
@Override @Override
@@ -51,8 +54,8 @@ public class SkyHookUserOverlay extends BaseUserOverlay{
} }
/** /**
* Called when the location provider needs to be enabled * Called when the location provider needs to be enabled (non-Javadoc)
* (non-Javadoc) *
* @see com.TwentyCodes.android.overlays.BaseUserOverlay#onMyLocationEnabled() * @see com.TwentyCodes.android.overlays.BaseUserOverlay#onMyLocationEnabled()
*/ */
@Override @Override

View File

@@ -12,6 +12,7 @@ import com.google.android.maps.MapView;
/** /**
* This is the standard version of the UserOverlay. * This is the standard version of the UserOverlay.
*
* @author ricky barrette * @author ricky barrette
*/ */
public class UserOverlay extends BaseUserOverlay { public class UserOverlay extends BaseUserOverlay {