Permalink
Browse files

Merge branch 'release/1.1'

  • Loading branch information...
2 parents fffe1d6 + d7638a0 commit b7af5368d0d1fd2cc24243386f800e946a2d226c Cyril Mottier committed Mar 7, 2013
View
@@ -1,7 +1,16 @@
Change Log
==========
-Version 1.0.1 *(2012-10-28)*
+Version 1.1 *(2013-03-07)*
+--------------------------
+
+- New API version: 2 (Californication)
+ * [get|set]MarkerHeight renamed to [get|set]BottomOffset
+ * [is|set]Actionnable renamed to [is|set]Interactive
+ * New `OnMapViewClickListener` to listen to taps
+- Fix: Incorrect measurement of the `MapCalloutDrawable` intrinsic height
+
+Version 1.0.1 *(2012-10-23)*
--------------------------
- General code and Javadoc cleanup
View
@@ -1,5 +1,6 @@
Polaris
=======
+_**Note**: Polaris relies on the Google Maps Android API v1 which as been [officially deprecated](https://developers.google.com/maps/documentation/android/v1/) as of December3rd, 2012. Because of this requirement, chances are high this library won't be updated is the future._
Polaris is a framework greatly enhancing the Google Maps external framework. It aims to:
@@ -19,8 +19,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cyrilmottier.polaris"
- android:versionCode="1"
- android:versionName="1.0" >
+ android:versionCode="2"
+ android:versionName="1.1" >
<uses-sdk android:minSdkVersion="7" />
@@ -26,6 +26,19 @@ private Build() {
}
/**
+ * Various version strings.
+ *
+ * @author Cyril Mottier
+ */
+ public static class VERSION {
+ /**
+ * The user-visible version of the library; its possible values are
+ * defined in {@link VERSION_CODES}.
+ */
+ public static final int LIBRARY = VERSION_CODES.CALIFORNICATION;
+ }
+
+ /**
* Enumeration of the currently known library version codes. These are the
* values that can be found in library. Version numbers increment
* monotonically with each official library release.
@@ -40,5 +53,7 @@ private Build() {
* version naming.
*/
public static final int BREAKING_BAD = 1;
+
+ public static final int CALIFORNICATION = 2;
}
}
@@ -181,7 +181,7 @@ protected void onBoundsChange(Rect bounds) {
@Override
public int getIntrinsicHeight() {
- return Math.max(mLeftCapDrawable.getIntrinsicWidth(),
+ return Math.max(mLeftCapDrawable.getIntrinsicHeight(),
Math.max(mBottomAnchorDrawable.getIntrinsicHeight(), mRightCapDrawable.getIntrinsicHeight()));
}
@@ -83,7 +83,7 @@
private int mInset;
private int mSpacing;
- private int mMarkerHeight;
+ private int mBottomOffset;
private int mAnchorMode = ANCHOR_MODE_VARIABLE;
private boolean mNeedRelayout;
@@ -176,7 +176,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
mCallout.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.getMode(widthMeasureSpec)),
MeasureSpec.makeMeasureSpec(heightSize, MeasureSpec.getMode(heightMeasureSpec)));
- setMeasuredDimension(mCallout.getMeasuredWidth() * widthCoeff, mCallout.getMeasuredHeight() + mMarkerHeight);
+ setMeasuredDimension(mCallout.getMeasuredWidth() * widthCoeff, mCallout.getMeasuredHeight() + mBottomOffset);
}
@Override
@@ -558,27 +558,45 @@ public boolean hasDisplayableContent() {
}
/**
- * Defines the height of the marker i.e. the dimension in pixels the callout
- * will be offset from the bottom.
- *
- * @return
+ * @deprecated use {@link #getBottomOffset()} instead
*/
+ @Deprecated
public int getMarkerHeight() {
- return mMarkerHeight;
+ return mBottomOffset;
}
/**
- * Defines the height of the marker i.e. the dimension in pixels the callout
- * will be offset from the bottom.
- *
- * @return The height (in pixels) of the pin.
+ * @deprecated use {@link #setBottomOffset(int)} instead
*/
+ @Deprecated
public void setMarkerHeight(int markerHeight) {
- if (markerHeight < 0) {
- markerHeight = 0;
+ setBottomOffset(markerHeight);
+ }
+
+ /**
+ * Return the dimension in pixels the callout will be offset from the
+ * bottom.
+ *
+ * @return The bottom offset in pixels
+ */
+ public int getBottomOffset() {
+ return mBottomOffset;
+ }
+
+ /**
+ * Define the dimension in pixels the callout will be offset from the
+ * bottom. This is usually used to offset the callout from the height of the
+ * marker so that it appears on top of it.
+ *
+ * @return The bottom offset (in pixels) the callout should be drawn
+ * regarding its normal Y-origin.
+ */
+ public void setBottomOffset(int bottomOffset) {
+ if (bottomOffset < 0) {
+ bottomOffset = 0;
}
- if (mMarkerHeight != markerHeight) {
- mMarkerHeight = markerHeight;
+ if (mBottomOffset != bottomOffset) {
+ mBottomOffset = bottomOffset;
requestLayout();
invalidate();
}
@@ -264,6 +264,10 @@ public void onAnnotationClicked(PolarisMapView mapView, MapCalloutView calloutVi
void onLongClick(PolarisMapView mapView, GeoPoint geoPoint);
}
+ public interface OnMapViewClickListener {
+ void onClick(PolarisMapView mapView, GeoPoint geoPoint);
+ }
+
/**
* Amount of time to display about 10 frames at 60Hz
*/
@@ -279,6 +283,7 @@ public void onAnnotationClicked(PolarisMapView mapView, MapCalloutView calloutVi
private OnAnnotationSelectionChangedListener mOnAnnotationSelectionChangedListener;
private OnRegionChangedListener mOnRegionChangedListener;
private OnMapViewLongClickListener mOnMapViewLongClickListener;
+ private OnMapViewClickListener mOnMapViewClickListener;
private OverlayContainer mOverlayContainer;
private MyLocationOverlay mMyLocationOverlay;
@@ -327,7 +332,7 @@ public PolarisMapView(Context context, String apiKey) {
@TargetApi(3)
private void init() {
setBuiltInZoomControls(!supportsMultiTouchZoom());
- setActionnable(true);
+ setInteractive(true);
mOverlayContainer = new OverlayContainer(getContext(), mMagnetoCallback);
getOverlays().add(mOverlayContainer);
@@ -497,6 +502,15 @@ public void setOnMapViewLongClickListener(OnMapViewLongClickListener l) {
}
/**
+ * Set a new {@link OnMapViewClickListener}.
+ *
+ * @param l The new {@link OnMapViewClickListener}
+ */
+ public void setOnMapViewClickListener(OnMapViewClickListener l) {
+ mOnMapViewClickListener = l;
+ }
+
+ /**
* Indicate whether user tracking is enabled or not. Having user tracking
* enabled will automatically add a {@link MyLocationOverlay} and a button
* on the upper-right corner to center the map back to the user's location.
@@ -546,25 +560,40 @@ public void setUserTrackingButtonEnabled(boolean enabled) {
}
/**
- * Indicates whether this {@link PolarisMapView} is actionnable (i.e. if it
+ * @deprecated Use {@link #isInteractive()} instead
+ */
+ public boolean isActionnable() {
+ return isInteractive();
+ }
+
+ /**
+ * @deprecated Use {@link #setInteractive(boolean)} instead
+ */
+ @Deprecated
+ public void setActionnable(boolean actionnable) {
+ setInteractive(actionnable);
+ }
+
+ /**
+ * Indicates whether this {@link PolarisMapView} is interactive (i.e. if it
* can be zoomed and panned by the user). More specifically, this method is
* a replacement for the {@link MapView#isClickable()}.
*
- * @return true if this {@link PolarisMapView} is actionnable, false
+ * @return true if this {@link PolarisMapView} is interactive, false
* otherwise
*/
- public boolean isActionnable() {
+ public boolean isInteractive() {
return isClickable();
}
/**
* Enables or disables action events for this view. When a
- * {@link PolarisMapView} is actionnable it will be zoomable and pannable.
+ * {@link PolarisMapView} is interactive it will be zoomable and pannable.
*
- * @param actionnable true to make the view actionnable, false otherwise
+ * @param actionnable true to make the view interactive, false otherwise
*/
- public void setActionnable(boolean actionnable) {
- setClickable(actionnable);
+ public void setInteractive(boolean interactive) {
+ setClickable(interactive);
}
// /**
@@ -795,7 +824,7 @@ public void showCallout(int position) {
if (marker != null) {
markerHeight = marker.getBounds().height();
}
- mapCalloutView.setMarkerHeight(markerHeight);
+ mapCalloutView.setBottomOffset(markerHeight);
if (mOnAnnotationSelectionChangedListener != null) {
//@formatter:off
@@ -818,19 +847,26 @@ public void showCallout(int position) {
@Override
public void onSimpleTap(MotionEvent e) {
setSelectedAnnotation(INVALID_POSITION);
+ if (mOnMapViewClickListener != null) {
+ mOnMapViewClickListener.onClick(PolarisMapView.this, getGeoPointForEvent(e));
+ }
}
@Override
public void onLongPress(MotionEvent e) {
if (mOnMapViewLongClickListener != null) {
- mOnMapViewLongClickListener.onLongClick(PolarisMapView.this, getProjection().fromPixels((int) e.getX(), (int) e.getY()));
+ mOnMapViewLongClickListener.onLongClick(PolarisMapView.this, getGeoPointForEvent(e));
}
}
@Override
public void onDoubleTap(MotionEvent e) {
getController().zoomInFixing((int) e.getX(), (int) e.getY());
}
+
+ private GeoPoint getGeoPointForEvent(MotionEvent e) {
+ return getProjection().fromPixels((int) e.getX(), (int) e.getY());
+ }
};
private final OnClickListener mOnClickListener = new OnClickListener() {
@@ -19,8 +19,8 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:drawable="@drawable/map_pin_holed_violet_alt" android:state_pressed="true"/>
- <item android:drawable="@drawable/map_pin_holed_violet_alt" android:state_focused="true"/>
- <item android:drawable="@drawable/map_pin_holed_violet_normal"/>
+ <item android:drawable="@drawable/map_pin_holed_purple_alt" android:state_pressed="true"/>
+ <item android:drawable="@drawable/map_pin_holed_purple_alt" android:state_focused="true"/>
+ <item android:drawable="@drawable/map_pin_holed_purple_normal"/>
</selector>
@@ -99,7 +99,7 @@ protected void onCreate(Bundle savedInstanceState) {
mMapView.setOnAnnotationSelectionChangedListener(this);
// Prepare an alternate pin Drawable
- final Drawable altMarker = MapViewUtils.boundMarkerCenterBottom(getResources().getDrawable(R.drawable.map_pin_holed_violet));
+ final Drawable altMarker = MapViewUtils.boundMarkerCenterBottom(getResources().getDrawable(R.drawable.map_pin_holed_purple));
// Prepare the list of Annotation using the alternate Drawable for all
// Annotation located in France

0 comments on commit b7af536

Please sign in to comment.