diff --git a/LocationLib/.classpath b/LocationLib/.classpath index d8cb310..ec62837 100644 --- a/LocationLib/.classpath +++ b/LocationLib/.classpath @@ -9,5 +9,6 @@ + diff --git a/LocationLib/AndroidManifest.xml b/LocationLib/AndroidManifest.xml index d9d8bc4..3fda38b 100644 --- a/LocationLib/AndroidManifest.xml +++ b/LocationLib/AndroidManifest.xml @@ -4,32 +4,6 @@ android:versionCode="11" android:versionName="0.1.1" > - - - - - - - - - - - - - - @@ -41,4 +15,24 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/LocationLib/bin/locationlib.jar b/LocationLib/bin/locationlib.jar index f12ceec..af2caed 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/map_fragment.xml index f6e66ed..0c9c29a 100644 --- a/LocationLib/res/layout/map_fragment.xml +++ b/LocationLib/res/layout/map_fragment.xml @@ -1,11 +1,28 @@ - - \ No newline at end of file + --> + + + + + + \ No newline at end of file diff --git a/LocationLib/src/com/TwentyCodes/android/SkyHook/SkyHook.java b/LocationLib/src/com/TwentyCodes/android/SkyHook/SkyHook.java index 45b7629..b620cab 100644 --- a/LocationLib/src/com/TwentyCodes/android/SkyHook/SkyHook.java +++ b/LocationLib/src/com/TwentyCodes/android/SkyHook/SkyHook.java @@ -289,4 +289,9 @@ public class SkyHook implements GeoPointLocationListener{ if(mListener != null) mListener.onLocationChanged(point, accuracy); } + + @Override + public void onFirstFix(boolean isFistFix) { + // unused + } } \ No newline at end of file diff --git a/LocationLib/src/com/TwentyCodes/android/SkyHook/SkyHookService.java b/LocationLib/src/com/TwentyCodes/android/SkyHook/SkyHookService.java index d1e45b0..c8397df 100644 --- a/LocationLib/src/com/TwentyCodes/android/SkyHook/SkyHookService.java +++ b/LocationLib/src/com/TwentyCodes/android/SkyHook/SkyHookService.java @@ -235,19 +235,25 @@ public class SkyHookService extends Service implements GeoPointLocationListener, @Override public void done() { - // TODO Auto-generated method stub + // unused } @Override public WPSContinuation handleError(WPSReturnCode arg0) { - // TODO Auto-generated method stub + // unused return null; } @Override public void handleSuccess() { - // TODO Auto-generated method stub + // unused + + } + + @Override + public void onFirstFix(boolean isFistFix) { + // unused } } \ No newline at end of file diff --git a/LocationLib/src/com/TwentyCodes/android/fragments/MapFragmentBase.java b/LocationLib/src/com/TwentyCodes/android/fragments/MapFragmentBase.java index 9939432..015971e 100644 --- a/LocationLib/src/com/TwentyCodes/android/fragments/MapFragmentBase.java +++ b/LocationLib/src/com/TwentyCodes/android/fragments/MapFragmentBase.java @@ -11,6 +11,7 @@ import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ProgressBar; import com.TwentyCodes.android.location.MapView; import com.TwentyCodes.android.location.R; @@ -25,6 +26,8 @@ import com.google.android.maps.Overlay; public abstract class MapFragmentBase extends Fragment { private MapView mMapView; + private boolean isGPSDialogEnabled; + private ProgressBar mProgress; /** * Creates a new MapFragment @@ -65,6 +68,8 @@ public abstract class MapFragmentBase extends Fragment { mMapView = (MapView) view.findViewById(R.id.mapview); mMapView.setClickable(true); + + mProgress = (ProgressBar) view.findViewById(R.id.mapProgressBar); onMapViewCreate(mMapView); @@ -98,4 +103,27 @@ public abstract class MapFragmentBase extends Fragment { mMapView.getController().setCenter(point); return true; } + + /** + * Disables the Acquiring GPS dialog + * @author ricky barrette + */ + public void disableGPSProgess(){ + isGPSDialogEnabled = false; + mProgress.setVisibility(View.GONE); + } + + /** + * Enables the Acquiring GPS dialog if the location has not been acquired + * + * @author ricky barrette + */ + public void enableGPSProgess(){ + isGPSDialogEnabled = true; + mProgress.setVisibility(View.VISIBLE); + } + + public boolean isGPSProgessShowing(){ + return isGPSDialogEnabled; + } } \ No newline at end of file diff --git a/LocationLib/src/com/TwentyCodes/android/fragments/SkyHoookUserOverlayMapFragment.java b/LocationLib/src/com/TwentyCodes/android/fragments/SkyHoookUserOverlayMapFragment.java index 91445ac..ec9b5a7 100644 --- a/LocationLib/src/com/TwentyCodes/android/fragments/SkyHoookUserOverlayMapFragment.java +++ b/LocationLib/src/com/TwentyCodes/android/fragments/SkyHoookUserOverlayMapFragment.java @@ -31,22 +31,6 @@ public class SkyHoookUserOverlayMapFragment extends MapFragmentBase implements G public SkyHoookUserOverlayMapFragment() { super(); } - - /** - * disables the GPS dialog - * @author ricky barrette - */ - public void disableGPSDialog(){ - mUserOverlay.disableGPSDialog(); - } - - /** - * enables the GPS dialog - * @author ricky barrette - */ - public void enableGPSDialog(){ - mUserOverlay.enableGPSDialog(); - } /** * Tells the useroverlay to pan the map to follow the user @@ -96,7 +80,6 @@ public class SkyHoookUserOverlayMapFragment extends MapFragmentBase implements G mUserOverlay.registerListener(this); mUserOverlay.setCompassListener(this); mUserOverlay.enableCompass(); - mUserOverlay.disableGPSDialog(); mUserOverlay.followUser(true); map.getOverlays().add(mUserOverlay); @@ -120,8 +103,10 @@ public class SkyHoookUserOverlayMapFragment extends MapFragmentBase implements G @Override public void onResume() { super.onResume(); - if(mUserOverlay != null) + if(mUserOverlay != null) { mUserOverlay.enableMyLocation(); + addOverlay(mUserOverlay); + } } /** @@ -169,4 +154,9 @@ public class SkyHoookUserOverlayMapFragment extends MapFragmentBase implements G mGeoPointLocationListener = listener; } -} + @Override + public void onFirstFix(boolean isFistFix) { + if(mGeoPointLocationListener != null) + mGeoPointLocationListener.onFirstFix(isFistFix); + } +} \ No newline at end of file diff --git a/LocationLib/src/com/TwentyCodes/android/fragments/UserOverlayMapFragment.java b/LocationLib/src/com/TwentyCodes/android/fragments/UserOverlayMapFragment.java index 0b1fd2c..04d464a 100644 --- a/LocationLib/src/com/TwentyCodes/android/fragments/UserOverlayMapFragment.java +++ b/LocationLib/src/com/TwentyCodes/android/fragments/UserOverlayMapFragment.java @@ -32,22 +32,6 @@ public class UserOverlayMapFragment extends MapFragmentBase implements GeoPointL super(); } - /** - * disables the GPS dialog - * @author ricky barrette - */ - public void disableGPSDialog(){ - mUserOverlay.disableGPSDialog(); - } - - /** - * enables the GPS dialog - * @author ricky barrette - */ - public void enableGPSDialog(){ - mUserOverlay.enableGPSDialog(); - } - /** * Tells the useroverlay to pan the map to follow the user * @param followUser @@ -96,7 +80,6 @@ public class UserOverlayMapFragment extends MapFragmentBase implements GeoPointL mUserOverlay.registerListener(this); mUserOverlay.setCompassListener(this); mUserOverlay.enableCompass(); - mUserOverlay.disableGPSDialog(); mUserOverlay.followUser(true); map.getOverlays().add(mUserOverlay); @@ -120,8 +103,10 @@ public class UserOverlayMapFragment extends MapFragmentBase implements GeoPointL @Override public void onResume() { super.onResume(); - if(mUserOverlay != null) + if(mUserOverlay != null) { mUserOverlay.enableMyLocation(); + addOverlay(mUserOverlay); + } } /** @@ -168,4 +153,10 @@ public class UserOverlayMapFragment extends MapFragmentBase implements GeoPointL public void setGeoPointLocationListener(GeoPointLocationListener listener){ mGeoPointLocationListener = listener; } -} + + @Override + public void onFirstFix(boolean isFistFix) { + if(mGeoPointLocationListener != null) + mGeoPointLocationListener.onFirstFix(isFistFix); + } +} \ No newline at end of file diff --git a/LocationLib/src/com/TwentyCodes/android/location/GeoPointLocationListener.java b/LocationLib/src/com/TwentyCodes/android/location/GeoPointLocationListener.java index fed0162..dd25135 100644 --- a/LocationLib/src/com/TwentyCodes/android/location/GeoPointLocationListener.java +++ b/LocationLib/src/com/TwentyCodes/android/location/GeoPointLocationListener.java @@ -20,4 +20,11 @@ public interface GeoPointLocationListener { * @author ricky barrette */ public void onLocationChanged(GeoPoint point, int accuracy); + + /** + * Called when first fix is aquired + * @param isFirstFix + * @author ricky barrette + */ + public void onFirstFix(boolean isFirstFix); } diff --git a/LocationLib/src/com/TwentyCodes/android/overlays/SkyHookUserOverlay.java b/LocationLib/src/com/TwentyCodes/android/overlays/SkyHookUserOverlay.java index 26f0fff..c678b31 100644 --- a/LocationLib/src/com/TwentyCodes/android/overlays/SkyHookUserOverlay.java +++ b/LocationLib/src/com/TwentyCodes/android/overlays/SkyHookUserOverlay.java @@ -56,4 +56,9 @@ public class SkyHookUserOverlay extends UserOverlayBase{ mSkyHook.getUpdates(); } + @Override + public void onFirstFix(boolean isFistFix) { + // unused + } + } \ No newline at end of file diff --git a/LocationLib/src/com/TwentyCodes/android/overlays/UserOverlay.java b/LocationLib/src/com/TwentyCodes/android/overlays/UserOverlay.java index fb9e504..67e61ae 100644 --- a/LocationLib/src/com/TwentyCodes/android/overlays/UserOverlay.java +++ b/LocationLib/src/com/TwentyCodes/android/overlays/UserOverlay.java @@ -37,5 +37,10 @@ public class UserOverlay extends UserOverlayBase{ public void onMyLocationEnabled() { mAndroidGPS.enableLocationUpdates(this); } + + @Override + public void onFirstFix(boolean isFistFix) { + // unused + } } \ No newline at end of file diff --git a/LocationLib/src/com/TwentyCodes/android/overlays/UserOverlayBase.java b/LocationLib/src/com/TwentyCodes/android/overlays/UserOverlayBase.java index 977c04b..11f2488 100644 --- a/LocationLib/src/com/TwentyCodes/android/overlays/UserOverlayBase.java +++ b/LocationLib/src/com/TwentyCodes/android/overlays/UserOverlayBase.java @@ -6,10 +6,7 @@ */ package com.TwentyCodes.android.overlays; -import android.app.AlertDialog; -import android.app.ProgressDialog; import android.content.Context; -import android.content.DialogInterface; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; @@ -18,8 +15,6 @@ import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.Paint.Style; import android.graphics.Point; -import android.os.Handler; -import android.os.SystemClock; import android.util.Log; import com.TwentyCodes.android.debug.Debug; @@ -117,13 +112,11 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio private GeoPoint mPoint; private Context mContext; private MapView mMapView; - private ProgressDialog mGPSprogress; private boolean isFistFix = true; private GeoPointLocationListener mListener; public boolean isFollowingUser = true; private CompasOverlay mCompass; private boolean isCompassEnabled; - private boolean isGPSDialogEnabled; private CompassListener mCompassListener; @@ -162,16 +155,6 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio mMapView.getOverlays().remove(mCompass); } - /** - * Disables the Acquiring GPS dialog - * @author ricky barrette - */ - public void disableGPSDialog(){ - isGPSDialogEnabled = false; - if(mGPSprogress != null) - mGPSprogress.dismiss(); - } - /** * Stops location updates and removes the overlay from view * @author ricky barrette @@ -181,8 +164,8 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio onMyLocationDisabled(); isEnabled = false; mCompass.disable(); - if(mGPSprogress != null) - mGPSprogress.cancel(); + if(mListener != null) + mListener.onFirstFix(false); mAnimationThread.abort(); } @@ -298,22 +281,6 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio } } - /** - * Enables the Acquiring GPS dialog if the location has not been acquired - * - * TODO fix funtion currently generates bad window token - * @author ricky barrette - */ - public void enableGPSDialog(){ - isGPSDialogEnabled = true; - if(isFistFix) - if(mGPSprogress != null){ - if(! mGPSprogress.isShowing()) - mGPSprogress = ProgressDialog.show(mContext, "", mContext.getText(R.string.gps_fix), true, true); - } else - mGPSprogress = ProgressDialog.show(mContext, "", mContext.getText(R.string.gps_fix), true, true); - } - /** * Attempts to enable MyLocation, registering for updates from provider * @author ricky barrette @@ -329,32 +296,8 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio isEnabled = true; mCompass.enable(this); isFistFix = true; - if(isGPSDialogEnabled) - enableGPSDialog(); - - /** - * this is a message that tells the user that we are having trouble getting an GPS signal - */ - new Handler().postAtTime(new Runnable() { - @Override - public void run() { - if(mGPSprogress != null) - if (mGPSprogress.isShowing()) { - mGPSprogress.cancel(); - AlertDialog.Builder builder = new AlertDialog.Builder(mContext); - builder.setMessage( - mContext.getText(R.string.sorry_theres_trouble)) - .setCancelable(false) - .setPositiveButton(mContext.getText(android.R.string.ok), - new DialogInterface.OnClickListener() { - public void onClick( DialogInterface dialog, int id) { - dialog.cancel(); - } - }); - builder.show(); - } - } - }, SystemClock.uptimeMillis()+90000L); + if(mListener != null) + mListener.onFirstFix(false); } } @@ -417,8 +360,8 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio if(point != null && isFistFix){ mMapView.getController().setCenter(point); mMapView.getController().setZoom( (mMapView.getMaxZoomLevel() - 2) ); - if(mGPSprogress != null) - mGPSprogress.dismiss(); + if(mListener != null) + mListener.onFirstFix(true); isFistFix = false; }