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
|
Before Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 9.1 KiB |
|
Before Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 136 KiB |
|
Before Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 825 B |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
@@ -16,19 +16,23 @@ public final class R {
|
|||||||
public static int compass_med=0x7f020002;
|
public static int compass_med=0x7f020002;
|
||||||
public static int compass_sm=0x7f020003;
|
public static int compass_sm=0x7f020003;
|
||||||
public static int logoidea3=0x7f020004;
|
public static int logoidea3=0x7f020004;
|
||||||
public static int needle=0x7f020005;
|
public static int map_action_bar=0x7f020005;
|
||||||
public static int needle_lrg=0x7f020006;
|
public static int map_mode_action_bar=0x7f020006;
|
||||||
public static int needle_med=0x7f020007;
|
public static int mark_my_location_action_bar=0x7f020007;
|
||||||
public static int needle_sm=0x7f020008;
|
public static int my_location_action_bar=0x7f020008;
|
||||||
public static int skyhook_logo=0x7f020009;
|
public static int nav_action_bar=0x7f020009;
|
||||||
public static int skyhook_logo_alpha=0x7f02000a;
|
public static int needle=0x7f02000a;
|
||||||
public static int skyhook_logo_alpha_small=0x7f02000b;
|
public static int needle_lrg=0x7f02000b;
|
||||||
public static int tc_logo_complete=0x7f02000c;
|
public static int needle_med=0x7f02000c;
|
||||||
public static int user=0x7f02000d;
|
public static int needle_sm=0x7f02000d;
|
||||||
public static int user_arrow_animation_1=0x7f02000e;
|
public static int skyhook_logo=0x7f02000e;
|
||||||
public static int user_arrow_animation_2=0x7f02000f;
|
public static int skyhook_logo_alpha=0x7f02000f;
|
||||||
public static int user_arrow_animation_3=0x7f020010;
|
public static int skyhook_logo_alpha_small=0x7f020010;
|
||||||
public static int userarrow=0x7f020011;
|
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 final class id {
|
||||||
public static int skyhook_img=0x7f050000;
|
public static int skyhook_img=0x7f050000;
|
||||||
|
|||||||
4
LocationLib/res/drawable-hdpi/.directory
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
[Dolphin]
|
||||||
|
ShowPreview=true
|
||||||
|
Timestamp=2011,12,8,10,59,54
|
||||||
|
Version=2
|
||||||
BIN
LocationLib/res/drawable-hdpi/map_action_bar.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
LocationLib/res/drawable-hdpi/map_mode_action_bar.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
LocationLib/res/drawable-hdpi/mark_my_location_action_bar.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
LocationLib/res/drawable-hdpi/my_location_action_bar.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
LocationLib/res/drawable-hdpi/nav_action_bar.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
4
LocationLib/res/drawable-ldpi/.directory
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
[Dolphin]
|
||||||
|
ShowPreview=true
|
||||||
|
Timestamp=2011,12,8,10,59,27
|
||||||
|
Version=2
|
||||||
BIN
LocationLib/res/drawable-ldpi/map_action_bar.png
Normal file
|
After Width: | Height: | Size: 621 B |
BIN
LocationLib/res/drawable-ldpi/map_mode_action_bar.png
Normal file
|
After Width: | Height: | Size: 529 B |
BIN
LocationLib/res/drawable-ldpi/mark_my_location_action_bar.png
Normal file
|
After Width: | Height: | Size: 569 B |
BIN
LocationLib/res/drawable-ldpi/my_location_action_bar.png
Normal file
|
After Width: | Height: | Size: 603 B |
BIN
LocationLib/res/drawable-ldpi/nav_action_bar.png
Normal file
|
After Width: | Height: | Size: 713 B |
4
LocationLib/res/drawable-mdpi/.directory
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
[Dolphin]
|
||||||
|
ShowPreview=true
|
||||||
|
Timestamp=2011,12,8,10,59,43
|
||||||
|
Version=2
|
||||||
BIN
LocationLib/res/drawable-mdpi/map_action_bar.png
Normal file
|
After Width: | Height: | Size: 823 B |
BIN
LocationLib/res/drawable-mdpi/map_mode_action_bar.png
Normal file
|
After Width: | Height: | Size: 752 B |
BIN
LocationLib/res/drawable-mdpi/mark_my_location_action_bar.png
Normal file
|
After Width: | Height: | Size: 743 B |
BIN
LocationLib/res/drawable-mdpi/my_location_action_bar.png
Normal file
|
After Width: | Height: | Size: 769 B |
BIN
LocationLib/res/drawable-mdpi/nav_action_bar.png
Normal file
|
After Width: | Height: | Size: 1009 B |
4
LocationLib/res/drawable-xhdpi/.directory
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
[Dolphin]
|
||||||
|
ShowPreview=true
|
||||||
|
Timestamp=2011,12,8,11,0,5
|
||||||
|
Version=2
|
||||||
BIN
LocationLib/res/drawable-xhdpi/map_action_bar.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
LocationLib/res/drawable-xhdpi/map_mode_action_bar.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
LocationLib/res/drawable-xhdpi/mark_my_location_action_bar.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
LocationLib/res/drawable-xhdpi/my_location_action_bar.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
LocationLib/res/drawable-xhdpi/nav_action_bar.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
@@ -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>
|
|
||||||
@@ -91,22 +91,6 @@ public class CompasOverlay extends Overlay implements CompassListener {
|
|||||||
this(context, null, needleResId, backgroundResId, x, y);
|
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
|
* Converts dip to px
|
||||||
* @param dip
|
* @param dip
|
||||||
@@ -152,7 +136,7 @@ public class CompasOverlay extends Overlay implements CompassListener {
|
|||||||
//draw the compass needle
|
//draw the compass needle
|
||||||
Bitmap arrowBitmap = BitmapFactory.decodeResource( mContext.getResources(), mNeedleResId);
|
Bitmap arrowBitmap = BitmapFactory.decodeResource( mContext.getResources(), mNeedleResId);
|
||||||
Matrix matrix = new Matrix();
|
Matrix matrix = new Matrix();
|
||||||
matrix.postRotate(calculateBearing());
|
matrix.postRotate(GeoUtils.calculateBearing(mLocation, mDestination, mBearing));
|
||||||
Bitmap rotatedBmp = Bitmap.createBitmap(
|
Bitmap rotatedBmp = Bitmap.createBitmap(
|
||||||
arrowBitmap,
|
arrowBitmap,
|
||||||
0, 0,
|
0, 0,
|
||||||
|
|||||||
@@ -37,6 +37,30 @@ public class GeoUtils {
|
|||||||
|
|
||||||
public static final int EARTH_RADIUS_KM = 6371;
|
public static final int EARTH_RADIUS_KM = 6371;
|
||||||
public static final double MILLION = 1000000;
|
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
|
* 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 lon1 source lon
|
||||||
* @param lat2 destination lat
|
* @param lat2 destination lat
|
||||||
* @param lon2 destination lon
|
* @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.
|
* @author Google Inc.
|
||||||
*/
|
*/
|
||||||
public static double bearing(double lat1, double lon1, double lat2, double lon2) {
|
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 p1 source geopoint
|
||||||
* @param p2 destination geopoint
|
* @param p2 destination geopoint
|
||||||
* @return the bearing of p2 in relationship from p1 in degrees East
|
* @return the bearing of p2 in relationship from p1 in degrees East
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ public class UserOverlay extends Overlay implements GeoPointLocationListener, Co
|
|||||||
private CompasOverlay mCompass;
|
private CompasOverlay mCompass;
|
||||||
private boolean isCompassEnabled;
|
private boolean isCompassEnabled;
|
||||||
private boolean isGPSDialogEnabled;
|
private boolean isGPSDialogEnabled;
|
||||||
|
private CompassListener mCompassListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new SkyHookUserOverlaymFollowUser
|
* Construct a new SkyHookUserOverlaymFollowUser
|
||||||
@@ -262,20 +263,21 @@ public class UserOverlay extends Overlay implements GeoPointLocationListener, Co
|
|||||||
new Handler().postAtTime(new Runnable() {
|
new Handler().postAtTime(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (mGPSprogress.isShowing()) {
|
if(mGPSprogress != null)
|
||||||
mGPSprogress.cancel();
|
if (mGPSprogress.isShowing()) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
|
mGPSprogress.cancel();
|
||||||
builder.setMessage(
|
AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
|
||||||
mContext.getText(R.string.sorry_theres_trouble))
|
builder.setMessage(
|
||||||
.setCancelable(false)
|
mContext.getText(R.string.sorry_theres_trouble))
|
||||||
.setPositiveButton(mContext.getText(android.R.string.ok),
|
.setCancelable(false)
|
||||||
new DialogInterface.OnClickListener() {
|
.setPositiveButton(mContext.getText(android.R.string.ok),
|
||||||
public void onClick( DialogInterface dialog, int id) {
|
new DialogInterface.OnClickListener() {
|
||||||
dialog.cancel();
|
public void onClick( DialogInterface dialog, int id) {
|
||||||
}
|
dialog.cancel();
|
||||||
});
|
}
|
||||||
builder.show();
|
});
|
||||||
}
|
builder.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, SystemClock.uptimeMillis()+90000L);
|
}, SystemClock.uptimeMillis()+90000L);
|
||||||
}
|
}
|
||||||
@@ -313,6 +315,8 @@ public class UserOverlay extends Overlay implements GeoPointLocationListener, Co
|
|||||||
public void onCompassUpdate(float bearing) {
|
public void onCompassUpdate(float bearing) {
|
||||||
if(Debug.DEBUG)
|
if(Debug.DEBUG)
|
||||||
Log.v(TAG, "onCompassUpdate()");
|
Log.v(TAG, "onCompassUpdate()");
|
||||||
|
if(mCompassListener != null)
|
||||||
|
mCompassListener.onCompassUpdate(bearing);
|
||||||
mBearing = bearing;
|
mBearing = bearing;
|
||||||
mMapView.invalidate();
|
mMapView.invalidate();
|
||||||
}
|
}
|
||||||
@@ -420,6 +424,14 @@ public class UserOverlay extends Overlay implements GeoPointLocationListener, Co
|
|||||||
mCompass.setDrawables(needleResId, backgroundResId, x, y);
|
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
|
* This thread is responsible for animating the user icon
|
||||||
|
|||||||