diff --git a/LocationLib/bin/locationlib.jar b/LocationLib/bin/locationlib.jar index 434d0eb..0c931a4 100644 Binary files a/LocationLib/bin/locationlib.jar and b/LocationLib/bin/locationlib.jar differ diff --git a/LocationLib/res/layout/map_fragment.xml b/LocationLib/res/layout/base_map_fragment.xml similarity index 100% rename from LocationLib/res/layout/map_fragment.xml rename to LocationLib/res/layout/base_map_fragment.xml diff --git a/LocationLib/src/com/TwentyCodes/android/SkyHook/SkyHook.java b/LocationLib/src/com/TwentyCodes/android/SkyHook/SkyHook.java index b620cab..79966fe 100644 --- a/LocationLib/src/com/TwentyCodes/android/SkyHook/SkyHook.java +++ b/LocationLib/src/com/TwentyCodes/android/SkyHook/SkyHook.java @@ -37,12 +37,12 @@ public class SkyHook implements GeoPointLocationListener{ private GeoPointLocationListener mListener; private long mPeriod = 0l; //period is in milliseconds for periodic updates private int mIterations = 0; - private XPS mXps; + private final XPS mXps; private WPSAuthentication mWPSAuthentication; private Handler mHandler; private final XPScallback mXPScallback = new XPScallback(); private boolean isPeriodicEnabled; - private Context mContext; + private final Context mContext; private boolean hasLocation; protected AndroidGPS mSkyHookFallback = null; protected long mFallBackDelay = 5000l; @@ -248,7 +248,7 @@ public class SkyHook implements GeoPointLocationListener{ if (isUnauthorized){ isPeriodicEnabled = false; mXps.abort(); - mXps = null; +// mXps = null; } isUnauthorized = true; } diff --git a/LocationLib/src/com/TwentyCodes/android/SkyHook/SkyHookRegistration.java b/LocationLib/src/com/TwentyCodes/android/SkyHook/SkyHookRegistration.java index c3ca6fc..8a5316a 100644 --- a/LocationLib/src/com/TwentyCodes/android/SkyHook/SkyHookRegistration.java +++ b/LocationLib/src/com/TwentyCodes/android/SkyHook/SkyHookRegistration.java @@ -20,8 +20,8 @@ import com.skyhookwireless.wps.XPS; */ public class SkyHookRegistration{ - private XPS mXps; - private Context mContext; + private final XPS mXps; + private final Context mContext; public SkyHookRegistration(Context context){ mContext = context; @@ -35,9 +35,9 @@ public class SkyHookRegistration{ * @param listener for call back methods * @author ricky barrette */ - public void registerNewUser(RegistrationCallback listener){ + public void registerNewUser(final RegistrationCallback listener){ if(mXps != null){ - TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); + final TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); if(tm == null) Log.v(SkyHook.TAG, "TelephonyManager is null"); String newUser = tm.getLine1Number(); @@ -58,7 +58,7 @@ public class SkyHookRegistration{ * @return * @author ricky barrette */ - public static String getUserName(Context context){ + public static String getUserName(final Context context){ switch(Debug.DEFAULT_REGISTRATION_BEHAVIOR){ case NORMAL: diff --git a/LocationLib/src/com/TwentyCodes/android/fragments/MapFragmentBase.java b/LocationLib/src/com/TwentyCodes/android/fragments/BaseMapFragment.java similarity index 94% rename from LocationLib/src/com/TwentyCodes/android/fragments/MapFragmentBase.java rename to LocationLib/src/com/TwentyCodes/android/fragments/BaseMapFragment.java index 015971e..189cd7b 100644 --- a/LocationLib/src/com/TwentyCodes/android/fragments/MapFragmentBase.java +++ b/LocationLib/src/com/TwentyCodes/android/fragments/BaseMapFragment.java @@ -23,7 +23,7 @@ import com.google.android.maps.Overlay; * * @author ricky barrette */ -public abstract class MapFragmentBase extends Fragment { +public abstract class BaseMapFragment extends Fragment { private MapView mMapView; private boolean isGPSDialogEnabled; @@ -33,7 +33,7 @@ public abstract class MapFragmentBase extends Fragment { * Creates a new MapFragment * @author ricky barrette */ - public MapFragmentBase() { + public BaseMapFragment() { super(); } @@ -64,7 +64,7 @@ public abstract class MapFragmentBase extends Fragment { */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.map_fragment, container, false); + View view = inflater.inflate(R.layout.base_map_fragment, container, false); mMapView = (MapView) view.findViewById(R.id.mapview); mMapView.setClickable(true); diff --git a/LocationLib/src/com/TwentyCodes/android/fragments/DirectionsAdapter.java b/LocationLib/src/com/TwentyCodes/android/fragments/DirectionsAdapter.java index d9464ef..572ef61 100644 --- a/LocationLib/src/com/TwentyCodes/android/fragments/DirectionsAdapter.java +++ b/LocationLib/src/com/TwentyCodes/android/fragments/DirectionsAdapter.java @@ -22,8 +22,8 @@ import com.TwentyCodes.android.overlays.DirectionsOverlay; */ public class DirectionsAdapter extends BaseAdapter { - private LayoutInflater mInflater; - private DirectionsOverlay mDirections; + private final LayoutInflater mInflater; + private final DirectionsOverlay mDirections; /** @@ -80,8 +80,8 @@ public class DirectionsAdapter extends BaseAdapter { * @author ricky barrette */ @Override - public View getView(int position, View convertView, ViewGroup parent) { - ViewHolder holder; + public View getView(final int position, View convertView, final ViewGroup parent) { + final ViewHolder holder; if (convertView == null) { convertView = mInflater.inflate(R.layout.list_row, null); holder = new ViewHolder(); diff --git a/LocationLib/src/com/TwentyCodes/android/fragments/SkyHoookUserOverlayMapFragment.java b/LocationLib/src/com/TwentyCodes/android/fragments/SkyHoookUserOverlayMapFragment.java index 7745960..93233ff 100644 --- a/LocationLib/src/com/TwentyCodes/android/fragments/SkyHoookUserOverlayMapFragment.java +++ b/LocationLib/src/com/TwentyCodes/android/fragments/SkyHoookUserOverlayMapFragment.java @@ -18,7 +18,7 @@ import com.google.android.maps.GeoPoint; * TODO acquiring gps dialog * @author ricky barrette */ -public class SkyHoookUserOverlayMapFragment extends MapFragmentBase implements GeoPointLocationListener, CompassListener{ +public class SkyHoookUserOverlayMapFragment extends BaseMapFragment implements GeoPointLocationListener, CompassListener{ private SkyHookUserOverlay mUserOverlay; private GeoPointLocationListener mGeoPointLocationListener; @@ -86,7 +86,7 @@ public class SkyHoookUserOverlayMapFragment extends MapFragmentBase implements G /** * (non-Javadoc) - * @see com.TwentyCodes.android.fragments.MapFragmentBase#onMapViewCreate(com.TwentyCodes.android.location.MapView) + * @see com.TwentyCodes.android.fragments.BaseMapFragment#onMapViewCreate(com.TwentyCodes.android.location.MapView) */ @Override public void onMapViewCreate(MapView map) { @@ -101,7 +101,7 @@ public class SkyHoookUserOverlayMapFragment extends MapFragmentBase implements G /** * (non-Javadoc) - * @see com.TwentyCodes.android.fragments.MapFragmentBase#onPause() + * @see com.TwentyCodes.android.fragments.BaseMapFragment#onPause() */ @Override public void onPause() { @@ -112,7 +112,7 @@ public class SkyHoookUserOverlayMapFragment extends MapFragmentBase implements G /** * (non-Javadoc) - * @see com.TwentyCodes.android.fragments.MapFragmentBase#onResume() + * @see com.TwentyCodes.android.fragments.BaseMapFragment#onResume() */ @Override public void onResume() { diff --git a/LocationLib/src/com/TwentyCodes/android/fragments/UserOverlayMapFragment.java b/LocationLib/src/com/TwentyCodes/android/fragments/UserOverlayMapFragment.java index 850043d..5984676 100644 --- a/LocationLib/src/com/TwentyCodes/android/fragments/UserOverlayMapFragment.java +++ b/LocationLib/src/com/TwentyCodes/android/fragments/UserOverlayMapFragment.java @@ -18,7 +18,7 @@ import com.google.android.maps.GeoPoint; * TODO acquiring gps dialog * @author ricky barrette */ -public class UserOverlayMapFragment extends MapFragmentBase implements GeoPointLocationListener, CompassListener{ +public class UserOverlayMapFragment extends BaseMapFragment implements GeoPointLocationListener, CompassListener{ private UserOverlay mUserOverlay; private GeoPointLocationListener mGeoPointLocationListener; @@ -86,7 +86,7 @@ public class UserOverlayMapFragment extends MapFragmentBase implements GeoPointL /** * (non-Javadoc) - * @see com.TwentyCodes.android.fragments.MapFragmentBase#onMapViewCreate(com.TwentyCodes.android.location.MapView) + * @see com.TwentyCodes.android.fragments.BaseMapFragment#onMapViewCreate(com.TwentyCodes.android.location.MapView) */ @Override public void onMapViewCreate(MapView map) { @@ -101,7 +101,7 @@ public class UserOverlayMapFragment extends MapFragmentBase implements GeoPointL /** * (non-Javadoc) - * @see com.TwentyCodes.android.fragments.MapFragmentBase#onPause() + * @see com.TwentyCodes.android.fragments.BaseMapFragment#onPause() */ @Override public void onPause() { @@ -112,7 +112,7 @@ public class UserOverlayMapFragment extends MapFragmentBase implements GeoPointL /** * (non-Javadoc) - * @see com.TwentyCodes.android.fragments.MapFragmentBase#onResume() + * @see com.TwentyCodes.android.fragments.BaseMapFragment#onResume() */ @Override public void onResume() { diff --git a/LocationLib/src/com/TwentyCodes/android/location/AndroidGPS.java b/LocationLib/src/com/TwentyCodes/android/location/AndroidGPS.java index fb5effb..6568c3f 100644 --- a/LocationLib/src/com/TwentyCodes/android/location/AndroidGPS.java +++ b/LocationLib/src/com/TwentyCodes/android/location/AndroidGPS.java @@ -24,7 +24,7 @@ import com.google.android.maps.GeoPoint; public class AndroidGPS implements LocationListener { private static final String TAG = "AndroidGPS"; - private LocationManager mLocationManager; + private final LocationManager mLocationManager; private GeoPointLocationListener mListener; private LocationListener mLocationListener; @@ -131,8 +131,6 @@ public class AndroidGPS implements LocationListener { * @author ricky barrette */ private void requestUpdates() { - mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this); - mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this); try { mLocationManager.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER, 0, 0, this); } catch (IllegalArgumentException e) { @@ -141,6 +139,8 @@ public class AndroidGPS implements LocationListener { * to function we can ignore it. */ } + mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this); + mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this); } } \ No newline at end of file diff --git a/LocationLib/src/com/TwentyCodes/android/location/CompassSensor.java b/LocationLib/src/com/TwentyCodes/android/location/CompassSensor.java index 8edb8a0..68421cc 100644 --- a/LocationLib/src/com/TwentyCodes/android/location/CompassSensor.java +++ b/LocationLib/src/com/TwentyCodes/android/location/CompassSensor.java @@ -16,6 +16,7 @@ import android.hardware.SensorManager; import android.location.Location; import android.os.Handler; import android.os.Message; +import android.util.Log; import com.TwentyCodes.android.debug.Debug; @@ -31,6 +32,7 @@ public class CompassSensor{ private final Handler mHandler; private Context mContext; private float mDelination = 0; + public static final String TAG = "CompassSensor"; private final SensorEventListener mCallBack = new SensorEventListener() { @@ -45,8 +47,26 @@ public class CompassSensor{ double mRoll = 0; private float mInclination; - public void onSensorChanged(SensorEvent sensorEvent) { - // If the sensor data is unreliable return + public void onSensorChanged(final SensorEvent sensorEvent) { + if(Debug.DEBUG){ + switch (sensorEvent.accuracy){ + case SensorManager.SENSOR_STATUS_UNRELIABLE: + Log.v(TAG , "UNRELIABLE"); + break; + case SensorManager.SENSOR_STATUS_ACCURACY_LOW: + Log.v(TAG , "LOW"); + break; + case SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM: + Log.v(TAG , "MEDIUM"); + break; + case SensorManager.SENSOR_STATUS_ACCURACY_HIGH: + Log.v(TAG , "HIGH"); + break; + + } + } + + // If the sensor data is unreliable return if (sensorEvent.accuracy == SensorManager.SENSOR_STATUS_UNRELIABLE) return; @@ -70,6 +90,10 @@ public class CompassSensor{ /* * TODO remap cords due to Display.getRotation() */ +// Display display = ((WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); +// switch (display.getOrientation()){ +// } + // SensorManager.remapCoordinateSystem(mR, SensorManager.AXIS_MINUS_Y, SensorManager.AXIS_X, mR); SensorManager.getOrientation(mR, mOrientVals); mInclination = SensorManager.getInclination(mI); @@ -163,10 +187,9 @@ public class CompassSensor{ * @param location last known (lat,lon,altitude), null will reset * @author ricky barrette */ - public void setDeclination(Location location){ + public void setDeclination(final Location location){ if (location != null) { - GeomagneticField geomagneticField; - geomagneticField = new GeomagneticField(new Double(location.getLatitude()).floatValue(), + final GeomagneticField geomagneticField = new GeomagneticField(new Double(location.getLatitude()).floatValue(), new Double(location.getLongitude()).floatValue(), new Double(location.getAltitude()).floatValue(), System.currentTimeMillis()); diff --git a/LocationLib/src/com/TwentyCodes/android/location/GeoUtils.java b/LocationLib/src/com/TwentyCodes/android/location/GeoUtils.java index 3388d74..6b15590 100644 --- a/LocationLib/src/com/TwentyCodes/android/location/GeoUtils.java +++ b/LocationLib/src/com/TwentyCodes/android/location/GeoUtils.java @@ -41,14 +41,14 @@ 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 make a compass point toward the destination rather than North. + * 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 */ - public static float calculateBearing(GeoPoint user, GeoPoint dest, float bearing) { + public static float calculateBearing(final GeoPoint user, final GeoPoint dest, float bearing) { if( (user == null) || (dest == null) ) return bearing; @@ -72,7 +72,7 @@ public class GeoUtils { * @return the bearing of lat2/lon2 in relationship from lat1/lon1 in degrees East of true north * @author Google Inc. */ - public static double bearing(double lat1, double lon1, double lat2, double lon2) { + public static double bearing(final double lat1, final double lon1, final double lat2, final double lon2) { double lat1Rad = Math.toRadians(lat1); double lat2Rad = Math.toRadians(lat2); double deltaLonRad = Math.toRadians(lon2 - lon1); @@ -88,7 +88,7 @@ public class GeoUtils { * @return the bearing of p2 in relationship from p1 in degrees East * @author Google Inc. */ - public static Double bearing(GeoPoint p1, GeoPoint p2) { + public static Double bearing(final GeoPoint p1, final GeoPoint p2) { double lat1 = p1.getLatitudeE6() / MILLION; double lon1 = p1.getLongitudeE6() / MILLION; double lat2 = p2.getLatitudeE6() / MILLION; @@ -105,7 +105,7 @@ public class GeoUtils { * @return geopoint that is x meters away from the geopoint supplied * @author ricky barrette */ - public static GeoPoint distanceFrom(GeoPoint point, double distance){ + public static GeoPoint distanceFrom(final GeoPoint point, double distance){ //convert meters into kilometers distance = distance / 1000; @@ -145,7 +145,7 @@ public class GeoUtils { * @return the distance between to lat1/lon1 and lat2/lon2 * @author Google Inc. */ - public static double distanceKm(double lat1, double lon1, double lat2, double lon2) { + public static double distanceKm(final double lat1, final double lon1, final double lat2, final double lon2) { double lat1Rad = Math.toRadians(lat1); double lat2Rad = Math.toRadians(lat2); double deltaLonRad = Math.toRadians(lon2 - lon1); @@ -159,7 +159,7 @@ public class GeoUtils { * @return string distance * @author ricky barrette */ - public static String distanceToString(double distance, boolean returnMetric) { + public static String distanceToString(double distance, final boolean returnMetric) { DecimalFormat threeDForm = new DecimalFormat("#.###"); DecimalFormat twoDForm = new DecimalFormat("#.##"); @@ -190,7 +190,7 @@ public class GeoUtils { * @return true if the circles intersect * @author ricky barrette */ - public static boolean isIntersecting(GeoPoint userPoint, float accuracyRadius, GeoPoint locationPoint, float locationRadius, 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; @@ -203,7 +203,7 @@ public class GeoUtils { * @return the distance between to p1 and p2 * @author Google Inc. */ - public static double distanceKm(GeoPoint p1, GeoPoint p2) { + public static double distanceKm(final GeoPoint p1, final GeoPoint p2) { //if we are handed a null, return -1 so we don't break if(p1 == null || p2 == null) return -1; @@ -221,7 +221,7 @@ public class GeoUtils { * @return true is the point is off the map * @author ricky barrette */ - public static boolean isPointOffMap(MapView map , GeoPoint point){ + public static boolean isPointOffMap(final MapView map , final GeoPoint point){ if(map == null) return false; if (point == null) @@ -243,8 +243,8 @@ public class GeoUtils { * @return a MidPoint object * @author ricky barrette */ - public static MidPoint midPoint(GeoPoint p1, GeoPoint p2) { - int minLatitude = (int)(+81 * 1E6); + public static MidPoint midPoint(final GeoPoint p1, final GeoPoint p2) { + int minLatitude = (int)(+81 * 1E6); int maxLatitude = (int)(-81 * 1E6); int minLongitude = (int)(+181 * 1E6); int maxLongitude = (int)(-181 * 1E6); @@ -277,7 +277,7 @@ public class GeoUtils { * @return bearing * @author Google Inc. */ - public static double radToBearing(double rad) { + public static double radToBearing(final double rad) { return (Math.toDegrees(rad) + 360) % 360; } } \ No newline at end of file diff --git a/LocationLib/src/com/TwentyCodes/android/location/LocationReceiver.java b/LocationLib/src/com/TwentyCodes/android/location/LocationReceiver.java index cfd365e..79178c3 100644 --- a/LocationLib/src/com/TwentyCodes/android/location/LocationReceiver.java +++ b/LocationLib/src/com/TwentyCodes/android/location/LocationReceiver.java @@ -28,7 +28,7 @@ public abstract class LocationReceiver extends BroadcastReceiver { * @author ricky barrette */ @Override - public void onReceive(Context context, Intent intent) { + public void onReceive(final Context context, final Intent intent) { mContext = context; if(intent.getParcelableExtra(INTENT_EXTRA_LOCATION_PARCEL) != null){ Location location = intent.getParcelableExtra(INTENT_EXTRA_LOCATION_PARCEL); diff --git a/LocationLib/src/com/TwentyCodes/android/location/MidPoint.java b/LocationLib/src/com/TwentyCodes/android/location/MidPoint.java index 96408f0..1325b4e 100644 --- a/LocationLib/src/com/TwentyCodes/android/location/MidPoint.java +++ b/LocationLib/src/com/TwentyCodes/android/location/MidPoint.java @@ -11,7 +11,7 @@ import com.google.android.maps.GeoPoint; * This MidPoint object will hold the information form the calculations performed by GeoUtils.midPoint(). * @author ricky barrette */ -public final class MidPoint { +public class MidPoint { private final int mMinLatitude; private final int mMaxLatitude; diff --git a/LocationLib/src/com/TwentyCodes/android/location/ReverseGeocoder.java b/LocationLib/src/com/TwentyCodes/android/location/ReverseGeocoder.java index 2a5dbce..5b4e612 100644 --- a/LocationLib/src/com/TwentyCodes/android/location/ReverseGeocoder.java +++ b/LocationLib/src/com/TwentyCodes/android/location/ReverseGeocoder.java @@ -43,7 +43,7 @@ public class ReverseGeocoder { * @throws IOException * @throws JSONException */ - public static JSONArray getFromLocation(Location location) throws IOException, JSONException { + public static JSONArray getFromLocation(final Location location) throws IOException, JSONException { String urlStr = "http://maps.google.com/maps/geo?q=" + location.getLatitude() + "," + location.getLongitude() + "&output=json&sensor=false"; StringBuffer response = new StringBuffer(); HttpClient client = new DefaultHttpClient(); @@ -72,7 +72,7 @@ public class ReverseGeocoder { * @return string address, or lat, lon if search fails * @author ricky barrette */ - public static String getAddressFromLocation(Location location) { + public static String getAddressFromLocation(final Location location) { String urlStr = "http://maps.google.com/maps/geo?q=" + location.getLatitude() + "," + location.getLongitude() + "&output=json&sensor=false"; StringBuffer response = new StringBuffer(); HttpClient client = new DefaultHttpClient(); @@ -124,7 +124,7 @@ public class ReverseGeocoder { * @throws JSONException * @author ricky barrette */ - public static JSONArray addressSearch(String address) throws IOException, JSONException { + public static JSONArray addressSearch(final String address) throws IOException, JSONException { String urlStr = "http://maps.google.com/maps/geo?q=" + address + "&output=json&sensor=false"; urlStr = urlStr.replace(' ', '+'); StringBuffer response = new StringBuffer(); diff --git a/LocationLib/src/com/TwentyCodes/android/overlays/UserOverlayBase.java b/LocationLib/src/com/TwentyCodes/android/overlays/BaseUserOverlay.java similarity index 95% rename from LocationLib/src/com/TwentyCodes/android/overlays/UserOverlayBase.java rename to LocationLib/src/com/TwentyCodes/android/overlays/BaseUserOverlay.java index e97f91f..4f4fcd3 100644 --- a/LocationLib/src/com/TwentyCodes/android/overlays/UserOverlayBase.java +++ b/LocationLib/src/com/TwentyCodes/android/overlays/BaseUserOverlay.java @@ -15,6 +15,7 @@ import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.Paint.Style; import android.graphics.Point; +import android.graphics.RectF; import android.util.Log; import com.TwentyCodes.android.debug.Debug; @@ -31,7 +32,7 @@ import com.google.android.maps.Projection; * This class will be used to build user overlays * @author ricky barrette */ -public abstract class UserOverlayBase extends Overlay implements GeoPointLocationListener, CompassListener { +public abstract class BaseUserOverlay extends Overlay implements GeoPointLocationListener, CompassListener { /** * This thread is responsible for animating the user icon @@ -126,7 +127,7 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio * @param context * @author ricky barrette */ - public UserOverlayBase(MapView mapView, Context context) { + public BaseUserOverlay(MapView mapView, Context context) { super(); mContext = context; mMapView = mapView; @@ -141,7 +142,7 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio * @param followUser * @author ricky barrette */ - public UserOverlayBase(MapView mapView, Context context, boolean followUser) { + public BaseUserOverlay(MapView mapView, Context context, boolean followUser) { this(mapView, context); isFollowingUser = followUser; } @@ -192,7 +193,8 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio /* * the following log is used to demonstrate if the leftGeo point is the correct */ -// Log.d(TAG, (GeoUtils.distanceKm(mPoint, leftGeo) * 1000)+"m"); + if(Debug.DEBUG) + Log.d(TAG, (GeoUtils.distanceKm(mPoint, leftGeo) * 1000)+"m"); } super.draw(canvas, mapView, shadow); } @@ -234,9 +236,11 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio * for testing * draw a dot over the left geopoint */ -// paint.setColor(Color.RED); -// RectF oval = new RectF(left.x - 1, left.y - 1, left.x + 1, left.y + 1); -// canvas.drawOval(oval, paint); + if(Debug.DEBUG){ + paint.setColor(Color.RED); + RectF oval = new RectF(left.x - 1, left.y - 1, left.x + 1, left.y + 1); + canvas.drawOval(oval, paint); + } return canvas; } @@ -286,7 +290,8 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio * @author ricky barrette */ public void enableMyLocation(){ - Log.d(TAG,"enableMyLocation()"); + if(Debug.DEBUG) + Log.d(TAG,"enableMyLocation()"); if (! isEnabled) { mAnimationThread = new AnimationThread(); @@ -307,7 +312,8 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio * @author ricky barrette */ public void followUser(boolean followUser){ - Log.d(TAG,"followUser()"); + if(Debug.DEBUG) + Log.d(TAG,"followUser()"); isFollowingUser = followUser; } @@ -339,8 +345,6 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio @Override public void onCompassUpdate(float bearing) { - if(Debug.DEBUG) - Log.v(TAG, "onCompassUpdate()"); if(mCompassListener != null) mCompassListener.onCompassUpdate(bearing); mBearing = bearing; @@ -467,7 +471,6 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio * @author Ricky Barrette */ public void unRegisterListener(){ - Log.d(TAG,"unRegisterListener()"); mListener = null; } } \ No newline at end of file diff --git a/LocationLib/src/com/TwentyCodes/android/overlays/CompasOverlay.java b/LocationLib/src/com/TwentyCodes/android/overlays/CompasOverlay.java index 81f1dfe..15ea9bc 100644 --- a/LocationLib/src/com/TwentyCodes/android/overlays/CompasOverlay.java +++ b/LocationLib/src/com/TwentyCodes/android/overlays/CompasOverlay.java @@ -30,11 +30,11 @@ import com.google.android.maps.Overlay; public class CompasOverlay extends Overlay implements CompassListener { private float mBearing; - private Context mContext; + private final Context mContext; private GeoPoint mDestination; private GeoPoint mLocation; private boolean isEnabled; - private CompassSensor mCompassSensor; + private final CompassSensor mCompassSensor; private int mNeedleResId = R.drawable.needle_sm; private int mBackgroundResId = R.drawable.compass_sm; private int mX; @@ -121,7 +121,7 @@ public class CompasOverlay extends Overlay implements CompassListener { * @author ricky barrette */ @Override - public void draw(Canvas canvas, MapView mapView, boolean shadow) { + 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 diff --git a/LocationLib/src/com/TwentyCodes/android/overlays/DirectionsOverlay.java b/LocationLib/src/com/TwentyCodes/android/overlays/DirectionsOverlay.java index ffc6b08..c715709 100644 --- a/LocationLib/src/com/TwentyCodes/android/overlays/DirectionsOverlay.java +++ b/LocationLib/src/com/TwentyCodes/android/overlays/DirectionsOverlay.java @@ -41,8 +41,8 @@ public class DirectionsOverlay { private static final String TAG = "DirectionsOverlay"; private ArrayList mPath; private ArrayList mDirections; - private MapView mMapView; - private OnDirectionsCompleteListener mListener; + private final MapView mMapView; + private final OnDirectionsCompleteListener mListener; private String mCopyRights; private ArrayList mPoints; private ArrayList mDistance; @@ -59,7 +59,7 @@ public class DirectionsOverlay { * @throws IllegalStateException * @throws JSONException */ - public DirectionsOverlay(MapView map, GeoPoint origin, GeoPoint destination, 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; String json = downloadJSON(generateUrl(origin, destination)); @@ -72,7 +72,7 @@ public class DirectionsOverlay { * @throws JSONException * @author ricky barrette */ - public DirectionsOverlay(MapView map, String json, OnDirectionsCompleteListener listener) throws JSONException{ + public DirectionsOverlay(final MapView map, final String json, final OnDirectionsCompleteListener listener) throws JSONException{ mListener = listener; mMapView = map; drawPath(json); @@ -86,7 +86,7 @@ public class DirectionsOverlay { * @author ricky barrette * @throws JSONException */ - private void decodePoly(JSONObject step) throws JSONException { + private void decodePoly(final JSONObject step) throws JSONException { if(Debug.DEBUG) Log.d(TAG, "decodePoly"); @@ -143,7 +143,7 @@ public class DirectionsOverlay { * @throws IOException * @author ricky barrette */ - private String downloadJSON(String url) throws IllegalStateException, ClientProtocolException, IOException { + private String downloadJSON(final String url) throws IllegalStateException, ClientProtocolException, IOException { if(Debug.DEBUG) Log.d(TAG, url); if(url == null) @@ -164,7 +164,7 @@ public class DirectionsOverlay { * @return * @throws JSONException */ - public void drawPath(String json) throws JSONException{ + public void drawPath(final String json) throws JSONException{ if(Debug.DEBUG){ Log.d(TAG, "drawPath"); Log.d(TAG, json); @@ -245,7 +245,7 @@ public class DirectionsOverlay { * @return The Google API url for our directions * @author ricky barrette */ - private String generateUrl(GeoPoint origin, GeoPoint destination){ + 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)+ ","+ @@ -279,7 +279,7 @@ public class DirectionsOverlay { * @throws JSONException * @author ricky barrette */ - private String getDistance(JSONObject step) throws JSONException{ + private String getDistance(final JSONObject step) throws JSONException{ return step.getJSONObject("distance").getString("text"); } @@ -297,7 +297,7 @@ public class DirectionsOverlay { * @throws JSONException * @author ricky barrette */ - private String getDuration(JSONObject step) throws JSONException{ + private String getDuration(final JSONObject step) throws JSONException{ return step.getJSONObject("duration").getString("text"); } @@ -316,7 +316,7 @@ public class DirectionsOverlay { * @throws JSONException * @author ricky barrette */ - private GeoPoint getGeoPoint(JSONObject point) throws JSONException{ + private GeoPoint getGeoPoint(final JSONObject point) throws JSONException{ return new GeoPoint((int) (point.getDouble("lat")*1E6), (int) (point.getDouble("lng")*1E6)); } diff --git a/LocationLib/src/com/TwentyCodes/android/overlays/PathOverlay.java b/LocationLib/src/com/TwentyCodes/android/overlays/PathOverlay.java index f1b708c..5712fc8 100644 --- a/LocationLib/src/com/TwentyCodes/android/overlays/PathOverlay.java +++ b/LocationLib/src/com/TwentyCodes/android/overlays/PathOverlay.java @@ -34,7 +34,7 @@ public final class PathOverlay extends Overlay { * Creates a new PathOverlay in path mode * @author ricky barrette */ - public PathOverlay(GeoPoint start, GeoPoint end, int color) { + public PathOverlay(final GeoPoint start, final GeoPoint end, final int color) { mStart = start; mEnd = end; mColor = color; @@ -49,7 +49,7 @@ public final class PathOverlay extends Overlay { * @param color * @author ricky barrette */ - public PathOverlay(GeoPoint point, int radius, int color){ + public PathOverlay(final GeoPoint point, final int radius, final int color){ mMode = POINT; mRadius = radius; mStart = point; @@ -66,8 +66,8 @@ public final class PathOverlay extends Overlay { */ @Override public void draw(Canvas canvas, MapView mapView, boolean shadow) { - Projection projection = mapView.getProjection(); - Paint paint = new Paint(); + final Projection projection = mapView.getProjection(); + final Paint paint = new Paint(); paint.setColor(mColor); paint.setAntiAlias(true); Point point = new Point(); diff --git a/LocationLib/src/com/TwentyCodes/android/overlays/RadiusOverlay.java b/LocationLib/src/com/TwentyCodes/android/overlays/RadiusOverlay.java index 4ef0675..a12121d 100644 --- a/LocationLib/src/com/TwentyCodes/android/overlays/RadiusOverlay.java +++ b/LocationLib/src/com/TwentyCodes/android/overlays/RadiusOverlay.java @@ -62,12 +62,12 @@ public class RadiusOverlay extends Overlay{ * @param when */ @Override - public void draw(Canvas canvas, MapView mapView, boolean shadow){ + public void draw(final Canvas canvas, final MapView mapView, final boolean shadow){ if(mPoint != null){ - Paint paint = new Paint(); - Point center = new Point(); - Point left = new Point(); - Projection projection = mapView.getProjection(); + final Paint paint = new Paint(); + final Point center = new Point(); + final Point left = new Point(); + final Projection projection = mapView.getProjection(); /* * Calculate a geopoint that is "radius" meters away from geopoint point and diff --git a/LocationLib/src/com/TwentyCodes/android/overlays/SkyHookUserOverlay.java b/LocationLib/src/com/TwentyCodes/android/overlays/SkyHookUserOverlay.java index c678b31..360fcc0 100644 --- a/LocationLib/src/com/TwentyCodes/android/overlays/SkyHookUserOverlay.java +++ b/LocationLib/src/com/TwentyCodes/android/overlays/SkyHookUserOverlay.java @@ -14,9 +14,9 @@ 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 * @author ricky barrette */ -public class SkyHookUserOverlay extends UserOverlayBase{ +public class SkyHookUserOverlay extends BaseUserOverlay{ - private SkyHook mSkyHook; + private final SkyHook mSkyHook; public SkyHookUserOverlay(MapView mapView, Context context) { super(mapView, context); @@ -38,7 +38,7 @@ public class SkyHookUserOverlay extends UserOverlayBase{ /** * Called when the location provider needs to be disabled * (non-Javadoc) - * @see com.TwentyCodes.android.overlays.UserOverlayBase#onMyLocationDisabled() + * @see com.TwentyCodes.android.overlays.BaseUserOverlay#onMyLocationDisabled() */ @Override public void onMyLocationDisabled() { @@ -48,7 +48,7 @@ public class SkyHookUserOverlay extends UserOverlayBase{ /** * Called when the location provider needs to be enabled * (non-Javadoc) - * @see com.TwentyCodes.android.overlays.UserOverlayBase#onMyLocationEnabled() + * @see com.TwentyCodes.android.overlays.BaseUserOverlay#onMyLocationEnabled() */ @Override public void onMyLocationEnabled() { diff --git a/LocationLib/src/com/TwentyCodes/android/overlays/UserOverlay.java b/LocationLib/src/com/TwentyCodes/android/overlays/UserOverlay.java index 67e61ae..468ba7f 100644 --- a/LocationLib/src/com/TwentyCodes/android/overlays/UserOverlay.java +++ b/LocationLib/src/com/TwentyCodes/android/overlays/UserOverlay.java @@ -14,9 +14,9 @@ import com.google.android.maps.MapView; * This is the standard version of the UserOverlay. * @author ricky barrette */ -public class UserOverlay extends UserOverlayBase{ +public class UserOverlay extends BaseUserOverlay{ - private AndroidGPS mAndroidGPS; + private final AndroidGPS mAndroidGPS; public UserOverlay(MapView mapView, Context context) { super(mapView, context);