summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--circle.yml2
-rw-r--r--platform/android/CHANGELOG.md28
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java67
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java39
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java11
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java100
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java30
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java57
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java23
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java10
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/RasterSource.java13
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/VectorSource.java10
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/res/drawable-hdpi/mapbox_logo_icon.pngbin3408 -> 4778 bytes
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/res/drawable-mdpi/mapbox_logo_icon.pngbin1958 -> 2622 bytes
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xhdpi/mapbox_logo_icon.pngbin4492 -> 6579 bytes
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xxhdpi/mapbox_logo_icon.pngbin7059 -> 10802 bytes
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xxxhdpi/mapbox_logo_icon.pngbin9402 -> 14441 bytes
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/res/drawable/mapbox_info_icon_default.xml8
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/res/drawable/mapbox_info_icon_selected.xml10
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapbox_mapview_internal.xml3
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapbox_mapview_preview.xml35
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/res/values/dimens.xml9
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java33
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java31
-rw-r--r--platform/android/gradle/wrapper/gradle-wrapper.properties2
-rw-r--r--platform/android/src/style/sources/geojson_source.cpp6
-rw-r--r--platform/android/src/style/sources/geojson_source.hpp2
-rw-r--r--platform/android/src/style/sources/raster_source.cpp8
-rw-r--r--platform/android/src/style/sources/raster_source.hpp2
-rw-r--r--platform/android/src/style/sources/vector_source.cpp8
-rw-r--r--platform/android/src/style/sources/vector_source.hpp2
-rw-r--r--platform/default/default_file_source.cpp16
33 files changed, 468 insertions, 99 deletions
diff --git a/Makefile b/Makefile
index e8f7f175ff..abccb306a6 100644
--- a/Makefile
+++ b/Makefile
@@ -571,7 +571,7 @@ run-android-ui-test-$1: platform/android/configuration.gradle
run-android-ui-test-$1-%: platform/android/configuration.gradle
adb uninstall com.mapbox.mapboxsdk.testapp > /dev/null
- cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=$2 :MapboxGLAndroidSDKTestApp:connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.class="$*"
+ cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=$2 :MapboxGLAndroidSDKTestApp:connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.class="$$*"
endef
diff --git a/circle.yml b/circle.yml
index 7d75427bcb..4ce00872b4 100644
--- a/circle.yml
+++ b/circle.yml
@@ -133,4 +133,4 @@ jobs:
- deploy:
name: Publish to Maven
command: |
- if [ "${CIRCLE_BRANCH}" == "master" ]; then make run-android-upload-archives ; fi
+ if [ "${CIRCLE_BRANCH}" == "release-android-v5.1.0-beta.2" ]; then make run-android-upload-archives ; fi
diff --git a/platform/android/CHANGELOG.md b/platform/android/CHANGELOG.md
index fdc6343b7c..bc307e5061 100644
--- a/platform/android/CHANGELOG.md
+++ b/platform/android/CHANGELOG.md
@@ -3,11 +3,35 @@
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.
## 5.1.0 - TBA
-
+* Update attribution with new Mapbox wordmark [#8774](https://github.com/mapbox/mapbox-gl-native/pull/8774)
+
+## 5.1.0-beta.2 - May 12, 2017
+
+5.1.0-beta.2 builds further on 5.1.0-beta.1 and adds:
+
+* When a layer is added, reload its source's tiles [#8963](https://github.com/mapbox/mapbox-gl-native/pull/8963)
+* Update release script to support CircleCI builds [#8950](https://github.com/mapbox/mapbox-gl-native/pull/8950)
+* URL getter on Sources [#8959](https://github.com/mapbox/mapbox-gl-native/pull/8959)
+* Build SNAPSHOT from release branch CI configuration [#8958](https://github.com/mapbox/mapbox-gl-native/pull/8958)
+* Fix UI test filter in Makefile [#8960](https://github.com/mapbox/mapbox-gl-native/pull/8960)
+* Bump & fixup dependencies [#8921](https://github.com/mapbox/mapbox-gl-native/pull/8921)
+* Ignore already deleted region [#8920](https://github.com/mapbox/mapbox-gl-native/pull/8920)
+* Keep offline observer when timeout occurs [#8919](https://github.com/mapbox/mapbox-gl-native/pull/8919)
+* Show error message when no browser installed [#8920](https://github.com/mapbox/mapbox-gl-native/pull/8920)
+* Reset observers of removed Sources and Layers [#8900](https://github.com/mapbox/mapbox-gl-native/pull/8900)
+* Only build custom layer .so for debug builds [#8885](https://github.com/mapbox/mapbox-gl-native/pull/8885)
+* Update localizations [#8883](https://github.com/mapbox/mapbox-gl-native/pull/8883)
+* Reset observers of removed Sources and Layers [#8862](https://github.com/mapbox/mapbox-gl-native/pull/8862)
+* Remove force style cascade [#8866](https://github.com/mapbox/mapbox-gl-native/pull/8866)
+* Update proguard config [#8944](https://github.com/mapbox/mapbox-gl-native/pull/8944)
+* Update LOST to 2.3.0-SNAPSHOT [#8872](https://github.com/mapbox/mapbox-gl-native/pull/8872)
+* Update logo [#8774](https://github.com/mapbox/mapbox-gl-native/pull/8774)
+* Camera change listener v2.0 [#8644](https://github.com/mapbox/mapbox-gl-native/pull/8644)
+* Allow filesource url transform reset [#8957](https://github.com/mapbox/mapbox-gl-native/pull/8957)
## 5.1.0-beta.1 - May 2, 2017
-5.1.0 builds further on 5.0.2 and adds:
+5.1.0-beta.1 builds further on 5.0.2 and adds:
* Support for FillExtrusionLayer [#8431](https://github.com/mapbox/mapbox-gl-native/pull/8431)
* Limit Viewport [#8622](https://github.com/mapbox/mapbox-gl-native/pull/8622)
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java
new file mode 100644
index 0000000000..bd028aecb6
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/CameraChangeDispatcher.java
@@ -0,0 +1,67 @@
+package com.mapbox.mapboxsdk.maps;
+
+import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraIdleListener;
+import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveCanceledListener;
+import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveStartedListener;
+import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveListener;
+
+class CameraChangeDispatcher implements MapboxMap.OnCameraMoveStartedListener, MapboxMap.OnCameraMoveListener,
+ MapboxMap.OnCameraMoveCanceledListener, OnCameraIdleListener {
+
+ private boolean idle = true;
+
+ private OnCameraMoveStartedListener onCameraMoveStartedListener;
+ private OnCameraMoveCanceledListener onCameraMoveCanceledListener;
+ private OnCameraMoveListener onCameraMoveListener;
+ private OnCameraIdleListener onCameraIdleListener;
+
+ void setOnCameraMoveStartedListener(OnCameraMoveStartedListener onCameraMoveStartedListener) {
+ this.onCameraMoveStartedListener = onCameraMoveStartedListener;
+ }
+
+ void setOnCameraMoveCanceledListener(OnCameraMoveCanceledListener onCameraMoveCanceledListener) {
+ this.onCameraMoveCanceledListener = onCameraMoveCanceledListener;
+ }
+
+ void setOnCameraMoveListener(OnCameraMoveListener onCameraMoveListener) {
+ this.onCameraMoveListener = onCameraMoveListener;
+ }
+
+ void setOnCameraIdleListener(OnCameraIdleListener onCameraIdleListener) {
+ this.onCameraIdleListener = onCameraIdleListener;
+ }
+
+ @Override
+ public void onCameraMoveStarted(int reason) {
+ if (!idle) {
+ return;
+ }
+
+ idle = false;
+ if (onCameraMoveStartedListener != null) {
+ onCameraMoveStartedListener.onCameraMoveStarted(reason);
+ }
+ }
+
+ @Override
+ public void onCameraMove() {
+ if (onCameraMoveListener != null && !idle) {
+ onCameraMoveListener.onCameraMove();
+ }
+ }
+
+ @Override
+ public void onCameraMoveCanceled() {
+ if (onCameraMoveCanceledListener != null && !idle) {
+ onCameraMoveCanceledListener.onCameraMoveCanceled();
+ }
+ }
+
+ @Override
+ public void onCameraIdle() {
+ if (onCameraIdleListener != null && !idle) {
+ idle = true;
+ onCameraIdleListener.onCameraIdle();
+ }
+ }
+}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java
index dca833bbf4..39433d8b93 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java
@@ -22,6 +22,8 @@ import com.mapbox.services.android.telemetry.MapboxTelemetry;
import com.mapbox.services.android.telemetry.utils.MathUtils;
import com.mapbox.services.android.telemetry.utils.TelemetryUtils;
+import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveStartedListener.REASON_API_GESTURE;
+
/**
* Manages gestures events on a MapView.
* <p>
@@ -35,6 +37,7 @@ final class MapGestureDetector {
private final UiSettings uiSettings;
private final TrackingSettings trackingSettings;
private final AnnotationManager annotationManager;
+ private final CameraChangeDispatcher cameraChangeDispatcher;
private final GestureDetectorCompat gestureDetector;
private final ScaleGestureDetector scaleGestureDetector;
@@ -56,12 +59,14 @@ final class MapGestureDetector {
private boolean scaleGestureOccurred = false;
MapGestureDetector(Context context, Transform transform, Projection projection, UiSettings uiSettings,
- TrackingSettings trackingSettings, AnnotationManager annotationManager) {
+ TrackingSettings trackingSettings, AnnotationManager annotationManager,
+ CameraChangeDispatcher cameraChangeDispatcher) {
this.annotationManager = annotationManager;
this.transform = transform;
this.projection = projection;
this.uiSettings = uiSettings;
this.trackingSettings = trackingSettings;
+ this.cameraChangeDispatcher = cameraChangeDispatcher;
// Touch gesture detectors
gestureDetector = new GestureDetectorCompat(context, new GestureListener());
@@ -187,6 +192,7 @@ final class MapGestureDetector {
MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapDragEndEvent(
getLocationFromGesture(event.getX(), event.getY()), transform));
scrollInProgress = false;
+ cameraChangeDispatcher.onCameraIdle();
}
twoTap = false;
@@ -273,6 +279,9 @@ final class MapGestureDetector {
break;
}
+ // notify camera change listener
+ cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
+
// Single finger double tap
if (focalPoint != null) {
// User provided focal point
@@ -337,6 +346,7 @@ final class MapGestureDetector {
// and ignore when a scale gesture has occurred
return false;
}
+ cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
float screenDensity = uiSettings.getPixelRatio();
@@ -362,9 +372,7 @@ final class MapGestureDetector {
long animationTime = (long) (velocityXY / 7 / tiltFactor + MapboxConstants.ANIMATION_DURATION_FLING_BASE);
// update transformation
- transform.setGestureInProgress(true);
transform.moveBy(offsetX, offsetY, animationTime);
- transform.setGestureInProgress(false);
if (onFlingListener != null) {
onFlingListener.onFling();
@@ -377,6 +385,10 @@ final class MapGestureDetector {
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
if (!scrollInProgress) {
scrollInProgress = true;
+
+ // Cancel any animation
+ transform.cancelTransitions();
+ cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapClickEvent(
getLocationFromGesture(e1.getX(), e1.getY()),
MapboxEvent.GESTURE_PAN_START, transform));
@@ -391,8 +403,6 @@ final class MapGestureDetector {
// reset tracking if needed
trackingSettings.resetTrackingModesIfRequired(true, false);
- // Cancel any animation
- transform.cancelTransitions();
// Scroll the map
transform.moveBy(-distanceX, -distanceY, 0 /*no duration*/);
@@ -446,6 +456,8 @@ final class MapGestureDetector {
// If scale is large enough ignore a tap
scaleFactor *= detector.getScaleFactor();
if ((scaleFactor > 1.05f) || (scaleFactor < 0.95f)) {
+ // notify camera change listener
+ cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
zoomStarted = true;
}
@@ -465,9 +477,6 @@ final class MapGestureDetector {
return false;
}
- // Cancel any animation
- transform.cancelTransitions();
-
// Gesture is a quickzoom if there aren't two fingers
quickZoom = !twoTap;
@@ -512,6 +521,9 @@ final class MapGestureDetector {
return false;
}
+ // notify camera change listener
+ cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
+
beginTime = detector.getEventTime();
MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapClickEvent(
getLocationFromGesture(detector.getFocusX(), detector.getFocusY()),
@@ -522,6 +534,7 @@ final class MapGestureDetector {
// Called when the fingers leave the screen
@Override
public void onRotateEnd(RotateGestureDetector detector) {
+ // notify camera change listener
beginTime = 0;
totalAngle = 0.0f;
started = false;
@@ -553,13 +566,8 @@ final class MapGestureDetector {
if (!started) {
return false;
}
-
- // Cancel any animation
- transform.cancelTransitions();
-
// rotation constitutes translation of anything except the center of
// rotation, so cancel both location and bearing tracking if required
-
trackingSettings.resetTrackingModesIfRequired(true, true);
// Get rotate value
@@ -593,6 +601,8 @@ final class MapGestureDetector {
return false;
}
+ // notify camera change listener
+ cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
beginTime = detector.getEventTime();
MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapClickEvent(
getLocationFromGesture(detector.getFocusX(), detector.getFocusY()),
@@ -633,9 +643,6 @@ final class MapGestureDetector {
return false;
}
- // Cancel any animation
- transform.cancelTransitions();
-
// Get tilt value (scale and clamp)
double pitch = transform.getTilt();
pitch -= 0.1 * detector.getShovePixelsDelta();
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 872802292c..d00da4c155 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
@@ -129,6 +129,9 @@ public class MapView extends FrameLayout {
// callback for zooming in the camera
CameraZoomInvalidator zoomInvalidator = new CameraZoomInvalidator();
+ // callback for camera change events
+ CameraChangeDispatcher cameraChangeDispatcher = new CameraChangeDispatcher();
+
// setup components for MapboxMap creation
Projection proj = new Projection(nativeMapView);
UiSettings uiSettings = new UiSettings(proj, focalPoint, compassView, attrView, view.findViewById(R.id.logoView));
@@ -136,12 +139,14 @@ public class MapView extends FrameLayout {
MyLocationViewSettings myLocationViewSettings = new MyLocationViewSettings(myLocationView, proj, focalPoint);
MarkerViewManager markerViewManager = new MarkerViewManager((ViewGroup) findViewById(R.id.markerViewContainer));
AnnotationManager annotations = new AnnotationManager(nativeMapView, this, markerViewManager);
- Transform transform = new Transform(nativeMapView, annotations.getMarkerViewManager(), trackingSettings);
+ Transform transform = new Transform(nativeMapView, annotations.getMarkerViewManager(), trackingSettings,
+ cameraChangeDispatcher);
mapboxMap = new MapboxMap(nativeMapView, transform, uiSettings, trackingSettings, myLocationViewSettings, proj,
- registerTouchListener, annotations);
+ registerTouchListener, annotations, cameraChangeDispatcher);
// user input
- mapGestureDetector = new MapGestureDetector(context, transform, proj, uiSettings, trackingSettings, annotations);
+ mapGestureDetector = new MapGestureDetector(context, transform, proj, uiSettings, trackingSettings, annotations,
+ cameraChangeDispatcher);
mapKeyListener = new MapKeyListener(transform, trackingSettings, uiSettings);
MapZoomControllerListener zoomListener = new MapZoomControllerListener(mapGestureDetector, uiSettings, transform);
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 1751dcf042..96603355f1 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
@@ -69,6 +69,7 @@ public final class MapboxMap {
private final Transform transform;
private final AnnotationManager annotationManager;
private final MyLocationViewSettings myLocationViewSettings;
+ private final CameraChangeDispatcher cameraChangeDispatcher;
private final OnRegisterTouchListener onRegisterTouchListener;
@@ -76,7 +77,7 @@ public final class MapboxMap {
MapboxMap(NativeMapView map, Transform transform, UiSettings ui, TrackingSettings tracking,
MyLocationViewSettings myLocationView, Projection projection, OnRegisterTouchListener listener,
- AnnotationManager annotations) {
+ AnnotationManager annotations, CameraChangeDispatcher cameraChangeDispatcher) {
this.nativeMapView = map;
this.uiSettings = ui;
this.trackingSettings = tracking;
@@ -85,6 +86,7 @@ public final class MapboxMap {
this.annotationManager = annotations.bind(this);
this.transform = transform;
this.onRegisterTouchListener = listener;
+ this.cameraChangeDispatcher = cameraChangeDispatcher;
}
void initialise(@NonNull Context context, @NonNull MapboxMapOptions options) {
@@ -1595,11 +1597,52 @@ public final class MapboxMap {
* To unset the callback, use null.
*/
@UiThread
+ @Deprecated
public void setOnCameraChangeListener(@Nullable OnCameraChangeListener listener) {
transform.setOnCameraChangeListener(listener);
}
/**
+ * Sets a callback that is invoked when camera movement has ended.
+ *
+ * @param listener the listener to notify
+ */
+ @UiThread
+ public void setOnCameraIdleListener(@Nullable OnCameraIdleListener listener) {
+ cameraChangeDispatcher.setOnCameraIdleListener(listener);
+ }
+
+ /**
+ * Sets a callback that is invoked when camera movement was cancelled.
+ *
+ * @param listener the listener to notify
+ */
+ @UiThread
+ public void setOnCameraMoveCancelListener(@Nullable OnCameraMoveCanceledListener listener) {
+ cameraChangeDispatcher.setOnCameraMoveCanceledListener(listener);
+ }
+
+ /**
+ * Sets a callback that is invoked when camera movement has started.
+ *
+ * @param listener the listener to notify
+ */
+ @UiThread
+ public void setOnCameraMoveStartedistener(@Nullable OnCameraMoveStartedListener listener) {
+ cameraChangeDispatcher.setOnCameraMoveStartedListener(listener);
+ }
+
+ /**
+ * Sets a callback that is invoked when camera position changes.
+ *
+ * @param listener the listener to notify
+ */
+ @UiThread
+ public void setOnCameraMoveListener(@Nullable OnCameraMoveListener listener) {
+ cameraChangeDispatcher.setOnCameraMoveListener(listener);
+ }
+
+ /**
* Sets a callback that's invoked on every frame rendered to the map view.
*
* @param listener The callback that's invoked on every frame rendered to the map view.
@@ -1913,7 +1956,12 @@ public final class MapboxMap {
/**
* Interface definition for a callback to be invoked when the camera changes position.
+ *
+ * @deprecated Replaced by MapboxMap.OnCameraMoveStartedListener, MapboxMap.OnCameraMoveListener and
+ * MapboxMap.OnCameraIdleListener. The order in which the deprecated onCameraChange method will be called in relation
+ * to the methods in the new camera change listeners is undefined.
*/
+ @Deprecated
public interface OnCameraChangeListener {
/**
* Called after the camera position has changed. During an animation,
@@ -1926,6 +1974,56 @@ public final class MapboxMap {
}
/**
+ * Interface definition for a callback to be invoked for when the camera motion starts.
+ */
+ public interface OnCameraMoveStartedListener {
+ int REASON_API_GESTURE = 1;
+ int REASON_DEVELOPER_ANIMATION = 2;
+ int REASON_API_ANIMATION = 3;
+
+ /**
+ * Called when the camera starts moving after it has been idle or when the reason for camera motion has changed.
+ *
+ * @param reason the reason for the camera change
+ */
+ void onCameraMoveStarted(int reason);
+ }
+
+ /**
+ * Interface definition for a callback to be invoked for when the camera changes position.
+ */
+ public interface OnCameraMoveListener {
+ /**
+ * Called repeatedly as the camera continues to move after an onCameraMoveStarted call.
+ * This may be called as often as once every frame and should not perform expensive operations.
+ */
+ void onCameraMove();
+ }
+
+ /**
+ * Interface definition for a callback to be invoked for when the camera's motion has been stopped or when the camera
+ * starts moving for a new reason.
+ */
+ public interface OnCameraMoveCanceledListener {
+ /**
+ * Called when the developer explicitly calls the cancelTransitions() method or if the reason for camera motion has
+ * changed before the onCameraIdle had a chance to fire after the previous animation.
+ * Do not update or animate the camera from within this method.
+ */
+ void onCameraMoveCanceled();
+ }
+
+ /**
+ * Interface definition for a callback to be invoked for when camera movement has ended.
+ */
+ public interface OnCameraIdleListener {
+ /**
+ * Called when camera movement has ended.
+ */
+ void onCameraIdle();
+ }
+
+ /**
* Interface definition for a callback to be invoked when a frame is rendered to the map view.
*
* @see MapboxMap#setOnFpsChangedListener(OnFpsChangedListener)
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 8fcfdd6db0..68603ab1a3 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
@@ -35,10 +35,8 @@ import java.util.Arrays;
*/
public class MapboxMapOptions implements Parcelable {
- private static final float DIMENSION_SEVEN_DP = 7f;
- private static final float DIMENSION_TEN_DP = 10f;
- private static final float DIMENSION_SIXTEEN_DP = 16f;
- private static final float DIMENSION_SEVENTY_SIX_DP = 76f;
+ private static final float FOUR_DP = 4f;
+ private static final float EIGHTY_NINE_DP = 92f;
private CameraPosition cameraPosition;
@@ -206,13 +204,13 @@ public class MapboxMapOptions implements Parcelable {
Gravity.TOP | Gravity.END));
mapboxMapOptions.compassMargins(new int[] {
(int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiCompassMarginLeft,
- DIMENSION_TEN_DP * pxlRatio)),
+ FOUR_DP * pxlRatio)),
((int) typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiCompassMarginTop,
- DIMENSION_TEN_DP * pxlRatio)),
+ FOUR_DP * pxlRatio)),
((int) typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiCompassMarginRight,
- DIMENSION_TEN_DP * pxlRatio)),
+ FOUR_DP * pxlRatio)),
((int) typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiCompassMarginBottom,
- DIMENSION_TEN_DP * pxlRatio))});
+ FOUR_DP * pxlRatio))});
mapboxMapOptions.compassFadesWhenFacingNorth(typedArray.getBoolean(
R.styleable.mapbox_MapView_mapbox_uiCompassFadeFacingNorth, true));
Drawable compassDrawable = typedArray.getDrawable(
@@ -227,13 +225,13 @@ public class MapboxMapOptions implements Parcelable {
Gravity.BOTTOM | Gravity.START));
mapboxMapOptions.logoMargins(new int[] {
(int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiLogoMarginLeft,
- DIMENSION_SIXTEEN_DP * pxlRatio)),
+ FOUR_DP * pxlRatio)),
(int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiLogoMarginTop,
- DIMENSION_SIXTEEN_DP * pxlRatio)),
+ FOUR_DP * pxlRatio)),
(int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiLogoMarginRight,
- DIMENSION_SIXTEEN_DP * pxlRatio)),
+ FOUR_DP * pxlRatio)),
(int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiLogoMarginBottom,
- DIMENSION_SIXTEEN_DP * pxlRatio))});
+ FOUR_DP * pxlRatio))});
mapboxMapOptions.attributionTintColor(typedArray.getColor(
R.styleable.mapbox_MapView_mapbox_uiAttributionTintColor, -1));
@@ -243,13 +241,13 @@ public class MapboxMapOptions implements Parcelable {
R.styleable.mapbox_MapView_mapbox_uiAttributionGravity, Gravity.BOTTOM));
mapboxMapOptions.attributionMargins(new int[] {
(int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiAttributionMarginLeft,
- DIMENSION_SEVENTY_SIX_DP) * pxlRatio),
+ EIGHTY_NINE_DP * pxlRatio)),
(int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiAttributionMarginTop,
- DIMENSION_SEVEN_DP * pxlRatio)),
+ FOUR_DP * pxlRatio)),
(int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiAttributionMarginRight,
- DIMENSION_SEVEN_DP * pxlRatio)),
+ FOUR_DP * pxlRatio)),
(int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiAttributionMarginBottom,
- DIMENSION_SEVEN_DP * pxlRatio))});
+ FOUR_DP * pxlRatio))});
mapboxMapOptions.locationEnabled(typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_myLocation, false));
mapboxMapOptions.myLocationForegroundTintColor(
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java
index e101340111..af44a08a81 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java
@@ -16,6 +16,7 @@ import com.mapbox.mapboxsdk.maps.widgets.MyLocationView;
import timber.log.Timber;
import static com.mapbox.mapboxsdk.maps.MapView.REGION_DID_CHANGE_ANIMATED;
+import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveStartedListener;
/**
* Resembles the current Map transformation.
@@ -33,13 +34,18 @@ final class Transform implements MapView.OnMapChangedListener {
private CameraPosition cameraPosition;
private MapboxMap.CancelableCallback cameraCancelableCallback;
+
private MapboxMap.OnCameraChangeListener onCameraChangeListener;
- Transform(NativeMapView mapView, MarkerViewManager markerViewManager, TrackingSettings trackingSettings) {
+ private CameraChangeDispatcher cameraChangeDispatcher;
+
+ Transform(NativeMapView mapView, MarkerViewManager markerViewManager, TrackingSettings trackingSettings,
+ CameraChangeDispatcher cameraChangeDispatcher) {
this.mapView = mapView;
this.markerViewManager = markerViewManager;
this.trackingSettings = trackingSettings;
this.myLocationView = trackingSettings.getMyLocationView();
+ this.cameraChangeDispatcher = cameraChangeDispatcher;
}
void initialise(@NonNull MapboxMap mapboxMap, @NonNull MapboxMapOptions options) {
@@ -79,6 +85,7 @@ final class Transform implements MapView.OnMapChangedListener {
cameraCancelableCallback.onFinish();
cameraCancelableCallback = null;
}
+ cameraChangeDispatcher.onCameraIdle();
mapView.removeOnMapChangedListener(this);
}
}
@@ -89,10 +96,12 @@ final class Transform implements MapView.OnMapChangedListener {
if (!cameraPosition.equals(this.cameraPosition)) {
trackingSettings.resetTrackingModesIfRequired(cameraPosition);
cancelTransitions();
+ cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION);
mapView.jumpTo(cameraPosition.bearing, cameraPosition.target, cameraPosition.tilt, cameraPosition.zoom);
if (callback != null) {
callback.onFinish();
}
+ cameraChangeDispatcher.onCameraIdle();
}
}
@@ -103,6 +112,8 @@ final class Transform implements MapView.OnMapChangedListener {
if (!cameraPosition.equals(this.cameraPosition)) {
trackingSettings.resetTrackingModesIfRequired(cameraPosition);
cancelTransitions();
+ cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION);
+
if (callback != null) {
cameraCancelableCallback = callback;
mapView.addOnMapChangedListener(this);
@@ -119,8 +130,9 @@ final class Transform implements MapView.OnMapChangedListener {
CameraPosition cameraPosition = update.getCameraPosition(mapboxMap);
if (!cameraPosition.equals(this.cameraPosition)) {
trackingSettings.resetTrackingModesIfRequired(cameraPosition);
-
cancelTransitions();
+ cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION);
+
if (callback != null) {
cameraCancelableCallback = callback;
mapView.addOnMapChangedListener(this);
@@ -135,7 +147,12 @@ final class Transform implements MapView.OnMapChangedListener {
@Nullable
CameraPosition invalidateCameraPosition() {
if (mapView != null) {
- cameraPosition = mapView.getCameraPosition();
+ CameraPosition cameraPosition = mapView.getCameraPosition();
+ if (this.cameraPosition != null && !this.cameraPosition.equals(cameraPosition)) {
+ cameraChangeDispatcher.onCameraMove();
+ }
+
+ this.cameraPosition = cameraPosition;
if (onCameraChangeListener != null) {
onCameraChangeListener.onCameraChange(this.cameraPosition);
}
@@ -144,10 +161,17 @@ final class Transform implements MapView.OnMapChangedListener {
}
void cancelTransitions() {
+ // notify user about cancel
+ cameraChangeDispatcher.onCameraMoveCanceled();
+
+ // notify animateCamera and easeCamera about cancelling
if (cameraCancelableCallback != null) {
+ cameraChangeDispatcher.onCameraIdle();
cameraCancelableCallback.onCancel();
cameraCancelableCallback = null;
}
+
+ // cancel ongoing transitions
mapView.cancelTransitions();
}
@@ -157,6 +181,10 @@ final class Transform implements MapView.OnMapChangedListener {
mapView.resetNorth();
}
+ //
+ // Camera change listener API
+ //
+
void setOnCameraChangeListener(@Nullable MapboxMap.OnCameraChangeListener listener) {
this.onCameraChangeListener = listener;
}
@@ -172,9 +200,6 @@ final class Transform implements MapView.OnMapChangedListener {
}
void zoom(boolean zoomIn, @NonNull PointF focalPoint) {
- // Cancel any animation
- cancelTransitions();
-
CameraPosition cameraPosition = invalidateCameraPosition();
if (cameraPosition != null) {
int newZoom = (int) Math.round(cameraPosition.zoom + (zoomIn ? 1 : -1));
@@ -187,6 +212,15 @@ final class Transform implements MapView.OnMapChangedListener {
}
void setZoom(double zoom, @NonNull PointF focalPoint, long duration) {
+ mapView.addOnMapChangedListener(new MapView.OnMapChangedListener() {
+ @Override
+ public void onMapChanged(int change) {
+ if (change == MapView.REGION_DID_CHANGE_ANIMATED) {
+ mapView.removeOnMapChangedListener(this);
+ cameraChangeDispatcher.onCameraIdle();
+ }
+ }
+ });
mapView.setZoom(zoom, focalPoint, duration);
}
@@ -278,6 +312,17 @@ final class Transform implements MapView.OnMapChangedListener {
}
void moveBy(double offsetX, double offsetY, long duration) {
+ if (duration > 0) {
+ mapView.addOnMapChangedListener(new MapView.OnMapChangedListener() {
+ @Override
+ public void onMapChanged(int change) {
+ if (change == MapView.DID_FINISH_RENDERING_MAP_FULLY_RENDERED) {
+ mapView.removeOnMapChangedListener(this);
+ cameraChangeDispatcher.onCameraIdle();
+ }
+ }
+ });
+ }
mapView.moveBy(offsetX, offsetY, duration);
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java
index 354a42536a..1bcf8a70b9 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java
@@ -146,7 +146,7 @@ public final class UiSettings {
if (compassMargins != null) {
setCompassMargins(compassMargins[0], compassMargins[1], compassMargins[2], compassMargins[3]);
} else {
- int tenDp = (int) resources.getDimension(R.dimen.mapbox_ten_dp);
+ int tenDp = (int) resources.getDimension(R.dimen.mapbox_four_dp);
setCompassMargins(tenDp, tenDp, tenDp, tenDp);
}
setCompassFadeFacingNorth(options.getCompassFadeFacingNorth());
@@ -171,9 +171,7 @@ public final class UiSettings {
private byte[] convert(Bitmap resource) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
resource.compress(Bitmap.CompressFormat.PNG, 100, stream);
- byte[] byteArray = stream.toByteArray();
-
- return byteArray;
+ return stream.toByteArray();
}
private void restoreCompass(Bundle savedInstanceState) {
@@ -189,10 +187,7 @@ public final class UiSettings {
private Drawable decode(byte[] bitmap) {
Bitmap compass = BitmapFactory.decodeByteArray(bitmap, 0, bitmap.length);
-
- Drawable compassImage = new BitmapDrawable(compassView.getResources(), compass);
-
- return compassImage;
+ return new BitmapDrawable(compassView.getResources(), compass);
}
private void initialiseLogo(MapboxMapOptions options, Resources resources) {
@@ -202,8 +197,8 @@ public final class UiSettings {
if (logoMargins != null) {
setLogoMargins(logoMargins[0], logoMargins[1], logoMargins[2], logoMargins[3]);
} else {
- int sixteenDp = (int) resources.getDimension(R.dimen.mapbox_sixteen_dp);
- setLogoMargins(sixteenDp, sixteenDp, sixteenDp, sixteenDp);
+ int twoDp = (int) resources.getDimension(R.dimen.mapbox_two_dp);
+ setLogoMargins(twoDp, twoDp, twoDp, twoDp);
}
}
@@ -226,16 +221,12 @@ public final class UiSettings {
}
private void initialiseAttribution(Context context, MapboxMapOptions options) {
- Resources resources = context.getResources();
setAttributionEnabled(options.getAttributionEnabled());
setAttributionGravity(options.getAttributionGravity());
int[] attributionMargins = options.getAttributionMargins();
if (attributionMargins != null) {
- setAttributionMargins(attributionMargins[0], attributionMargins[1], attributionMargins[2], attributionMargins[3]);
- } else {
- int sevenDp = (int) resources.getDimension(R.dimen.mapbox_seven_dp);
- int seventySixDp = (int) resources.getDimension(R.dimen.mapbox_seventy_six_dp);
- setAttributionMargins(seventySixDp, sevenDp, sevenDp, sevenDp);
+ setAttributionMargins(attributionMargins[0], attributionMargins[1],
+ attributionMargins[2], attributionMargins[3]);
}
int attributionTintColor = options.getAttributionTintColor();
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java
index ec80186761..10ecb945ad 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java
@@ -228,6 +228,14 @@ public class GeoJsonSource extends Source {
}
/**
+ * @return The url or null
+ */
+ @Nullable
+ public String getUrl() {
+ return nativeGetUrl();
+ }
+
+ /**
* Queries the source for features.
*
* @param filter an optional filter statement to filter the returned Features
@@ -243,6 +251,8 @@ public class GeoJsonSource extends Source {
protected native void nativeSetUrl(String url);
+ protected native String nativeGetUrl();
+
private native void nativeSetGeoJsonString(String geoJson);
private native void nativeSetFeatureCollection(FeatureCollection geoJson);
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/RasterSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/RasterSource.java
index 98b74afcff..38ed208618 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/RasterSource.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/RasterSource.java
@@ -1,5 +1,7 @@
package com.mapbox.mapboxsdk.style.sources;
+import android.support.annotation.Nullable;
+
import java.net.URL;
/**
@@ -72,8 +74,19 @@ public class RasterSource extends Source {
initialize(id, tileSet.toValueObject(), tileSize);
}
+ /**
+ * @return The url or null
+ */
+ @Nullable
+ public String getUrl() {
+ return nativeGetUrl();
+ }
+
protected native void initialize(String layerId, Object payload, int tileSize);
@Override
protected native void finalize() throws Throwable;
+
+ protected native String nativeGetUrl();
+
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/VectorSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/VectorSource.java
index 7230492d0e..9b59cf8967 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/VectorSource.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/VectorSource.java
@@ -76,11 +76,21 @@ public class VectorSource extends Source {
return features != null ? Arrays.asList(features) : new ArrayList<Feature>();
}
+ /**
+ * @return The url or null
+ */
+ @Nullable
+ public String getUrl() {
+ return nativeGetUrl();
+ }
+
protected native void initialize(String layerId, Object payload);
@Override
protected native void finalize() throws Throwable;
+ protected native String nativeGetUrl();
+
private native Feature[] querySourceFeatures(String[] sourceLayerId,
Object[] filter);
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-hdpi/mapbox_logo_icon.png b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-hdpi/mapbox_logo_icon.png
index c0f4ed2c4c..7568387a8d 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-hdpi/mapbox_logo_icon.png
+++ b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-hdpi/mapbox_logo_icon.png
Binary files differ
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-mdpi/mapbox_logo_icon.png b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-mdpi/mapbox_logo_icon.png
index 5a9da3fe39..9cdec5151c 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-mdpi/mapbox_logo_icon.png
+++ b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-mdpi/mapbox_logo_icon.png
Binary files differ
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xhdpi/mapbox_logo_icon.png b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xhdpi/mapbox_logo_icon.png
index 194aa64da2..7eec45f4b1 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xhdpi/mapbox_logo_icon.png
+++ b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xhdpi/mapbox_logo_icon.png
Binary files differ
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xxhdpi/mapbox_logo_icon.png b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xxhdpi/mapbox_logo_icon.png
index d1260a16f3..5876056f1c 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xxhdpi/mapbox_logo_icon.png
+++ b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xxhdpi/mapbox_logo_icon.png
Binary files differ
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xxxhdpi/mapbox_logo_icon.png b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xxxhdpi/mapbox_logo_icon.png
index 5f9647610a..e5780ccc07 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xxxhdpi/mapbox_logo_icon.png
+++ b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable-xxxhdpi/mapbox_logo_icon.png
Binary files differ
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable/mapbox_info_icon_default.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable/mapbox_info_icon_default.xml
index fa82bb8d9b..65837d65d0 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable/mapbox_info_icon_default.xml
+++ b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable/mapbox_info_icon_default.xml
@@ -1,8 +1,8 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:viewportWidth="24.0"
- android:viewportHeight="24.0">
+ android:width="21dp"
+ android:height="21dp"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0">
<path
android:fillColor="#FF1E8CAB"
android:pathData="M11,17h2v-6h-2v6zm1,-15C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zm0,18c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM11,9h2V7h-2v2z"/>
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable/mapbox_info_icon_selected.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable/mapbox_info_icon_selected.xml
index 074928d05a..ccbd1d8d39 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/res/drawable/mapbox_info_icon_selected.xml
+++ b/platform/android/MapboxGLAndroidSDK/src/main/res/drawable/mapbox_info_icon_selected.xml
@@ -1,9 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:viewportHeight="24.0"
- android:viewportWidth="24.0">
+ android:width="21dp"
+ android:height="21dp"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0">
<path
android:fillColor="#551E8CAB"
- android:pathData="M11,17h2v-6h-2v6zm1,-15C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zm0,18c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM11,9h2V7h-2v2z" />
+ android:pathData="M11,17h2v-6h-2v6zm1,-15C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zm0,18c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM11,9h2V7h-2v2z"/>
</vector>
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapbox_mapview_internal.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapbox_mapview_internal.xml
index e6a2677785..6d07de7baa 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapbox_mapview_internal.xml
+++ b/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapbox_mapview_internal.xml
@@ -39,10 +39,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
- android:background="@drawable/mapbox_default_bg_selector"
android:clickable="true"
+ android:focusable="true"
android:contentDescription="@string/mapbox_attributionsIconContentDescription"
- android:padding="7dp"
android:src="@drawable/mapbox_info_bg_selector"/>
</merge>
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapbox_mapview_preview.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapbox_mapview_preview.xml
index d015bc5785..1c1ab0e71b 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapbox_mapview_preview.xml
+++ b/platform/android/MapboxGLAndroidSDK/src/main/res/layout/mapbox_mapview_preview.xml
@@ -1,22 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
- android:src="@drawable/mapbox_mapview_preview" />
+ android:contentDescription="@null"
+ android:src="@drawable/mapbox_mapview_preview"
+ android:layout_alignParentTop="true"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentStart="true"/>
<ImageView
+ android:id="@id/logoView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
- android:layout_marginBottom="@dimen/mapbox_eight_dp"
- android:layout_marginLeft="@dimen/mapbox_eight_dp"
+ android:layout_alignParentStart="true"
+ android:layout_marginBottom="@dimen/mapbox_four_dp"
+ android:layout_marginLeft="@dimen/mapbox_four_dp"
+ android:layout_marginStart="@dimen/mapbox_four_dp"
android:contentDescription="@null"
android:src="@drawable/mapbox_logo_icon"/>
@@ -24,18 +31,22 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
- android:layout_marginBottom="@dimen/mapbox_seven_dp"
- android:layout_marginLeft="@dimen/mapbox_seventy_six_dp"
+ android:layout_toEndOf="@+id/logoView"
+ android:contentDescription="@null"
+ android:layout_marginBottom="@dimen/mapbox_four_dp"
android:background="@drawable/mapbox_default_bg_selector"
- android:clickable="true"
- android:contentDescription="@string/mapbox_attributionsIconContentDescription"
- android:src="@drawable/mapbox_info_bg_selector" />
+ android:src="@drawable/mapbox_info_bg_selector"
+ android:layout_marginLeft="@dimen/mapbox_four_dp"
+ android:layout_marginStart="@dimen/mapbox_four_dp"
+ android:layout_toRightOf="@+id/logoView"/>
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
+ android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_margin="10dp"
- android:src="@drawable/mapbox_compass_icon" />
+ android:contentDescription="@null"
+ android:src="@drawable/mapbox_compass_icon"/>
</RelativeLayout>
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/res/values/dimens.xml b/platform/android/MapboxGLAndroidSDK/src/main/res/values/dimens.xml
index df6983e11d..ce20cb9a8b 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/res/values/dimens.xml
+++ b/platform/android/MapboxGLAndroidSDK/src/main/res/values/dimens.xml
@@ -4,10 +4,15 @@
<dimen name="mapbox_infowindow_margin">8dp</dimen>
<dimen name="mapbox_infowindow_offset">-2dp</dimen>
<dimen name="mapbox_infowindow_line_width">1.5dp</dimen>
- <dimen name="mapbox_seven_dp">7dp</dimen>
+ <dimen name="mapbox_attribution_icon_left_padding">@dimen/mapbox_two_dp</dimen>
+ <dimen name="mapbox_attribution_icon_top_padding">@dimen/mapbox_two_dp</dimen>
+ <dimen name="mapbox_attribution_icon_right_padding">@dimen/mapbox_two_dp</dimen>
+ <dimen name="mapbox_attribution_icon_bottom_padding">@dimen/mapbox_two_dp</dimen>
+ <dimen name="mapbox_two_dp">2dp</dimen>
+ <dimen name="mapbox_four_dp">4dp</dimen>
<dimen name="mapbox_eight_dp">8dp</dimen>
<dimen name="mapbox_ten_dp">10dp</dimen>
<dimen name="mapbox_sixteen_dp">16dp</dimen>
- <dimen name="mapbox_seventy_six_dp">76dp</dimen>
+ <dimen name="mapbox_ninety_five_dp">95dp</dimen>
<dimen name="mapbox_my_locationview_outer_circle">18dp</dimen>
</resources>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java
index 354f5def6f..a1c46903bf 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java
@@ -15,6 +15,8 @@ import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.layers.Property;
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
import com.mapbox.mapboxsdk.style.sources.CannotAddSourceException;
+import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
+import com.mapbox.mapboxsdk.style.sources.RasterSource;
import com.mapbox.mapboxsdk.style.sources.Source;
import com.mapbox.mapboxsdk.style.sources.VectorSource;
import com.mapbox.mapboxsdk.testapp.R;
@@ -28,6 +30,8 @@ import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.List;
import timber.log.Timber;
@@ -190,6 +194,35 @@ public class RuntimeStyleTests extends BaseActivityTest {
onView(withId(R.id.mapView)).perform(new AddRemoveSourceAction());
}
+ @Test
+ public void testVectorSourceUrlGetter() {
+ validateTestSetup();
+
+ VectorSource source = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
+ mapboxMap.addSource(source);
+ assertEquals("mapbox://mapbox.mapbox-terrain-v2", source.getUrl());
+ }
+
+ @Test
+ public void testRasterSourceUrlGetter() {
+ validateTestSetup();
+
+ RasterSource source = new RasterSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
+ mapboxMap.addSource(source);
+ assertEquals("mapbox://mapbox.mapbox-terrain-v2", source.getUrl());
+ }
+
+ @Test
+ public void testGeoJsonSourceUrlGetter() throws MalformedURLException {
+ validateTestSetup();
+
+ GeoJsonSource source = new GeoJsonSource("my-source");
+ mapboxMap.addSource(source);
+ assertNull(source.getUrl());
+ source.setUrl(new URL("http://mapbox.com/my-file.json"));
+ assertEquals("http://mapbox.com/my-file.json", source.getUrl());
+ }
+
/**
* https://github.com/mapbox/mapbox-gl-native/issues/7973
*/
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java
index 08399f3b3e..60518239c8 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java
@@ -43,10 +43,35 @@ public class CameraPositionActivity extends AppCompatActivity implements OnMapRe
public void onMapReady(@NonNull final MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
- mapboxMap.setOnCameraChangeListener(new MapboxMap.OnCameraChangeListener() {
+ mapboxMap.setOnCameraIdleListener(new MapboxMap.OnCameraIdleListener() {
@Override
- public void onCameraChange(CameraPosition position) {
- Timber.w("OnCameraChange: " + position);
+ public void onCameraIdle() {
+ Timber.e("OnCameraIdle");
+ }
+ });
+
+ mapboxMap.setOnCameraMoveCancelListener(new MapboxMap.OnCameraMoveCanceledListener() {
+ @Override
+ public void onCameraMoveCanceled() {
+ Timber.e("OnCameraMoveCanceled");
+ }
+ });
+
+ mapboxMap.setOnCameraMoveListener(new MapboxMap.OnCameraMoveListener() {
+ @Override
+ public void onCameraMove() {
+ Timber.e("OnCameraMove");
+ }
+ });
+
+ mapboxMap.setOnCameraMoveStartedistener(new MapboxMap.OnCameraMoveStartedListener() {
+
+ private final String[] REASONS = {"REASON_API_GESTURE", "REASON_DEVELOPER_ANIMATION", "REASON_API_ANIMATION"};
+
+ @Override
+ public void onCameraMoveStarted(int reason) {
+ // reason ranges from 1 <-> 3
+ Timber.e("OnCameraMoveStarted: %s", REASONS[reason - 1]);
}
});
diff --git a/platform/android/gradle/wrapper/gradle-wrapper.properties b/platform/android/gradle/wrapper/gradle-wrapper.properties
index c7ad166b13..1d35abd7b2 100644
--- a/platform/android/gradle/wrapper/gradle-wrapper.properties
+++ b/platform/android/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip \ No newline at end of file
diff --git a/platform/android/src/style/sources/geojson_source.cpp b/platform/android/src/style/sources/geojson_source.cpp
index 9b56446e31..780cc4b6f6 100644
--- a/platform/android/src/style/sources/geojson_source.cpp
+++ b/platform/android/src/style/sources/geojson_source.cpp
@@ -97,6 +97,11 @@ namespace android {
source.as<mbgl::style::GeoJSONSource>()->GeoJSONSource::setURL(jni::Make<std::string>(env, url));
}
+ jni::String GeoJSONSource::getURL(jni::JNIEnv& env) {
+ optional<std::string> url = source.as<mbgl::style::GeoJSONSource>()->GeoJSONSource::getURL();
+ return url ? jni::Make<jni::String>(env, *url) : jni::String();
+ }
+
jni::Array<jni::Object<geojson::Feature>> GeoJSONSource::querySourceFeatures(jni::JNIEnv& env,
jni::Array<jni::Object<>> jfilter) {
using namespace mbgl::android::conversion;
@@ -133,6 +138,7 @@ namespace android {
METHOD(&GeoJSONSource::setFeature, "nativeSetFeature"),
METHOD(&GeoJSONSource::setGeometry, "nativeSetGeometry"),
METHOD(&GeoJSONSource::setURL, "nativeSetUrl"),
+ METHOD(&GeoJSONSource::getURL, "nativeGetUrl"),
METHOD(&GeoJSONSource::querySourceFeatures, "querySourceFeatures")
);
}
diff --git a/platform/android/src/style/sources/geojson_source.hpp b/platform/android/src/style/sources/geojson_source.hpp
index 51ea452fb2..938a20612c 100644
--- a/platform/android/src/style/sources/geojson_source.hpp
+++ b/platform/android/src/style/sources/geojson_source.hpp
@@ -38,6 +38,8 @@ public:
jni::Array<jni::Object<geojson::Feature>> querySourceFeatures(jni::JNIEnv&,
jni::Array<jni::Object<>> jfilter);
+ jni::String getURL(jni::JNIEnv&);
+
jni::jobject* createJavaPeer(jni::JNIEnv&);
}; // class GeoJSONSource
diff --git a/platform/android/src/style/sources/raster_source.cpp b/platform/android/src/style/sources/raster_source.cpp
index 0234901a77..32fdb163b0 100644
--- a/platform/android/src/style/sources/raster_source.cpp
+++ b/platform/android/src/style/sources/raster_source.cpp
@@ -28,6 +28,11 @@ namespace android {
RasterSource::~RasterSource() = default;
+ jni::String RasterSource::getURL(jni::JNIEnv& env) {
+ optional<std::string> url = source.as<mbgl::style::RasterSource>()->RasterSource::getURL();
+ return url ? jni::Make<jni::String>(env, *url) : jni::String();
+ }
+
jni::Class<RasterSource> RasterSource::javaClass;
jni::jobject* RasterSource::createJavaPeer(jni::JNIEnv& env) {
@@ -46,7 +51,8 @@ namespace android {
env, RasterSource::javaClass, "nativePtr",
std::make_unique<RasterSource, JNIEnv&, jni::String, jni::Object<>, jni::jint>,
"initialize",
- "finalize"
+ "finalize",
+ METHOD(&RasterSource::getURL, "nativeGetUrl")
);
}
diff --git a/platform/android/src/style/sources/raster_source.hpp b/platform/android/src/style/sources/raster_source.hpp
index 6600096f6d..a79ccc10a4 100644
--- a/platform/android/src/style/sources/raster_source.hpp
+++ b/platform/android/src/style/sources/raster_source.hpp
@@ -22,6 +22,8 @@ public:
~RasterSource();
+ jni::String getURL(jni::JNIEnv&);
+
jni::jobject* createJavaPeer(jni::JNIEnv&);
}; // class RasterSource
diff --git a/platform/android/src/style/sources/vector_source.cpp b/platform/android/src/style/sources/vector_source.cpp
index a8f74df142..e2d9f60dec 100644
--- a/platform/android/src/style/sources/vector_source.cpp
+++ b/platform/android/src/style/sources/vector_source.cpp
@@ -34,6 +34,11 @@ namespace android {
VectorSource::~VectorSource() = default;
+ jni::String VectorSource::getURL(jni::JNIEnv& env) {
+ optional<std::string> url = source.as<mbgl::style::VectorSource>()->VectorSource::getURL();
+ return url ? jni::Make<jni::String>(env, *url) : jni::String();
+ }
+
jni::Array<jni::Object<geojson::Feature>> VectorSource::querySourceFeatures(jni::JNIEnv& env,
jni::Array<jni::String> jSourceLayerIds,
jni::Array<jni::Object<>> jfilter) {
@@ -66,7 +71,8 @@ namespace android {
std::make_unique<VectorSource, JNIEnv&, jni::String, jni::Object<>>,
"initialize",
"finalize",
- METHOD(&VectorSource::querySourceFeatures, "querySourceFeatures")
+ METHOD(&VectorSource::querySourceFeatures, "querySourceFeatures"),
+ METHOD(&VectorSource::getURL, "nativeGetUrl")
);
}
diff --git a/platform/android/src/style/sources/vector_source.hpp b/platform/android/src/style/sources/vector_source.hpp
index cac687bb6f..643b468338 100644
--- a/platform/android/src/style/sources/vector_source.hpp
+++ b/platform/android/src/style/sources/vector_source.hpp
@@ -26,6 +26,8 @@ public:
jni::Array<jni::Object<geojson::Feature>> querySourceFeatures(jni::JNIEnv&, jni::Array<jni::String>,
jni::Array<jni::Object<>> jfilter);
+ jni::String getURL(jni::JNIEnv&);
+
jni::jobject* createJavaPeer(jni::JNIEnv&);
}; // class VectorSource
diff --git a/platform/default/default_file_source.cpp b/platform/default/default_file_source.cpp
index 27c3950e2a..7db0b85461 100644
--- a/platform/default/default_file_source.cpp
+++ b/platform/default/default_file_source.cpp
@@ -200,12 +200,16 @@ std::string DefaultFileSource::getAccessToken() const {
}
void DefaultFileSource::setResourceTransform(std::function<std::string(Resource::Kind, std::string&&)> transform) {
- auto loop = util::RunLoop::Get();
- thread->invoke(&Impl::setResourceTransform, [loop, transform](Resource::Kind kind_, std::string&& url_, auto callback_) {
- return loop->invokeWithCallback([transform](Resource::Kind kind, std::string&& url, auto callback) {
- callback(transform(kind, std::move(url)));
- }, kind_, std::move(url_), callback_);
- });
+ if (transform) {
+ auto loop = util::RunLoop::Get();
+ thread->invoke(&Impl::setResourceTransform, [loop, transform](Resource::Kind kind_, std::string&& url_, auto callback_) {
+ return loop->invokeWithCallback([transform](Resource::Kind kind, std::string&& url, auto callback) {
+ callback(transform(kind, std::move(url)));
+ }, kind_, std::move(url_), callback_);
+ });
+ } else {
+ thread->invoke(&Impl::setResourceTransform, nullptr);
+ }
}
std::unique_ptr<AsyncRequest> DefaultFileSource::request(const Resource& resource, Callback callback) {