diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/R$attr.class b/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/R$attr.class deleted file mode 100644 index ab2f0e9..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/R$attr.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/R$drawable.class b/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/R$drawable.class deleted file mode 100644 index 3d50a4b..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/R$drawable.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/R$id.class b/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/R$id.class deleted file mode 100644 index cd08410..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/R$id.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/R$layout.class b/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/R$layout.class deleted file mode 100644 index 53a84e8..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/R$layout.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/R$string.class b/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/R$string.class deleted file mode 100644 index aec304c..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/R$string.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/R.class b/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/R.class deleted file mode 100644 index fe87f4b..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/R.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHook$1.class b/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHook$1.class deleted file mode 100644 index 8ff0b68..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHook$1.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHook$2.class b/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHook$2.class deleted file mode 100644 index aca0d79..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHook$2.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHook$3.class b/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHook$3.class deleted file mode 100644 index de07fbb..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHook$3.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHook$XPScallback.class b/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHook$XPScallback.class deleted file mode 100644 index 9cec317..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHook$XPScallback.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHook.class b/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHook.class deleted file mode 100644 index cb4a111..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHook.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHookRegistration.class b/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHookRegistration.class deleted file mode 100644 index 1a4d872..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHookRegistration.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHookService$1.class b/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHookService$1.class deleted file mode 100644 index 291ccb6..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHookService$1.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHookService$2.class b/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHookService$2.class deleted file mode 100644 index 0007882..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHookService$2.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHookService.class b/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHookService.class deleted file mode 100644 index 9885271..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHookService.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHookUserOverlay$1.class b/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHookUserOverlay$1.class deleted file mode 100644 index 8272a97..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHookUserOverlay$1.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHookUserOverlay$2$1.class b/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHookUserOverlay$2$1.class deleted file mode 100644 index ef4994a..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHookUserOverlay$2$1.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHookUserOverlay$2.class b/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHookUserOverlay$2.class deleted file mode 100644 index 17f888f..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHookUserOverlay$2.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHookUserOverlay.class b/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHookUserOverlay.class deleted file mode 100644 index 8a9c7e5..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/SkyHookUserOverlay.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/Splash$1.class b/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/Splash$1.class deleted file mode 100644 index 9b74cf8..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/Splash$1.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/Splash$2.class b/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/Splash$2.class deleted file mode 100644 index f4bed6f..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/Splash$2.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/Splash.class b/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/Splash.class deleted file mode 100644 index a86f238..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/SkyHook/Splash.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/debug/Debug.class b/LocationLib/bin/classes/com/TwentyCodes/android/debug/Debug.class deleted file mode 100644 index 1c5fe83..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/debug/Debug.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/debug/SkyHookRegistrationBehavior.class b/LocationLib/bin/classes/com/TwentyCodes/android/debug/SkyHookRegistrationBehavior.class deleted file mode 100644 index 602e0e3..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/debug/SkyHookRegistrationBehavior.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/location/AndroidGPS.class b/LocationLib/bin/classes/com/TwentyCodes/android/location/AndroidGPS.class deleted file mode 100644 index b40dabc..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/location/AndroidGPS.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/location/CompasOverlay.class b/LocationLib/bin/classes/com/TwentyCodes/android/location/CompasOverlay.class deleted file mode 100644 index b08072a..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/location/CompasOverlay.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/location/CompassListener.class b/LocationLib/bin/classes/com/TwentyCodes/android/location/CompassListener.class deleted file mode 100644 index 3447f73..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/location/CompassListener.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/location/CompassSensor$1.class b/LocationLib/bin/classes/com/TwentyCodes/android/location/CompassSensor$1.class deleted file mode 100644 index bb5a5b0..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/location/CompassSensor$1.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/location/CompassSensor$2.class b/LocationLib/bin/classes/com/TwentyCodes/android/location/CompassSensor$2.class deleted file mode 100644 index 54e0444..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/location/CompassSensor$2.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/location/CompassSensor$SensorCallBack.class b/LocationLib/bin/classes/com/TwentyCodes/android/location/CompassSensor$SensorCallBack.class deleted file mode 100644 index 1b25e47..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/location/CompassSensor$SensorCallBack.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/location/CompassSensor.class b/LocationLib/bin/classes/com/TwentyCodes/android/location/CompassSensor.class deleted file mode 100644 index 5dedab4..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/location/CompassSensor.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/location/GeoPointLocationListener.class b/LocationLib/bin/classes/com/TwentyCodes/android/location/GeoPointLocationListener.class deleted file mode 100644 index 1fc5a88..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/location/GeoPointLocationListener.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/location/GeoUtils.class b/LocationLib/bin/classes/com/TwentyCodes/android/location/GeoUtils.class deleted file mode 100644 index 0e425cf..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/location/GeoUtils.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/location/LocationReceiver.class b/LocationLib/bin/classes/com/TwentyCodes/android/location/LocationReceiver.class deleted file mode 100644 index 7a41c74..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/location/LocationReceiver.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/location/LocationService$1.class b/LocationLib/bin/classes/com/TwentyCodes/android/location/LocationService$1.class deleted file mode 100644 index 4db1725..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/location/LocationService$1.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/location/LocationService$2.class b/LocationLib/bin/classes/com/TwentyCodes/android/location/LocationService$2.class deleted file mode 100644 index 28c6bc6..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/location/LocationService$2.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/location/LocationService.class b/LocationLib/bin/classes/com/TwentyCodes/android/location/LocationService.class deleted file mode 100644 index 71d3734..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/location/LocationService.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/location/MapView.class b/LocationLib/bin/classes/com/TwentyCodes/android/location/MapView.class deleted file mode 100644 index 59e8bdb..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/location/MapView.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/location/MidPoint.class b/LocationLib/bin/classes/com/TwentyCodes/android/location/MidPoint.class deleted file mode 100644 index b159550..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/location/MidPoint.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/location/ReverseGeocoder.class b/LocationLib/bin/classes/com/TwentyCodes/android/location/ReverseGeocoder.class deleted file mode 100644 index 3cd5f2d..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/location/ReverseGeocoder.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/location/UserOverlay$1$1.class b/LocationLib/bin/classes/com/TwentyCodes/android/location/UserOverlay$1$1.class deleted file mode 100644 index 76cf60b..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/location/UserOverlay$1$1.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/location/UserOverlay$1.class b/LocationLib/bin/classes/com/TwentyCodes/android/location/UserOverlay$1.class deleted file mode 100644 index 866e533..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/location/UserOverlay$1.class and /dev/null differ diff --git a/LocationLib/bin/classes/com/TwentyCodes/android/location/UserOverlay.class b/LocationLib/bin/classes/com/TwentyCodes/android/location/UserOverlay.class deleted file mode 100644 index 1ab7da5..0000000 Binary files a/LocationLib/bin/classes/com/TwentyCodes/android/location/UserOverlay.class and /dev/null differ diff --git a/LocationLib/bin/locationlib.jar b/LocationLib/bin/locationlib.jar index a9a72ab..9a4bc62 100644 Binary files a/LocationLib/bin/locationlib.jar and b/LocationLib/bin/locationlib.jar differ diff --git a/LocationLib/bin/res/drawable/compass.png b/LocationLib/bin/res/drawable/compass.png deleted file mode 100644 index 87848e5..0000000 Binary files a/LocationLib/bin/res/drawable/compass.png and /dev/null differ diff --git a/LocationLib/bin/res/drawable/logoidea3.png b/LocationLib/bin/res/drawable/logoidea3.png deleted file mode 100644 index fdc73c3..0000000 Binary files a/LocationLib/bin/res/drawable/logoidea3.png and /dev/null differ diff --git a/LocationLib/bin/res/drawable/needle.png b/LocationLib/bin/res/drawable/needle.png deleted file mode 100644 index 93fad78..0000000 Binary files a/LocationLib/bin/res/drawable/needle.png and /dev/null differ diff --git a/LocationLib/bin/res/drawable/skyhook_logo_alpha.png b/LocationLib/bin/res/drawable/skyhook_logo_alpha.png deleted file mode 100644 index d5ce291..0000000 Binary files a/LocationLib/bin/res/drawable/skyhook_logo_alpha.png and /dev/null differ diff --git a/LocationLib/bin/res/drawable/skyhook_logo_alpha_small.png b/LocationLib/bin/res/drawable/skyhook_logo_alpha_small.png deleted file mode 100644 index 8058c19..0000000 Binary files a/LocationLib/bin/res/drawable/skyhook_logo_alpha_small.png and /dev/null differ diff --git a/LocationLib/bin/res/drawable/tc_logo_complete.png b/LocationLib/bin/res/drawable/tc_logo_complete.png deleted file mode 100644 index 073970c..0000000 Binary files a/LocationLib/bin/res/drawable/tc_logo_complete.png and /dev/null differ diff --git a/LocationLib/bin/res/drawable/user.png b/LocationLib/bin/res/drawable/user.png deleted file mode 100644 index 579f876..0000000 Binary files a/LocationLib/bin/res/drawable/user.png and /dev/null differ diff --git a/LocationLib/bin/res/drawable/user_arrow_animation_1.png b/LocationLib/bin/res/drawable/user_arrow_animation_1.png deleted file mode 100644 index 9c6778e..0000000 Binary files a/LocationLib/bin/res/drawable/user_arrow_animation_1.png and /dev/null differ diff --git a/LocationLib/bin/res/drawable/user_arrow_animation_2.png b/LocationLib/bin/res/drawable/user_arrow_animation_2.png deleted file mode 100644 index 630fd72..0000000 Binary files a/LocationLib/bin/res/drawable/user_arrow_animation_2.png and /dev/null differ diff --git a/LocationLib/bin/res/drawable/user_arrow_animation_3.png b/LocationLib/bin/res/drawable/user_arrow_animation_3.png deleted file mode 100644 index c1448f7..0000000 Binary files a/LocationLib/bin/res/drawable/user_arrow_animation_3.png and /dev/null differ diff --git a/LocationLib/gen/com/TwentyCodes/android/SkyHook/R.java b/LocationLib/gen/com/TwentyCodes/android/SkyHook/R.java index 8bc5ae4..e18c37d 100644 --- a/LocationLib/gen/com/TwentyCodes/android/SkyHook/R.java +++ b/LocationLib/gen/com/TwentyCodes/android/SkyHook/R.java @@ -12,17 +12,23 @@ public final class R { } public static final class drawable { public static int compass=0x7f020000; - public static int logoidea3=0x7f020001; - public static int needle=0x7f020002; - public static int skyhook_logo=0x7f020003; - public static int skyhook_logo_alpha=0x7f020004; - public static int skyhook_logo_alpha_small=0x7f020005; - public static int tc_logo_complete=0x7f020006; - public static int user=0x7f020007; - public static int user_arrow_animation_1=0x7f020008; - public static int user_arrow_animation_2=0x7f020009; - public static int user_arrow_animation_3=0x7f02000a; - public static int userarrow=0x7f02000b; + public static int compass_lrg=0x7f020001; + public static int compass_med=0x7f020002; + public static int compass_sm=0x7f020003; + public static int logoidea3=0x7f020004; + public static int needle=0x7f020005; + public static int needle_lrg=0x7f020006; + public static int needle_med=0x7f020007; + public static int needle_sm=0x7f020008; + public static int skyhook_logo=0x7f020009; + public static int skyhook_logo_alpha=0x7f02000a; + public static int skyhook_logo_alpha_small=0x7f02000b; + public static int tc_logo_complete=0x7f02000c; + public static int user=0x7f02000d; + public static int user_arrow_animation_1=0x7f02000e; + public static int user_arrow_animation_2=0x7f02000f; + public static int user_arrow_animation_3=0x7f020010; + public static int userarrow=0x7f020011; } public static final class id { public static int skyhook_img=0x7f050000; diff --git a/LocationLib/res/drawable/compass_lrg.png b/LocationLib/res/drawable/compass_lrg.png new file mode 100644 index 0000000..398a055 Binary files /dev/null and b/LocationLib/res/drawable/compass_lrg.png differ diff --git a/LocationLib/res/drawable/compass_med.png b/LocationLib/res/drawable/compass_med.png new file mode 100644 index 0000000..7aeb78e Binary files /dev/null and b/LocationLib/res/drawable/compass_med.png differ diff --git a/LocationLib/res/drawable/compass_sm.png b/LocationLib/res/drawable/compass_sm.png new file mode 100644 index 0000000..cb0f8b0 Binary files /dev/null and b/LocationLib/res/drawable/compass_sm.png differ diff --git a/LocationLib/res/drawable/needle_lrg.png b/LocationLib/res/drawable/needle_lrg.png new file mode 100644 index 0000000..9c6a63c Binary files /dev/null and b/LocationLib/res/drawable/needle_lrg.png differ diff --git a/LocationLib/res/drawable/needle_med.png b/LocationLib/res/drawable/needle_med.png new file mode 100644 index 0000000..f8544d4 Binary files /dev/null and b/LocationLib/res/drawable/needle_med.png differ diff --git a/LocationLib/res/drawable/needle_sm.png b/LocationLib/res/drawable/needle_sm.png new file mode 100644 index 0000000..b37aa62 Binary files /dev/null and b/LocationLib/res/drawable/needle_sm.png differ diff --git a/LocationLib/src/com/TwentyCodes/android/location/CompasOverlay.java b/LocationLib/src/com/TwentyCodes/android/location/CompasOverlay.java index 793e33c..6781c21 100644 --- a/LocationLib/src/com/TwentyCodes/android/location/CompasOverlay.java +++ b/LocationLib/src/com/TwentyCodes/android/location/CompasOverlay.java @@ -7,11 +7,13 @@ package com.TwentyCodes.android.location; import android.content.Context; +import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Point; +import android.util.TypedValue; import com.TwentyCodes.android.SkyHook.R; import com.google.android.maps.GeoPoint; @@ -30,10 +32,10 @@ public class CompasOverlay extends Overlay implements CompassListener { private GeoPoint mLocation; private boolean isEnabled; private CompassSensor mCompassSensor; - private int mNeedleResId = R.drawable.needle; - private int mBackgroundResId = R.drawable.compass; - private int mX = 100; - private int mY = 100; + private int mNeedleResId = R.drawable.needle_sm; + private int mBackgroundResId = R.drawable.compass_sm; + private int mX; + private int mY; private CompassListener mListener; /** @@ -43,6 +45,8 @@ public class CompasOverlay extends Overlay implements CompassListener { public CompasOverlay(Context context) { mContext = context; mCompassSensor = new CompassSensor(context); + mX = convertDipToPx(40); + mY = mX; } /** @@ -55,6 +59,24 @@ public class CompasOverlay extends Overlay implements CompassListener { this(context); mDestination = destination; } + + /** + * Creates a new CompasOverlay + * @param context + * @param destination + * @param needleResId + * @param backgroundResId + * @param x dip + * @param y dip + * @author ricky barrette + */ + public CompasOverlay(Context context, GeoPoint destination, int needleResId, int backgroundResId, int x, int y){ + this(context, destination); + mX = convertDipToPx(x); + mY = convertDipToPx(y); + mNeedleResId = needleResId; + mBackgroundResId = backgroundResId; + } /** * Creates a new CompasOverlay @@ -69,24 +91,6 @@ public class CompasOverlay extends Overlay implements CompassListener { this(context, null, needleResId, backgroundResId, x, y); } - /** - * Creates a new CompasOverlay - * @param context - * @param destination - * @param needleResId - * @param backgroundResId - * @param x - * @param y - * @author ricky barrette - */ - public CompasOverlay(Context context, GeoPoint destination, int needleResId, int backgroundResId, int x, int y){ - this(context, destination); - mX = x; - mY = y; - mNeedleResId = needleResId; - mBackgroundResId = backgroundResId; - } - /** * Calculated the bearing from the current location to the current destination, or returns the bearing for north if there is no destination * @return bearing @@ -102,6 +106,17 @@ public class CompasOverlay extends Overlay implements CompassListener { return bearing; } + + /** + * Converts dip to px + * @param dip + * @return px + * @author ricky barrette + */ + private int convertDipToPx(int i) { + Resources r = mContext.getResources(); + return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, i, r.getDisplayMetrics()); + } /** * Disables the compass overlay @@ -214,11 +229,13 @@ public class CompasOverlay extends Overlay implements CompassListener { /** * @param needleResId * @param backgroundResId + * @param x dip + * @param y dip * @author ricky barrette */ public void setDrawables(int needleResId, int backgroundResId, int x, int y){ - mX = x; - mY = y; + mX = convertDipToPx(x); + mY = convertDipToPx(y); mNeedleResId = needleResId; mBackgroundResId = backgroundResId; } diff --git a/LocationLib/src/com/TwentyCodes/android/location/LocationSelectedListener.java b/LocationLib/src/com/TwentyCodes/android/location/LocationSelectedListener.java new file mode 100644 index 0000000..61a0d25 --- /dev/null +++ b/LocationLib/src/com/TwentyCodes/android/location/LocationSelectedListener.java @@ -0,0 +1,12 @@ +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 + * @author ricky barrette + */ +public interface LocationSelectedListener { + + public void onLocationSelected(GeoPoint point); +} \ No newline at end of file diff --git a/LocationLib/src/com/TwentyCodes/android/location/RadiusOverlay.java b/LocationLib/src/com/TwentyCodes/android/location/RadiusOverlay.java new file mode 100644 index 0000000..75ccc48 --- /dev/null +++ b/LocationLib/src/com/TwentyCodes/android/location/RadiusOverlay.java @@ -0,0 +1,156 @@ +/** +* @author Twenty Codes +* @author ricky barrette +*/ + +package com.TwentyCodes.android.location; + +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.Paint.Style; +import android.graphics.Point; +import android.graphics.RectF; + +import com.google.android.maps.GeoPoint; +import com.google.android.maps.MapView; +import com.google.android.maps.Overlay; +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 + * @author ricky barrette + */ +public class RadiusOverlay extends Overlay{ + + public OverlayItem mOverlayItem; + private GeoPoint mPoint; + private float mRadius = 0; + private int mColor = Color.GREEN; + private GeoPoint mRadiusPoint; + private LocationSelectedListener mListener; + + /** + * 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 + * @author ricky barrette + */ + public RadiusOverlay(GeoPoint point, float radius, int color) { + mPoint = point; + mRadius = radius; + mColor = color; + } + + /** + * draws a specific radius on the mapview that is handed to it + * @param canvas canvas to be drawn on + * @param mapView + * @param shadow + * @param when + */ + @Override + public void draw(Canvas canvas, MapView mapView, boolean shadow){ + if(mPoint != null){ + Paint paint = new Paint(); + Point center = new Point(); + Point left = new Point(); + 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. + */ + mRadiusPoint = GeoUtils.distanceFrom(mPoint , mRadius); + projection.toPixels(mRadiusPoint, left); + projection.toPixels(mPoint, center); + + /* + * get radius of the circle being drawn by + */ + int circleRadius = center.x - left.x; + if(circleRadius <= 0){ + circleRadius = left.x - center.x; + } + + /* + * paint a circle on the map + */ + paint.setAntiAlias(true); + paint.setStrokeWidth(2.0f); + paint.setColor(mColor); + paint.setStyle(Style.STROKE); + canvas.drawCircle(center.x, center.y, circleRadius, paint); + + //draw a dot over the geopoint + RectF oval = new RectF(center.x - 2, center.y - 2, center.x + 2, center.y + 2); + canvas.drawOval(oval, paint); + + //fill the radius with a nice green + paint.setAlpha(25); + paint.setStyle(Style.FILL); + canvas.drawCircle(center.x, center.y, circleRadius, paint); + } + } + + /** + * @return the selected location + * @author ricky barrette + */ + public GeoPoint getLocation(){ + return mPoint; + } + + @Override + public boolean onTap(GeoPoint p, MapView mapView) { + mPoint = p; + if(this.mListener != null) + this.mListener.onLocationSelected(p); + return super.onTap(p, mapView); + } + + /** + * @param color + * @author ricky barrette + */ + public void setColor(int color){ + mColor = color; + } + + /** + * @param location + * @author ricky barrette + */ + public void setLocation(GeoPoint location){ + mPoint = location; + } + + /** + * @param radius in meters + * @author ricky barrette + * @param radius + */ + public void setRadius(int radius){ + mRadius = radius; + } + + public int getZoomLevel() { +// GeoUtils.GeoUtils.distanceFrom(mPoint , mRadius) + return 0; + } + + public void setLocationSelectedListener(LocationSelectedListener listener) { + this.mListener = listener; + } +} \ No newline at end of file diff --git a/LocationLib/src/com/TwentyCodes/android/location/UserOverlay.java b/LocationLib/src/com/TwentyCodes/android/location/UserOverlay.java index 4b36d82..bd4c2ee 100644 --- a/LocationLib/src/com/TwentyCodes/android/location/UserOverlay.java +++ b/LocationLib/src/com/TwentyCodes/android/location/UserOverlay.java @@ -10,81 +10,136 @@ import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.Paint.Style; import android.graphics.Point; -import android.graphics.drawable.AnimationDrawable; -import android.graphics.drawable.BitmapDrawable; -import android.location.Location; import android.os.Handler; import android.os.SystemClock; +import android.util.Log; import com.TwentyCodes.android.SkyHook.R; +import com.TwentyCodes.android.debug.Debug; import com.google.android.maps.GeoPoint; import com.google.android.maps.MapView; -import com.google.android.maps.MyLocationOverlay; +import com.google.android.maps.Overlay; import com.google.android.maps.Projection; /** * This is the standard version of the UserOverlay. * @author ricky barrette */ -public class UserOverlay extends MyLocationOverlay { +public class UserOverlay extends Overlay implements GeoPointLocationListener, CompassListener { + private boolean isEnabled; + private int mUserArrow = R.drawable.user_arrow_animation_1; + private Thread mAnimationThread; + + private float mBearing = 0; + private int mAccuracy; + private GeoPoint mPoint; private Context mContext; + private AndroidGPS mAndroidGPS; private MapView mMapView; private ProgressDialog mGPSprogress; - private boolean isFirstFix = true; + private boolean isFistFix = true; private GeoPointLocationListener mListener; - private boolean isFollowingUser = true; - private float myAzimuth; - private GeoPoint mUser; - private GeoPoint mDest; - private boolean isShowingCompass; - private AnimationDrawable mUserArrow; - + public boolean isFollowingUser = true; + private final String TAG = "SkyHookUserOverlay"; + private CompasOverlay mCompass; + private boolean isCompassEnabled; + private boolean isGPSDialogEnabled; + /** - * Creates a new UserOverlay - * @param context + * Construct a new SkyHookUserOverlaymFollowUser * @param mapView + * @param context * @author ricky barrette */ - public UserOverlay(Context context, MapView mapView) { - super(context, mapView); - mMapView = mapView; + public UserOverlay(MapView mapView, Context context) { mContext = context; - mUserArrow = (AnimationDrawable) mContext.getResources().getAnimation(R.drawable.userarrow); - mUserArrow.start(); + mMapView = mapView; + mAndroidGPS = new AndroidGPS(context); + mCompass = new CompasOverlay(context); + mUserArrow = R.drawable.user_arrow_animation_1; } /** - * disables the compass view - * (non-Javadoc) - * @see com.google.android.maps.MyLocationOverlay#disableCompass() + * Construct a new SkyHookUserOverlay + * @param mapView + * @param context + * @param followUser + * @author ricky barrette + */ + public UserOverlay(MapView mapView, Context context, boolean followUser) { + this(mapView, context); + isFollowingUser = followUser; + } + + /** + * Disables the compass * @author ricky barrette */ - @Override public void disableCompass(){ - isShowingCompass = false; + isCompassEnabled = false; + mMapView.getOverlays().remove(mCompass); + } /** - * called when the overlay is disabled. this will disable all progress dialogs, and location based servicess + * Stops location updates and removes the overlay from view + * @author ricky barrette + */ + public void disableMyLocation(){ + Log.d(TAG,"disableMyLocation()"); + mAndroidGPS.disableLocationUpdates(); + isEnabled = false; + mCompass.disable(); + if(mGPSprogress != null) + mGPSprogress.cancel(); + } + + /** + * Disables the Acquiring GPS dialog + * @author ricky barrette + */ + public void disableGPSDialog(){ + isGPSDialogEnabled = false; + if(mGPSprogress != null) + mGPSprogress.dismiss(); + } + + /** + * 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.MyLocationOverlay#disableMyLocation() + * @see com.google.android.maps.Overlay#draw(android.graphics.Canvas, com.google.android.maps.MapView, boolean) + * @param canvas + * @param mapView + * @param shadow * @author ricky barrette */ @Override - public void disableMyLocation(){ - super.disableCompass(); - super.disableMyLocation(); - mGPSprogress.dismiss(); + public void draw(Canvas canvas, MapView mapView, boolean shadow){ + if (isEnabled && mPoint != null) { + Point center = new Point(); + Point left = new Point(); + Projection projection = mapView.getProjection(); + GeoPoint leftGeo = GeoUtils.distanceFrom(mPoint, mAccuracy); + projection.toPixels(leftGeo, left); + projection.toPixels(mPoint, center); + canvas = drawAccuracyCircle(center, left, canvas); + canvas = drawUser(center, mBearing, canvas); + /* + * the following log is used to demonstrate if the leftGeo point is the correct + */ +// Log.d(SkyHook.TAG, (GeoUtils.distanceKm(mPoint, leftGeo) * 1000)+"m"); + } + super.draw(canvas, mapView, shadow); } - - + /** * draws an accuracy circle onto the canvas supplied * @param center point of the circle @@ -129,64 +184,7 @@ public class UserOverlay extends MyLocationOverlay { return canvas; } - /** - * computes bearing to geopoint based on device oriantaion and draws the compass of what you want really really badly on screen - * @param - canvas - the canvas to draw on - * @param - bearing - bearing of user based on magnetic compass - * @author ricky barrette - */ - @Override - protected void drawCompass(Canvas canvas, float bearing){ - myAzimuth = bearing; - - mMapView.invalidate(); - - if (isShowingCompass) { - /* - * if the dest and user geopoint are not null, then draw the compass point to the dest geopoint - * - * else draw the compass to point north - */ - if (mUser != null && mDest != null){ - Double d = GeoUtils.bearing(mUser, mDest); - bearing = bearing - d.floatValue(); - } else if (bearing != 0){ - bearing = 360 - bearing; - } - - super.drawCompass(canvas, bearing); - } - } - - /** - * 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 - * @author ricky barrette - */ - @Override - protected void drawMyLocation(Canvas canvas, MapView mapView, Location lastFix, GeoPoint point, long when){ - if (point != null) { - - Point center = new Point(); - Point left = new Point(); - Projection projection = mapView.getProjection(); - GeoPoint leftGeo = GeoUtils.distanceFrom(point, lastFix.getAccuracy()); - projection.toPixels(leftGeo, left); - projection.toPixels(point, center); - canvas = drawAccuracyCircle(center, left, canvas); - canvas = drawUser(center, myAzimuth, canvas); - /* - * the following log is used to demonstrate if the leftGeo point is the correct - */ -// Log.d(SkyHook.TAG, (GeoUtils.distanceKm(mPoint, leftGeo) * 1000)+"m"); - } - } - - /** + /** * 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 @@ -195,14 +193,14 @@ public class UserOverlay extends MyLocationOverlay { * @author ricky barrette */ private Canvas drawUser(Point point, float bearing, Canvas canvas){ - Bitmap arrowBitmap = ((BitmapDrawable)mUserArrow.getCurrent()).getBitmap(); + Bitmap user = BitmapFactory.decodeResource(mContext.getResources(), mUserArrow); Matrix matrix = new Matrix(); matrix.postRotate(bearing); Bitmap rotatedBmp = Bitmap.createBitmap( - arrowBitmap, + user, 0, 0, - arrowBitmap.getWidth(), - arrowBitmap.getHeight(), + user.getWidth(), + user.getHeight(), matrix, true ); @@ -214,56 +212,74 @@ public class UserOverlay extends MyLocationOverlay { ); return canvas; } - - /** - * enables the compass view - * (non-Javadoc) - * @see com.google.android.maps.MyLocationOverlay#enableCompass() - * @author ricky barrette - */ - @Override - public boolean enableCompass(){ - isShowingCompass = true; - return isShowingCompass; - } - + /** - * called when the user overlay is enabled, this will display the progress dialog - * (non-Javadoc) - * @see com.google.android.maps.MyLocationOverlay#enableMyLocation() - * @author ricky barrette - */ - @Override - public boolean enableMyLocation(){ - mGPSprogress = ProgressDialog.show(mContext, "", mContext.getText(R.string.gps_fix), true, true); - isFirstFix = true; - super.enableCompass(); - - /** - * 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.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(); + * Enables the compass + * @author ricky barrette + */ + public synchronized void enableCompass(){ + if(! this.isCompassEnabled){ + this.mMapView.getOverlays().add(this.mCompass); + this.isCompassEnabled = true; + } + } + + /** + * Enables the Acquiring GPS dialog if the location has not been acquired + * @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 sky hook + * @author ricky barrette + */ + public void enableMyLocation(){ + Log.d(TAG,"enableMyLocation()"); + if (! isEnabled) { + + mAnimationThread = new AnimationThread(); + mAnimationThread.start(); + + mAndroidGPS.enableLocationUpdates(this); + 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.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); - - return super.enableMyLocation(); - } + }, SystemClock.uptimeMillis()+90000L); + } + } /** * Allows the map to follow the user @@ -271,11 +287,38 @@ public class UserOverlay extends MyLocationOverlay { * @author ricky barrette */ public void followUser(boolean followUser){ + Log.d(TAG,"followUser()"); isFollowingUser = followUser; } + + /** + * returns the users current bearing + * @return + * @author ricky barrette + */ + public float getUserBearing(){ + return mBearing; + } + + /** + * returns the users current location + * @return + * @author ricky barrette + */ + public GeoPoint getUserLocation(){ + return mPoint; + } + + @Override + public void onCompassUpdate(float bearing) { + if(Debug.DEBUG) + Log.v(TAG, "onCompassUpdate()"); + mBearing = bearing; + mMapView.invalidate(); + } /** - * called when the SkyHook location changes, this method is resposiable for updating the overlay location and accuracy circle. + * 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 @@ -283,28 +326,34 @@ public class UserOverlay extends MyLocationOverlay { * @author ricky barrette */ @Override - public void onLocationChanged(Location location) { + public void onLocationChanged(GeoPoint point, int accuracy) { - GeoPoint point = new GeoPoint((int) (location.getLatitude() *1e6), (int) (location.getLongitude() *1e6)); + if(mCompass != null) + mCompass.setLocation(point); /* * if this is the first fix * set map center the users location, and zoom to the max zoom level */ - if(point != null && isFirstFix){ + if(point != null && isFistFix){ mMapView.getController().setCenter(point); - mMapView.getController().setZoom(mMapView.getMaxZoomLevel()+3); - mGPSprogress.dismiss(); - isFirstFix = false; + mMapView.getController().setZoom( (mMapView.getMaxZoomLevel() - 2) ); + if(mGPSprogress != null) + mGPSprogress.dismiss(); + isFistFix = false; + } + + //update the users point, and accuracy for the UI + mPoint = point; + mAccuracy = accuracy; + mMapView.invalidate(); + if(mListener != null){ + mListener.onLocationChanged(point, accuracy); } - //pan to user if off map if (isFollowingUser) { panToUserIfOffMap(point); } - - mListener.onLocationChanged(point, (int) location.getAccuracy()); - super.onLocationChanged(location); } /** @@ -335,17 +384,107 @@ public class UserOverlay extends MyLocationOverlay { * @author Ricky Barrette */ public void registerListener(GeoPointLocationListener listener){ + Log.d(TAG,"registerListener()"); if (mListener == null){ mListener = listener; } } + /** + * Sets the destination for the compass + * @author ricky barrette + */ + public void setDestination(GeoPoint destination){ + if(mCompass != null) + mCompass.setDestination(destination); + } + /** * UnResgisters the listener. after this call you will no longer get location updates * @author Ricky Barrette */ public void unRegisterListener(){ + Log.d(TAG,"unRegisterListener()"); mListener = null; } + /** + * Set the compass drawables and location + * @param needleResId + * @param backgroundResId + * @param x + * @param y + * @author ricky barrette + */ + public void setCompassDrawables(int needleResId, int backgroundResId, int x, int y) { + mCompass.setDrawables(needleResId, backgroundResId, x, y); + } + + + /** + * This thread is responsible for animating the user icon + * @author ricky barrette + */ + private class AnimationThread extends Thread { + + /** + * Main method of this animation thread + * (non-Javadoc) + * @see java.lang.Thread#run() + */ + @Override + public void run(){ + super.run(); + int index = 0; + boolean isCountingUp = true; + while (true) { + synchronized (this) { + if (! isEnabled) { + break; + } + + switch(index){ + case 1: + setDrawable(R.drawable.user_arrow_animation_2); + break; + case 2: + setDrawable(R.drawable.user_arrow_animation_3); + break; + default: + setDrawable(R.drawable.user_arrow_animation_1); + try { + sleep(300l); + } catch (InterruptedException e) { + e.printStackTrace(); + return; + } + break; + } + + try { + sleep(200l); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + if(isCountingUp){ + if(index++ == 2) + isCountingUp = false; + } else if(index-- == 0) + isCountingUp = true; + + } + } + + } + + /** + * Sets the id of the user drawable + * @param id + * @author ricky barrette + */ + private synchronized void setDrawable(int id){ + mUserArrow = id; + } + } } \ No newline at end of file