Merge branch 'release-ios-v3.5.0-android-v5.0.0' into boundsj-merge-release-branch

# Conflicts:
#	cmake/core-files.cmake
#	mapbox-gl-js
#	platform/android/CHANGELOG.md
#	platform/ios/CHANGELOG.md
#	platform/macos/CHANGELOG.md
#	platform/qt/bitrise-qt5.yml
#	src/mbgl/gl/attribute.hpp
#	src/mbgl/gl/context.cpp
#	src/mbgl/gl/program.hpp
#	src/mbgl/map/map.cpp
#	src/mbgl/programs/program.hpp
#	src/mbgl/renderer/painter.cpp
This commit is contained in:
Fabian Guerra
2017-04-11 21:46:23 -04:00
47 changed files with 566 additions and 598 deletions

View File

@@ -1,34 +0,0 @@
package com.mapbox.mapboxsdk.annotations;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ViewGroup;
import android.widget.FrameLayout;
/**
* ViewGroup that dispatches TouchEvents to the parent ViewGroup.
* <p>
* This allows to dispatch touch events that occur on MarkerView to MapView.
* https://github.com/mapbox/mapbox-gl-native/issues/5388
* </p>
*/
public class MarkerViewContainer extends FrameLayout {
public MarkerViewContainer(Context context, AttributeSet attrs) {
super(context, attrs);
setTag(false);
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
super.dispatchTouchEvent(ev);
boolean actionUp = (boolean) getTag();
if (!actionUp) {
((ViewGroup) getParent()).onTouchEvent(ev);
} else {
setTag(false);
}
return true;
}
}

View File

@@ -8,7 +8,6 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.util.LongSparseArray;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
@@ -505,26 +504,6 @@ public class MarkerViewManager implements MapView.OnMapChangedListener {
}
}
adaptedView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
boolean clickHandled = false;
if (onMarkerViewClickListener != null) {
clickHandled = onMarkerViewClickListener.onMarkerClick(marker, v, adapter);
markerViewContainer.setTag(true);
}
if (!clickHandled) {
ensureInfoWindowOffset(marker);
select(marker, v, adapter);
}
}
return true;
}
});
marker.setMapboxMap(mapboxMap);
markerViewMap.put(marker, adaptedView);
if (convertView == null) {
@@ -552,6 +531,34 @@ public class MarkerViewManager implements MapView.OnMapChangedListener {
updateMarkerViewsPosition();
}
/**
* When the provided {@link MarkerView} is clicked on by a user, we check if a custom click
* event has been created and if not, display a {@link InfoWindow}.
*
* @param markerView that the click event occurred.
*/
public boolean onClickMarkerView(MarkerView markerView) {
boolean clickHandled = false;
MapboxMap.MarkerViewAdapter adapter = getViewAdapter(markerView);
View view = getView(markerView);
if (adapter == null || view == null) {
// not a valid state
return true;
}
if (onMarkerViewClickListener != null) {
clickHandled = onMarkerViewClickListener.onMarkerClick(markerView, view, adapter);
}
if (!clickHandled) {
ensureInfoWindowOffset(markerView);
select(markerView, view, adapter);
}
return clickHandled;
}
/**
* Handles the {@link MarkerView}'s info window offset.
*

View File

@@ -293,7 +293,7 @@ public final class CameraPosition implements Parcelable {
* Set the tilt in degrees
* <p>
* value is clamped to 0 and 60.
* <p/>
* </p>
*
* @param tilt Tilt value
* @return Builder

View File

@@ -18,11 +18,10 @@ import java.lang.ref.WeakReference;
/**
* Manages locational updates. Contains methods to register and unregister location listeners.
* <ul>
* <li>You can register a {@link LocationEngineListener} with
* {@link #addLocationEngineListener(LocationEngineListener)} to receive
* location updates.</li>
* <li> You can unregister a {@link LocationEngineListener} with
* {@link #removeLocationEngineListener(LocationEngineListener)} to stop receiving location updates.</li>
* <li>You can register a LocationEngineListener with LocationSource#addLocationEngineListener(LocationEngineListener)
* to receive location updates.</li>
* <li> You can unregister a LocationEngineListener with
* LocationEngine#removeLocationEngineListener(LocationEngineListener)} to stop receiving location updates.</li>
* </ul>
* <p>
* Note: If registering a listener in your Activity.onStart() implementation, you should unregister it in

View File

@@ -10,7 +10,6 @@ import com.mapbox.mapboxsdk.annotations.Annotation;
import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions;
import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions;
import com.mapbox.mapboxsdk.annotations.Icon;
import com.mapbox.mapboxsdk.annotations.IconFactory;
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.MarkerView;
import com.mapbox.mapboxsdk.annotations.MarkerViewManager;
@@ -257,11 +256,7 @@ class AnnotationManager {
private MarkerView prepareViewMarker(BaseMarkerViewOptions markerViewOptions) {
MarkerView marker = markerViewOptions.getMarker();
Icon icon = markerViewOptions.getIcon();
if (icon == null) {
icon = IconFactory.getInstance(mapView.getContext()).defaultMarkerView();
}
marker.setIcon(icon);
iconManager.loadIconForMarkerView(marker);
return marker;
}
@@ -665,16 +660,24 @@ class AnnotationManager {
if (annotation.getId() == newSelectedMarkerId) {
Marker marker = (Marker) annotation;
if (!(marker instanceof MarkerView)) {
if (marker instanceof MarkerView) {
handledDefaultClick = markerViewManager.onClickMarkerView((MarkerView) marker);
} else {
if (onMarkerClickListener != null) {
// end developer has provided a custom click listener
handledDefaultClick = onMarkerClickListener.onMarkerClick(marker);
}
}
if (annotation instanceof MarkerView) {
markerViewManager.onClickMarkerView((MarkerView) annotation);
} else {
if (!handledDefaultClick) {
// only select marker if user didn't handle the click event themselves
selectMarker(marker);
}
}
return true;
}
}

View File

@@ -71,6 +71,27 @@ class IconManager {
return icon;
}
Icon loadIconForMarkerView(MarkerView marker) {
Icon icon = marker.getIcon();
int iconSize = icons.size() + 1;
if (icon == null) {
icon = IconFactory.getInstance(nativeMapView.getContext()).defaultMarkerView();
marker.setIcon(icon);
}
Bitmap bitmap = icon.getBitmap();
averageIconHeight = averageIconHeight + (bitmap.getHeight() - averageIconHeight) / iconSize;
averageIconWidth = averageIconWidth + (bitmap.getWidth() - averageIconWidth) / iconSize;
if (!icons.contains(icon)) {
icons.add(icon);
} else {
Icon oldIcon = icons.get(icons.indexOf(icon));
if (!oldIcon.getBitmap().sameAs(icon.getBitmap())) {
throw new IconBitmapChangedException();
}
}
return icon;
}
int getTopOffsetPixelsForIcon(Icon icon) {
return (int) (nativeMapView.getTopOffsetPixelsForAnnotationSymbol(icon.getId()) * nativeMapView.getPixelRatio());
}

View File

@@ -42,7 +42,7 @@ public class GeoJsonSource extends Source {
}
/**
* Create an empty GeoJsonSource with non-default {@link GeoJsonOptions}
* Create an empty GeoJsonSource with non-default GeoJsonOptions.
*
* @param id the source id
* @param options options
@@ -67,7 +67,7 @@ public class GeoJsonSource extends Source {
}
/**
* Create a GeoJsonSource from a raw json string and non-default {@link GeoJsonOptions}
* Create a GeoJsonSource from a raw json string and non-default GeoJsonOptions
*
* @param id the source id
* @param geoJson raw Json body
@@ -93,7 +93,7 @@ public class GeoJsonSource extends Source {
}
/**
* Create a GeoJsonSource from a remote geo json file and non-default {@link GeoJsonOptions}
* Create a GeoJsonSource from a remote geo json file and non-default GeoJsonOptions
*
* @param id the source id
* @param url remote json file
@@ -105,7 +105,7 @@ public class GeoJsonSource extends Source {
}
/**
* Create a GeoJsonSource from a {@link FeatureCollection}
* Create a GeoJsonSource from a FeatureCollection.
*
* @param id the source id
* @param features the features
@@ -116,7 +116,7 @@ public class GeoJsonSource extends Source {
}
/**
* Create a GeoJsonSource from a {@link FeatureCollection} and non-default {@link GeoJsonOptions}
* Create a GeoJsonSource from a FeatureCollection and non-default GeoJsonOptions.
*
* @param id the source id
* @param features the features
@@ -194,7 +194,7 @@ public class GeoJsonSource extends Source {
/**
* Updates the GeoJson
*
* @param features the GeoJSON {@link FeatureCollection}
* @param features the GeoJSON FeatureCollection
*/
public void setGeoJson(FeatureCollection features) {
nativeSetFeatureCollection(features);