added compass drawables to the lib

CompasOverlay.java
updated all methods that set mX and mY to use dip instead of px
updated default drawables to compass_sm.png and needle_sm.png

added RadiusOverlay.java and LocationSelectedListener.java to the library
This commit is contained in:
2012-01-12 13:30:48 +00:00
parent d2d643afe6
commit 5cf1e61c6c
46 changed files with 86 additions and 59 deletions

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 825 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -16,19 +16,23 @@ public final class R {
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 int map_action_bar=0x7f020005;
public static int map_mode_action_bar=0x7f020006;
public static int mark_my_location_action_bar=0x7f020007;
public static int my_location_action_bar=0x7f020008;
public static int nav_action_bar=0x7f020009;
public static int needle=0x7f02000a;
public static int needle_lrg=0x7f02000b;
public static int needle_med=0x7f02000c;
public static int needle_sm=0x7f02000d;
public static int skyhook_logo=0x7f02000e;
public static int skyhook_logo_alpha=0x7f02000f;
public static int skyhook_logo_alpha_small=0x7f020010;
public static int tc_logo_complete=0x7f020011;
public static int user=0x7f020012;
public static int user_arrow_animation_1=0x7f020013;
public static int user_arrow_animation_2=0x7f020014;
public static int user_arrow_animation_3=0x7f020015;
}
public static final class id {
public static int skyhook_img=0x7f050000;

View File

@@ -0,0 +1,4 @@
[Dolphin]
ShowPreview=true
Timestamp=2011,12,8,10,59,54
Version=2

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,4 @@
[Dolphin]
ShowPreview=true
Timestamp=2011,12,8,10,59,27
Version=2

Binary file not shown.

After

Width:  |  Height:  |  Size: 621 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 529 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 569 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 603 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 713 B

View File

@@ -0,0 +1,4 @@
[Dolphin]
ShowPreview=true
Timestamp=2011,12,8,10,59,43
Version=2

Binary file not shown.

After

Width:  |  Height:  |  Size: 823 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 752 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 743 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 769 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1009 B

View File

@@ -0,0 +1,4 @@
[Dolphin]
ShowPreview=true
Timestamp=2011,12,8,11,0,5
Version=2

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false" >
<item
android:drawable="@drawable/user_arrow_animation_1"
android:duration="500" />
<item
android:drawable="@drawable/user_arrow_animation_2"
android:duration="200" />
<item
android:drawable="@drawable/user_arrow_animation_3"
android:duration="200" />
</animation-list>

View File

@@ -91,22 +91,6 @@ public class CompasOverlay extends Overlay implements CompassListener {
this(context, null, needleResId, backgroundResId, x, y);
}
/**
* Calculated the bearing from the current location to the current destination, or returns the bearing for north if there is no destination
* @return bearing
* @author ricky barrette
*/
private float calculateBearing() {
if( (mLocation == null) || (mDestination == null) )
return mBearing;
float bearing = mBearing - GeoUtils.bearing(mLocation, mDestination).floatValue();
if (bearing != 0)
bearing = 360 - bearing;
return bearing;
}
/**
* Converts dip to px
* @param dip
@@ -152,7 +136,7 @@ public class CompasOverlay extends Overlay implements CompassListener {
//draw the compass needle
Bitmap arrowBitmap = BitmapFactory.decodeResource( mContext.getResources(), mNeedleResId);
Matrix matrix = new Matrix();
matrix.postRotate(calculateBearing());
matrix.postRotate(GeoUtils.calculateBearing(mLocation, mDestination, mBearing));
Bitmap rotatedBmp = Bitmap.createBitmap(
arrowBitmap,
0, 0,

View File

@@ -37,6 +37,30 @@ public class GeoUtils {
public static final int EARTH_RADIUS_KM = 6371;
public static final double MILLION = 1000000;
/**
* 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.
* @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) {
if( (user == null) || (dest == null) )
return bearing;
float heading = bearing(user, dest).floatValue();
bearing = (360 - heading) + bearing;
if (bearing > 360)
return bearing - 360;
return bearing;
}
/**
* computes the bearing of lat2/lon2 in relationship from lat1/lon1 in degrees East
@@ -44,7 +68,7 @@ public class GeoUtils {
* @param lon1 source lon
* @param lat2 destination lat
* @param lon2 destination lon
* @return the bearing of lat2/lon2 in relationship from lat1/lon1 in degrees East
* @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) {
@@ -57,7 +81,7 @@ public class GeoUtils {
}
/**
* computes the bearing of lat2/lon2 in relationship from lat1/lon1 in degrees East
* computes the bearing of lat2/lon2 in relationship from lat1/lon1 in degrees East of true north
* @param p1 source geopoint
* @param p2 destination geopoint
* @return the bearing of p2 in relationship from p1 in degrees East

View File

@@ -52,6 +52,7 @@ public class UserOverlay extends Overlay implements GeoPointLocationListener, Co
private CompasOverlay mCompass;
private boolean isCompassEnabled;
private boolean isGPSDialogEnabled;
private CompassListener mCompassListener;
/**
* Construct a new SkyHookUserOverlaymFollowUser
@@ -262,20 +263,21 @@ public class UserOverlay extends Overlay implements GeoPointLocationListener, Co
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();
}
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);
}
@@ -313,6 +315,8 @@ public class UserOverlay extends Overlay implements GeoPointLocationListener, Co
public void onCompassUpdate(float bearing) {
if(Debug.DEBUG)
Log.v(TAG, "onCompassUpdate()");
if(mCompassListener != null)
mCompassListener.onCompassUpdate(bearing);
mBearing = bearing;
mMapView.invalidate();
}
@@ -420,6 +424,14 @@ public class UserOverlay extends Overlay implements GeoPointLocationListener, Co
mCompass.setDrawables(needleResId, backgroundResId, x, y);
}
/**
* Sets the CompassListener
* @param listener
* @author ricky barrette
*/
public void setCompassListener(CompassListener listener){
mCompassListener = listener;
}
/**
* This thread is responsible for animating the user icon