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;
/**
* 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
*/
public class SkyHook implements GeoPointLocationListener {
@@ -45,6 +47,7 @@ public class SkyHook implements GeoPointLocationListener{
return WPSContinuation.WPS_CONTINUE;
}
}
public static final String TAG = "Skyhook";
public static final String USERNAME = "cjyh95q32gsc";
public static final String USERNAME_FOR_TESTING = "twentycodes";
@@ -71,8 +74,8 @@ public class SkyHook implements GeoPointLocationListener{
private boolean isFirstFix;
/*
* this runnable will be used to check if we have location from skyhook,
* if we dont, then we will us android's location services to fall back on.
* this runnable will be used to check if we have location from skyhook, if
* we dont, then we will us android's location services to fall back on.
*/
private final Runnable mFallBack = new Runnable() {
@Override
@@ -116,6 +119,7 @@ public class SkyHook implements GeoPointLocationListener{
/**
* Constructors a new skyhook object
*
* @param context
* @author ricky barrette
*/
@@ -131,8 +135,10 @@ public class SkyHook implements GeoPointLocationListener{
/**
* Constructors a new skyhook object
*
* @param context
* @param period between location updates in milliseconds
* @param period
* between location updates in milliseconds
* @author ricky barrette
*/
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.
* updates will stop once an accurate location is determined.
* request current user location, note that the listeners
* onLocationChanged() will be call multiple times. updates will stop once
* an accurate location is determined.
*
* @author Ricky Barrette
*/
public void getLoctaion() {
@@ -155,6 +163,7 @@ public class SkyHook implements GeoPointLocationListener{
/**
* Attempts to register the the listener for periodic updates
*
* @author Ricky Barrette
*/
public void getUpdates() {
@@ -186,9 +195,10 @@ public class SkyHook implements GeoPointLocationListener{
}
/**
* called from our skyhook to android fall back class
* (non-Javadoc)
* @see com.TwentyCodes.android.location.GeoPointLocationListener#onLocationChanged(com.google.android.maps.GeoPoint, int)
* called from our skyhook to android fall back class (non-Javadoc)
*
* @see com.TwentyCodes.android.location.GeoPointLocationListener#onLocationChanged(com.google.android.maps.GeoPoint,
* int)
* @author ricky barrette
*/
@Override
@@ -199,9 +209,10 @@ public class SkyHook implements GeoPointLocationListener{
}
/**
* Removes any current registration for location updates of the current activity
* with the given LocationListener. Following this call, updates will no longer
* occur for this listener.
* Removes any current registration for location updates of the current
* activity with the given LocationListener. Following this call, updates
* will no longer occur for this listener.
*
* @param listener
* @author ricky barrette
*/
@@ -222,9 +233,10 @@ public class SkyHook implements GeoPointLocationListener{
}
/**
* Used for receiving notifications from SkyHook when
* the location has changed. These methods are called if the
* LocationListener has been registered with the location manager service using the method.
* Used for receiving notifications from SkyHook when the location has
* changed. These methods are called if the LocationListener has been
* registered with the location manager service using the method.
*
* @param listener
* @author ricky barrette
*/
@@ -265,9 +277,11 @@ public class SkyHook implements GeoPointLocationListener{
hasLocation = false;
/*
* check to see if the error returned is an WPS_ERROR_UNAUTHORIZED
* then check to see if this is the second occurrence of WPS_ERROR_UNAUTHORIZED,
* if so we will stop skyhook's services to cut down the work load
* check to see if the error returned is an
* WPS_ERROR_UNAUTHORIZED then check to see if this is
* 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 (isUnauthorized) {
@@ -278,10 +292,10 @@ public class SkyHook implements GeoPointLocationListener{
isUnauthorized = true;
}
/*
* 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) {
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
*
* @author ricky barrette
*/
public class SkyHookRegistration {
/**
* returns the users username
*
* @param context
* @return
* @author ricky barrette
@@ -45,6 +47,7 @@ public class SkyHookRegistration{
return null;
}
private final XPS mXps;
private final Context mContext;
@@ -58,7 +61,9 @@ public class SkyHookRegistration{
* attempts to register the user by their cell #
*
* TODO hash cell number for privacy
* @param listener for call back methods
*
* @param listener
* for call back methods
* @author ricky barrette
*/
public void registerNewUser(final RegistrationCallback listener) {

View File

@@ -26,12 +26,17 @@ import com.skyhookwireless.wps.WPSContinuation;
import com.skyhookwireless.wps.WPSReturnCode;
/**
* This service class will be used broadcast the users location either one time, or periodically.
* To use as a one shot location service:
* <blockquote><pre>PendingIntent pendingIntent = PendingIntent.getService(context, 0, SkyHookService.startService(context), 0);
* This service class will be used broadcast the users location either one time,
* or periodically. To use as a one shot location service: <blockquote>
*
* <pre>
* PendingIntent pendingIntent = PendingIntent.getService(context, 0, SkyHookService.startService(context), 0);
* or
* Intent service = new Intent(context, SkyHookService.class);
* context.startService(service);<pre></bloackquote>
* context.startService(service);
*
* <pre>
* </bloackquote>
* To use as a recurring service:
* <blockquote>SkyHookService.startService(this, (60000 * Integer.parseInt(ringer.getString(UPDATE_INTVERVAL , "5")))).run();</bloackquote>
* @author ricky barrette
@@ -40,8 +45,10 @@ public class SkyHookService extends Service implements GeoPointLocationListener,
public static final String TAG = "SkyHookService";
public static final int REQUEST_CODE = 32741942;
/**
* a convince method for getting an intent to start the service
*
* @param context
* @return a intent that will be used to start the service
* @author ricky barrette
@@ -49,8 +56,11 @@ public class SkyHookService extends Service implements GeoPointLocationListener,
public static Intent getStartServiceIntent(final Context context) {
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
* @return a runnable that will stop the service
* @author ricky barrette
@@ -60,10 +70,12 @@ public class SkyHookService extends Service implements GeoPointLocationListener,
@Override
public void run() {
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;
protected long mPeriod = -1;
private GeoPoint mLocation;
@@ -93,6 +105,7 @@ public class SkyHookService extends Service implements GeoPointLocationListener,
/**
* converts skyhook's location object into android's location object
*
* @return converted location
* @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
// */
// @Override
// 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);
// this.mSkyhook.getUpdates();
// }
@@ -138,6 +154,7 @@ public class SkyHookService extends Service implements GeoPointLocationListener,
/**
* (non-Javadoc)
*
* @see android.app.Service#onBind(android.content.Intent)
* @param arg0
* @return
@@ -155,8 +172,8 @@ public class SkyHookService extends Service implements GeoPointLocationListener,
mSkyhook.setLocationListener(this);
/*
* fail safe
* this will stop the service after the maximum running time, if location has not been reported
* fail safe this will stop the service after the maximum running time,
* if location has not been reported
*/
new Handler().postDelayed(new Runnable() {
@Override
@@ -167,8 +184,8 @@ public class SkyHookService extends Service implements GeoPointLocationListener,
}
/**
* aborts location services
* (non-Javadoc)
* aborts location services (non-Javadoc)
*
* @see android.app.Service#onDestroy()
* @author Ricky Barrette
*/
@@ -193,18 +210,19 @@ public class SkyHookService extends Service implements GeoPointLocationListener,
mLocation = point;
mAccuracy = accuracy;
/*
* fail safe
* if the accuracy is greater than the minimum required accuracy
* then continue
* else stop to report location
* fail safe if the accuracy is greater than the minimum required
* accuracy 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 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
*/
@Override
@@ -236,6 +254,7 @@ public class SkyHookService extends Service implements GeoPointLocationListener,
/**
* registers our Receiver the starts the service with the alarm manager
*
* @author ricky barrette
*/
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
*
* @author ricky barrette
*/
public class Debug {
/**
* Sets the logging level for this library
*
* @author ricky barrette
*/
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
*
* @author ricky barrette
*/
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
*/
public static final SkyHookRegistrationBehavior DEFAULT_REGISTRATION_BEHAVIOR = SkyHookRegistrationBehavior.NORMAL;
/**
* Sets the default compass sensor update interval
*
* @author ricky barrette
*/
public static final int COMPASS_UPDATE_INTERVAL = SensorManager.SENSOR_DELAY_NORMAL;
/**
* The maximum running time for a single shot location service
*
* @author ricky barrette
*/
public static final long MAX_LOCATION_SERVICE_RUN_TIME = 60000l;
/**
* Forces single shot location services to return the first location
*
* @author ricky barrette
*/
public static final boolean REPORT_FIRST_LOCATION = false;
/**
* Minimum Required accuracy to report
*
* @author ricky barrette
*/
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;
/**
* 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";
@@ -71,7 +79,8 @@ public final class LocationLibraryConstants {
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;
}

View File

@@ -8,6 +8,7 @@ package com.TwentyCodes.android.debug;
/**
* This enum will be used to select the testing level
*
* @author ricky barrette
*/
public enum SkyHookRegistrationBehavior {
@@ -18,7 +19,8 @@ public enum SkyHookRegistrationBehavior {
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,

View File

@@ -31,6 +31,7 @@ public abstract class BaseMapFragment extends Fragment {
/**
* Creates a new MapFragment
*
* @author ricky barrette
*/
public BaseMapFragment() {
@@ -43,6 +44,7 @@ public abstract class BaseMapFragment extends Fragment {
/**
* changes the map mode
*
* @author ricky barrette
*/
public void changeMapMode() {
@@ -51,6 +53,7 @@ public abstract class BaseMapFragment extends Fragment {
/**
* Disables the Acquiring GPS dialog
*
* @author ricky barrette
*/
public void disableGPSProgess() {
@@ -78,6 +81,7 @@ public abstract class BaseMapFragment extends Fragment {
/**
* Forces the map to redraw
*
* @author ricky barrette
*/
public void invalidate() {
@@ -101,9 +105,10 @@ public abstract class BaseMapFragment extends Fragment {
}
/**
* Called when the fragment view is first created
* (non-Javadoc)
* @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
* Called when the fragment view is first created (non-Javadoc)
*
* @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater,
* android.view.ViewGroup, android.os.Bundle)
*/
@Override
public View onCreateView(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
* @author ricky barrette
*/
@@ -128,6 +135,7 @@ public abstract class BaseMapFragment extends Fragment {
/**
* Removes an overlay from the mapview
*
* @param overlay
* @author ricky barrette
*/
@@ -137,6 +145,7 @@ public abstract class BaseMapFragment extends Fragment {
/**
* Enables or disables the built in zoom controls
*
* @param isShowing
* @author ricky barrette
*/
@@ -146,6 +155,7 @@ public abstract class BaseMapFragment extends Fragment {
/**
* Sets where or not the map view is interactive
*
* @param isClickable
* @author ricky barrette
*/
@@ -155,6 +165,7 @@ public abstract class BaseMapFragment extends Fragment {
/**
* Sets double tap zoom
*
* @param isDoubleTapZoonEnabled
* @author ricky barrette
*/
@@ -164,6 +175,7 @@ public abstract class BaseMapFragment extends Fragment {
/**
* Sets the center of the map to the provided point
*
* @param point
* @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
*
* @param isSat
* @author ricky barrette
*/
@@ -185,6 +198,7 @@ public abstract class BaseMapFragment extends Fragment {
/**
* Sets the zoom level of the map
*
* @param zoom
* @author ricky barrette
*/

View File

@@ -17,26 +17,30 @@ import com.TwentyCodes.android.location.R;
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
*/
public class DirectionsAdapter extends BaseAdapter {
/**
* this class will hold the TextViews
*
* @author ricky barrette
*/
class ViewHolder {
TextView text;
TextView text2;
}
private final LayoutInflater mInflater;
private final LayoutInflater mInflater;
private final DirectionsOverlay mDirections;
/**
* Creates a new DirectionsAdapter
*
* @author ricky barrette
*/
public DirectionsAdapter(final Context context, final DirectionsOverlay directions) {
@@ -46,6 +50,7 @@ public class DirectionsAdapter extends BaseAdapter {
/**
* returns the size of the main list
*
* @see android.widget.Adapter#getCount()
* @return
* @author ricky barrette
@@ -57,6 +62,7 @@ public class DirectionsAdapter extends BaseAdapter {
/**
* (non-Javadoc)
*
* @see android.widget.Adapter#getItem(int)
* @param position
* @return
@@ -69,6 +75,7 @@ public class DirectionsAdapter extends BaseAdapter {
/**
* returns the current position in the list
*
* @see android.widget.Adapter#getItemId(int)
* @param position
* @return
@@ -81,7 +88,9 @@ public class DirectionsAdapter extends BaseAdapter {
/**
* 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 convertView
* @param parent

View File

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

View File

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

View File

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

View File

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

View File

@@ -12,7 +12,9 @@ import android.location.Location;
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
*/
public abstract class BaseLocationReceiver extends BroadcastReceiver {
@@ -21,6 +23,7 @@ public abstract class BaseLocationReceiver extends BroadcastReceiver {
/**
* called when a location update is received
*
* @param parcelableExtra
* @author ricky barrette
*/
@@ -28,7 +31,9 @@ public abstract class BaseLocationReceiver extends BroadcastReceiver {
/**
* (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
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
*
* @author ricky barrette
*/
public class CompassSensor {
/**
* A simple listener interface to get updates from CompassSensor
*
* @author ricky barrette
*/
public interface CompassListener {
/**
* Called when there is an update from the Compass Sensor
*
* @param bearing
* @author ricky barrette
*/
@@ -73,6 +76,7 @@ public class CompassSensor{
private final float[] mOrientVals = new float[3];
private double mAzimuth = 0;
// double mPitch = 0;
// double mRoll = 0;
// private float mInclination;
@@ -124,19 +128,27 @@ public class CompassSensor{
// switch (mDisplay.getOrientation()){
// case Surface.ROTATION_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;
// case Surface.ROTATION_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;
// case Surface.ROTATION_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;
// case Surface.ROTATION_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;
// }
@@ -179,6 +191,7 @@ public class CompassSensor{
/**
* Creates a new CompassSensor
*
* @author ricky barrette
*/
public CompassSensor(final Context context) {
@@ -189,6 +202,7 @@ public class CompassSensor{
/**
* Disables compass updates
*
* @author ricky barrette
*/
public void disable() {
@@ -198,6 +212,7 @@ public class CompassSensor{
/**
* Attempts to register the listener for compass updates
*
* @param listener
* @author ricky barrette
*/
@@ -208,26 +223,30 @@ public class CompassSensor{
new Thread(new Runnable() {
@Override
public void run() {
// Register this class as a listener for the accelerometer sensor
mSensorManager.registerListener(mCallBack, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), LocationLibraryConstants.COMPASS_UPDATE_INTERVAL);
// Register this class as a listener for the
// accelerometer sensor
mSensorManager.registerListener(mCallBack, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER),
LocationLibraryConstants.COMPASS_UPDATE_INTERVAL);
// ...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();
}
}
/**
* Updates the Geomagnetic Field Declination based off of the provided location
* @param location last known (lat,lon,altitude), null will reset
* Updates the Geomagnetic Field Declination based off of the provided
* location
*
* @param location
* last known (lat,lon,altitude), null will reset
* @author ricky barrette
*/
public void setDeclination(final Location location) {
if (location != null) {
final GeomagneticField geomagneticField = new GeomagneticField(Double.valueOf(location.getLatitude()).floatValue(),
Double.valueOf(location.getLongitude()).floatValue(),
Double.valueOf(location.getAltitude()).floatValue(),
System.currentTimeMillis());
final GeomagneticField geomagneticField = new GeomagneticField(Double.valueOf(location.getLatitude()).floatValue(), Double.valueOf(location.getLongitude())
.floatValue(), Double.valueOf(location.getAltitude()).floatValue(), System.currentTimeMillis());
mDelination = geomagneticField.getDeclination();
} else
mDelination = 0;

View File

@@ -8,13 +8,16 @@ package com.TwentyCodes.android.location;
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
*/
public interface GeoPointLocationListener {
/**
* Called when first fix is aquired
*
* @param isFirstFix
* @author ricky barrette
*/
@@ -22,6 +25,7 @@ public interface GeoPointLocationListener {
/**
* Called when the location has changed
*
* @param point
* @param accuracy
* @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
*
* @author ricky barrette
* @author Google Inc.
*/
@@ -40,12 +41,19 @@ public class GeoUtils {
public static final double MILLION = 1000000;
/**
* computes the bearing of lat2/lon2 in relationship from lat1/lon1 in degrees East
* @param lat1 source lat
* @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
* computes the bearing of lat2/lon2 in relationship from lat1/lon1 in
* degrees East
*
* @param lat1
* source lat
* @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.
*/
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
* @param p1 source geopoint
* @param p2 destination geopoint
* computes the bearing of lat2/lon2 in relationship from lat1/lon1 in
* degrees East of true north
*
* @param p1
* source geopoint
* @param p2
* destination geopoint
* @return the bearing of p2 in relationship from p1 in degrees East
* @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.
* This method is awesome for making a compass point toward the destination rather than North.
* @param user location
* @param dest location
* @param bearing Degrees East from compass
* Calculates the bearing from the user location to the destination
* location, or returns the bearing for north if there is no destination.
* This method is awesome for making a compass point toward the destination
* rather than North.
*
* @param user
* location
* @param dest
* location
* @param bearing
* Degrees East from compass
* @return Degrees East of dest location
* @author ricky barrette
*/
@@ -97,11 +115,14 @@ public class GeoUtils {
}
/**
* Calculates a geopoint x meters away of the geopoint supplied. The new geopoint
* shares the same latitude as geopoint point, this way they are on the same latitude arc.
* Calculates a geopoint x meters away of the geopoint supplied. The new
* geopoint shares the same latitude as geopoint point, this way they are on
* the same latitude arc.
*
* @param point central geopoint
* @param distance in meters from the geopoint
* @param point
* central geopoint
* @param distance
* in meters from the geopoint
* @return geopoint that is x meters away from the geopoint supplied
* @author ricky barrette
*/
@@ -114,34 +135,45 @@ public class GeoUtils {
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
*
* 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: that lat2Rad is = lat1Rad because we want to keep the new geopoint on the same lat arc
* therefore i saw no need to create a new variable for lat2Rad,
* and simply inputed lat1Rad in place of lat2Rad in the equation
* NOTE: that lat2Rad is = lat1Rad because we want to keep the new
* geopoint on the same lat arc therefore i saw no need to create a new
* 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
* and has been proven to be damn close
* NOTE: this equation has be tested in the field against another gps
* 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))
* (1 / Math.cos(lat1Rad)) - Math.tan(lat1Rad) * Math.tan(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));
// return a geopoint that is x meters away from the geopoint supplied
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
* @param lat1 source lat
* @param lon1 source lon
* @param lat2 destination lat
* @param lon2 destination lon
* computes the distance between to lat1/lon1 and lat2/lon2 based on the
* curve of the earth
*
* @param lat1
* source lat
* @param lon1
* source lon
* @param lat2
* destination lat
* @param lon2
* destination lon
* @return the distance between to lat1/lon1 and lat2/lon2
* @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 p2
* @return the distance between to p1 and p2
@@ -173,8 +207,11 @@ public class GeoUtils {
/**
* 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
* @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.
* we will use this method to test if the users accuracy circle intersects a marked locaton's radius
* if ( (accuracyCircleRadius + locationRadius) - fudgeFactor) > acos(sin(lat1Rad)sin(lat2Rad)+cos(lat1Rad)cos(lat2Rad)cos(lon2Rad-lon1Rad)6371
* a convince method for testing if 2 circles on the the surface of the
* earth intersect. we will use this method to test if the users accuracy
* 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 accuracyRadius in KM
* @param accuracyRadius
* in KM
* @param locationPoint
* @param locationRadius in KM
* @param fudgeFactor how many KM the circles have to intersect
* @param locationRadius
* in KM
* @param fudgeFactor
* how many KM the circles have to intersect
* @return true if the circles intersect
* @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))
return true;
return false;
@@ -217,6 +262,7 @@ public class GeoUtils {
/**
* determines when the specified point is off the map
*
* @param point
* @return true is the point is off the map
* @author ricky barrette
@@ -237,8 +283,11 @@ public class GeoUtils {
/**
* 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
* @author ricky barrette
*/
@@ -272,6 +321,7 @@ public class GeoUtils {
/**
* converts radians to bearing
*
* @param rad
* @return bearing
* @author Google Inc.

View File

@@ -25,15 +25,19 @@ import com.TwentyCodes.android.debug.Debug;
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
*/
public class LocationService extends Service implements LocationListener {
public static final String TAG = "LocationService";
private static final int REQUEST_CODE = 7893749;
/**
* a convince method for getting an intent to start the service
*
* @param context
* @return a intent that will start the service
* @author ricky barrette
@@ -41,8 +45,10 @@ public class LocationService extends Service implements LocationListener {
public static Intent getStartServiceIntent(final Context context) {
return new Intent(context, LocationService.class);
}
/**
* a convince method for stopping the service and removing it's alarm
*
* @param context
* @return a runnable that will stop the service
* @author ricky barrette
@@ -52,10 +58,12 @@ public class LocationService extends Service implements LocationListener {
@Override
public void run() {
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;
protected long mPeriod = -1;
private Location mLocation;
@@ -63,11 +71,11 @@ public class LocationService extends Service implements LocationListener {
private AndroidGPS mLocationManager;
private int mRequiredAccuracy;
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() {
@Override
@@ -77,8 +85,9 @@ public class LocationService extends Service implements LocationListener {
};
/**
* broadcasts location to anything listening for updates,
* since this is the last function of the service, we call finish()u
* broadcasts location to anything listening for updates, since this is the
* last function of the service, we call finish()u
*
* @author ricky barrette
*/
private void broadcastLocation() {
@@ -97,6 +106,7 @@ public class LocationService extends Service implements LocationListener {
/**
* (non-Javadoc)
*
* @see android.app.Service#onBind(android.content.Intent)
* @param arg0
* @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
* (non-Javadoc)
* called when the service is created. this will initialize the location
* manager, and acquire a wakelock (non-Javadoc)
*
* @see android.app.Service#onCreate()
* @author ricky barrette
*/
@@ -122,16 +133,17 @@ public class LocationService extends Service implements LocationListener {
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);
super.onCreate();
}
/**
* called when the service is destroyed.
* this will remove any wakelock or location service running, and register to be waken back up
* (non-Javadoc)
* called when the service is destroyed. this will remove any wakelock or
* location service running, and register to be waken back up (non-Javadoc)
*
* @see android.app.Service#onDestroy()
* @author ricky barrette
*/
@@ -150,7 +162,8 @@ public class LocationService extends Service implements LocationListener {
if (Debug.DEBUG)
Log.d(TAG, "got location +- " + location.getAccuracy() + "m");
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);
}
@@ -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
*/
@Override
@@ -205,6 +220,7 @@ public class LocationService extends Service implements LocationListener {
/**
* registers this service to be waken up by android's alarm manager
*
* @author ricky barrette
*/
private void registerwakeUp() {

View File

@@ -14,7 +14,9 @@ import android.view.MotionEvent;
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
*/
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
* (non-Javadoc)
* We will override the draw method to help prevent issues (non-Javadoc)
*
* @see android.view.View#draw(android.graphics.Canvas)
* @author ricky barrette
*/
@@ -63,8 +65,7 @@ public class MapView extends com.google.android.maps.MapView {
if (getZoomLevel() >= 21)
getController().setZoom(20);
super.draw(canvas);
}
catch(final Exception ex) {
} catch (final Exception ex) {
// getController().setCenter(this.getMapCenter());
// getController().setZoom(this.getZoomLevel() - 2);
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
*/
public void setDoubleTapZoonEnabled(final boolean isDoubleTapZoonEnabled) {

View File

@@ -8,7 +8,9 @@ package com.TwentyCodes.android.location;
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
*/
public class MidPoint {
@@ -21,6 +23,7 @@ public class MidPoint {
/**
* Creates a new MidPoint
*
* @author ricky barrette
*/
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
*
* @return
* @author ricky barrette
*/
@@ -42,6 +46,7 @@ public class MidPoint {
/**
* zooms the provided map view to the span of this mid point
*
* @param mMapView
* @author ricky barrette
*/

View File

@@ -3,7 +3,9 @@ package com.TwentyCodes.android.location;
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
*/
public interface OnLocationSelectedListener {

View File

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

View File

@@ -26,8 +26,9 @@ import android.util.Log;
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+.
* I found this source in one of the comments mentioning that it is a work around.
* 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+. I found this
* source in one of the comments mentioning that it is a work around.
*
* @author ricky barrette
*/
@@ -37,7 +38,9 @@ public class ReverseGeocoder {
/**
* Performs a google maps search for the address
* @param address to search
*
* @param address
* to search
* @return JSON Array of google place marks
* @throws IOException
* @throws JSONException
@@ -68,6 +71,7 @@ public class ReverseGeocoder {
/**
* Performs a google maps search for the closest address to the location
*
* @param lat
* @param lon
* @return string address, or lat, lon if search fails
@@ -96,7 +100,6 @@ public class ReverseGeocoder {
if (Debug.DEBUG)
Log.d(TAG, response.toString());
JSONArray responseArray = null;
try {
responseArray = new JSONObject(response.toString()).getJSONArray("Placemark");
@@ -119,6 +122,7 @@ public class ReverseGeocoder {
/**
* Performs a google maps search for the address
*
* @param location
* @return JSON Array on google place marks nearby
* @author ricky barrette

View File

@@ -30,12 +30,14 @@ import com.google.android.maps.Projection;
/**
* This class will be used to build user overlays
*
* @author ricky barrette
*/
public abstract class BaseUserOverlay extends Overlay implements GeoPointLocationListener, CompassListener {
/**
* This thread is responsible for animating the user icon
*
* @author ricky barrette
*/
public class AnimationThread extends Thread {
@@ -47,8 +49,8 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
}
/**
* Main method of this animation thread
* (non-Javadoc)
* Main method of this animation thread (non-Javadoc)
*
* @see java.lang.Thread#run()
*/
@Override
@@ -121,6 +123,7 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
/**
* Construct a new UserOverlay
*
* @param mapView
* @param context
* @author ricky barrette
@@ -135,6 +138,7 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
/**
* Construct a new UserOverlayTODO Auto-generated method stub
*
* @param mapView
* @param context
* @param followUser
@@ -147,6 +151,7 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
/**
* Disables the compass
*
* @author ricky barrette
*/
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
*
* @author ricky barrette
*/
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.
* (non-Javadoc)
* @see com.google.android.maps.Overlay#draw(android.graphics.Canvas, com.google.android.maps.MapView, boolean)
* we override this methods so we can provide a drawable and a location to
* draw on the canvas. (non-Javadoc)
*
* @see com.google.android.maps.Overlay#draw(android.graphics.Canvas,
* com.google.android.maps.MapView, boolean)
* @param canvas
* @param mapView
* @param shadow
@@ -189,7 +197,8 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
canvas = drawAccuracyCircle(center, left, 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)
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
* @param center point of the circle
* @param left point of the circle
* @param canvas to be drawn on
*
* @param center
* point of the circle
* @param left
* point of the circle
* @param canvas
* to be drawn on
* @return modified canvas
* @author ricky barrette
*/
@@ -230,8 +243,7 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
canvas.drawCircle(center.x, center.y, circleRadius, paint);
/*
* for testing
* draw a dot over the left geopoint
* for testing draw a dot over the left geopoint
*/
if (Debug.DEBUG) {
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
* @param point to draw user arrow on
* @param bearing of the device
* @param canvas to draw on
* draws user arrow that points north based on bearing onto the supplied
* canvas
*
* @param point
* to draw user arrow on
* @param bearing
* of the device
* @param canvas
* to draw on
* @return modified canvas
* @author ricky barrette
*/
@@ -254,25 +271,14 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
final Bitmap user = BitmapFactory.decodeResource(mContext.getResources(), mUserArrow);
final Matrix matrix = new Matrix();
matrix.postRotate(bearing);
final Bitmap rotatedBmp = Bitmap.createBitmap(
user,
0, 0,
user.getWidth(),
user.getHeight(),
matrix,
true
);
canvas.drawBitmap(
rotatedBmp,
point.x - rotatedBmp.getWidth() / 2,
point.y - rotatedBmp.getHeight() / 2,
null
);
final Bitmap rotatedBmp = Bitmap.createBitmap(user, 0, 0, user.getWidth(), user.getHeight(), matrix, true);
canvas.drawBitmap(rotatedBmp, point.x - rotatedBmp.getWidth() / 2, point.y - rotatedBmp.getHeight() / 2, null);
return canvas;
}
/**
* Enables the compass
*
* @author ricky barrette
*/
public void enableCompass() {
@@ -284,6 +290,7 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
/**
* Attempts to enable MyLocation, registering for updates from provider
*
* @author ricky barrette
*/
public void enableMyLocation() {
@@ -305,6 +312,7 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
/**
* Allows the map to follow the user
*
* @param followUser
* @author ricky barrette
*/
@@ -324,6 +332,7 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
/**
* returns the users current bearing
*
* @return
* @author ricky barrette
*/
@@ -333,6 +342,7 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
/**
* returns the users current location
*
* @return
* @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.
* (non-Javadoc)
* @see com.TwentyCodes.android.SkyHook.GeoPointLocationListener.location.LocationListener#onLocationChanged(com.google.android.maps.GeoPoint, float)
* called when the SkyHook location changes, this mthod is resposiable for
* updating the overlay location and accuracy circle. (non-Javadoc)
*
* @see com.TwentyCodes.android.SkyHook.GeoPointLocationListener.location.LocationListener#onLocationChanged(com.google.android.maps.GeoPoint,
* float)
* @param point
* @param accuracy
* @author ricky barrette
@@ -363,8 +375,8 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
mCompass.setLocation(point);
/*
* if this is the first fix
* set map center the users location, and zoom to the max zoom level
* if this is the first fix set map center the users location, and zoom
* to the max zoom level
*/
if (point != null && isFistFix) {
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
*/
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
*/
public abstract void onMyLocationEnabled();
/**
* pans the map view if the user is off screen.
*
* @author ricky barrette
*/
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;
/**
* if the user is one the map, keep them their
* else don't pan to user unless they pan pack to them
* if the user is one the map, keep them their else don't pan to user
* unless they pan pack to them
*/
if (!(distance > whichIsGreater))
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
*
* @param listener
* @author Ricky Barrette
*/
@@ -431,6 +449,7 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
/**
* Set the compass drawables and location
*
* @param needleResId
* @param backgroundResId
* @param x
@@ -443,6 +462,7 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
/**
* Sets the CompassListener
*
* @param listener
* @author ricky barrette
*/
@@ -452,6 +472,7 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
/**
* Sets the destination for the compass
*
* @author ricky barrette
*/
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
*/
public void unRegisterListener() {

View File

@@ -24,7 +24,9 @@ import com.google.android.maps.MapView;
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
*/
public class CompasOverlay extends Overlay implements CompassListener {
@@ -43,6 +45,7 @@ public class CompasOverlay extends Overlay implements CompassListener {
/**
* Creates a new CompasOverlay
*
* @author ricky barrette
*/
public CompasOverlay(final Context context) {
@@ -54,6 +57,7 @@ public class CompasOverlay extends Overlay implements CompassListener {
/**
* Creates a new CompasOverlay
*
* @param context
* @param destination
* @author ricky barrette
@@ -65,12 +69,15 @@ public class CompasOverlay extends Overlay implements CompassListener {
/**
* Creates a new CompasOverlay
*
* @param context
* @param destination
* @param needleResId
* @param backgroundResId
* @param x dip
* @param y dip
* @param x
* dip
* @param y
* dip
* @author ricky barrette
*/
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
*
* @param context
* @param needleResId
* @param backgroundResId
@@ -96,6 +104,7 @@ public class CompasOverlay extends Overlay implements CompassListener {
/**
* Converts dip to px
*
* @param dip
* @return px
* @author ricky barrette
@@ -107,6 +116,7 @@ public class CompasOverlay extends Overlay implements CompassListener {
/**
* Disables the compass overlay
*
* @author ricky barrette
*/
public void disable() {
@@ -117,43 +127,30 @@ public class CompasOverlay extends Overlay implements CompassListener {
/**
* (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
*/
@Override
public void draw(final Canvas canvas, final MapView mapView, final boolean shadow) {
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();
point.set(mX, mY);
// draw compass background
final Bitmap compass = BitmapFactory.decodeResource(mContext.getResources(), mBackgroundResId);
canvas.drawBitmap(compass,
point.x - compass.getWidth() / 2,
point.y - compass.getHeight() / 2,
null
);
canvas.drawBitmap(compass, point.x - compass.getWidth() / 2, point.y - compass.getHeight() / 2, null);
// draw the compass needle
final Bitmap arrowBitmap = BitmapFactory.decodeResource(mContext.getResources(), mNeedleResId);
final Matrix matrix = new Matrix();
matrix.postRotate(GeoUtils.calculateBearing(mLocation, mDestination, mBearing));
final Bitmap rotatedBmp = Bitmap.createBitmap(
arrowBitmap,
0, 0,
arrowBitmap.getWidth(),
arrowBitmap.getHeight(),
matrix,
true
);
canvas.drawBitmap(
rotatedBmp,
point.x - rotatedBmp.getWidth() / 2,
point.y - rotatedBmp.getHeight() / 2,
null
);
final Bitmap rotatedBmp = Bitmap.createBitmap(arrowBitmap, 0, 0, arrowBitmap.getWidth(), arrowBitmap.getHeight(), matrix, true);
canvas.drawBitmap(rotatedBmp, point.x - rotatedBmp.getWidth() / 2, point.y - rotatedBmp.getHeight() / 2, null);
mapView.invalidate();
}
super.draw(canvas, mapView, shadow);
@@ -161,6 +158,7 @@ public class CompasOverlay extends Overlay implements CompassListener {
/**
* Enables the compass overlay
*
* @author ricky barrette
*/
public void enable() {
@@ -172,6 +170,7 @@ public class CompasOverlay extends Overlay implements CompassListener {
/**
* Enables the compass overlay
*
* @param listener
* @author ricky barrette
*/
@@ -199,6 +198,7 @@ public class CompasOverlay extends Overlay implements CompassListener {
/**
* Called from the compass Sensor to update the current bearing
* (non-Javadoc)
*
* @see com.TwentyCodes.android.location.CompassListener#onCompassUpdate(float)
* @author ricky barrette
*/
@@ -224,8 +224,10 @@ public class CompasOverlay extends Overlay implements CompassListener {
/**
* @param needleResId
* @param backgroundResId
* @param x dip
* @param y dip
* @param x
* dip
* @param y
* dip
* @author ricky barrette
*/
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;
/**
* 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
*/
public class DirectionsOverlay {
@@ -51,15 +53,19 @@ public class DirectionsOverlay {
/**
* 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
* @throws IOException
* @throws ClientProtocolException
* @throws IllegalStateException
* @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;
mListener = listener;
final String json = downloadJSON(generateUrl(origin, destination));
@@ -68,6 +74,7 @@ public class DirectionsOverlay {
/**
* Creates a new DirectionsOverlay from the provided String JSON
*
* @param json
* @throws JSONException
* @author ricky barrette
@@ -80,9 +87,11 @@ public class DirectionsOverlay {
/**
* Deocodes googles polyline
*
* @param encoded
* @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
* @throws JSONException
*/
@@ -124,7 +133,6 @@ public class DirectionsOverlay {
Log.d(TAG, "last = " + last.toString());
}
if (last != null)
mPath.add(new PathOverlay(last, p, Color.RED));
// else
@@ -137,6 +145,7 @@ public class DirectionsOverlay {
/**
* Downloads Google Directions JSON from the Internet
*
* @param url
* @return
* @throws IllegalStateException
@@ -157,10 +166,11 @@ public class DirectionsOverlay {
return response.toString();
}
/**
* Creates a new DirectionsOverlay from the json provided
* @param json of Google Directions API
*
* @param json
* of Google Directions API
* @author ricky barrette
* @return
* @throws JSONException
@@ -185,8 +195,12 @@ public class DirectionsOverlay {
final JSONObject leg = route.getJSONArray("legs").getJSONObject(0);
getDistance(leg);
getDuration(leg);
// mMapView.getOverlays().add(new PathOverlay(getGeoPoint(leg.getJSONObject("start_location")), 12, Color.GREEN));
// mMapView.getOverlays().add(new PathOverlay(getGeoPoint(leg.getJSONObject("end_location")), 12, Color.RED));
// mMapView.getOverlays().add(new
// 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("end_address");
@@ -215,7 +229,9 @@ public class DirectionsOverlay {
}
// 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);
@@ -247,15 +263,9 @@ public class DirectionsOverlay {
* @author ricky barrette
*/
private String generateUrl(final GeoPoint origin, final GeoPoint destination) {
return "http://maps.googleapis.com/maps/api/directions/json?&origin="+
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";
return "http://maps.googleapis.com/maps/api/directions/json?&origin=" + 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";
}
/**
@@ -312,6 +322,7 @@ public class DirectionsOverlay {
/**
* Converts a JSON location object into a GeoPoint
*
* @param point
* @return Geopoint parsed from the provided JSON Object
* @throws JSONException
@@ -347,9 +358,11 @@ public class DirectionsOverlay {
/**
* Removes the directions overlay from the map view
*
* @author ricky barrette
*/
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
*
* @author ricky barrette
*/
public final class PathOverlay extends Overlay {
@@ -32,6 +33,7 @@ public final class PathOverlay extends Overlay {
/**
* Creates a new PathOverlay in path mode
*
* @author ricky barrette
*/
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.
*
* @param point
* @param radius
* @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 shadow
* @param when

View File

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

View File

@@ -11,7 +11,9 @@ import com.TwentyCodes.android.SkyHook.SkyHook;
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
*/
public class SkyHookUserOverlay extends BaseUserOverlay {
@@ -25,6 +27,7 @@ public class SkyHookUserOverlay extends BaseUserOverlay{
/**
* Construct a new SkyHookUserOverlay
*
* @param mapView
* @param context
* @param followUser
@@ -41,8 +44,8 @@ public class SkyHookUserOverlay extends BaseUserOverlay{
}
/**
* Called when the location provider needs to be disabled
* (non-Javadoc)
* Called when the location provider needs to be disabled (non-Javadoc)
*
* @see com.TwentyCodes.android.overlays.BaseUserOverlay#onMyLocationDisabled()
*/
@Override
@@ -51,8 +54,8 @@ public class SkyHookUserOverlay extends BaseUserOverlay{
}
/**
* Called when the location provider needs to be enabled
* (non-Javadoc)
* Called when the location provider needs to be enabled (non-Javadoc)
*
* @see com.TwentyCodes.android.overlays.BaseUserOverlay#onMyLocationEnabled()
*/
@Override

View File

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