Skip to content
This repository has been archived by the owner on Mar 26, 2021. It is now read-only.

Commit

Permalink
Merge branch 'release-ios-v3.6.0-android-v5.1.0' into merge_mapbox_v5_1
Browse files Browse the repository at this point in the history
* release-ios-v3.6.0-android-v5.1.0:
  [android] - update changelog for 5.1.0 release (mapbox#9405)
  [android] - bump Mapbox Android Services to latest for 5.1.0 final release (mapbox#9402)
  Downgrade location provider dependency (mapbox#9394)
  macos-v0.5.0
  [macos] Updated screenshot
  ios] Update pods spec for iOS v3.6.0
  [macos] Fixed cursor shifting after drag gesture
  [macos] Reorganized changelog
  [ios] moved changes to darwin (mapbox#9387)
  OnCameraIdle hook into quickzoom gesture (mapbox#9339)
  [core] Fix iterator invalidation in erase_if
  [ios] Minimize tilt gesture delay
  [ios, macos] Fix size and color of default marker image
  [ios] Fixed infinite loop zooming in past z23

# Conflicts:
#	platform/android/MapboxGLAndroidSDK/build.gradle
#	platform/android/MapboxGLAndroidSDK/gradle.properties
#	platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java
#	platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java
  • Loading branch information
Tran Thuong Tien committed Jul 4, 2017
2 parents 5e1b9c5 + d2d8a57 commit c8456d3
Show file tree
Hide file tree
Showing 29 changed files with 120 additions and 108 deletions.
7 changes: 6 additions & 1 deletion platform/android/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

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
## 5.1.0 - June 30, 2017

* Update to MAS 2.1.3 [#9402](https://github.com/mapbox/mapbox-gl-native/pull/9402)
* Downgrade LOST to v1.1.1 [#9394](https://github.com/mapbox/mapbox-gl-native/pull/9394)
* OnCameraIdle hook into quickzoom gesture [#9339](https://github.com/mapbox/mapbox-gl-native/pull/9339)
* LatLngBounds conversion regression, add test [#9324](https://github.com/mapbox/mapbox-gl-native/pull/9324)

## 5.1.0-beta.5 - June 21, 2017

Expand Down
4 changes: 3 additions & 1 deletion platform/android/MapboxGLAndroidSDK/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ dependencies {
compile project.ext.dep.supportDesign
compile project.ext.dep.timber
compile project.ext.dep.okhttp3
compile project.ext.dep.lost
compile(project.ext.dep.lost) {
exclude group: 'com.google.guava'
}

// Mapbox Android Services (GeoJSON support)
compile(project.ext.dep.mapboxJavaGeoJSON) {
Expand Down
2 changes: 1 addition & 1 deletion platform/android/MapboxGLAndroidSDK/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GROUP=com.mapbox.mapboxsdk
VERSION_NAME=5.0.1
VERSION_NAME=5.2.0-SNAPSHOT

POM_DESCRIPTION=Mapbox GL Android SDK
POM_URL=https://github.com/mapbox/mapbox-gl-native
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* in the history stack.
* </p>
*/
public class LocationSource extends LocationEngine implements LostApiClient.ConnectionCallbacks, LocationListener {
public class LocationSource extends LocationEngine implements LocationListener {

private static final String LOG_TAG = LocationSource.class.getSimpleName();

Expand All @@ -43,9 +43,7 @@ public class LocationSource extends LocationEngine implements LostApiClient.Conn
public LocationSource(Context context) {
super();
this.context = context.getApplicationContext();
lostApiClient = new LostApiClient.Builder(this.context)
.addConnectionCallbacks(this)
.build();
lostApiClient = new LostApiClient.Builder(this.context).build();
}

/**
Expand All @@ -57,6 +55,9 @@ public void activate() {
if (!lostApiClient.isConnected()) {
lostApiClient.connect();
}
for (LocationEngineListener listener : locationListeners) {
listener.onConnected();
}
}

/**
Expand All @@ -82,23 +83,6 @@ public boolean isConnected() {
return lostApiClient.isConnected();
}

/**
* Invoked when the location provider has connected.
*/
@Override
public void onConnected() {
for (LocationEngineListener listener : locationListeners) {
listener.onConnected();
}
}

/**
* Invoked when the location provider connection has been suspended.
*/
@Override
public void onConnectionSuspended() {
}

/**
* Returns the Last known location is the location provider is connected and location permissions are granted.
*
Expand All @@ -109,9 +93,8 @@ public void onConnectionSuspended() {
public Location getLastLocation() {
if (lostApiClient.isConnected() && PermissionsManager.areLocationPermissionsGranted(context)) {
//noinspection MissingPermission
return LocationServices.FusedLocationApi.getLastLocation(lostApiClient);
return LocationServices.FusedLocationApi.getLastLocation();
}

return null;
}

Expand Down Expand Up @@ -139,7 +122,7 @@ public void requestLocationUpdates() {

if (lostApiClient.isConnected() && PermissionsManager.areLocationPermissionsGranted(context)) {
//noinspection MissingPermission
LocationServices.FusedLocationApi.requestLocationUpdates(lostApiClient, request, this);
LocationServices.FusedLocationApi.requestLocationUpdates(request, this);
}
}

Expand All @@ -149,7 +132,7 @@ public void requestLocationUpdates() {
@Override
public void removeLocationUpdates() {
if (lostApiClient.isConnected()) {
LocationServices.FusedLocationApi.removeLocationUpdates(lostApiClient, this);
LocationServices.FusedLocationApi.removeLocationUpdates(this);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

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;
import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveStartedListener;

class CameraChangeDispatcher implements MapboxMap.OnCameraMoveStartedListener, MapboxMap.OnCameraMoveListener,
MapboxMap.OnCameraMoveCanceledListener, OnCameraIdleListener {
Expand Down Expand Up @@ -59,9 +59,11 @@ public void onCameraMoveCanceled() {

@Override
public void onCameraIdle() {
if (onCameraIdleListener != null && !idle) {
if (!idle) {
idle = true;
onCameraIdleListener.onCameraIdle();
if (onCameraIdleListener != null) {
onCameraIdleListener.onCameraIdle();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ final class MapGestureDetector {
private boolean quickZoom = false;
private boolean scrollInProgress = false;
private boolean scaleGestureOccurred = false;
private boolean recentScaleGestureOccurred = false;

MapGestureDetector(Context context, Transform transform, Projection projection, UiSettings uiSettings,
TrackingSettings trackingSettings, AnnotationManager annotationManager,
Expand Down Expand Up @@ -151,7 +152,7 @@ boolean onTouchEvent(@NonNull MotionEvent event) {
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
// First pointer down, reset scaleGestureOccurred, used to avoid triggering a fling after a scale gesture #7666
scaleGestureOccurred = false;
recentScaleGestureOccurred = false;
transform.setGestureInProgress(true);
break;

Expand Down Expand Up @@ -281,7 +282,7 @@ public boolean onDoubleTapEvent(MotionEvent e) {
break;
case MotionEvent.ACTION_UP:
if (quickZoom) {
// insert here?
cameraChangeDispatcher.onCameraIdle();
quickZoom = false;
break;
}
Expand Down Expand Up @@ -365,7 +366,7 @@ public void onLongPress(MotionEvent motionEvent) {

@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if ((!trackingSettings.isScrollGestureCurrentlyEnabled()) || scaleGestureOccurred) {
if ((!trackingSettings.isScrollGestureCurrentlyEnabled()) || recentScaleGestureOccurred) {
// don't allow a fling is scroll is disabled
// and ignore when a scale gesture has occurred
return false;
Expand Down Expand Up @@ -416,6 +417,10 @@ public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float d
return false;
}

if (scaleGestureOccurred) {
return false;
}

if (!scrollInProgress) {
scrollInProgress = true;

Expand Down Expand Up @@ -458,6 +463,7 @@ public boolean onScaleBegin(ScaleGestureDetector detector) {
}

scaleGestureOccurred = true;
recentScaleGestureOccurred = true;
beginTime = detector.getEventTime();
if (Mapbox.ENABLE_METRICS_ON_MAPPY) {
MapboxTelemetry.getInstance().pushEvent(MapboxEventWrapper.buildMapClickEvent(
Expand All @@ -470,9 +476,11 @@ public boolean onScaleBegin(ScaleGestureDetector detector) {
// Called when fingers leave screen
@Override
public void onScaleEnd(ScaleGestureDetector detector) {
scaleGestureOccurred = false;
beginTime = 0;
scaleFactor = 1.0f;
zoomStarted = false;
cameraChangeDispatcher.onCameraIdle();
}

// Called each time a finger moves
Expand Down Expand Up @@ -508,6 +516,9 @@ public boolean onScale(ScaleGestureDetector detector) {
}

// Gesture is a quickzoom if there aren't two fingers
if (!quickZoom && !twoTap) {
cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
}
quickZoom = !twoTap;

// make an assumption here; if the zoom center is specified by the gesture, it's NOT going
Expand All @@ -520,6 +531,7 @@ public boolean onScale(ScaleGestureDetector detector) {
// arround user provided focal point
transform.zoomBy(Math.log(detector.getScaleFactor()) / Math.log(2), focalPoint.x, focalPoint.y);
} else if (quickZoom) {
cameraChangeDispatcher.onCameraMove();
// clamp scale factors we feed to core #7514
float scaleFactor = MathUtils.clamp(detector.getScaleFactor(),
MapboxConstants.MINIMUM_SCALE_FACTOR_CLAMP,
Expand Down Expand Up @@ -583,7 +595,7 @@ public boolean onRotate(RotateGestureDetector detector) {
// If rotate is large enough ignore a tap
// Also is zoom already started, don't rotate
totalAngle += detector.getRotationDegreesDelta();
if (!zoomStarted && ((totalAngle > 20.0f) || (totalAngle < -20.0f))) {
if (totalAngle > 20.0f || totalAngle < -20.0f) {
started = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ void zoom(boolean zoomIn, @NonNull PointF focalPoint) {
if (cameraPosition != null) {
int newZoom = (int) Math.round(cameraPosition.zoom + (zoomIn ? 1 : -1));
setZoom(newZoom, focalPoint, MapboxConstants.ANIMATION_DURATION);
} else {
// we are not transforming, notify about being idle
cameraChangeDispatcher.onCameraIdle();
}
}

Expand All @@ -228,8 +231,8 @@ void setZoom(double zoom, @NonNull PointF focalPoint, long duration) {
@Override
public void onMapChanged(int change) {
if (change == MapView.REGION_DID_CHANGE_ANIMATED) {
mapView.removeOnMapChangedListener(this);
cameraChangeDispatcher.onCameraIdle();
mapView.removeOnMapChangedListener(this);
}
}
});
Expand Down Expand Up @@ -328,7 +331,7 @@ void moveBy(double offsetX, double offsetY, long duration) {
mapView.addOnMapChangedListener(new MapView.OnMapChangedListener() {
@Override
public void onMapChanged(int change) {
if (change == MapView.DID_FINISH_RENDERING_MAP_FULLY_RENDERED) {
if (change == MapView.REGION_DID_CHANGE_ANIMATED) {
mapView.removeOnMapChangedListener(this);
cameraChangeDispatcher.onCameraIdle();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,12 @@ protected void onDraw(Canvas canvas) {
if (myBearingTrackingMode == MyBearingTracking.NONE || !compassListener.isSensorAvailable()) {
draw(canvas, foregroundDrawable, backgroundDrawable);
} else if (foregroundBearingDrawable != null && foregroundBounds != null) {
draw(canvas, foregroundBearingDrawable, backgroundBearingDrawable);
if (myBearingTrackingMode == MyBearingTracking.GPS || compassListener.isSensorAvailable()) {
draw(canvas, foregroundBearingDrawable, backgroundBearingDrawable);
} else {
// We are tracking MyBearingTracking.COMPASS, but sensor is not available.
draw(canvas, foregroundDrawable, backgroundDrawable);
}
}
}

Expand Down Expand Up @@ -840,9 +845,9 @@ private class CompassListener implements SensorEventListener {
private final SensorManager sensorManager;

private Sensor rotationVectorSensor;
float[] matrix = new float[9];
float[] orientation = new float[3];

private float[] matrix = new float[9];
private float[] orientation = new float[3];
private boolean reportMissingSensor = true;
// Compass data
private long compassUpdateNextTimestamp = 0;

Expand All @@ -860,7 +865,8 @@ public void onPause() {
}

public boolean isSensorAvailable() {
if (rotationVectorSensor == null) {
if (rotationVectorSensor == null && reportMissingSensor) {
reportMissingSensor = false;
Timber.e("Sensor.TYPE_ROTATION_VECTOR is missing from this device. Unable to use MyBearingTracking.COMPASS.");
}
return rotationVectorSensor != null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
fabric-identifier=com.mapbox.mapboxsdk.mapbox-android-sdk
fabric-version=5.0.1
fabric-version=5.1.0
fabric-build-type=binary
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class CameraPositionActivity extends AppCompatActivity implements OnMapRe

private MapView mapView;
private MapboxMap mapboxMap;
private FloatingActionButton fab;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -40,13 +41,14 @@ protected void onCreate(Bundle savedInstanceState) {
}

@Override
public void onMapReady(@NonNull final MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
public void onMapReady(@NonNull final MapboxMap map) {
mapboxMap = map;

mapboxMap.setOnCameraIdleListener(new MapboxMap.OnCameraIdleListener() {
@Override
public void onCameraIdle() {
Timber.e("OnCameraIdle");
fab.setColorFilter(ContextCompat.getColor(CameraPositionActivity.this, android.R.color.holo_green_dark));
}
});

Expand All @@ -61,6 +63,7 @@ public void onCameraMoveCanceled() {
@Override
public void onCameraMove() {
Timber.e("OnCameraMove");
fab.setColorFilter(ContextCompat.getColor(CameraPositionActivity.this, android.R.color.holo_orange_dark));
}
});

Expand All @@ -71,12 +74,13 @@ public void onCameraMove() {
@Override
public void onCameraMoveStarted(int reason) {
// reason ranges from 1 <-> 3
fab.setColorFilter(ContextCompat.getColor(CameraPositionActivity.this, android.R.color.holo_red_dark));
Timber.e("OnCameraMoveStarted: %s", REASONS[reason - 1]);
}
});

// add a listener to FAB
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setColorFilter(ContextCompat.getColor(CameraPositionActivity.this, R.color.primary));
fab.setOnClickListener(new View.OnClickListener() {
@Override
Expand Down
Loading

0 comments on commit c8456d3

Please sign in to comment.