Added a progress circle to the mapfragment

the progress circle will be used to indicate that there is work being
done in the background

Change-Id: Id2929f5be68fce0d223e18d8dd07babfcdb37a34
Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
2012-03-08 09:59:32 -05:00
parent c4a4938e2b
commit 9e244ee772
13 changed files with 129 additions and 137 deletions

View File

@@ -9,5 +9,6 @@
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="lib" path="/app/android-sdk-linux_86/extras/android-support-v4-r6-googlemaps.jar"/> <classpathentry kind="lib" path="/app/android-sdk-linux_86/extras/android-support-v4-r6-googlemaps.jar"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/> <classpathentry kind="output" path="bin/classes"/>
</classpath> </classpath>

View File

@@ -4,32 +4,6 @@
android:versionCode="11" android:versionCode="11"
android:versionName="0.1.1" > android:versionName="0.1.1" >
<application android:label="@string/app_name" >
<service
android:name="SkyHookService"
android:enabled="true"
android:exported="true"
android:process=":locationservice" >
</service>
<receiver
android:name="com.TwentyCodes.android.location.ServiceWakeUpReceiver"
android:enabled="true"
android:exported="true"
android:process=":startinglocationservice" >
</receiver>
<service
android:name="com.TwentyCodes.android.location.LocationService"
android:enabled="true"
android:exported="true"
android:process=":locationservice" >
</service>
<activity android:name="Splash" >
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
@@ -41,4 +15,24 @@
<uses-permission android:name="android.permission.READ_PHONE_STATE" > <uses-permission android:name="android.permission.READ_PHONE_STATE" >
</uses-permission> </uses-permission>
<application android:label="@string/app_name" >
<service
android:name="SkyHookService"
android:process=":locationservice" >
</service>
<receiver
android:name="com.TwentyCodes.android.location.ServiceWakeUpReceiver"
android:process=":startinglocationservice" >
</receiver>
<service
android:name="com.TwentyCodes.android.location.LocationService"
android:process=":locationservice" >
</service>
<activity android:name="Splash" >
</activity>
</application>
</manifest> </manifest>

Binary file not shown.

View File

@@ -1,11 +1,28 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!--
ricky beta release 0rKmsWMM0D-IRAEgcSZEqwZCs_8AUwxjYjj0bnA ricky beta release 0rKmsWMM0D-IRAEgcSZEqwZCs_8AUwxjYjj0bnA
ricky 0rKmsWMM0D-LWOndcfwrmW-S0OXlnQl2SJCMeTg ricky 0rKmsWMM0D-LWOndcfwrmW-S0OXlnQl2SJCMeTg
TWENTYCODES 0rKmsWMM0D-K15bEM_kwabPbNhsn4dp4rcq2q5Q TWENTYCODES 0rKmsWMM0D-K15bEM_kwabPbNhsn4dp4rcq2q5Q
--> -->
<com.TwentyCodes.android.location.MapView xmlns:android="http://schemas.android.com/apk/res/android"
<com.TwentyCodes.android.location.MapView
android:id="@+id/mapview" android:id="@+id/mapview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:apiKey="0rKmsWMM0D-K15bEM_kwabPbNhsn4dp4rcq2q5Q" /> android:apiKey="0rKmsWMM0D-LWOndcfwrmW-S0OXlnQl2SJCMeTg" />
<ProgressBar
android:id="@+id/mapProgressBar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:indeterminate="true"
android:visibility="gone" />
</RelativeLayout>

View File

@@ -289,4 +289,9 @@ public class SkyHook implements GeoPointLocationListener{
if(mListener != null) if(mListener != null)
mListener.onLocationChanged(point, accuracy); mListener.onLocationChanged(point, accuracy);
} }
@Override
public void onFirstFix(boolean isFistFix) {
// unused
}
} }

View File

@@ -235,19 +235,25 @@ public class SkyHookService extends Service implements GeoPointLocationListener,
@Override @Override
public void done() { public void done() {
// TODO Auto-generated method stub // unused
} }
@Override @Override
public WPSContinuation handleError(WPSReturnCode arg0) { public WPSContinuation handleError(WPSReturnCode arg0) {
// TODO Auto-generated method stub // unused
return null; return null;
} }
@Override @Override
public void handleSuccess() { public void handleSuccess() {
// TODO Auto-generated method stub // unused
}
@Override
public void onFirstFix(boolean isFistFix) {
// unused
} }
} }

View File

@@ -11,6 +11,7 @@ import android.support.v4.app.Fragment;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ProgressBar;
import com.TwentyCodes.android.location.MapView; import com.TwentyCodes.android.location.MapView;
import com.TwentyCodes.android.location.R; import com.TwentyCodes.android.location.R;
@@ -25,6 +26,8 @@ import com.google.android.maps.Overlay;
public abstract class MapFragmentBase extends Fragment { public abstract class MapFragmentBase extends Fragment {
private MapView mMapView; private MapView mMapView;
private boolean isGPSDialogEnabled;
private ProgressBar mProgress;
/** /**
* Creates a new MapFragment * Creates a new MapFragment
@@ -66,6 +69,8 @@ public abstract class MapFragmentBase extends Fragment {
mMapView = (MapView) view.findViewById(R.id.mapview); mMapView = (MapView) view.findViewById(R.id.mapview);
mMapView.setClickable(true); mMapView.setClickable(true);
mProgress = (ProgressBar) view.findViewById(R.id.mapProgressBar);
onMapViewCreate(mMapView); onMapViewCreate(mMapView);
return view; return view;
@@ -98,4 +103,27 @@ public abstract class MapFragmentBase extends Fragment {
mMapView.getController().setCenter(point); mMapView.getController().setCenter(point);
return true; 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;
}
} }

View File

@@ -32,22 +32,6 @@ public class SkyHoookUserOverlayMapFragment extends MapFragmentBase implements G
super(); 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 * Tells the useroverlay to pan the map to follow the user
* @param followUser * @param followUser
@@ -96,7 +80,6 @@ public class SkyHoookUserOverlayMapFragment extends MapFragmentBase implements G
mUserOverlay.registerListener(this); mUserOverlay.registerListener(this);
mUserOverlay.setCompassListener(this); mUserOverlay.setCompassListener(this);
mUserOverlay.enableCompass(); mUserOverlay.enableCompass();
mUserOverlay.disableGPSDialog();
mUserOverlay.followUser(true); mUserOverlay.followUser(true);
map.getOverlays().add(mUserOverlay); map.getOverlays().add(mUserOverlay);
@@ -120,8 +103,10 @@ public class SkyHoookUserOverlayMapFragment extends MapFragmentBase implements G
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
if(mUserOverlay != null) if(mUserOverlay != null) {
mUserOverlay.enableMyLocation(); mUserOverlay.enableMyLocation();
addOverlay(mUserOverlay);
}
} }
/** /**
@@ -169,4 +154,9 @@ public class SkyHoookUserOverlayMapFragment extends MapFragmentBase implements G
mGeoPointLocationListener = listener; mGeoPointLocationListener = listener;
} }
@Override
public void onFirstFix(boolean isFistFix) {
if(mGeoPointLocationListener != null)
mGeoPointLocationListener.onFirstFix(isFistFix);
}
} }

View File

@@ -32,22 +32,6 @@ public class UserOverlayMapFragment extends MapFragmentBase implements GeoPointL
super(); 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 * Tells the useroverlay to pan the map to follow the user
* @param followUser * @param followUser
@@ -96,7 +80,6 @@ public class UserOverlayMapFragment extends MapFragmentBase implements GeoPointL
mUserOverlay.registerListener(this); mUserOverlay.registerListener(this);
mUserOverlay.setCompassListener(this); mUserOverlay.setCompassListener(this);
mUserOverlay.enableCompass(); mUserOverlay.enableCompass();
mUserOverlay.disableGPSDialog();
mUserOverlay.followUser(true); mUserOverlay.followUser(true);
map.getOverlays().add(mUserOverlay); map.getOverlays().add(mUserOverlay);
@@ -120,8 +103,10 @@ public class UserOverlayMapFragment extends MapFragmentBase implements GeoPointL
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
if(mUserOverlay != null) if(mUserOverlay != null) {
mUserOverlay.enableMyLocation(); mUserOverlay.enableMyLocation();
addOverlay(mUserOverlay);
}
} }
/** /**
@@ -168,4 +153,10 @@ public class UserOverlayMapFragment extends MapFragmentBase implements GeoPointL
public void setGeoPointLocationListener(GeoPointLocationListener listener){ public void setGeoPointLocationListener(GeoPointLocationListener listener){
mGeoPointLocationListener = listener; mGeoPointLocationListener = listener;
} }
@Override
public void onFirstFix(boolean isFistFix) {
if(mGeoPointLocationListener != null)
mGeoPointLocationListener.onFirstFix(isFistFix);
}
} }

View File

@@ -20,4 +20,11 @@ public interface GeoPointLocationListener {
* @author ricky barrette * @author ricky barrette
*/ */
public void onLocationChanged(GeoPoint point, int accuracy); public void onLocationChanged(GeoPoint point, int accuracy);
/**
* Called when first fix is aquired
* @param isFirstFix
* @author ricky barrette
*/
public void onFirstFix(boolean isFirstFix);
} }

View File

@@ -56,4 +56,9 @@ public class SkyHookUserOverlay extends UserOverlayBase{
mSkyHook.getUpdates(); mSkyHook.getUpdates();
} }
@Override
public void onFirstFix(boolean isFistFix) {
// unused
}
} }

View File

@@ -38,4 +38,9 @@ public class UserOverlay extends UserOverlayBase{
mAndroidGPS.enableLocationUpdates(this); mAndroidGPS.enableLocationUpdates(this);
} }
@Override
public void onFirstFix(boolean isFistFix) {
// unused
}
} }

View File

@@ -6,10 +6,7 @@
*/ */
package com.TwentyCodes.android.overlays; package com.TwentyCodes.android.overlays;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.Canvas; import android.graphics.Canvas;
@@ -18,8 +15,6 @@ import android.graphics.Matrix;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Paint.Style; import android.graphics.Paint.Style;
import android.graphics.Point; import android.graphics.Point;
import android.os.Handler;
import android.os.SystemClock;
import android.util.Log; import android.util.Log;
import com.TwentyCodes.android.debug.Debug; import com.TwentyCodes.android.debug.Debug;
@@ -117,13 +112,11 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio
private GeoPoint mPoint; private GeoPoint mPoint;
private Context mContext; private Context mContext;
private MapView mMapView; private MapView mMapView;
private ProgressDialog mGPSprogress;
private boolean isFistFix = true; private boolean isFistFix = true;
private GeoPointLocationListener mListener; private GeoPointLocationListener mListener;
public boolean isFollowingUser = true; public boolean isFollowingUser = true;
private CompasOverlay mCompass; private CompasOverlay mCompass;
private boolean isCompassEnabled; private boolean isCompassEnabled;
private boolean isGPSDialogEnabled;
private CompassListener mCompassListener; private CompassListener mCompassListener;
@@ -162,16 +155,6 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio
mMapView.getOverlays().remove(mCompass); 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 * Stops location updates and removes the overlay from view
* @author ricky barrette * @author ricky barrette
@@ -181,8 +164,8 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio
onMyLocationDisabled(); onMyLocationDisabled();
isEnabled = false; isEnabled = false;
mCompass.disable(); mCompass.disable();
if(mGPSprogress != null) if(mListener != null)
mGPSprogress.cancel(); mListener.onFirstFix(false);
mAnimationThread.abort(); 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 * Attempts to enable MyLocation, registering for updates from provider
* @author ricky barrette * @author ricky barrette
@@ -329,32 +296,8 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio
isEnabled = true; isEnabled = true;
mCompass.enable(this); mCompass.enable(this);
isFistFix = true; isFistFix = true;
if(isGPSDialogEnabled) if(mListener != null)
enableGPSDialog(); mListener.onFirstFix(false);
/**
* 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);
} }
} }
@@ -417,8 +360,8 @@ public abstract class UserOverlayBase extends Overlay implements GeoPointLocatio
if(point != null && isFistFix){ if(point != null && isFistFix){
mMapView.getController().setCenter(point); mMapView.getController().setCenter(point);
mMapView.getController().setZoom( (mMapView.getMaxZoomLevel() - 2) ); mMapView.getController().setZoom( (mMapView.getMaxZoomLevel() - 2) );
if(mGPSprogress != null) if(mListener != null)
mGPSprogress.dismiss(); mListener.onFirstFix(true);
isFistFix = false; isFistFix = false;
} }