Skip to content

Commit

Permalink
Merge branch 'release/1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyril Mottier committed Mar 7, 2013
2 parents fffe1d6 + d7638a0 commit b7af536
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 33 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
@@ -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
Expand Down
1 change: 1 addition & 0 deletions README.md
@@ -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:

Expand Down
4 changes: 2 additions & 2 deletions library/AndroidManifest.xml
Expand Up @@ -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" />

Expand Down
15 changes: 15 additions & 0 deletions library/src/com/cyrilmottier/polaris/Build.java
Expand Up @@ -25,6 +25,19 @@ public final class Build {
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
Expand All @@ -40,5 +53,7 @@ public static class VERSION_CODES {
* version naming.
*/
public static final int BREAKING_BAD = 1;

public static final int CALIFORNICATION = 2;
}
}
Expand Up @@ -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()));
}

Expand Down
48 changes: 33 additions & 15 deletions library/src/com/cyrilmottier/polaris/MapCalloutView.java
Expand Up @@ -83,7 +83,7 @@ public interface OnDoubleTapListener {

private int mInset;
private int mSpacing;
private int mMarkerHeight;
private int mBottomOffset;
private int mAnchorMode = ANCHOR_MODE_VARIABLE;

private boolean mNeedRelayout;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
}
Expand Down
56 changes: 46 additions & 10 deletions library/src/com/cyrilmottier/polaris/PolarisMapView.java
Expand Up @@ -264,6 +264,10 @@ public interface OnMapViewLongClickListener {
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
*/
Expand All @@ -279,6 +283,7 @@ public interface OnMapViewLongClickListener {
private OnAnnotationSelectionChangedListener mOnAnnotationSelectionChangedListener;
private OnRegionChangedListener mOnRegionChangedListener;
private OnMapViewLongClickListener mOnMapViewLongClickListener;
private OnMapViewClickListener mOnMapViewClickListener;

private OverlayContainer mOverlayContainer;
private MyLocationOverlay mMyLocationOverlay;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -496,6 +501,15 @@ public void setOnMapViewLongClickListener(OnMapViewLongClickListener l) {
mOnMapViewLongClickListener = 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
Expand Down Expand Up @@ -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);
}

// /**
Expand Down Expand Up @@ -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
Expand All @@ -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() {
Expand Down
Expand Up @@ -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>
Expand Up @@ -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
Expand Down

0 comments on commit b7af536

Please sign in to comment.