From 50297a5ad16fad6b7928538c3700653ad81f49ff Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Thu, 26 May 2016 11:13:44 -0500 Subject: [PATCH 01/41] [android] #5160 - Setting Android Version to 4.1.0-beta.1 --- platform/android/MapboxGLAndroidSDK/gradle.properties | 2 +- .../fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/gradle.properties b/platform/android/MapboxGLAndroidSDK/gradle.properties index c2df63b0b..5b723120c 100644 --- a/platform/android/MapboxGLAndroidSDK/gradle.properties +++ b/platform/android/MapboxGLAndroidSDK/gradle.properties @@ -1,5 +1,5 @@ GROUP=com.mapbox.mapboxsdk -VERSION_NAME=4.1.0-SNAPSHOT +VERSION_NAME=4.1.0-beta.1 POM_DESCRIPTION=Mapbox GL Android SDK POM_URL=https://github.com/mapbox/mapbox-gl-native diff --git a/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties b/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties index 8c1dcc38c..652ce3ec5 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties +++ b/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties @@ -1,3 +1,3 @@ fabric-identifier=com.mapbox.mapboxsdk.mapbox-android-sdk -fabric-version=4.0.0 +fabric-version=4.1.0-beta.1 fabric-build-type=binary From 7315a353aa8958e20e49e4c0383b96800e71f953 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Thu, 26 May 2016 12:17:26 -0500 Subject: [PATCH 02/41] [android] #5160 - Fixing JavaDoc markup --- .../com/mapbox/mapboxsdk/constants/Style.java | 14 +------------- .../mapboxsdk/location/LocationServices.java | 2 -- .../com/mapbox/mapboxsdk/maps/MapView.java | 2 +- .../com/mapbox/mapboxsdk/maps/MapboxMap.java | 18 ++++++++++-------- 4 files changed, 12 insertions(+), 24 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java index aa24d5865..3fdff5a7c 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java @@ -47,11 +47,9 @@ public class Style { /** * Get versioned url of Mapbox streets style. - *

*

+ * *

* More information on the Mapbox styles API can be found on https://www.mapbox.com/api-documentation/#styles *

@@ -65,11 +63,9 @@ public class Style { /** * Get versioned url of Outdoors streets style. - *

*

- *

*

* More information on the Mapbox styles API can be found on https://www.mapbox.com/api-documentation/#styles *

@@ -83,11 +79,9 @@ public class Style { /** * Get versioned url of Light style. - *

*

- *

*

* More information on the Mapbox styles API can be found on https://www.mapbox.com/api-documentation/#styles *

@@ -101,11 +95,9 @@ public class Style { /** * Get versioned url of Dark style. - *

*

- *

*

* More information on the Mapbox styles API can be found on https://www.mapbox.com/api-documentation/#styles *

@@ -119,11 +111,9 @@ public class Style { /** * Get versioned url of Satellite style. - *

*

- *

*

* More information on the Mapbox styles API can be found on https://www.mapbox.com/api-documentation/#styles *

@@ -137,11 +127,9 @@ public class Style { /** * Get versioned url of Satellite streets style. - *

*

- *

*

* More information on the Mapbox styles API can be found on https://www.mapbox.com/api-documentation/#styles *

diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationServices.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationServices.java index e45f3cc71..2f1be900e 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationServices.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationServices.java @@ -18,12 +18,10 @@ import java.util.concurrent.CopyOnWriteArrayList; /** * Manages locational updates. Contains methods to register and unregister location listeners. - *

*

- *

*

* Note: If registering a listener in your Activity.onResume() implementation, you should unregister it in Activity.onPause(). * (You won't receive location updates when paused, and this will cut down on unnecessary system overhead). diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java index 403f58153..36ecece61 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java @@ -874,7 +874,7 @@ public class MapView extends FrameLayout { *

* DEPRECATED @see MapboxAccountManager#getAccessToken() *

- *

+ *

* Returns the current Mapbox access token used to load map styles and tiles. *

* diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java index 62cb74979..19cd2aebc 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java @@ -291,7 +291,7 @@ public class MapboxMap { * it will return the current location of the camera in flight. * * @param update The change that should be applied to the camera. - * @see {@link CameraUpdateFactory} for a set of updates. + * @see com.mapbox.mapboxsdk.camera.CameraUpdateFactory for a set of updates. */ @UiThread public final void easeCamera(CameraUpdate update) { @@ -306,7 +306,7 @@ public class MapboxMap { * @param update The change that should be applied to the camera. * @param durationMs The duration of the animation in milliseconds. This must be strictly * positive, otherwise an IllegalArgumentException will be thrown. - * @see {@link CameraUpdateFactory} for a set of updates. + * @see com.mapbox.mapboxsdk.camera.CameraUpdateFactory for a set of updates. */ @UiThread public final void easeCamera(CameraUpdate update, int durationMs) { @@ -327,7 +327,7 @@ public class MapboxMap { * will be notified with onFinish(). If the animation stops due to interruption * by a later camera movement or a user gesture, onCancel() will be called. * Do not update or ease the camera from within onCancel(). - * @see {@link CameraUpdateFactory} for a set of camera updates. + * @see com.mapbox.mapboxsdk.camera.CameraUpdateFactory for a set of updates. */ @UiThread public final void easeCamera(CameraUpdate update, int durationMs, final MapboxMap.CancelableCallback callback) { @@ -368,7 +368,7 @@ public class MapboxMap { * of the camera in flight. * * @param update The change that should be applied to the camera. - * @see {@link CameraUpdateFactory} for a set of updates. + * @see com.mapbox.mapboxsdk.camera.CameraUpdateFactory for a set of updates. */ @UiThread public final void animateCamera(CameraUpdate update) { @@ -385,7 +385,7 @@ public class MapboxMap { * @param callback The callback to invoke from the main thread when the animation stops. If the * animation completes normally, onFinish() is called; otherwise, onCancel() is * called. Do not update or animate the camera from within onCancel(). - * @see {@link CameraUpdateFactory} for a set of updates. + * @see com.mapbox.mapboxsdk.camera.CameraUpdateFactory for a set of updates. */ @UiThread public final void animateCamera(CameraUpdate update, MapboxMap.CancelableCallback callback) { @@ -401,7 +401,7 @@ public class MapboxMap { * @param update The change that should be applied to the camera. * @param durationMs The duration of the animation in milliseconds. This must be strictly * positive, otherwise an IllegalArgumentException will be thrown. - * @see {@link CameraUpdateFactory} for a set of updates. + * @see com.mapbox.mapboxsdk.camera.CameraUpdateFactory for a set of updates. */ @UiThread public final void animateCamera(CameraUpdate update, int durationMs) { @@ -424,7 +424,7 @@ public class MapboxMap { * by a later camera movement or a user gesture, onCancel() will be called. * Do not update or animate the camera from within onCancel(). If a callback * isn't required, leave it as null. - * @see {@link CameraUpdateFactory} for a set of updates. + * @see com.mapbox.mapboxsdk.camera.CameraUpdateFactory for a set of updates. */ @UiThread public final void animateCamera(CameraUpdate update, int durationMs, final MapboxMap.CancelableCallback callback) { @@ -1282,9 +1282,11 @@ public class MapboxMap { // /** + *

* Sets the distance from the edges of the map view’s frame to the edges of the map * view’s logical viewport. - *

+ *

+ *

* When the value of this property is equal to {0,0,0,0}, viewport * properties such as `centerCoordinate` assume a viewport that matches the map * view’s frame. Otherwise, those properties are inset, excluding part of the From ee93e600978d9990ccddb189b95573d960845947 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Thu, 26 May 2016 13:49:12 -0500 Subject: [PATCH 03/41] [android] #5160 - CHANGELOG for 4.1.0-beta.1 --- platform/android/CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/platform/android/CHANGELOG.md b/platform/android/CHANGELOG.md index f73c5ba19..c7eb4f5b9 100644 --- a/platform/android/CHANGELOG.md +++ b/platform/android/CHANGELOG.md @@ -2,6 +2,14 @@ Mapbox welcomes participation and contributions from everyone. If you'd like to do so please see the [`Contributing Guide`](https://github.com/mapbox/mapbox-gl-native/blob/master/CONTRIBUTING.md) first to get started. +## 4.1.0-beta.1 + +Mapbox Android 4.1.0 builds off our ambitious 4.0.0 version with 3 major new features being released. To help us produce the highest quality SDK possible we're releasing an official Beta release first so that everyone has time to explore it and help hardened it before the official 4.1.0 Final Release. + +* View Based Annotations ([#3276](https://github.com/mapbox/mapbox-gl-native/issues/3276)) +* UserLocationView Refactor ([#4396](https://github.com/mapbox/mapbox-gl-native/issues/4396)) +* MapboxAccountManager ([#5004](https://github.com/mapbox/mapbox-gl-native/issues/5004)) + ## 4.0.1 Mapbox Android 4.0.1 is a patch release to make this bug fix available sooner. From 9b8951e09d596d3d3e847a2f5765bb7017b24572 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Thu, 26 May 2016 14:49:39 -0500 Subject: [PATCH 04/41] [android] #5160 - Setting Version Back To 4.1.0-SNAPSHOT --- platform/android/MapboxGLAndroidSDK/gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/android/MapboxGLAndroidSDK/gradle.properties b/platform/android/MapboxGLAndroidSDK/gradle.properties index 5b723120c..c2df63b0b 100644 --- a/platform/android/MapboxGLAndroidSDK/gradle.properties +++ b/platform/android/MapboxGLAndroidSDK/gradle.properties @@ -1,5 +1,5 @@ GROUP=com.mapbox.mapboxsdk -VERSION_NAME=4.1.0-beta.1 +VERSION_NAME=4.1.0-SNAPSHOT POM_DESCRIPTION=Mapbox GL Android SDK POM_URL=https://github.com/mapbox/mapbox-gl-native From f75b4f15dd33be3bcd30ec0138f06b1441469987 Mon Sep 17 00:00:00 2001 From: Tobrun Van Nuland Date: Thu, 26 May 2016 17:47:52 +0200 Subject: [PATCH 05/41] [android] #5113 - added javadoc for MarkerViewManager --- .../annotations/MarkerViewManager.java | 117 +++++++++++++++++- .../com/mapbox/mapboxsdk/maps/MapView.java | 2 +- 2 files changed, 112 insertions(+), 7 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java index fcb7894d1..03d554656 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java @@ -18,6 +18,12 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +/** + * Interface for interacting with ViewMarkers objects inside of a MapView. + *

+ * This class is responsible for managing a {@link MarkerView} item. + *

+ */ public class MarkerViewManager { private Map mMarkerViewMap; @@ -27,6 +33,12 @@ public class MarkerViewManager { private long mViewMarkerBoundsUpdateTime; private MapboxMap.OnMarkerViewClickListener onMarkerViewClickListener; + /** + * Creates an instance of MarkerViewManager. + * + * @param mapboxMap the MapboxMap associated with the MarkerViewManager + * @param mapView the MapView associarted with the MarkerViewManager + */ public MarkerViewManager(@NonNull MapboxMap mapboxMap, @NonNull MapView mapView) { this.mapboxMap = mapboxMap; this.markerViewAdapters = new ArrayList<>(); @@ -34,6 +46,15 @@ public class MarkerViewManager { mMarkerViewMap = new HashMap<>(); } + /** + * Animate a MarkerView to a given rotation. + *

+ * The {@link MarkerView} will be rotated from its current rotation to the given rotation. + *

+ * + * @param marker the MarkerView to rotate + * @param rotation the rotation value + */ public void animateRotation(@NonNull MarkerView marker, float rotation) { View convertView = mMarkerViewMap.get(marker); if (convertView != null) { @@ -41,6 +62,15 @@ public class MarkerViewManager { } } + /** + * Animate a MarkerView to a given alpha value. + *

+ * The {@link MarkerView} will be transformed from its current alpha value to the given value. + *

+ * + * @param marker the MarkerView to change its alpha value + * @param alpha the alpha value + */ public void animateAlpha(@NonNull MarkerView marker, float alpha) { View convertView = mMarkerViewMap.get(marker); if (convertView != null) { @@ -48,6 +78,15 @@ public class MarkerViewManager { } } + /** + * Animate a MarkerVIew to be visible or invisible + *

+ * The {@link MarkerView} will be made {@link View#VISIBLE} or {@link View#GONE}. + *

+ * + * @param marker the MarkerView to change its visibility + * @param visible the flag indicating if MarkerView is visible + */ public void animateVisible(@NonNull MarkerView marker, boolean visible) { View convertView = mMarkerViewMap.get(marker); if (convertView != null) { @@ -55,6 +94,14 @@ public class MarkerViewManager { } } + /** + * Updates the position of MarkerViews currently found in the viewport. + *

+ * The collection of {@link MarkerView} will be iterated and each item position will be updated. + * If an item is View state is not visible and its related flag is set to visible, + * The {@link MarkerView} will be animated to visible using alpha animation. + *

+ */ public void update() { View convertView; for (MarkerView marker : mMarkerViewMap.keySet()) { @@ -63,8 +110,10 @@ public class MarkerViewManager { PointF point = mapboxMap.getProjection().toScreenLocation(marker.getPosition()); int x = (int) (marker.getAnchorU() * convertView.getMeasuredWidth()); int y = (int) (marker.getAnchorV() * convertView.getMeasuredHeight()); + marker.setOffsetX(x); marker.setOffsetY(y); + convertView.setX(point.x - x); convertView.setY(point.y - y); @@ -77,6 +126,11 @@ public class MarkerViewManager { } } + /** + * Set tilt on every non flat MarkerView currently shown in the Viewport. + * + * @param tilt the tilt value + */ public void setTilt(float tilt) { View convertView; for (MarkerView markerView : mMarkerViewMap.keySet()) { @@ -90,6 +144,15 @@ public class MarkerViewManager { } } + /** + * Animate a MarkerView to a deselected state. + *

+ * The {@link MarkerView#getDeselectAnimRes()} will be called to get the related animation. + * If non are provided, no animation will be started. + *

+ * + * @param marker the MarkerView to deselect + */ public void deselect(@NonNull MarkerView marker) { final View convertView = mMarkerViewMap.get(marker); if (convertView != null) { @@ -100,6 +163,18 @@ public class MarkerViewManager { } } + /** + * Remove a MarkerView from a map. + *

+ * The {@link MarkerView} will be removed using an alpha animation and related {@link View} + * will be released to the {@link android.support.v4.util.Pools.SimplePool} from the related + * {@link com.mapbox.mapboxsdk.maps.MapboxMap.MarkerViewAdapter}. It's possible to remove + * the {@link MarkerView} from the underlying collection if needed. + *

+ * + * @param marker the MarkerView to remove + * @param removeFromMap flag indicating if a MarkerView will be removed from the collection. + */ public void removeMarkerView(MarkerView marker, boolean removeFromMap) { final View viewHolder = mMarkerViewMap.get(marker); if (viewHolder != null && marker != null) { @@ -127,6 +202,11 @@ public class MarkerViewManager { } } + /** + * Add a MarkerViewAdapter. + * + * @param markerViewAdapter the MarkerViewAdapter to add + */ public void addMarkerViewAdapter(@Nullable MapboxMap.MarkerViewAdapter markerViewAdapter) { if (!markerViewAdapters.contains(markerViewAdapter)) { markerViewAdapters.add(markerViewAdapter); @@ -134,15 +214,33 @@ public class MarkerViewManager { } } - public void setOnMarkerViewClickListener(@Nullable MapboxMap.OnMarkerViewClickListener listener) { - onMarkerViewClickListener = listener; - } - + /** + * Get all MarkerViewAdapters associated with this MarkerViewManager. + * + * @return a List of MarkerViewAdapters + */ public List getMarkerViewAdapters() { return markerViewAdapters; } - public void invalidateViewMarkers() { + + /** + * Register a callback to be invoked when this view is clicked. + * + * @param listener the callback to be invoked + */ + public void setOnMarkerViewClickListener(@Nullable MapboxMap.OnMarkerViewClickListener listener) { + onMarkerViewClickListener = listener; + } + + /** + * Schedule that ViewMarkers found in the viewport are invalidated. + *

+ * This method is rate limited, and {@link #invalidateViewMarkersInBounds} will only be called + * once each 250 ms. + *

+ */ + public void scheduleViewMarkerInvalidation() { if (!markerViewAdapters.isEmpty()) { long currentTime = SystemClock.elapsedRealtime(); if (currentTime < mViewMarkerBoundsUpdateTime) { @@ -153,6 +251,13 @@ public class MarkerViewManager { } } + /** + * Invalidate the ViewMarkers found in the viewport. + *

+ * This method will remove any markers that aren't in the viewport any more and will add new + * ones for each found Marker in the changed viewport. + *

+ */ public void invalidateViewMarkersInBounds() { Projection projection = mapboxMap.getProjection(); List markers = mapView.getMarkerViewsInBounds(projection.getVisibleRegion().latLngBounds); @@ -216,7 +321,7 @@ public class MarkerViewManager { if (!clickHandled) { // InfoWindow offset int infoWindowOffsetX = (int) ((adaptedView.getWidth() * marker.getInfoWindowAnchorU()) - marker.getOffsetX()); - int infoWindowOffsetY = (int) ((adaptedView.getHeight() * marker.getInfoWindowAnchorV()) -marker.getOffsetY()); + int infoWindowOffsetY = (int) ((adaptedView.getHeight() * marker.getInfoWindowAnchorV()) - marker.getOffsetY()); marker.setTopOffsetPixels(infoWindowOffsetY); marker.setRightOffsetPixels(infoWindowOffsetX); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java index 36ecece61..3f8dd863f 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java @@ -447,7 +447,7 @@ public class MapView extends FrameLayout { } } } else if (change == REGION_IS_CHANGING || change == REGION_DID_CHANGE || change == DID_FINISH_LOADING_MAP) { - mMapboxMap.getMarkerViewManager().invalidateViewMarkers(); + mMapboxMap.getMarkerViewManager().scheduleViewMarkerInvalidation(); } } }); From d5cd1e1f9de83894a0d1928cad61a5902a715abb Mon Sep 17 00:00:00 2001 From: Tobrun Van Nuland Date: Fri, 27 May 2016 08:36:41 +0200 Subject: [PATCH 06/41] [android] #5113 - added javadoc to the MarkerView API --- .../annotations/BaseMarkerViewOptions.java | 152 ++++++++++++++- .../mapboxsdk/annotations/MarkerView.java | 182 +++++++++++++++++- .../annotations/MarkerViewManager.java | 2 +- .../annotations/MarkerViewOptions.java | 6 + .../com/mapbox/mapboxsdk/maps/MapboxMap.java | 53 ++++- 5 files changed, 388 insertions(+), 7 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BaseMarkerViewOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BaseMarkerViewOptions.java index 892eee180..0cd54fc0f 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BaseMarkerViewOptions.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BaseMarkerViewOptions.java @@ -10,9 +10,10 @@ import com.mapbox.mapboxsdk.geometry.LatLng; * Abstract builder class for composing custom MarkerView objects. *

* Extending this class requires implementing Parceable interface. + *

* * @param Type of the marker view to be composed - * @param Type of the builder to be used for composing a custom Marker + * @param Type of the builder to be used for composing */ public abstract class BaseMarkerViewOptions> implements Parcelable { @@ -30,120 +31,265 @@ public abstract class BaseMarkerViewOptions + * This class uses {@link com.mapbox.mapboxsdk.maps.MapboxMap.MarkerViewAdapter} to adapt a + * MarkerView model to an Android SDK {@link android.view.View} object. + *

+ *

+ * An {@link InfoWindow} can be shown when a MarkerView is pressed + *

+ */ public class MarkerView extends Marker { private MarkerViewManager markerViewManager; @@ -25,9 +35,17 @@ public class MarkerView extends Marker { private float rotation; private float alpha = 1; + /** + * Publicly hidden default constructor + */ MarkerView() { } + /** + * Creates a instance of MarkerView using the builder of MarkerView + * + * @param baseMarkerViewOptions the builder used to construct the MarkerView + */ public MarkerView(BaseMarkerViewOptions baseMarkerViewOptions) { super(baseMarkerViewOptions); this.anchorU = baseMarkerViewOptions.getAnchorU(); @@ -43,80 +61,194 @@ public class MarkerView extends Marker { this.anchorV = baseMarkerViewOptions.anchorV; } + /** + * Specifies the anchor being set on a particular point point of the MarkerView. + *

+ * The anchor point is specified in the continuous space [0.0, 1.0] x [0.0, 1.0], where (0, 0) + * is the top-left corner of the image, and (1, 1) is the bottom-right corner. + *

+ * + * @param u u-coordinate of the anchor, as a ratio of the image width (in the range [0, 1]) + * @param v v-coordinate of the anchor, as a ratio of the image height (in the range [0, 1]) + */ public void setAnchor(float u, float v) { this.anchorU = u; this.anchorV = v; } + /** + * Get the horizontal distance, normalized to [0, 1], of the anchor from the left edge. + * + * @return the u-value of the anchor + */ public float getAnchorU() { return anchorU; } + /** + * Get the vertical distance, normalized to [0, 1], of the anchor from the top edge. + * + * @return the v-value of the anchor + */ public float getAnchorV() { return anchorV; } - void setOffsetX(float x){ + /** + * Internal method to set the horizontal calculated offset. + *

+ * These are calculated based on the View bounds and the provided anchor. + *

+ * + * @param x the x-value of the offset + */ + void setOffsetX(float x) { offsetX = x; } - void setOffsetY(float y){ + /** + * Internal method to set the vertical calculated offset. + *

+ * These are calculated based on the View bounds and the provided anchor. + *

+ * + * @param y the y-value of the offset + */ + void setOffsetY(float y) { offsetY = y; } + /** + * Internal method to get the horizontal calculated offset + * + * @return the calculated horizontal offset + */ float getOffsetX() { return offsetX; } + /** + * Internal method to get the vertical calculated offset + * + * @return the calculated vertical offset + */ float getOffsetY() { return offsetY; } + /** + * Specifies the anchor point of the info window on the View of the MarkerView. + *

+ * This is specified in the same coordinate system as the anchor. + *

+ *

+ * The default is the top middle of the View. + *

+ * + * @param u u-coordinate of the info window anchor, as a ratio of the image width (in the range [0, 1]) + * @param v v-coordinate of the info window anchor, as a ratio of the image height (in the range [0, 1]) + * @see #setAnchor(float, float) for more details. + */ public void setInfoWindowAnchor(float u, float v) { this.infoWindowAnchorU = u; this.infoWindowAnchorV = v; } + /** + * Get the horizontal distance, normalized to [0, 1], of the info window anchor from the left edge. + * + * @return the u value of the InfoWindow anchor. + */ public float getInfoWindowAnchorU() { return infoWindowAnchorU; } + /** + * Get the vertical distance, normalized to [0, 1], of the info window anchor from the top edge. + * + * @return the v value of the InfoWindow anchor. + */ public float getInfoWindowAnchorV() { return infoWindowAnchorV; } + /** + * Get the flat state of a MarkerView. + * + * @return true is the MarkerView is flat; false is the MarkerView is billboard + */ public boolean isFlat() { return flat; } + /** + * Sets whether this marker should be flat against the map true or a billboard facing the camera false. + * + * @param flat the flat state of the MarkerView + */ public void setFlat(boolean flat) { this.flat = flat; } + /** + * Get the animator resource used to animate to the selected state of a MarkerView. + * + * @return the animator resource used + */ public int getSelectAnimRes() { return selectAnimRes; } + /** + * Set the animator resource used to animate to the deselected state of a MarkerView. + * + * @param selectAnimRes the animator resource used + */ public void setSelectAnimRes(int selectAnimRes) { this.selectAnimRes = selectAnimRes; } + /** + * Get the animator resource used to animate to the deslected state of a MarkerView. + * + * @return the animator resource used + */ public int getDeselectAnimRes() { return deselectAnimRes; } + /** + * Set the animator resource used to animate to the selected state of a MarkerView. + * + * @param deselectAnimRes the animator resource used + */ public void setDeselectAnimRes(int deselectAnimRes) { this.deselectAnimRes = deselectAnimRes; } + /** + * Internal method to get the current tilted value of a MarkerView. + * + * @return the tilted value + */ float getTilt() { return tiltValue; } + /** + * Internal method to set the current titled value of a MarkerView. + * + * @param tiltValue the tilted value to set + */ void setTilt(float tiltValue) { this.tiltValue = tiltValue; } + /** + * Set the visible state of a MarkerView. + * + * @param visible true will make the MarkerView visible, false will hide the MarkerViews + */ public void setVisible(boolean visible) { this.visible = visible; if (markerViewManager != null) { @@ -124,10 +256,24 @@ public class MarkerView extends Marker { } } + /** + * Returns the visible state of the MarkerView. + * + * @return the visible state + */ public boolean isVisible() { return visible; } + /** + * Set the rotation value of the MarkerView. + *

+ * This will result in animating the rotation of the MarkerView using an rotation animator + * from current value to the provided parameter value. + *

+ * + * @param rotation the rotation value to animate to + */ public void setRotation(float rotation) { this.rotation = rotation; if (markerViewManager != null) { @@ -135,14 +281,33 @@ public class MarkerView extends Marker { } } + /** + * Get the rotation value of the MarkerView. + * + * @return the rotation value + */ public float getRotation() { return rotation; } + /** + * Get the alpha value of the MarkerView. + * + * @return the alpha value + */ public float getAlpha() { return alpha; } + /** + * Set the alpha value of the MarkerView. + *

+ * This will result in animating the alpha of the MarkerView using an alpha animator + * from current value to the provided parameter value. + *

+ * + * @param alpha the alpha value to animate to + */ public void setAlpha(float alpha) { this.alpha = alpha; if (markerViewManager != null) { @@ -150,12 +315,25 @@ public class MarkerView extends Marker { } } + /** + * Set the MapboxMap associated tot the MapView containing the MarkerView. + *

+ * This method is used to instantiate the MarkerView and provide an instance of {@link com.mapbox.mapboxsdk.maps.MapboxMap.MarkerViewAdapter} + *

+ * + * @param mapboxMap the MapboxMap instances + */ @Override public void setMapboxMap(MapboxMap mapboxMap) { super.setMapboxMap(mapboxMap); markerViewManager = mapboxMap.getMarkerViewManager(); } + /** + * Get the String representation of a MarkerView. + * + * @return the String representation + */ @Override public String toString() { return "MarkerView [position[" + getPosition() + "]]"; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java index 03d554656..d9fc9e62a 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java @@ -37,7 +37,7 @@ public class MarkerViewManager { * Creates an instance of MarkerViewManager. * * @param mapboxMap the MapboxMap associated with the MarkerViewManager - * @param mapView the MapView associarted with the MarkerViewManager + * @param mapView the MapView associated with the MarkerViewManager */ public MarkerViewManager(@NonNull MapboxMap mapboxMap, @NonNull MapView mapView) { this.mapboxMap = mapboxMap; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewOptions.java index a688a8b1a..0c9faed35 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewOptions.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewOptions.java @@ -6,6 +6,12 @@ import android.os.Parcelable; import com.mapbox.mapboxsdk.geometry.LatLng; +/** + * builder class for composing MarkerView objects. + *

+ * Do not extend this class directly but extend BaseMarkerViewOptions instead. + *

+ */ public class MarkerViewOptions extends BaseMarkerViewOptions { private MarkerView marker; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java index 19cd2aebc..a19588b8c 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java @@ -1214,6 +1214,11 @@ public class MapboxMap { return marker; } + /** + * Get the MarkerViewManager associated to the MapView. + * + * @return the associated MarkerViewManager + */ public MarkerViewManager getMarkerViewManager() { return mMarkerViewManager; } @@ -1803,12 +1808,22 @@ public class MapboxMap { View getInfoWindow(@NonNull Marker marker); } + /** + * Interface definition for a callback to be invoked when an MarkerView will be shown. + * + * @param the instance type of MarkerView + */ public static abstract class MarkerViewAdapter { private Context context; private final Class persistentClass; private final Pools.SimplePool mViewReusePool; + /** + * Create an instance of MarkerViewAdapter. + * + * @param context the context associated to a MapView + */ @SuppressWarnings("unchecked") public MarkerViewAdapter(Context context) { this.context = context; @@ -1816,24 +1831,60 @@ public class MapboxMap { mViewReusePool = new Pools.SimplePool<>(20); } + /** + * Called when an MarkerView will be added to the MapView. + * + * @param marker the model representing the MarkerView + * @param convertView the reusable view + * @param parent the parent ViewGroup of the convertview + * @return the View that is adapted to the contents of MarkerView + */ @Nullable public abstract View getView(@NonNull U marker, @NonNull View convertView, @NonNull ViewGroup parent); + /** + * Returns the generic type of the used MarkerView. + * + * @return the generic type + */ public Class getMarkerClass() { return persistentClass; } + /** + * Returns the pool used to store reusable Views. + * + * @return the pool associated to this adapter + */ public Pools.SimplePool getViewReusePool() { return mViewReusePool; } + /** + * Returns the context associated to the hosting MapView. + * + * @return the context used + */ public Context getContext() { return context; } } + /** + * Interface definition for a callback to be invoked when the user clicks on a MarkerView. + * + * @see MarkerViewManager#setOnMarkerViewClickListener(OnMarkerViewClickListener) + */ public interface OnMarkerViewClickListener { + /** + * Called when the user clicks on a MarkerView. + * + * @param marker the MarkerView associated to the clicked View + * @param view the clicked View + * @param adapter the adapter used to adapt the MarkerView to the View + * @return If true the listener has consumed the event and the info window will not be shown + */ boolean onMarkerClick(@NonNull Marker marker, @NonNull View view, @NonNull MarkerViewAdapter adapter); } @@ -1905,7 +1956,7 @@ public class MapboxMap { public interface SnapshotReadyCallback { /** * Invoked when the snapshot has been taken. - **/ + */ void onSnapshotReady(Bitmap snapshot); } From af34481e6b5d14ee3966bd011e3a7f4095bde162 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Wed, 25 May 2016 23:53:43 +0300 Subject: [PATCH 07/41] [core] Move objectStore in {GL,TexturePool}Holder::reset() Fixes an issue where a moved {GL,TexturePool}Holder would use an invalid pointer when accessing 'objectStore'. Fixes #5136. --- src/mbgl/gl/gl_object_store.cpp | 11 +++++------ src/mbgl/gl/gl_object_store.hpp | 10 +++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/mbgl/gl/gl_object_store.cpp b/src/mbgl/gl/gl_object_store.cpp index 4948e2069..9646fb328 100644 --- a/src/mbgl/gl/gl_object_store.cpp +++ b/src/mbgl/gl/gl_object_store.cpp @@ -61,12 +61,11 @@ void TexturePoolHolder::create(GLObjectStore& objectStore_) { void TexturePoolHolder::reset() { if (!bool()) return; - for (GLuint id : ids) { - if (id) { - objectStore->abandonedTextures.push_back(id); - } - } - ids.fill(0); + for (GLuint& id : ids) { + if (id == 0) continue; + objectStore->abandonedTextures.push_back(id); + id = 0; + }; } void VAOHolder::create(GLObjectStore& objectStore_) { diff --git a/src/mbgl/gl/gl_object_store.hpp b/src/mbgl/gl/gl_object_store.hpp index b30abd389..9e0575046 100644 --- a/src/mbgl/gl/gl_object_store.hpp +++ b/src/mbgl/gl/gl_object_store.hpp @@ -38,8 +38,8 @@ class GLHolder : private util::noncopyable { public: GLHolder() {} - GLHolder(GLHolder&& o) noexcept : id(o.id) { o.id = 0; } - GLHolder& operator=(GLHolder&& o) noexcept { id = o.id; o.id = 0; return *this; } + GLHolder(GLHolder&& o) noexcept : id(o.id), objectStore(o.objectStore) { o.id = 0; } + GLHolder& operator=(GLHolder&& o) noexcept { id = o.id; objectStore = o.objectStore; o.id = 0; return *this; } explicit operator bool() const { return id; } GLuint getID() const { return id; } @@ -107,10 +107,10 @@ public: TexturePoolHolder() { ids.fill(0); } ~TexturePoolHolder() { reset(); } - TexturePoolHolder(TexturePoolHolder&& o) noexcept : ids(std::move(o.ids)) {} - TexturePoolHolder& operator=(TexturePoolHolder&& o) noexcept { ids = std::move(o.ids); return *this; } + TexturePoolHolder(TexturePoolHolder&& o) noexcept : ids(std::move(o.ids)), objectStore(o.objectStore) { o.ids.fill(0); } + TexturePoolHolder& operator=(TexturePoolHolder&& o) noexcept { ids = std::move(o.ids); objectStore = o.objectStore; o.ids.fill(0); return *this; } - explicit operator bool() { return std::none_of(ids.begin(), ids.end(), [](int id) { return id == 0; }); } + explicit operator bool() const { return std::any_of(ids.begin(), ids.end(), [](int id) { return id; }); } const std::array& getIDs() const { return ids; } const GLuint& operator[](size_t pos) { return ids[pos]; } From c6f22df8e57182d0671eb85481f46fc81e95d275 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Wed, 25 May 2016 23:56:52 +0300 Subject: [PATCH 08/41] [core] s/operator bool/created()/ in {GL,TexturePool}Holder Prevents confusing usage of GL holder objects. --- src/mbgl/geometry/buffer.hpp | 6 +++--- src/mbgl/geometry/glyph_atlas.cpp | 4 ++-- src/mbgl/geometry/line_atlas.cpp | 2 +- src/mbgl/geometry/vao.cpp | 4 +++- src/mbgl/geometry/vao.hpp | 4 ++-- src/mbgl/gl/gl_object_store.cpp | 24 ++++++++++++------------ src/mbgl/gl/gl_object_store.hpp | 4 ++-- src/mbgl/renderer/frame_history.cpp | 4 ++-- src/mbgl/shader/shader.cpp | 2 +- src/mbgl/sprite/sprite_atlas.cpp | 2 +- 10 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/mbgl/geometry/buffer.hpp b/src/mbgl/geometry/buffer.hpp index e8e2788f5..80fde6170 100644 --- a/src/mbgl/geometry/buffer.hpp +++ b/src/mbgl/geometry/buffer.hpp @@ -36,7 +36,7 @@ public: // Transfers this buffer to the GPU and binds the buffer to the GL context. void bind(gl::GLObjectStore& glObjectStore) { - if (buffer) { + if (buffer.created()) { MBGL_CHECK_ERROR(glBindBuffer(bufferType, getID())); } else { buffer.create(glObjectStore); @@ -65,7 +65,7 @@ public: // Uploads the buffer to the GPU to be available when we need it. inline void upload(gl::GLObjectStore& glObjectStore) { - if (!buffer) { + if (!buffer.created()) { bind(glObjectStore); } } @@ -73,7 +73,7 @@ public: protected: // increase the buffer size by at least /required/ bytes. inline void *addElement() { - if (buffer) { + if (buffer.created()) { throw std::runtime_error("Can't add elements after buffer was bound to GPU"); } if (length < pos + itemSize) { diff --git a/src/mbgl/geometry/glyph_atlas.cpp b/src/mbgl/geometry/glyph_atlas.cpp index fd43fb8c1..1b0f4bc7e 100644 --- a/src/mbgl/geometry/glyph_atlas.cpp +++ b/src/mbgl/geometry/glyph_atlas.cpp @@ -144,7 +144,7 @@ void GlyphAtlas::removeGlyphs(uintptr_t tileUID) { void GlyphAtlas::upload(gl::GLObjectStore& glObjectStore) { if (dirty) { - const bool first = !texture; + const bool first = !texture.created(); bind(glObjectStore); std::lock_guard lock(mtx); @@ -184,7 +184,7 @@ void GlyphAtlas::upload(gl::GLObjectStore& glObjectStore) { } void GlyphAtlas::bind(gl::GLObjectStore& glObjectStore) { - if (!texture) { + if (!texture.created()) { texture.create(glObjectStore); MBGL_CHECK_ERROR(glBindTexture(GL_TEXTURE_2D, texture.getID())); #ifndef GL_ES_VERSION_2_0 diff --git a/src/mbgl/geometry/line_atlas.cpp b/src/mbgl/geometry/line_atlas.cpp index 1213b8d77..614e3280c 100644 --- a/src/mbgl/geometry/line_atlas.cpp +++ b/src/mbgl/geometry/line_atlas.cpp @@ -129,7 +129,7 @@ void LineAtlas::upload(gl::GLObjectStore& glObjectStore) { void LineAtlas::bind(gl::GLObjectStore& glObjectStore) { bool first = false; - if (!texture) { + if (!texture.created()) { texture.create(glObjectStore); MBGL_CHECK_ERROR(glBindTexture(GL_TEXTURE_2D, texture.getID())); MBGL_CHECK_ERROR(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); diff --git a/src/mbgl/geometry/vao.cpp b/src/mbgl/geometry/vao.cpp index 823960426..c438fbd2e 100644 --- a/src/mbgl/geometry/vao.cpp +++ b/src/mbgl/geometry/vao.cpp @@ -26,7 +26,9 @@ void VertexArrayObject::bindVertexArrayObject(gl::GLObjectStore& glObjectStore) return; } - if (!vao) vao.create(glObjectStore); + if (!vao.created()) { + vao.create(glObjectStore); + } MBGL_CHECK_ERROR(gl::BindVertexArray(vao.getID())); } diff --git a/src/mbgl/geometry/vao.hpp b/src/mbgl/geometry/vao.hpp index 8e9e417c1..8bc375059 100644 --- a/src/mbgl/geometry/vao.hpp +++ b/src/mbgl/geometry/vao.hpp @@ -24,7 +24,7 @@ public: if (bound_shader == 0) { vertexBuffer.bind(glObjectStore); shader.bind(offset); - if (vao) { + if (vao.created()) { storeBinding(shader, vertexBuffer.getID(), 0, offset); } } else { @@ -39,7 +39,7 @@ public: vertexBuffer.bind(glObjectStore); elementsBuffer.bind(glObjectStore); shader.bind(offset); - if (vao) { + if (vao.created()) { storeBinding(shader, vertexBuffer.getID(), elementsBuffer.getID(), offset); } } else { diff --git a/src/mbgl/gl/gl_object_store.cpp b/src/mbgl/gl/gl_object_store.cpp index 9646fb328..040109d01 100644 --- a/src/mbgl/gl/gl_object_store.cpp +++ b/src/mbgl/gl/gl_object_store.cpp @@ -6,61 +6,61 @@ namespace mbgl { namespace gl { void ProgramHolder::create(GLObjectStore& objectStore_) { - if (id) return; + if (created()) return; objectStore = &objectStore_; id = MBGL_CHECK_ERROR(glCreateProgram()); } void ProgramHolder::reset() { - if (!id) return; + if (!created()) return; objectStore->abandonedPrograms.push_back(id); id = 0; } void ShaderHolder::create(GLObjectStore& objectStore_) { - if (id) return; + if (created()) return; objectStore = &objectStore_; id = MBGL_CHECK_ERROR(glCreateShader(type)); } void ShaderHolder::reset() { - if (!id) return; + if (!created()) return; objectStore->abandonedShaders.push_back(id); id = 0; } void BufferHolder::create(GLObjectStore& objectStore_) { - if (id) return; + if (created()) return; objectStore = &objectStore_; MBGL_CHECK_ERROR(glGenBuffers(1, &id)); } void BufferHolder::reset() { - if (!id) return; + if (!created()) return; objectStore->abandonedBuffers.push_back(id); id = 0; } void TextureHolder::create(GLObjectStore& objectStore_) { - if (id) return; + if (created()) return; objectStore = &objectStore_; MBGL_CHECK_ERROR(glGenTextures(1, &id)); } void TextureHolder::reset() { - if (!id) return; + if (!created()) return; objectStore->abandonedTextures.push_back(id); id = 0; } void TexturePoolHolder::create(GLObjectStore& objectStore_) { - if (bool()) return; + if (created()) return; objectStore = &objectStore_; MBGL_CHECK_ERROR(glGenTextures(TextureMax, ids.data())); } void TexturePoolHolder::reset() { - if (!bool()) return; + if (!created()) return; for (GLuint& id : ids) { if (id == 0) continue; objectStore->abandonedTextures.push_back(id); @@ -69,13 +69,13 @@ void TexturePoolHolder::reset() { } void VAOHolder::create(GLObjectStore& objectStore_) { - if (id) return; + if (created()) return; objectStore = &objectStore_; MBGL_CHECK_ERROR(gl::GenVertexArrays(1, &id)); } void VAOHolder::reset() { - if (!id) return; + if (!created()) return; objectStore->abandonedVAOs.push_back(id); id = 0; } diff --git a/src/mbgl/gl/gl_object_store.hpp b/src/mbgl/gl/gl_object_store.hpp index 9e0575046..2527bbf33 100644 --- a/src/mbgl/gl/gl_object_store.hpp +++ b/src/mbgl/gl/gl_object_store.hpp @@ -41,7 +41,7 @@ public: GLHolder(GLHolder&& o) noexcept : id(o.id), objectStore(o.objectStore) { o.id = 0; } GLHolder& operator=(GLHolder&& o) noexcept { id = o.id; objectStore = o.objectStore; o.id = 0; return *this; } - explicit operator bool() const { return id; } + bool created() const { return id; } GLuint getID() const { return id; } protected: @@ -110,7 +110,7 @@ public: TexturePoolHolder(TexturePoolHolder&& o) noexcept : ids(std::move(o.ids)), objectStore(o.objectStore) { o.ids.fill(0); } TexturePoolHolder& operator=(TexturePoolHolder&& o) noexcept { ids = std::move(o.ids); objectStore = o.objectStore; o.ids.fill(0); return *this; } - explicit operator bool() const { return std::any_of(ids.begin(), ids.end(), [](int id) { return id; }); } + bool created() const { return std::any_of(ids.begin(), ids.end(), [](int id) { return id; }); } const std::array& getIDs() const { return ids; } const GLuint& operator[](size_t pos) { return ids[pos]; } diff --git a/src/mbgl/renderer/frame_history.cpp b/src/mbgl/renderer/frame_history.cpp index eb125201f..74856ec87 100644 --- a/src/mbgl/renderer/frame_history.cpp +++ b/src/mbgl/renderer/frame_history.cpp @@ -60,7 +60,7 @@ bool FrameHistory::needsAnimation(const Duration& duration) const { void FrameHistory::upload(gl::GLObjectStore& glObjectStore) { if (changed) { - const bool first = !texture; + const bool first = !texture.created(); bind(glObjectStore); if (first) { @@ -95,7 +95,7 @@ void FrameHistory::upload(gl::GLObjectStore& glObjectStore) { } void FrameHistory::bind(gl::GLObjectStore& glObjectStore) { - if (!texture) { + if (!texture.created()) { texture.create(glObjectStore); MBGL_CHECK_ERROR(glBindTexture(GL_TEXTURE_2D, texture.getID())); #ifndef GL_ES_VERSION_2_0 diff --git a/src/mbgl/shader/shader.cpp b/src/mbgl/shader/shader.cpp index 8216de5b4..b0536cda9 100644 --- a/src/mbgl/shader/shader.cpp +++ b/src/mbgl/shader/shader.cpp @@ -86,7 +86,7 @@ bool Shader::compileShader(gl::ShaderHolder& shader, const GLchar *source[]) { } Shader::~Shader() { - if (program) { + if (program.created()) { MBGL_CHECK_ERROR(glDetachShader(program.getID(), vertexShader.getID())); MBGL_CHECK_ERROR(glDetachShader(program.getID(), fragmentShader.getID())); } diff --git a/src/mbgl/sprite/sprite_atlas.cpp b/src/mbgl/sprite/sprite_atlas.cpp index 26777abc8..6595d7137 100644 --- a/src/mbgl/sprite/sprite_atlas.cpp +++ b/src/mbgl/sprite/sprite_atlas.cpp @@ -184,7 +184,7 @@ void SpriteAtlas::bind(bool linear, gl::GLObjectStore& glObjectStore) { return; // Empty atlas } - if (!texture) { + if (!texture.created()) { texture.create(glObjectStore); MBGL_CHECK_ERROR(glBindTexture(GL_TEXTURE_2D, texture.getID())); #ifndef GL_ES_VERSION_2_0 From d4b3d75700e85e8b21d2dcb629dd6bed58183544 Mon Sep 17 00:00:00 2001 From: Rob | Labs Date: Wed, 25 May 2016 16:48:33 -0700 Subject: [PATCH 09/41] [privacy] [android] Remove logging of location due to privacy leak. * Location logs are not just kept on the device. * Some logging packages, e.g., Firebase, now has the option to upload logs to cloud. * This closes a potential privacy leak. --- .../java/com/mapbox/mapboxsdk/location/LocationServices.java | 2 +- .../mapbox/mapboxsdk/telemetry/TelemetryLocationReceiver.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationServices.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationServices.java index 2f1be900e..4fade484b 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationServices.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationServices.java @@ -130,7 +130,7 @@ public class LocationServices implements com.mapzen.android.lost.api.LocationLis */ @Override public void onLocationChanged(Location location) { - Log.d(TAG, "onLocationChanged()..." + location); +// Log.d(TAG, "onLocationChanged()..." + location); this.lastLocation = location; // Update Listeners diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/telemetry/TelemetryLocationReceiver.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/telemetry/TelemetryLocationReceiver.java index eb08baa9a..c18da41e4 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/telemetry/TelemetryLocationReceiver.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/telemetry/TelemetryLocationReceiver.java @@ -63,7 +63,7 @@ public class TelemetryLocationReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { Location location = (Location)intent.getExtras().get(LocationManager.KEY_LOCATION_CHANGED); if (location != null) { - Log.d(TAG, "location received = " + location); +// Log.d(TAG, "location received = " + location); MapboxEventManager.getMapboxEventManager().addLocationEvent(location); } else { Log.d(TAG, "location NOT received"); From 9f9b310a2faaa4948f29962088cca24764985d6b Mon Sep 17 00:00:00 2001 From: Tobrun Van Nuland Date: Thu, 26 May 2016 09:06:52 +0200 Subject: [PATCH 10/41] [android] #5106 - add check for destroyed map view for addMarker() --- .../src/main/java/com/mapbox/mapboxsdk/maps/MapView.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java index 3f8dd863f..76a3e6517 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java @@ -1021,6 +1021,9 @@ public class MapView extends FrameLayout { } long addMarker(@NonNull Marker marker) { + if(mDestroyed){ + return 0l; + } return mNativeMapView.addMarker(marker); } From 623b81fe0e199445350357c8c22088f4ac5cb52b Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Fri, 27 May 2016 23:24:25 +0300 Subject: [PATCH 11/41] [core] Fill the initial `changeTimes` with the reference timestamp of the first frame On the Javascript implementation the array is automatically filled with zeroes which is not the same thing as `TimePoint::min()`. Here we need to get our own "zero" which is the timestamp of the first frame. Fixes #5109 --- src/mbgl/renderer/frame_history.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mbgl/renderer/frame_history.cpp b/src/mbgl/renderer/frame_history.cpp index 74856ec87..09337c87a 100644 --- a/src/mbgl/renderer/frame_history.cpp +++ b/src/mbgl/renderer/frame_history.cpp @@ -4,7 +4,6 @@ using namespace mbgl; FrameHistory::FrameHistory() { - changeTimes.fill(TimePoint::min()); changeOpacities.fill(0); opacities.fill(0); }; @@ -14,6 +13,7 @@ void FrameHistory::record(const TimePoint& now, float zoom, const Duration& dura int16_t zoomIndex = std::floor(zoom * 10.0); if (firstFrame) { + changeTimes.fill(now); for (int16_t z = 0; z <= zoomIndex; z++) { opacities[z] = 255u; From 0c9d5441193f6e23be563cf8cd9aaedd3f60d71a Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Fri, 27 May 2016 18:27:09 -0500 Subject: [PATCH 12/41] [android] #5176 - Changing Telemetry events endpoint to events.mapbox.com --- .../com/mapbox/mapboxsdk/telemetry/MapboxEvent.java | 2 +- .../mapboxsdk/telemetry/MapboxEventManager.java | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/telemetry/MapboxEvent.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/telemetry/MapboxEvent.java index 41dec08ee..22e37ec53 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/telemetry/MapboxEvent.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/telemetry/MapboxEvent.java @@ -7,7 +7,7 @@ import java.io.Serializable; */ public class MapboxEvent implements Serializable { public static final int VERSION_NUMBER = 2; - public static final String MAPBOX_EVENTS_BASE_URL = "https://api.mapbox.com"; + public static final String MAPBOX_EVENTS_BASE_URL = "https://events.mapbox.com"; public static final String SOURCE_MAPBOX = "mapbox"; // Event Types diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/telemetry/MapboxEventManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/telemetry/MapboxEventManager.java index 7679f1d08..bf38c3233 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/telemetry/MapboxEventManager.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/telemetry/MapboxEventManager.java @@ -686,19 +686,20 @@ public class MapboxEventManager { .add("cloudfront-staging.tilestream.net", "sha256/sPbNCVpVasMJxps3IqFfLTRKkVnRCLrTlZVc5kspqlkw=") .add("cloudfront-staging.tilestream.net", "sha256/h6801m+z8v3zbgkRHpq6L29Esgfzhj89C1SyUCOQmqU=") // Prod - Geotrust - .add("api.mapbox.com", "sha256/svaiYM/ZVIfxC+CMDe4kj1KsviQmzyZ9To8nQqUJwFI=") - .add("api.mapbox.com", "sha256/owrR9U9FWDWtrFF+myoRIu75JwU4sJwzvhCNLZoY37g=") - .add("api.mapbox.com", "sha256/SQVGZiOrQXi+kqxcvWWE96HhfydlLVqFr4lQTqI5qqo=") + .add("events.mapbox.com", "sha256/BhynraKizavqoC5U26qgYuxLZst6pCu9J5stfL6RSYY=") + .add("events.mapbox.com", "sha256/owrR9U9FWDWtrFF+myoRIu75JwU4sJwzvhCNLZoY37g=") + .add("events.mapbox.com", "sha256/SQVGZiOrQXi+kqxcvWWE96HhfydlLVqFr4lQTqI5qqo=") // Prod - DigiCert - .add("api.mapbox.com", "sha256/JL+uwAwpA2U1UVl/AFdZy1ZnvkZJ1P1hRfmfPaPVSLU=") - .add("api.mapbox.com", "sha256/RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho=") - .add("api.mapbox.com", "sha256/WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18=") + .add("events.mapbox.com", "sha256/Tb0uHZ/KQjWh8N9+CZFLc4zx36LONQ55l6laDi1qtT4=") + .add("events.mapbox.com", "sha256/RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho=") + .add("events.mapbox.com", "sha256/WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18=") .build(); OkHttpClient client = new OkHttpClient.Builder().certificatePinner(certificatePinner).build(); RequestBody body = RequestBody.create(JSON, jsonArray.toString()); String url = eventsURL + "/events/v2?access_token=" + accessToken; +// Log.d(TAG, "Events URL = " + url); Request request = new Request.Builder() .url(url) From c66cf0f73fc1fb08d5b8397941e5c3845c88ccaa Mon Sep 17 00:00:00 2001 From: Tobrun Date: Mon, 30 May 2016 19:09:27 +0200 Subject: [PATCH 13/41] [android] #5113 - added javadoc for MyLocationViewSettings --- .../maps/widgets/MyLocationViewSettings.java | 120 +++++++++++++++++- 1 file changed, 117 insertions(+), 3 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettings.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettings.java index 9ae96ebf7..80bd1b3be 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettings.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettings.java @@ -6,6 +6,9 @@ import android.support.annotation.IntRange; import com.mapbox.mapboxsdk.maps.MapView; +/** + * Settings to configure the visual appearance of the MyLocationView. + */ public class MyLocationViewSettings { private MapView mapView; @@ -52,43 +55,101 @@ public class MyLocationViewSettings { private int[] padding = new int[4]; + /** + * Creates an instance of MyLocationViewSettings + * + * @param mapView the MapView that hosts the MyLocationView + * @param myLocationView the MyLocationView to apply the settings to + * @see MyLocationView + */ public MyLocationViewSettings(MapView mapView, MyLocationView myLocationView) { this.mapView = mapView; this.myLocationView = myLocationView; } + /** + * Returns if the MyLocationView is enabled + * + * @return true if MyLocationView is enabled, + */ public boolean isEnabled() { return enabled; } + /** + * Set the enabled state of MyLocationView + * + * @param enabled true shows the MyLocationView on the map + */ public void setEnabled(boolean enabled) { this.enabled = enabled; myLocationView.setEnabled(enabled); } + /** + * Set the foreground drawable of the MyLocationView + *

+ * The foreground drawable is the image visible on screen + *

+ * + * @param foregroundDrawable the drawable to show as foreground without bearing + * @param foregroundBearingDrawable the drawable to show as foreground when bearing is enabled + */ public void setForegroundDrawable(Drawable foregroundDrawable, Drawable foregroundBearingDrawable) { this.foregroundDrawable = foregroundDrawable; this.foregroundBearingDrawable = foregroundBearingDrawable; myLocationView.setForegroundDrawables(foregroundDrawable, foregroundBearingDrawable); } + /** + * Get the foreground drawable when bearing is disabled. + * + * @return the drawable used as foreground + */ public Drawable getForegroundDrawable() { return foregroundDrawable; } + /** + * Get the foreground drawable when bearing is enabled. + * + * @return the bearing drawable used as foreground + */ public Drawable getForegroundBearingDrawable() { return foregroundBearingDrawable; } + /** + * Set the foreground tint color. + *

+ * The color will tint both the foreground and the bearing foreground drawable. + *

+ * + * @param foregroundTintColor the color to tint the foreground drawable + */ public void setForegroundTintColor(@ColorInt int foregroundTintColor) { this.foregroundTintColor = foregroundTintColor; myLocationView.setForegroundDrawableTint(foregroundTintColor); } + /** + * Get the foreground tint color. + * + * @return the foreground tint color + */ public int getForegroundTintColor() { return foregroundTintColor; } + /** + * Set the background drawable of MyLocationView + *

+ * Padding can be added to provide an offset to the background + *

+ * + * @param backgroundDrawable the drawable to show as background + * @param padding the padding added to the background + */ public void setBackgroundDrawable(Drawable backgroundDrawable, int[] padding) { this.backgroundDrawable = backgroundDrawable; this.backgroundOffset = padding; @@ -99,46 +160,99 @@ public class MyLocationViewSettings { } } + /** + * Get the background drawable of MyLocationView. + * + * @return the drawable used as background + */ public Drawable getBackgroundDrawable() { return backgroundDrawable; } + /** + * Set the background tint color. + * + * @param backgroundTintColor the color to tint the background + */ public void setBackgroundTintColor(@ColorInt int backgroundTintColor) { this.backgroundTintColor = backgroundTintColor; myLocationView.setShadowDrawableTint(backgroundTintColor); } + /** + * Get the background tint color. + * + * @return the background tint color + */ public int getBackgroundTintColor() { return backgroundTintColor; } + /** + * Get the background offset. + * + * @return the background offset + */ public int[] getBackgroundOffset() { return backgroundOffset; } + /** + * Set the MyLocationView padding. + * + * @param left the padding left of MyLocationView + * @param top the padding top of MyLocationView + * @param right the padding right of MyLocationView + * @param bottom the padding bottom of MyLocaionView + */ public void setPadding(int left, int top, int right, int bottom) { padding = new int[]{left, top, right, bottom}; myLocationView.setContentPadding(padding); mapView.invalidateContentPadding(); } + /** + * Get the MyLocationView padding. + * + * @return an array describing the padding in a LTRB manner + */ public int[] getPadding() { return padding; } + /** + * Get the alpha value of the accuracy circle of MyLocationView + * + * @return the alpha value + */ public int getAccuracyAlpha() { return accuracyAlpha; } - public void setAccuracyAlpha(@IntRange(from = 0, to = 255) int arruracyAlpha) { - this.accuracyAlpha = arruracyAlpha; - myLocationView.setAccuracyAlpha(arruracyAlpha); + /** + * Set the alpha value of the accuracy circle of MyLocationView + * + * @param accuracyAlpha the alpha value to set + */ + public void setAccuracyAlpha(@IntRange(from = 0, to = 255) int accuracyAlpha) { + this.accuracyAlpha = accuracyAlpha; + myLocationView.setAccuracyAlpha(accuracyAlpha); } + /** + * Get the accuracy tint color of MyLocationView. + * + * @return the tint color used for accuracy + */ public int getAccuracyTintColor() { return accuracyTintColor; } + /** + * Set the accuracy tint color of MyLocationView. + * + * @param accuracyTintColor the accuracy tint color + */ public void setAccuracyTintColor(@ColorInt int accuracyTintColor) { this.accuracyTintColor = accuracyTintColor; myLocationView.setAccuracyTint(accuracyTintColor); From b0de21ed1de5ff166e10d9282224aa92413cb25a Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Tue, 31 May 2016 12:41:45 -0500 Subject: [PATCH 14/41] [android] #5126 - Serialize Bitrise Scheduled Build Process --- platform/android/bitrise.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/android/bitrise.yml b/platform/android/bitrise.yml index 3c06a0467..5eb5cfa50 100644 --- a/platform/android/bitrise.yml +++ b/platform/android/bitrise.yml @@ -75,7 +75,7 @@ workflows: signing.secretKeyRingFile=secring.gpg" >> platform/android/MapboxGLAndroidSDK/gradle.properties export BUILDTYPE=Release - make apackage -j4 + make apackage cd platform/android ./gradlew uploadArchives From de8744653d1a06df65fda529e8dc29d891d16d66 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Wed, 1 Jun 2016 00:46:28 +0300 Subject: [PATCH 15/41] [android] Fix x86_64 build sysroot path not being passed to the compiler and linker --- .mason | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mason b/.mason index c03b19241..34cb8a839 160000 --- a/.mason +++ b/.mason @@ -1 +1 @@ -Subproject commit c03b19241ad6450dab16bf06466f849cb5a15757 +Subproject commit 34cb8a83904d873dfcee6e3543c7527e83816d43 From c7fb8890feebdeac7aeab86474033f9d5f3ae48b Mon Sep 17 00:00:00 2001 From: Tobrun Van Nuland Date: Tue, 31 May 2016 18:54:00 +0200 Subject: [PATCH 16/41] [android] #4727 - fix proguard test app --- platform/android/MapboxGLAndroidSDKTestApp/proguard-rules.pro | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/android/MapboxGLAndroidSDKTestApp/proguard-rules.pro b/platform/android/MapboxGLAndroidSDKTestApp/proguard-rules.pro index 255a72474..fbeca9f23 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/proguard-rules.pro +++ b/platform/android/MapboxGLAndroidSDKTestApp/proguard-rules.pro @@ -3,4 +3,6 @@ -dontwarn com.squareup.** -dontwarn com.retrofit.** -dontwarn java.lang.** --dontwarn org.codehaus.** \ No newline at end of file +-dontwarn org.codehaus.** +-keep class com.google.** +-dontwarn com.google.** From 163ee916e5a868e6273641977bf413da2d233db8 Mon Sep 17 00:00:00 2001 From: Tobrun Van Nuland Date: Tue, 31 May 2016 17:02:49 +0200 Subject: [PATCH 17/41] [android] #4929 - rewrite MyLocationView with camera and transformation matrix --- .../maps/widgets/MyLocationView.java | 108 ++++++++++-------- .../src/main/res/layout/mapview_internal.xml | 4 +- .../src/main/res/values/dimens.xml | 1 - 3 files changed, 63 insertions(+), 50 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java index aed4e87c0..20513224f 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java @@ -3,8 +3,10 @@ package com.mapbox.mapboxsdk.maps.widgets; import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.content.Context; +import android.graphics.Camera; import android.graphics.Canvas; import android.graphics.Color; +import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.PointF; import android.graphics.PorterDuff; @@ -22,6 +24,7 @@ import android.support.annotation.IntRange; import android.support.annotation.NonNull; import android.util.AttributeSet; import android.view.View; +import android.view.ViewGroup; import com.mapbox.mapboxsdk.R; import com.mapbox.mapboxsdk.camera.CameraPosition; @@ -45,7 +48,6 @@ public class MyLocationView extends View { private MyLocationBehavior myLocationBehavior; private MapboxMap mapboxMap; private Projection projection; - private int maxSize; private int[] contentPadding = new int[4]; private Location location; @@ -57,8 +59,8 @@ public class MyLocationView extends View { private float gpsDirection; private float previousDirection; - private float accuracy = 0; - private Paint accuracyPaint = new Paint(); + private float accuracy; + private Paint accuracyPaint; private ValueAnimator locationChangeAnimator; private ValueAnimator accuracyAnimator; @@ -79,6 +81,11 @@ public class MyLocationView extends View { private int backgroundOffsetRight; private int backgroundOffsetBottom; + private Matrix matrix; + private Camera camera; + private PointF screenLocation; + private float tilt; + @MyLocationTracking.Mode private int myLocationTrackingMode; @@ -105,9 +112,20 @@ public class MyLocationView extends View { private void init(Context context) { setEnabled(false); + + // setup LayoutParams + ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT); + setLayoutParams(lp); + + matrix = new Matrix(); + camera = new Camera(); + camera.setLocation(0, 0, -1000); + accuracyPaint = new Paint(); + myLocationBehavior = new MyLocationBehaviorFactory().getBehavioralModel(MyLocationTracking.TRACKING_NONE); compassListener = new CompassListener(context); - maxSize = (int) context.getResources().getDimension(R.dimen.my_locationview_size); } public final void setForegroundDrawables(Drawable defaultDrawable, Drawable bearingDrawable) { @@ -151,7 +169,6 @@ public class MyLocationView extends View { backgroundOffsetTop = top; backgroundOffsetRight = right; backgroundOffsetBottom = bottom; - setShadowDrawableTint(backgroundTintColor); invalidateBounds(); @@ -187,19 +204,17 @@ public class MyLocationView extends View { int backgroundWidth = backgroundDrawable.getIntrinsicWidth(); int backgroundHeight = backgroundDrawable.getIntrinsicHeight(); + int horizontalOffset = backgroundOffsetLeft - backgroundOffsetRight; + int verticalOffset = backgroundOffsetTop - backgroundOffsetBottom; + backgroundBounds = new Rect(-backgroundWidth / 2 + horizontalOffset, -backgroundHeight / 2 + verticalOffset, backgroundWidth / 2 + horizontalOffset, backgroundHeight / 2 + verticalOffset); + backgroundDrawable.setBounds(backgroundBounds); int foregroundWidth = foregroundDrawable.getIntrinsicWidth(); int foregroundHeight = foregroundDrawable.getIntrinsicHeight(); + foregroundBounds = new Rect(-foregroundWidth / 2, -foregroundHeight / 2, foregroundWidth / 2, foregroundHeight / 2); + foregroundDrawable.setBounds(foregroundBounds); - int horizontalOffset = backgroundOffsetLeft - backgroundOffsetRight; - int verticalOffset = backgroundOffsetTop - backgroundOffsetBottom; - - int accuracyWidth = 2 * maxSize; - - backgroundBounds = new Rect(accuracyWidth - (backgroundWidth / 2) + horizontalOffset, accuracyWidth + verticalOffset - (backgroundWidth / 2), accuracyWidth + (backgroundWidth / 2) + horizontalOffset, accuracyWidth + (backgroundHeight / 2) + verticalOffset); - foregroundBounds = new Rect(accuracyWidth - (foregroundWidth / 2), accuracyWidth - (foregroundHeight / 2), accuracyWidth + (foregroundWidth / 2), accuracyWidth + (foregroundHeight / 2)); - - // invoke a new measure + // invoke a new draw invalidate(); } @@ -207,23 +222,44 @@ public class MyLocationView extends View { protected void onDraw(Canvas canvas) { super.onDraw(canvas); - if (location == null || foregroundBounds == null || backgroundBounds == null || accuracyAnimator == null) { + if (location == null || foregroundBounds == null || backgroundBounds == null || accuracyAnimator == null || screenLocation == null) { // Not ready yet return; } - // Draw circle float metersPerPixel = (float) projection.getMetersPerPixelAtLatitude(location.getLatitude()); - float accuracyPixels = (Float) accuracyAnimator.getAnimatedValue() / metersPerPixel; + float accuracyPixels = (Float) accuracyAnimator.getAnimatedValue() / metersPerPixel / 2; float maxRadius = getWidth() / 2; - canvas.drawCircle(foregroundBounds.centerX(), foregroundBounds.centerY(), accuracyPixels <= maxRadius ? accuracyPixels : maxRadius, accuracyPaint); + accuracyPixels = accuracyPixels <= maxRadius ? accuracyPixels : maxRadius; - // Draw shadow + // put matrix in origin + matrix.reset(); + + // apply tilt to camera + camera.save(); + camera.rotate(tilt, 0, 0); + + // map camera matrix on our matrix + camera.getMatrix(matrix); + + // put matrix at location of MyLocationView + matrix.postTranslate(screenLocation.x, screenLocation.y); + + // concat our matrix on canvas + canvas.concat(matrix); + + // restore orientation from camera + camera.restore(); + + // draw circle + canvas.drawCircle(0, 0, accuracyPixels, accuracyPaint); + + // draw shadow if (backgroundDrawable != null) { backgroundDrawable.draw(canvas); } - // Draw foreground + // draw foreground if (myBearingTrackingMode == MyBearingTracking.NONE) { if (foregroundDrawable != null) { foregroundDrawable.draw(canvas); @@ -233,27 +269,8 @@ public class MyLocationView extends View { } } - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - - if (foregroundDrawable != null && foregroundBounds != null) { - foregroundDrawable.setBounds(foregroundBounds); - } - - if (foregroundBearingDrawable != null && foregroundBounds != null) { - foregroundBearingDrawable.setBounds(foregroundBounds); - } - - if (backgroundDrawable != null && backgroundBounds != null) { - backgroundDrawable.setBounds(backgroundBounds); - } - - setMeasuredDimension(4 * maxSize, 4 * maxSize); - } - public void setTilt(@FloatRange(from = 0, to = 60.0f) double tilt) { - setRotationX((float) tilt); + this.tilt = (float) tilt; } void updateOnNextFrame() { @@ -627,8 +644,9 @@ public class MyLocationView extends View { void invalidate() { int[] mapPadding = mapboxMap.getPadding(); UiSettings uiSettings = mapboxMap.getUiSettings(); - setX((uiSettings.getWidth() - getWidth() + mapPadding[0] - mapPadding[2]) / 2 + (contentPadding[0] - contentPadding[2]) / 2); - setY((uiSettings.getHeight() - getHeight() - mapPadding[3] + mapPadding[1]) / 2 + (contentPadding[1] - contentPadding[3]) / 2); + float x = (uiSettings.getWidth() - getWidth() + mapPadding[0] - mapPadding[2]) / 2 + (contentPadding[0] - contentPadding[2]) / 2; + float y = (uiSettings.getHeight() - getHeight() - mapPadding[3] + mapPadding[1]) / 2 + (contentPadding[1] - contentPadding[3]) / 2; + screenLocation = new PointF(x, y); MyLocationView.this.invalidate(); } } @@ -694,11 +712,7 @@ public class MyLocationView extends View { @Override void invalidate() { - PointF screenLocation = projection.toScreenLocation(latLng); - if (screenLocation != null) { - setX((screenLocation.x - getWidth() / 2)); - setY((screenLocation.y - getHeight() / 2)); - } + screenLocation = projection.toScreenLocation(latLng); MyLocationView.this.invalidate(); } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapview_internal.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapview_internal.xml index 9799487f1..e944a5b4d 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapview_internal.xml +++ b/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapview_internal.xml @@ -31,7 +31,7 @@ + android:layout_width="match_parent" + android:layout_height="match_parent" /> \ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/values/dimens.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/values/dimens.xml index d6cca7090..fd0f4b98e 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/res/values/dimens.xml +++ b/platform/android/MapboxGLAndroidSDK/src/main/res/values/dimens.xml @@ -9,6 +9,5 @@ 10dp 16dp 76dp - 64dp 18dp From 3d2cc051219f6b3a2f7ef108d780522fd194897f Mon Sep 17 00:00:00 2001 From: Tobrun Van Nuland Date: Wed, 1 Jun 2016 08:57:23 +0200 Subject: [PATCH 18/41] [android] #4929 - MyLocationView now requires less drawables to configure, reuses the foreground instead. --- .../mapbox/mapboxsdk/maps/MapboxMapOptions.java | 10 ++++++++++ .../mapboxsdk/maps/widgets/MyLocationView.java | 15 ++++++++++++++- .../src/main/res/values/strings.xml | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java index 17593129e..25f1a255e 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java @@ -462,6 +462,16 @@ public class MapboxMapOptions implements Parcelable { return this; } + /** + * + * @param myLocationForegroundDrawable + * @return This + */ + public MapboxMapOptions myLocationForegroundDrawable(Drawable myLocationForegroundDrawable) { + this.myLocationForegroundDrawable = myLocationForegroundDrawable; + return this; + } + /** * @param myLocationBackgroundDrawable * @return This diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java index 20513224f..a730160ff 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java @@ -129,9 +129,22 @@ public class MyLocationView extends View { } public final void setForegroundDrawables(Drawable defaultDrawable, Drawable bearingDrawable) { - if (defaultDrawable == null || bearingDrawable == null) { + if (defaultDrawable == null) { return; } + + if (bearingDrawable == null) { + // if user only provided one resource + // use same for bearing mode + bearingDrawable = defaultDrawable; + } + + if (backgroundDrawable == null) { + // if the user didn't provide a background resource we will use the foreground resource instead, + // we need to create a new drawable to handle tinting correctly + backgroundDrawable = defaultDrawable.getConstantState().newDrawable(); + } + if (defaultDrawable.getIntrinsicWidth() != bearingDrawable.getIntrinsicWidth() || defaultDrawable.getIntrinsicHeight() != bearingDrawable.getIntrinsicHeight()) { throw new RuntimeException("The dimensions from location and bearing drawables should be match"); } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml index a84035aa5..c8a9b3c9b 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml @@ -38,7 +38,7 @@ Double Map Activity Snapshot Activity User tracking mode - User location customization + User location drawable User location tint color User location toggle Custom Layer From d2c9f26cb61234ee0df2945474c402439ba13223 Mon Sep 17 00:00:00 2001 From: Tobrun Van Nuland Date: Wed, 1 Jun 2016 11:45:09 +0200 Subject: [PATCH 19/41] [android] 4929 - fix tracking mode location calculation --- .../com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java index a730160ff..5c9b11126 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java @@ -656,9 +656,8 @@ public class MyLocationView extends View { @Override void invalidate() { int[] mapPadding = mapboxMap.getPadding(); - UiSettings uiSettings = mapboxMap.getUiSettings(); - float x = (uiSettings.getWidth() - getWidth() + mapPadding[0] - mapPadding[2]) / 2 + (contentPadding[0] - contentPadding[2]) / 2; - float y = (uiSettings.getHeight() - getHeight() - mapPadding[3] + mapPadding[1]) / 2 + (contentPadding[1] - contentPadding[3]) / 2; + float x = (getWidth() + mapPadding[0] - mapPadding[2]) / 2 + (contentPadding[0] - contentPadding[2]) / 2; + float y = (getHeight() - mapPadding[3] + mapPadding[1]) / 2 + (contentPadding[1] - contentPadding[3]) / 2; screenLocation = new PointF(x, y); MyLocationView.this.invalidate(); } From 041a351fb279751ede35fc0860651176ec0ca292 Mon Sep 17 00:00:00 2001 From: Tobrun Van Nuland Date: Wed, 1 Jun 2016 18:28:28 +0200 Subject: [PATCH 20/41] [android] #4929 - final fixes for refactor MyLocationView --- .../com/mapbox/mapboxsdk/maps/MapView.java | 2 +- .../maps/widgets/MyLocationView.java | 41 +++++++++++++++---- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java index 76a3e6517..20fe96e7a 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java @@ -252,6 +252,7 @@ public class MapView extends FrameLayout { CameraPosition position = options.getCamera(); if (position != null) { mMapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(position)); + mMyLocationView.setTilt(position.tilt); } String accessToken = null; @@ -407,7 +408,6 @@ public class MapView extends FrameLayout { // User location try { - //noinspection ResourceType mMapboxMap.setMyLocationEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_MY_LOCATION_ENABLED)); } catch (SecurityException ignore) { // User did not accept location permissions diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java index 5c9b11126..a1515b39c 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java @@ -17,6 +17,8 @@ import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.location.Location; +import android.os.Bundle; +import android.os.Parcelable; import android.os.SystemClock; import android.support.annotation.ColorInt; import android.support.annotation.FloatRange; @@ -36,7 +38,6 @@ import com.mapbox.mapboxsdk.location.LocationListener; import com.mapbox.mapboxsdk.location.LocationServices; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.Projection; -import com.mapbox.mapboxsdk.maps.UiSettings; import java.lang.ref.WeakReference; @@ -64,7 +65,7 @@ public class MyLocationView extends View { private ValueAnimator locationChangeAnimator; private ValueAnimator accuracyAnimator; - private ObjectAnimator directionAnimator; + private ValueAnimator directionAnimator; private Drawable foregroundDrawable; private Drawable foregroundBearingDrawable; @@ -136,7 +137,7 @@ public class MyLocationView extends View { if (bearingDrawable == null) { // if user only provided one resource // use same for bearing mode - bearingDrawable = defaultDrawable; + bearingDrawable = defaultDrawable.getConstantState().newDrawable(); } if (backgroundDrawable == null) { @@ -226,6 +227,7 @@ public class MyLocationView extends View { int foregroundHeight = foregroundDrawable.getIntrinsicHeight(); foregroundBounds = new Rect(-foregroundWidth / 2, -foregroundHeight / 2, foregroundWidth / 2, foregroundHeight / 2); foregroundDrawable.setBounds(foregroundBounds); + foregroundBearingDrawable.setBounds(foregroundBounds); // invoke a new draw invalidate(); @@ -240,6 +242,8 @@ public class MyLocationView extends View { return; } + final PointF pointF = screenLocation; + float metersPerPixel = (float) projection.getMetersPerPixelAtLatitude(location.getLatitude()); float accuracyPixels = (Float) accuracyAnimator.getAnimatedValue() / metersPerPixel / 2; float maxRadius = getWidth() / 2; @@ -255,8 +259,13 @@ public class MyLocationView extends View { // map camera matrix on our matrix camera.getMatrix(matrix); + // + if (myBearingTrackingMode != MyBearingTracking.NONE) { + matrix.postRotate((Float) directionAnimator.getAnimatedValue()); + } + // put matrix at location of MyLocationView - matrix.postTranslate(screenLocation.x, screenLocation.y); + matrix.postTranslate(pointF.x, pointF.y); // concat our matrix on canvas canvas.concat(matrix); @@ -324,6 +333,24 @@ public class MyLocationView extends View { toggleGps(enabled); } + @Override + protected Parcelable onSaveInstanceState() { + Bundle bundle = new Bundle(); + bundle.putParcelable("superState", super.onSaveInstanceState()); + bundle.putFloat("tilt", tilt); + return bundle; + } + + @Override + public void onRestoreInstanceState(Parcelable state){ + if (state instanceof Bundle){ + Bundle bundle = (Bundle) state; + tilt = bundle.getFloat("tilt"); + state = bundle.getParcelable("superState"); + } + super.onRestoreInstanceState(state); + } + /** * Enabled / Disable GPS location updates along with updating the UI * @@ -415,8 +442,8 @@ public class MyLocationView extends View { } previousDirection = newDir; - directionAnimator = ObjectAnimator.ofFloat(this, View.ROTATION, oldDir, newDir); - directionAnimator.setDuration(1000); + directionAnimator = ValueAnimator.ofFloat(oldDir, newDir); + directionAnimator.setDuration(375); directionAnimator.start(); } @@ -689,7 +716,7 @@ public class MyLocationView extends View { // calculate updateLatLng time + add some extra offset to improve animation long previousUpdateTimeStamp = locationUpdateTimestamp; locationUpdateTimestamp = SystemClock.elapsedRealtime(); - long locationUpdateDuration = (long) ((locationUpdateTimestamp - previousUpdateTimeStamp) * 1.1); + long locationUpdateDuration = (long) ((locationUpdateTimestamp - previousUpdateTimeStamp) * 1.3); // calculate interpolated entity interpolatedLocation = new LatLng((latLng.getLatitude() + previousLocation.getLatitude()) / 2, (latLng.getLongitude() + previousLocation.getLongitude()) / 2); From fe40127b12be1228a875bba3c0a5d662839660f8 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Thu, 2 Jun 2016 09:41:56 +0200 Subject: [PATCH 21/41] [android] #4929 - fix unit tests MyLocationSettings --- .../mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java index a03eb6aca..fd7030893 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettingsTest.java @@ -16,6 +16,7 @@ import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertTrue; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; public class MyLocationViewSettingsTest { @@ -41,6 +42,9 @@ public class MyLocationViewSettingsTest { public void testForegroundDrawables() { Drawable foregroundDrawable = mock(Drawable.class); Drawable foregroundBearingDrawable = mock(Drawable.class); + Drawable.ConstantState constantState = mock(Drawable.ConstantState.class); + when(foregroundDrawable.getConstantState()).thenReturn(constantState); + when(constantState.newDrawable()).thenReturn(foregroundDrawable); locationViewSettings.setForegroundDrawable(foregroundDrawable, foregroundBearingDrawable); assertEquals("foreground should match", foregroundDrawable, locationViewSettings.getForegroundDrawable()); assertEquals("foreground bearing should match", foregroundBearingDrawable, locationViewSettings.getForegroundBearingDrawable()); From 087cad037fe0ef57884b4a351a7ecb13248925e5 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Thu, 2 Jun 2016 15:14:07 +0200 Subject: [PATCH 22/41] [android] #5214 - remove requirement adapter for MarkerView, allow using Icon instead --- .../mapboxsdk/annotations/MarkerView.java | 33 +++++++ .../annotations/MarkerViewManager.java | 88 ++++++++++++++----- .../com/mapbox/mapboxsdk/maps/MapboxMap.java | 6 +- .../src/main/res/layout/view_image_marker.xml | 5 ++ .../annotation/MarkerViewActivity.java | 58 ++++-------- .../main/res/layout/view_custom_marker.xml | 4 +- 6 files changed, 127 insertions(+), 67 deletions(-) create mode 100644 platform/android/MapboxGLAndroidSDK/src/main/res/layout/view_image_marker.xml diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerView.java index 3e5104464..d0e47110f 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerView.java @@ -1,5 +1,8 @@ package com.mapbox.mapboxsdk.annotations; +import android.graphics.Bitmap; +import android.support.annotation.Nullable; + import com.mapbox.mapboxsdk.maps.MapboxMap; /** @@ -35,6 +38,8 @@ public class MarkerView extends Marker { private float rotation; private float alpha = 1; + private Icon markerViewIcon; + /** * Publicly hidden default constructor */ @@ -315,6 +320,34 @@ public class MarkerView extends Marker { } } + /** + * Set the icon of the MarkerView. + * + * @param icon the icon to be used as Marker image + */ + @Override + public void setIcon(@Nullable Icon icon) { + if (icon != null) { + markerViewIcon = IconFactory.recreate("icon", icon.getBitmap()); + } + Bitmap bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); + Icon transparentIcon = IconFactory.recreate("markerViewSettings", bitmap); + if (markerViewManager != null) { + markerViewManager.updateIcon(this); + } + super.setIcon(transparentIcon); + } + + /** + * Get the icon of the MarkerView. + * + * @return the icon use as Marker image + */ + @Override + public Icon getIcon() { + return markerViewIcon; + } + /** * Set the MapboxMap associated tot the MapView containing the MarkerView. *

diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java index d9fc9e62a..39e17fd68 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java @@ -1,12 +1,17 @@ package com.mapbox.mapboxsdk.annotations; +import android.content.Context; import android.graphics.PointF; import android.os.SystemClock; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.util.Pools; +import android.view.LayoutInflater; import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import com.mapbox.mapboxsdk.R; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.Projection; @@ -26,12 +31,13 @@ import java.util.Map; */ public class MarkerViewManager { - private Map mMarkerViewMap; + private Map markerViewMap; private MapboxMap mapboxMap; private MapView mapView; private List markerViewAdapters; - private long mViewMarkerBoundsUpdateTime; + private long viewMarkerBoundsUpdateTime; private MapboxMap.OnMarkerViewClickListener onMarkerViewClickListener; + private ImageMarkerViewAdapter defaultMarkerViewAdapter; /** * Creates an instance of MarkerViewManager. @@ -43,7 +49,10 @@ public class MarkerViewManager { this.mapboxMap = mapboxMap; this.markerViewAdapters = new ArrayList<>(); this.mapView = mapView; - mMarkerViewMap = new HashMap<>(); + this.markerViewMap = new HashMap<>(); + this.defaultMarkerViewAdapter = new ImageMarkerViewAdapter(mapView.getContext()); + // FIXME only add this if a MarkerView instance is added to MapboxMap + this.markerViewAdapters.add(defaultMarkerViewAdapter); } /** @@ -56,7 +65,7 @@ public class MarkerViewManager { * @param rotation the rotation value */ public void animateRotation(@NonNull MarkerView marker, float rotation) { - View convertView = mMarkerViewMap.get(marker); + View convertView = markerViewMap.get(marker); if (convertView != null) { AnimatorUtils.rotate(convertView, rotation); } @@ -72,7 +81,7 @@ public class MarkerViewManager { * @param alpha the alpha value */ public void animateAlpha(@NonNull MarkerView marker, float alpha) { - View convertView = mMarkerViewMap.get(marker); + View convertView = markerViewMap.get(marker); if (convertView != null) { AnimatorUtils.alpha(convertView, alpha); } @@ -88,7 +97,7 @@ public class MarkerViewManager { * @param visible the flag indicating if MarkerView is visible */ public void animateVisible(@NonNull MarkerView marker, boolean visible) { - View convertView = mMarkerViewMap.get(marker); + View convertView = markerViewMap.get(marker); if (convertView != null) { convertView.setVisibility(visible ? View.VISIBLE : View.GONE); } @@ -104,8 +113,8 @@ public class MarkerViewManager { */ public void update() { View convertView; - for (MarkerView marker : mMarkerViewMap.keySet()) { - convertView = mMarkerViewMap.get(marker); + for (MarkerView marker : markerViewMap.keySet()) { + convertView = markerViewMap.get(marker); if (convertView != null) { PointF point = mapboxMap.getProjection().toScreenLocation(marker.getPosition()); int x = (int) (marker.getAnchorU() * convertView.getMeasuredWidth()); @@ -133,9 +142,9 @@ public class MarkerViewManager { */ public void setTilt(float tilt) { View convertView; - for (MarkerView markerView : mMarkerViewMap.keySet()) { + for (MarkerView markerView : markerViewMap.keySet()) { if (markerView.isFlat()) { - convertView = mMarkerViewMap.get(markerView); + convertView = markerViewMap.get(markerView); if (convertView != null) { markerView.setTilt(tilt); convertView.setRotationX(tilt); @@ -144,6 +153,16 @@ public class MarkerViewManager { } } + /** + * + */ + public void updateIcon(@NonNull MarkerView markerView) { + View convertView = markerViewMap.get(markerView); + if (convertView != null && convertView instanceof ImageView) { + ((ImageView) convertView).setImageBitmap(markerView.getIcon().getBitmap()); + } + } + /** * Animate a MarkerView to a deselected state. *

@@ -154,7 +173,7 @@ public class MarkerViewManager { * @param marker the MarkerView to deselect */ public void deselect(@NonNull MarkerView marker) { - final View convertView = mMarkerViewMap.get(marker); + final View convertView = markerViewMap.get(marker); if (convertView != null) { int deselectAnimatorRes = marker.getDeselectAnimRes(); if (deselectAnimatorRes != 0) { @@ -176,7 +195,7 @@ public class MarkerViewManager { * @param removeFromMap flag indicating if a MarkerView will be removed from the collection. */ public void removeMarkerView(MarkerView marker, boolean removeFromMap) { - final View viewHolder = mMarkerViewMap.get(marker); + final View viewHolder = markerViewMap.get(marker); if (viewHolder != null && marker != null) { for (final MapboxMap.MarkerViewAdapter adapter : markerViewAdapters) { if (adapter.getMarkerClass() == marker.getClass()) { @@ -198,7 +217,7 @@ public class MarkerViewManager { } } if (removeFromMap) { - mMarkerViewMap.remove(marker); + markerViewMap.remove(marker); } } @@ -223,7 +242,6 @@ public class MarkerViewManager { return markerViewAdapters; } - /** * Register a callback to be invoked when this view is clicked. * @@ -243,11 +261,11 @@ public class MarkerViewManager { public void scheduleViewMarkerInvalidation() { if (!markerViewAdapters.isEmpty()) { long currentTime = SystemClock.elapsedRealtime(); - if (currentTime < mViewMarkerBoundsUpdateTime) { + if (currentTime < viewMarkerBoundsUpdateTime) { return; } invalidateViewMarkersInBounds(); - mViewMarkerBoundsUpdateTime = currentTime + 250; + viewMarkerBoundsUpdateTime = currentTime + 250; } } @@ -264,12 +282,12 @@ public class MarkerViewManager { View convertView; // remove old markers - Iterator iterator = mMarkerViewMap.keySet().iterator(); + Iterator iterator = markerViewMap.keySet().iterator(); while (iterator.hasNext()) { MarkerView m = iterator.next(); if (!markers.contains(m)) { // remove marker - convertView = mMarkerViewMap.get(m); + convertView = markerViewMap.get(m); int deselectAnimRes = m.getDeselectAnimRes(); if (deselectAnimRes != 0) { AnimatorUtils.animate(convertView, deselectAnimRes, 0); @@ -281,7 +299,7 @@ public class MarkerViewManager { // introduce new markers for (final MarkerView marker : markers) { - if (!mMarkerViewMap.containsKey(marker)) { + if (!markerViewMap.containsKey(marker)) { for (final MapboxMap.MarkerViewAdapter adapter : markerViewAdapters) { if (adapter.getMarkerClass() == marker.getClass()) { convertView = (View) adapter.getViewReusePool().acquire(); @@ -339,7 +357,7 @@ public class MarkerViewManager { } }); - mMarkerViewMap.put(marker, adaptedView); + markerViewMap.put(marker, adaptedView); if (convertView == null) { mapView.addView(adaptedView); } @@ -349,4 +367,34 @@ public class MarkerViewManager { } } } + + public static class ImageMarkerViewAdapter extends MapboxMap.MarkerViewAdapter { + + private LayoutInflater inflater; + + public ImageMarkerViewAdapter(Context context) { + super(context); + inflater = LayoutInflater.from(context); + } + + @Nullable + @Override + public View getView(@NonNull MarkerView marker, @Nullable View convertView, @NonNull ViewGroup parent) { + ViewHolder viewHolder; + if (convertView == null) { + viewHolder = new ViewHolder(); + convertView = inflater.inflate(R.layout.view_image_marker, parent, false); + viewHolder.imageView = (ImageView) convertView.findViewById(R.id.image); + convertView.setTag(viewHolder); + } else { + viewHolder = (ViewHolder) convertView.getTag(); + } + viewHolder.imageView.setImageBitmap(marker.getIcon().getBitmap()); + return convertView; + } + + private static class ViewHolder { + ImageView imageView; + } + } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java index a19588b8c..89ff6b9fc 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java @@ -72,7 +72,6 @@ public class MapboxMap { private List mInfoWindows; private MapboxMap.InfoWindowAdapter mInfoWindowAdapter; - private Bitmap mViewMarkerBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); private boolean mMyLocationEnabled; private boolean mAllowConcurrentMultipleInfoWindows; @@ -703,8 +702,8 @@ public class MapboxMap { @NonNull public MarkerView addMarker(@NonNull BaseMarkerViewOptions markerOptions) { MarkerView marker = prepareViewMarker(markerOptions); - long id = mMapView.addMarker(marker); marker.setMapboxMap(this); + long id = mMapView.addMarker(marker); marker.setId(id); mAnnotations.put(id, marker); return marker; @@ -1209,8 +1208,7 @@ public class MapboxMap { private MarkerView prepareViewMarker(BaseMarkerViewOptions markerViewOptions) { MarkerView marker = markerViewOptions.getMarker(); - Icon icon = IconFactory.recreate("markerViewSettings", mViewMarkerBitmap); - marker.setIcon(icon); + marker.setIcon(markerViewOptions.getIcon()); return marker; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/layout/view_image_marker.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/layout/view_image_marker.xml new file mode 100644 index 000000000..7e4a07906 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDK/src/main/res/layout/view_image_marker.xml @@ -0,0 +1,5 @@ + + diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java index 65a5afa60..60ace581a 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java @@ -1,9 +1,7 @@ package com.mapbox.mapboxsdk.testapp.activity.annotation; import android.content.Context; -import android.graphics.Point; import android.os.Bundle; -import android.os.Handler; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v7.app.ActionBar; @@ -17,8 +15,9 @@ import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; +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; import com.mapbox.mapboxsdk.annotations.MarkerViewOptions; import com.mapbox.mapboxsdk.geometry.LatLng; @@ -68,38 +67,42 @@ public class MarkerViewActivity extends AppCompatActivity { public void onMapReady(@NonNull MapboxMap mapboxMap) { mMapboxMap = mapboxMap; - // add text markers + final MarkerViewManager markerViewManager = mapboxMap.getMarkerViewManager(); + + Icon usFlag = IconFactory.getInstance(MarkerViewActivity.this) + .fromResource(R.drawable.ic_us); + + // add default ViewMarker markers for (int i = 0; i < LAT_LNGS.length; i++) { mMapboxMap.addMarker(new MarkerViewOptions() .position(LAT_LNGS[i]) .title(String.valueOf(i)) + .icon(usFlag) .selectAnimatorResource(R.animator.scale_up) .deselectAnimatorResource(R.animator.scale_down) ); } - // add flag marker + // add child classes of ViewMarker CountryMarkerViewOptions options = new CountryMarkerViewOptions(); - options.title("United States"); - options.abbrevName("us"); - options.flagRes(R.drawable.ic_us); + options.flagRes(R.drawable.icon_burned); + options.abbrevName("Mapbox"); options.position(new LatLng(38.899774, -77.023237)); options.selectAnimatorResource(R.animator.rotate_360); options.deselectAnimatorResource(R.animator.rotate_360); options.flat(true); mapboxMap.addMarker(options); - // default GL marker + // add default GL marker mMapboxMap.addMarker(new CountryMarkerOptions() .title("United States") .position(new LatLng(38.902580, -77.050102)) ); - // set adapters - final MarkerViewManager markerViewManager = mapboxMap.getMarkerViewManager(); - markerViewManager.addMarkerViewAdapter(new TextAdapter(MarkerViewActivity.this)); + // set adapters for child classes of ViewMarker markerViewManager.addMarkerViewAdapter(new CountryAdapter(MarkerViewActivity.this)); + // add a change listener to validate the size of amount of child views mMapView.addOnMapChangedListener(new MapView.OnMapChangedListener() { @Override public void onMapChanged(@MapView.MapChange int change) { @@ -111,6 +114,7 @@ public class MarkerViewActivity extends AppCompatActivity { } }); + // add a OnMarkerView click listener mMapboxMap.getMarkerViewManager().setOnMarkerViewClickListener(new MapboxMap.OnMarkerViewClickListener() { @Override public boolean onMarkerClick(@NonNull Marker marker, @NonNull View view, @NonNull MapboxMap.MarkerViewAdapter adapter) { @@ -122,36 +126,6 @@ public class MarkerViewActivity extends AppCompatActivity { }); } - private static class TextAdapter extends MapboxMap.MarkerViewAdapter { - - private LayoutInflater inflater; - - public TextAdapter(@NonNull Context context) { - super(context); - this.inflater = LayoutInflater.from(context); - } - - @Nullable - @Override - public View getView(@NonNull MarkerView marker, @Nullable View convertView, @NonNull ViewGroup parent) { - ViewHolder viewHolder; - if (convertView == null) { - viewHolder = new ViewHolder(); - convertView = inflater.inflate(R.layout.view_text_marker, parent, false); - viewHolder.title = (TextView) convertView.findViewById(R.id.textView); - convertView.setTag(viewHolder); - } else { - viewHolder = (ViewHolder) convertView.getTag(); - } - viewHolder.title.setText(marker.getTitle()); - return convertView; - } - - private static class ViewHolder { - TextView title; - } - } - private static class CountryAdapter extends MapboxMap.MarkerViewAdapter { private LayoutInflater inflater; diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/view_custom_marker.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/view_custom_marker.xml index 08caf1df6..98050c061 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/view_custom_marker.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/view_custom_marker.xml @@ -14,6 +14,8 @@ android:textColor="@android:color/white" android:layout_height="wrap_content" android:textStyle="bold" - android:layout_centerInParent="true" /> + android:layout_alignBottom="@id/imageView" + android:layout_centerHorizontal="true" + android:padding="2dp"/> \ No newline at end of file From c9c6ea7d6fa0da196a1de43ac2889013c3425ec8 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Fri, 3 Jun 2016 12:00:38 +0300 Subject: [PATCH 23/41] [build] Added Bitrise Qt{4,5} OS X Part of #5121. (cherry picked from commit f3b168b9a8013b4d116a0d75dc0898b0ee4a53bd) --- platform/qt/bitrise-qt4.yml | 56 ++++++++++++++++++++++++++++++++++++ platform/qt/bitrise-qt5.yml | 57 +++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 platform/qt/bitrise-qt4.yml create mode 100644 platform/qt/bitrise-qt5.yml diff --git a/platform/qt/bitrise-qt4.yml b/platform/qt/bitrise-qt4.yml new file mode 100644 index 000000000..83c222a9d --- /dev/null +++ b/platform/qt/bitrise-qt4.yml @@ -0,0 +1,56 @@ +--- +format_version: 1.0.0 +default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git +trigger_map: +- pattern: "*" + is_pull_request_allowed: true + workflow: primary +workflows: + primary: + steps: + - script: + title: Check for skipping CI + inputs: + - content: |- + #!/bin/bash + + if [[ -n "$(echo $GIT_CLONE_COMMIT_MESSAGE_SUBJECT | sed -n '/\[skip ci\]/p')" || + -n "$(echo $GIT_CLONE_COMMIT_MESSAGE_SUBJECT | sed -n '/\[ci skip\]/p')" || + -n "$(echo $GIT_CLONE_COMMIT_MESSAGE_BODY | sed -n 's/\[skip ci\]/p')" || + -n "$(echo $GIT_CLONE_COMMIT_MESSAGE_BODY | sed -n 's/\[ci skip\]/p')" ]]; then + envman add --key SKIPCI --value true + else + envman add --key SKIPCI --value false + fi + - script: + title: Run build + run_if: '{{enveq "SKIPCI" "false"}}' + inputs: + - content: |- + #!/bin/bash + set -eu -o pipefail + brew install qt + brew link qt + brew linkapps qt + export BUILDTYPE=Debug + make qt-app + make test-qt + - is_debug: 'yes' + - slack: + title: Post to Slack + run_if: '{{enveq "SKIPCI" "false"}}' + inputs: + - webhook_url: "$SLACK_HOOK_URL" + - channel: "#gl-bots" + - from_username: 'Bitrise Qt4 OS X' + - from_username_on_error: 'Bitrise Qt4 OS X' + - message: '<${BITRISE_BUILD_URL}|Build #${BITRISE_BUILD_NUMBER}> + for + by ${GIT_CLONE_COMMIT_COMMITER_NAME} + passed' + - message_on_error: '<${BITRISE_BUILD_URL}|Build #${BITRISE_BUILD_NUMBER}> + for + by ${GIT_CLONE_COMMIT_COMMITER_NAME} + failed' + - icon_url: https://bitrise-public-content-production.s3.amazonaws.com/slack/bitrise-slack-icon-128.png + - icon_url_on_error: https://bitrise-public-content-production.s3.amazonaws.com/slack/bitrise-slack-error-icon-128.png diff --git a/platform/qt/bitrise-qt5.yml b/platform/qt/bitrise-qt5.yml new file mode 100644 index 000000000..1e767b316 --- /dev/null +++ b/platform/qt/bitrise-qt5.yml @@ -0,0 +1,57 @@ +--- +format_version: 1.0.0 +default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git +trigger_map: +- pattern: "*" + is_pull_request_allowed: true + workflow: primary +workflows: + primary: + steps: + - script: + title: Check for skipping CI + inputs: + - content: |- + #!/bin/bash + + if [[ -n "$(echo $GIT_CLONE_COMMIT_MESSAGE_SUBJECT | sed -n '/\[skip ci\]/p')" || + -n "$(echo $GIT_CLONE_COMMIT_MESSAGE_SUBJECT | sed -n '/\[ci skip\]/p')" || + -n "$(echo $GIT_CLONE_COMMIT_MESSAGE_BODY | sed -n 's/\[skip ci\]/p')" || + -n "$(echo $GIT_CLONE_COMMIT_MESSAGE_BODY | sed -n 's/\[ci skip\]/p')" ]]; then + envman add --key SKIPCI --value true + else + envman add --key SKIPCI --value false + fi + - script: + title: Run build + run_if: '{{enveq "SKIPCI" "false"}}' + inputs: + - content: |- + #!/bin/bash + set -eu -o pipefail + brew install qt5 + brew link qt5 --force + brew linkapps qt5 + export BUILDTYPE=Debug + make qt-app + make qt-qml-app + make test-qt + - is_debug: 'yes' + - slack: + title: Post to Slack + run_if: '{{enveq "SKIPCI" "false"}}' + inputs: + - webhook_url: "$SLACK_HOOK_URL" + - channel: "#gl-bots" + - from_username: 'Bitrise Qt5 OS X' + - from_username_on_error: 'Bitrise Qt5 OS X' + - message: '<${BITRISE_BUILD_URL}|Build #${BITRISE_BUILD_NUMBER}> + for + by ${GIT_CLONE_COMMIT_COMMITER_NAME} + passed' + - message_on_error: '<${BITRISE_BUILD_URL}|Build #${BITRISE_BUILD_NUMBER}> + for + by ${GIT_CLONE_COMMIT_COMMITER_NAME} + failed' + - icon_url: https://bitrise-public-content-production.s3.amazonaws.com/slack/bitrise-slack-icon-128.png + - icon_url_on_error: https://bitrise-public-content-production.s3.amazonaws.com/slack/bitrise-slack-error-icon-128.png From 0bfe951b555710fbe7d0a56c301664d1ad324a12 Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 3 Jun 2016 12:05:06 -0400 Subject: [PATCH 24/41] [android] Fix style urls Fixes #5193 --- .../com/mapbox/mapboxsdk/constants/Style.java | 177 +++--------------- .../com/mapbox/mapboxsdk/maps/MapView.java | 4 +- .../com/mapbox/mapboxsdk/maps/MapboxMap.java | 2 +- .../src/main/res/values/strings.xml | 5 +- .../activity/annotation/PolygonActivity.java | 2 +- .../annotation/PressForMarkerActivity.java | 4 +- .../activity/camera/LatLngBoundsActivity.java | 7 +- .../activity/camera/ManualZoomActivity.java | 5 +- .../fragment/MapFragmentActivity.java | 3 +- .../fragment/SupportMapFragmentActivity.java | 3 +- .../activity/geocoding/GeocoderActivity.java | 7 +- .../activity/maplayout/DebugModeActivity.java | 13 +- .../activity/maplayout/DoubleMapActivity.java | 5 +- .../activity/offline/OfflineActivity.java | 6 +- .../MyLocationDrawableActivity.java | 4 +- .../src/main/res/values/strings.xml | 2 + 16 files changed, 61 insertions(+), 188 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java index 3fdff5a7c..51eb03805 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/Style.java @@ -1,7 +1,9 @@ package com.mapbox.mapboxsdk.constants; import android.support.annotation.StringDef; + import com.mapbox.mapboxsdk.maps.MapView; + import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -15,156 +17,32 @@ import java.lang.annotation.RetentionPolicy; */ public class Style { - /** - * Mapbox Streets: A complete basemap, perfect for incorporating your own data. - */ - private static final String MAPBOX_STREETS_BASE = "mapbox://styles/mapbox/streets-v%d"; - /** - * Outdoors: A general-purpose style tailored to outdoor activities. - */ - private static final String OUTDOORS_BASE = "mapbox://styles/mapbox/outdoors-v%d"; - /** - * Light: Subtle light backdrop for data visualizations. - */ - private static final String LIGHT_BASE = "mapbox://styles/mapbox/light-v%d"; - /** - * Dark: Subtle dark backdrop for data visualizations. - */ - private static final String DARK_BASE = "mapbox://styles/mapbox/dark-v%d"; - /** - * Satellite: A beautiful global satellite and aerial imagery layer. - */ - private static final String SATELLITE_BASE = "mapbox://styles/mapbox/satellite-v%d"; - /** - * Satellite Streets: Global satellite and aerial imagery with unobtrusive labels. - */ - private static final String SATELLITE_STREETS_BASE = "mapbox://styles/mapbox/satellite-streets-v%d"; /** - * Satellite Streets: Global satellite and aerial imagery with unobtrusive labels (Version 8). + * Indicates the parameter accepts one of the values from {@link Style}. Using one of these + * constants means your map style will always use the latest version and may change as we + * improve the style */ - private static final String SATELLITE_STREETS_V8 = "mapbox://styles/mapbox/satellite-hybrid-v8"; - - /** - * Get versioned url of Mapbox streets style. - *

    - *
  • Current default version is 9.
  • - *
- *

- * More information on the Mapbox styles API can be found on https://www.mapbox.com/api-documentation/#styles - *

- * - * @param version the version of the style. - * @return uri to load style from - */ - public static String getMapboxStreetsUrl(int version) { - return String.format(MapboxConstants.MAPBOX_LOCALE, MAPBOX_STREETS_BASE, version); - } - - /** - * Get versioned url of Outdoors streets style. - *
    - *
  • Current version is 9.
  • - *
- *

- * More information on the Mapbox styles API can be found on https://www.mapbox.com/api-documentation/#styles - *

- * - * @param version the version of the style. - * @return uri to load style from - */ - public static String getOutdoorsStyleUrl(int version) { - return String.format(MapboxConstants.MAPBOX_LOCALE, OUTDOORS_BASE, version); - } - - /** - * Get versioned url of Light style. - *
    - *
  • Current default version is 9.
  • - *
- *

- * More information on the Mapbox styles API can be found on https://www.mapbox.com/api-documentation/#styles - *

- * - * @param version the version of the style. - * @return uri to load style from - */ - public static String getLightStyleUrl(int version) { - return String.format(MapboxConstants.MAPBOX_LOCALE, LIGHT_BASE, version); - } - - /** - * Get versioned url of Dark style. - *
    - *
  • Current default version is 9.
  • - *
- *

- * More information on the Mapbox styles API can be found on https://www.mapbox.com/api-documentation/#styles - *

- * - * @param version the version of the style. - * @return uri to load style from - */ - public static String getDarkStyleUrl(int version) { - return String.format(MapboxConstants.MAPBOX_LOCALE, DARK_BASE, version); - } - - /** - * Get versioned url of Satellite style. - *
    - *
  • Current version is 9.
  • - *
- *

- * More information on the Mapbox styles API can be found on https://www.mapbox.com/api-documentation/#styles - *

- * - * @param version the version of the style. - * @return uri to load style from - */ - public static String getSatelliteStyleUrl(int version) { - return String.format(MapboxConstants.MAPBOX_LOCALE, SATELLITE_BASE, version); - } - - /** - * Get versioned url of Satellite streets style. - *
    - *
  • Current version is 9.
  • - *
- *

- * More information on the Mapbox styles API can be found on https://www.mapbox.com/api-documentation/#styles - *

- * - * @param version the version of the style. - * @return uri to load style from - */ - public static String getSatelliteStreetsStyleUrl(int version) { - if (version == 8) { - return SATELLITE_STREETS_V8; - } - return String.format(MapboxConstants.MAPBOX_LOCALE, SATELLITE_STREETS_BASE, version); - } - - /** - * Indicates the parameter accepts one of the values from {@link Style}. - * - * @deprecated use dedicated versioned methods in {@link Style} instead. - */ - @StringDef({MAPBOX_STREETS, EMERALD, LIGHT, DARK, SATELLITE, SATELLITE_STREETS}) + @StringDef({MAPBOX_STREETS, OUTDOORS, EMERALD, LIGHT, DARK, SATELLITE, SATELLITE_STREETS}) @Retention(RetentionPolicy.SOURCE) - @Deprecated public @interface StyleUrl { } // IMPORTANT: If you change any of these you also need to edit them in strings.xml /** - * Mapbox Streets: A complete basemap, perfect for incorporating your own data. - * - * @deprecated use {@link #getMapboxStreetsUrl(int)} instead. + * Mapbox Streets: A complete basemap, perfect for incorporating your own data. Using this + * constant means your map style will always use the latest version and may change as we + * improve the style. */ - @Deprecated public static final String MAPBOX_STREETS = "mapbox://styles/mapbox/streets-v9"; + /** + * Outdoors: A general-purpose style tailored to outdoor activities. Using this constant means + * your map style will always use the latest version and may change as we improve the style. + */ + public static final String OUTDOORS = "mapbox://styles/mapbox/outdoors-v9"; + /** * Emerald: A versatile style, with emphasis on road networks and public transit. * @@ -174,34 +52,27 @@ public class Style { public static final String EMERALD = "mapbox://styles/mapbox/emerald-v8"; /** - * Light: Subtle light backdrop for data visualizations. - * - * @deprecated use {@link #getLightStyleUrl(int)} instead. + * Light: Subtle light backdrop for data visualizations. Using this constant means your map + * style will always use the latest version and may change as we improve the style. */ - @Deprecated public static final String LIGHT = "mapbox://styles/mapbox/light-v9"; /** - * Dark: Subtle dark backdrop for data visualizations. - * - * @deprecated use {@link #getDarkStyleUrl(int)} (int)} instead. + * Dark: Subtle dark backdrop for data visualizations. Using this constant means your map style + * will always use the latest version and may change as we improve the style. */ - @Deprecated public static final String DARK = "mapbox://styles/mapbox/dark-v9"; /** - * Satellite: A beautiful global satellite and aerial imagery layer. - * - * @deprecated use {@link #getSatelliteStyleUrl(int)} instead. + * Satellite: A beautiful global satellite and aerial imagery layer. Using this constant means + * your map style will always use the latest version and may change as we improve the style. */ - @Deprecated public static final String SATELLITE = "mapbox://styles/mapbox/satellite-v9"; /** - * Satellite Streets: Global satellite and aerial imagery with unobtrusive labels. - * - * @deprecated use {@link #getSatelliteStreetsStyleUrl(int)} (int)} instead. + * Satellite Streets: Global satellite and aerial imagery with unobtrusive labels. Using this + * constant means your map style will always use the latest version and may change as we + * improve the style. */ - @Deprecated public static final String SATELLITE_STREETS = "mapbox://styles/mapbox/satellite-streets-v9"; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java index 20fe96e7a..55b8277c8 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java @@ -783,7 +783,7 @@ public class MapView extends FrameLayout { *
  • {@code asset://...}: * reads the style from the APK {@code assets/} directory. * This is used to load a style bundled with your app.
  • - *
  • {@code null}: loads the default {@link Style#getMapboxStreetsUrl(int)} style.
  • + *
  • {@code null}: loads the default {@link Style#MAPBOX_STREETS} style.
  • * *

    * This method is asynchronous and will return immediately before the style finishes loading. @@ -2708,7 +2708,7 @@ public class MapView extends FrameLayout { private boolean mDefaultStyle; StyleInitializer(@NonNull Context context) { - mStyle = Style.getMapboxStreetsUrl(context.getResources().getInteger(R.integer.style_version)); + mStyle = Style.MAPBOX_STREETS; mDefaultStyle = true; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java index 89ff6b9fc..81b56cbd4 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java @@ -549,7 +549,7 @@ public class MapboxMap { *

  • {@code asset://...}: * reads the style from the APK {@code assets/} directory. * This is used to load a style bundled with your app.
  • - *
  • {@code null}: loads the default {@link Style#getMapboxStreetsUrl(int)} style.
  • + *
  • {@code null}: loads the default {@link Style#MAPBOX_STREETS} style.
  • * *

    * This method is asynchronous and will return immediately before the style finishes loading. diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/values/strings.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/values/strings.xml index becbcce0b..451783015 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/res/values/strings.xml +++ b/platform/android/MapboxGLAndroidSDK/src/main/res/values/strings.xml @@ -11,8 +11,11 @@ Address - + mapbox://styles/mapbox/streets-v9 + mapbox://styles/mapbox/outdoors-v9 + mapbox://styles/mapbox/emerald-v8 mapbox://styles/mapbox/light-v9 mapbox://styles/mapbox/dark-v9 diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolygonActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolygonActivity.java index f08d65163..68a5b642c 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolygonActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolygonActivity.java @@ -44,7 +44,7 @@ public class PolygonActivity extends AppCompatActivity { MapboxMapOptions options = new MapboxMapOptions() .attributionTintColor(Color.RED) .accessToken(getString(R.string.mapbox_access_token)) - .styleUrl(Style.getMapboxStreetsUrl(AppConstant.STYLE_VERSION)) + .styleUrl(Style.MAPBOX_STREETS) .camera(new CameraPosition.Builder() .target(new LatLng(45.520486, -122.673541)) .zoom(12) diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PressForMarkerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PressForMarkerActivity.java index 88008d64f..114304188 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PressForMarkerActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PressForMarkerActivity.java @@ -9,6 +9,7 @@ import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; + import com.mapbox.mapboxsdk.annotations.MarkerOptions; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.constants.Style; @@ -17,6 +18,7 @@ import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.testapp.R; + import java.text.DecimalFormat; import java.util.ArrayList; @@ -50,7 +52,7 @@ public class PressForMarkerActivity extends AppCompatActivity { @Override public void onMapReady(final MapboxMap map) { mapboxMap = map; - mapboxMap.setStyleUrl(Style.getOutdoorsStyleUrl(9)); + mapboxMap.setStyleUrl(Style.OUTDOORS); resetMap(); mapboxMap.setOnMapLongClickListener(new MapboxMap.OnMapLongClickListener() { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java index b9a438b7d..bc7ef3c59 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java @@ -9,17 +9,16 @@ import android.util.Log; import android.view.MenuItem; import com.mapbox.mapboxsdk.annotations.MarkerOptions; -import com.mapbox.mapboxsdk.constants.MapboxConstants; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; +import com.mapbox.mapboxsdk.constants.MapboxConstants; import com.mapbox.mapboxsdk.constants.Style; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.geometry.LatLngBounds; +import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.maps.UiSettings; import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.maps.MapView; -import com.mapbox.mapboxsdk.testapp.model.constants.AppConstant; public class LatLngBoundsActivity extends AppCompatActivity { @@ -43,7 +42,7 @@ public class LatLngBoundsActivity extends AppCompatActivity { } mMapView = (MapView) findViewById(R.id.mapView); - mMapView.setStyleUrl(Style.getDarkStyleUrl(AppConstant.STYLE_VERSION)); + mMapView.setStyleUrl(Style.DARK); mMapView.onCreate(savedInstanceState); mMapView.getMapAsync(new OnMapReadyCallback() { @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ManualZoomActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ManualZoomActivity.java index bc3691a2f..897380d1a 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ManualZoomActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ManualZoomActivity.java @@ -12,12 +12,11 @@ import android.view.View; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.constants.Style; +import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.maps.UiSettings; import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.maps.MapView; -import com.mapbox.mapboxsdk.testapp.model.constants.AppConstant; public class ManualZoomActivity extends AppCompatActivity { @@ -39,7 +38,7 @@ public class ManualZoomActivity extends AppCompatActivity { } mMapView = (MapView) findViewById(R.id.manualZoomMapView); - mMapView.setStyleUrl(Style.getSatelliteStyleUrl(AppConstant.STYLE_VERSION)); + mMapView.setStyleUrl(Style.SATELLITE); mMapView.onCreate(savedInstanceState); mMapView.getMapAsync(new OnMapReadyCallback() { @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MapFragmentActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MapFragmentActivity.java index 5987855aa..9d72c2b02 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MapFragmentActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MapFragmentActivity.java @@ -17,7 +17,6 @@ import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.MapboxMapOptions; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.model.constants.AppConstant; public class MapFragmentActivity extends AppCompatActivity { @@ -40,7 +39,7 @@ public class MapFragmentActivity extends AppCompatActivity { FragmentTransaction transaction = getFragmentManager().beginTransaction(); MapboxMapOptions options = new MapboxMapOptions(); - options.styleUrl(Style.getOutdoorsStyleUrl(AppConstant.STYLE_VERSION)); + options.styleUrl(Style.OUTDOORS); options.scrollGesturesEnabled(false); options.zoomGesturesEnabled(false); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/SupportMapFragmentActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/SupportMapFragmentActivity.java index bb391fc93..cc61eb469 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/SupportMapFragmentActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/SupportMapFragmentActivity.java @@ -17,7 +17,6 @@ import com.mapbox.mapboxsdk.maps.MapboxMapOptions; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.maps.SupportMapFragment; import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.model.constants.AppConstant; public class SupportMapFragmentActivity extends AppCompatActivity { @@ -40,7 +39,7 @@ public class SupportMapFragmentActivity extends AppCompatActivity { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); MapboxMapOptions options = new MapboxMapOptions(); - options.styleUrl(Style.getSatelliteStreetsStyleUrl(AppConstant.STYLE_VERSION)); + options.styleUrl(Style.SATELLITE_STREETS); options.scrollGesturesEnabled(false); options.zoomGesturesEnabled(false); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/geocoding/GeocoderActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/geocoding/GeocoderActivity.java index fc03066a4..99d2f81aa 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/geocoding/GeocoderActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/geocoding/GeocoderActivity.java @@ -19,15 +19,14 @@ import com.mapbox.geocoder.GeocoderCriteria; import com.mapbox.geocoder.MapboxGeocoder; import com.mapbox.geocoder.service.models.GeocoderFeature; import com.mapbox.geocoder.service.models.GeocoderResponse; -import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.annotations.MarkerOptions; import com.mapbox.mapboxsdk.constants.Style; import com.mapbox.mapboxsdk.geometry.LatLng; +import com.mapbox.mapboxsdk.maps.MapView; +import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.maps.Projection; import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.maps.MapView; -import com.mapbox.mapboxsdk.testapp.model.constants.AppConstant; import java.util.List; @@ -60,7 +59,7 @@ public class GeocoderActivity extends AppCompatActivity { setMessage(getString(R.string.geocoder_instructions)); mapView = (MapView) findViewById(R.id.mapView); - mapView.setStyleUrl(Style.getMapboxStreetsUrl(AppConstant.STYLE_VERSION)); + mapView.setStyleUrl(Style.MAPBOX_STREETS); mapView.onCreate(savedInstanceState); final ImageView dropPinView = new ImageView(this); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java index f5835ab7b..760501c17 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java @@ -15,7 +15,6 @@ import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.model.constants.AppConstant; public class DebugModeActivity extends AppCompatActivity { @@ -27,12 +26,12 @@ public class DebugModeActivity extends AppCompatActivity { private int currentStyleIndex = 0; private static final String[] STYLES = new String[]{ - Style.getMapboxStreetsUrl(AppConstant.STYLE_VERSION), - Style.getOutdoorsStyleUrl(AppConstant.STYLE_VERSION), - Style.getLightStyleUrl(AppConstant.STYLE_VERSION), - Style.getDarkStyleUrl(AppConstant.STYLE_VERSION), - Style.getSatelliteStyleUrl(AppConstant.STYLE_VERSION), - Style.getSatelliteStreetsStyleUrl(AppConstant.STYLE_VERSION) + Style.MAPBOX_STREETS, + Style.OUTDOORS, + Style.LIGHT, + Style.DARK, + Style.SATELLITE, + Style.SATELLITE_STREETS }; @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java index 288817d67..a3517df20 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java @@ -23,7 +23,6 @@ import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.maps.TrackingSettings; import com.mapbox.mapboxsdk.maps.UiSettings; import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.model.constants.AppConstant; public class DoubleMapActivity extends AppCompatActivity { @@ -73,7 +72,7 @@ public class DoubleMapActivity extends AppCompatActivity { mMapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(@NonNull MapboxMap mapboxMap) { - mapboxMap.setStyleUrl(Style.getDarkStyleUrl(AppConstant.STYLE_VERSION)); + mapboxMap.setStyleUrl(Style.DARK); mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(18)); try { @@ -92,7 +91,7 @@ public class DoubleMapActivity extends AppCompatActivity { mMapViewMini.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(@NonNull MapboxMap mapboxMap) { - mapboxMap.setStyleUrl(Style.getLightStyleUrl(AppConstant.STYLE_VERSION)); + mapboxMap.setStyleUrl(Style.LIGHT); mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(4)); UiSettings uiSettings = mapboxMap.getUiSettings(); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/OfflineActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/OfflineActivity.java index fde46b1ca..881916847 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/OfflineActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/OfflineActivity.java @@ -12,6 +12,7 @@ import android.view.View; import android.widget.Button; import android.widget.ProgressBar; import android.widget.Toast; + import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.constants.Style; @@ -26,10 +27,11 @@ import com.mapbox.mapboxsdk.offline.OfflineRegionError; import com.mapbox.mapboxsdk.offline.OfflineRegionStatus; import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.model.constants.AppConstant; import com.mapbox.mapboxsdk.testapp.model.other.OfflineDownloadRegionDialog; import com.mapbox.mapboxsdk.testapp.model.other.OfflineListRegionsDialog; + import org.json.JSONObject; + import java.util.ArrayList; public class OfflineActivity extends AppCompatActivity @@ -74,7 +76,7 @@ public class OfflineActivity extends AppCompatActivity // Set up map mMapView = (MapView) findViewById(R.id.mapView); - mMapView.setStyleUrl(Style.getMapboxStreetsUrl(AppConstant.STYLE_VERSION)); + mMapView.setStyleUrl(Style.MAPBOX_STREETS); mMapView.onCreate(savedInstanceState); mMapView.getMapAsync(new OnMapReadyCallback() { @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java index a4a283907..e5e21fd03 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java @@ -11,6 +11,7 @@ import android.support.v7.widget.Toolbar; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; + import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.constants.Style; @@ -22,7 +23,6 @@ import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.MapboxMapOptions; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.model.constants.AppConstant; public class MyLocationDrawableActivity extends AppCompatActivity implements LocationListener { @@ -49,7 +49,7 @@ public class MyLocationDrawableActivity extends AppCompatActivity implements Loc MapboxMapOptions mapboxMapOptions = new MapboxMapOptions(); mapboxMapOptions.accessToken(getString(R.string.mapbox_access_token)); - mapboxMapOptions.styleUrl(Style.getMapboxStreetsUrl(AppConstant.STYLE_VERSION)); + mapboxMapOptions.styleUrl(Style.MAPBOX_STREETS); mapboxMapOptions.locationEnabled(true); mapboxMapOptions.camera(new CameraPosition.Builder() .target(location != null ? new LatLng(location) : new LatLng(0, 0)) diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml index c8a9b3c9b..16087fe7b 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml @@ -36,6 +36,7 @@ Double Map Activity + Back to map activity Snapshot Activity User tracking mode User location drawable @@ -77,6 +78,7 @@ Scroll with pixels in x,y direction Example to make a snapshot of the map 2 maps in a view hierarchy + Restart map view after temporarily leaving to another activity Use an Android SDK View as marker Concurrent Open InfoWindowsr From aa83245c07865bac02fa2f7722fe587b57908198 Mon Sep 17 00:00:00 2001 From: Tobrun Van Nuland Date: Fri, 3 Jun 2016 19:59:24 +0200 Subject: [PATCH 25/41] [android] #5193 - fix broken test case on Icon --- .../mapbox/mapboxsdk/annotations/MarkerViewTest.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java index ed8e4ff32..7d874f21f 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java @@ -1,6 +1,5 @@ package com.mapbox.mapboxsdk.annotations; -import android.graphics.Bitmap; import android.os.Parcelable; import com.mapbox.mapboxsdk.geometry.LatLng; @@ -52,16 +51,6 @@ public class MarkerViewTest { assertEquals(markerOptions.getTitle(), "Mapbox"); } - @Test - public void testIcon() { - Bitmap bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_4444); - Icon icon = IconFactory.recreate("test", bitmap); - MarkerViewOptions markerOptions = new MarkerViewOptions().icon(icon); - MarkerView marker = markerOptions.getMarker(); - assertEquals("Icon should match", icon, marker.getIcon()); - assertEquals("Icon should match", icon, markerOptions.getIcon()); - } - @Test public void testFlat() { MarkerViewOptions markerOptions = new MarkerViewOptions().flat(true); From ea67a995de93c2b6e06996d9e31d9a1db63a7109 Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 3 Jun 2016 14:58:43 -0400 Subject: [PATCH 26/41] changed satellite-hybrid to street in string.xml --- .../android/MapboxGLAndroidSDK/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/values/strings.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/values/strings.xml index 451783015..687b85b2d 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/res/values/strings.xml +++ b/platform/android/MapboxGLAndroidSDK/src/main/res/values/strings.xml @@ -20,5 +20,5 @@ mapbox://styles/mapbox/light-v9 mapbox://styles/mapbox/dark-v9 mapbox://styles/mapbox/satellite-v9 - mapbox://styles/mapbox/satellite-hybrid-v9 + mapbox://styles/mapbox/satellite-streets-v9 From 4094987fa09561c4c69b1b4cf8a6cbf9d3dd0433 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Wed, 1 Jun 2016 14:10:01 +0300 Subject: [PATCH 27/41] [build] Migrate LLVM bots to Trusty LLVM is no longer hosting a debian repo and the build was broken. Trusty has the LLVM version we need. --- .travis.yml | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index f224a17f3..7a1fcc3f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,22 +5,26 @@ git: addons_shortcuts: addons_clang35: &clang35 apt: - sources: [ 'ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5' ] - packages: [ 'gdb', 'clang-3.5', 'libstdc++-4.9-dev', 'libstdc++6', 'libllvm3.4', 'xutils-dev', - 'libxxf86vm-dev', 'x11proto-xf86vidmode-dev', 'mesa-utils' ] + sources: [ 'ubuntu-toolchain-r-test' ] + packages: [ 'clang-3.5', 'libstdc++-4.9-dev', 'libstdc++6', 'libllvm3.4', + 'mesa-utils', 'libxi-dev', 'libglu1-mesa-dev', 'x11proto-randr-dev', 'x11proto-xext-dev', 'libxrandr-dev', + 'x11proto-xf86vidmode-dev', 'libxxf86vm-dev', 'libxcursor-dev', 'libxinerama-dev' ] addons_gcc5: &gcc5 apt: - sources: [ 'ubuntu-toolchain-r-test' ] - packages: [ 'gdb', 'g++-5', 'gcc-5', 'libllvm3.4', 'xutils-dev', - 'libxxf86vm-dev', 'x11proto-xf86vidmode-dev', 'mesa-utils' ] + sources: [ 'ubuntu-toolchain-r-test' ] + packages: [ 'gdb', 'g++-5', 'gcc-5', + 'mesa-utils', 'libxi-dev', 'libglu1-mesa-dev', 'x11proto-randr-dev', 'x11proto-xext-dev', 'libxrandr-dev', + 'x11proto-xf86vidmode-dev', 'libxxf86vm-dev', 'libxcursor-dev', 'libxinerama-dev' ] addons_qt4: &qt4 apt: - sources: [ 'ubuntu-toolchain-r-test' ] - packages: [ 'gdb', 'g++-5', 'gcc-5', 'mesa-utils', 'qt4-default' ] + sources: [ 'ubuntu-toolchain-r-test' ] + packages: [ 'gdb', 'g++-5', 'gcc-5', + 'mesa-utils', 'qt4-default' ] addons_qt5: &qt5 apt: - sources: [ 'ubuntu-toolchain-r-test' ] - packages: [ 'gdb', 'g++-5', 'gcc-5', 'mesa-utils', 'qt5-default', 'libqt5opengl5-dev', 'qtdeclarative5-dev', 'qtpositioning5-dev', 'qtlocation5-dev' ] + sources: [ 'ubuntu-toolchain-r-test' ] + packages: [ 'gdb', 'g++-5', 'gcc-5', + 'mesa-utils', 'qt5-default', 'libqt5opengl5-dev', 'qtdeclarative5-dev', 'qtpositioning5-dev', 'qtlocation5-dev' ] env: global: @@ -48,7 +52,8 @@ matrix: include: # Clang 3.5 - Release - Node - os: linux - sudo: false + sudo: required + dist: trusty language: node compiler: ": node4-clang35-release" env: BUILDTYPE=Release _CXX=clang++-3.5 _CC=clang-3.5 @@ -58,9 +63,6 @@ matrix: - nvm use 4 - make node - make test-node - after_script: - - ccache --show-stats - - ./platform/node/scripts/after_script.sh ${TRAVIS_JOB_NUMBER} ${TRAVIS_TAG:-} # GCC 5 - Debug - Coverage - os: linux @@ -83,7 +85,8 @@ matrix: # Clang 3.5 - Debug - os: linux - sudo: false + sudo: required + dist: trusty language: cpp compiler: ": linux-clang35-debug" env: BUILDTYPE=Debug _CXX=clang++-3.5 _CC=clang-3.5 @@ -91,7 +94,8 @@ matrix: # Clang 3.5 - Release - os: linux - sudo: false + sudo: required + dist: trusty language: cpp compiler: ": linux-clang35-release" env: BUILDTYPE=Release _CXX=clang++-3.5 _CC=clang-3.5 From 436c23c40b37c4863ddfbc25c6463ae2f2767a06 Mon Sep 17 00:00:00 2001 From: Tobrun Van Nuland Date: Fri, 3 Jun 2016 14:29:20 +0200 Subject: [PATCH 28/41] [android] #5171 - introduce new select/deselect animation system for view markers --- .../annotations/BaseMarkerViewOptions.java | 1 + .../mapboxsdk/annotations/MarkerView.java | 57 ++---- .../annotations/MarkerViewManager.java | 99 +++++----- .../annotations/MarkerViewOptions.java | 2 - .../com/mapbox/mapboxsdk/maps/MapboxMap.java | 67 ++++++- .../annotation/BulkMarkerActivity.java | 56 ++---- .../annotation/MarkerViewActivity.java | 172 +++++++++++++++++- .../annotations/CountryMarkerViewOptions.java | 1 + .../model/annotations/TextMarkerView.java | 18 ++ .../annotations/TextMarkerViewOptions.java | 91 +++++++++ .../mapboxsdk/annotations/MarkerViewTest.java | 17 -- 11 files changed, 414 insertions(+), 167 deletions(-) create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/TextMarkerView.java create mode 100644 platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/TextMarkerViewOptions.java diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BaseMarkerViewOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BaseMarkerViewOptions.java index 0cd54fc0f..57e6adb86 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BaseMarkerViewOptions.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/BaseMarkerViewOptions.java @@ -30,6 +30,7 @@ public abstract class BaseMarkerViewOptions