Cherry pick release v4.2.0 (#6944)

* [android] - MyLocationView should facing above when location and compass bearing tracking are enabled. (#6829)

* [android] - use current animated rotation value for calculating animated marker rotation difference (#6826)

fix unit tests, input limiting is not handled by animateRotationBy instead of MarkerView.
Changed test to validate if method was called with correct value.

* [android] - only calculated offset margins for InfoWindow if View is found in current viewport, added example to the test app to test for regressions (#6877)

* upgraded okhttp dependency to latest version (#6880)

* Cancelable callback invocation (#6891)

* [android] - allow onCancel to be invoked from camera cancel callbacks

* set to null after finish

* [android]  - using bearing clockwise versus counterclockwise (#6917)

* [android]  - using bearing clockwise versus counterclockwise

* fixup brackets

* [android] - convert bearing values from core to Android SDK equivalent.
This commit is contained in:
Tobrun
2016-11-09 10:42:18 +01:00
committed by GitHub
parent efc427f9bb
commit 772324e8f2
12 changed files with 144 additions and 93 deletions

View File

@@ -172,6 +172,24 @@ public class MarkerViewActivity extends AppCompatActivity {
.icon(IconFactory.getInstance(mapView.getContext())
.fromResource(R.drawable.ic_arsenal))
);
// allow more open infowindows at the same time
mapboxMap.setAllowConcurrentMultipleOpenInfoWindows(true);
// add offscreen markers
Marker markerRightOffScreen = mapboxMap.addMarker(new MarkerOptions()
.setPosition(new LatLng(38.892846, -76.909399))
.title("InfoWindow")
.snippet("Offscreen, to the right of the Map."));
Marker markerRightBottomOffScreen = mapboxMap.addMarker(new MarkerOptions()
.setPosition(new LatLng(38.791645, -77.039006))
.title("InfoWindow")
.snippet("Offscreen, to the bottom of the Map"));
// open infowindow offscreen markers
mapboxMap.selectMarker(markerRightOffScreen);
mapboxMap.selectMarker(markerRightBottomOffScreen);
}
});
}

View File

@@ -87,7 +87,17 @@ public class CameraPositionActivity extends AppCompatActivity implements OnMapRe
.tilt(tilt)
.build();
mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 5000);
mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 5000, new MapboxMap.CancelableCallback() {
@Override
public void onCancel() {
Log.v(MapboxConstants.TAG, "OnCancel called");
}
@Override
public void onFinish() {
Log.v(MapboxConstants.TAG, "OnFinish called");
}
});
Log.v(MapboxConstants.TAG, cameraPosition.toString());
}
});

View File

@@ -146,7 +146,6 @@ public class MarkerViewTest {
public void testRotationUpdatePositive() {
float startRotation = 45;
float endRotation = 180;
float animationValue = 135;
// allow calls to our mock
when(mapboxMap.getMarkerViewManager()).thenReturn(markerViewManager);
@@ -156,14 +155,13 @@ public class MarkerViewTest {
marker.setMapboxMap(mapboxMap);
marker.setRotation(endRotation);
verify(markerViewManager, times(1)).animateRotationBy(marker, animationValue);
verify(markerViewManager, times(1)).animateRotationBy(marker, endRotation);
}
@Test
public void testRotationUpdateNegative() {
float startRotation = 10;
float endRotation = 270;
float animationValue = -100;
// allow calls to our mock
when(mapboxMap.getMarkerViewManager()).thenReturn(markerViewManager);
@@ -173,14 +171,13 @@ public class MarkerViewTest {
marker.setMapboxMap(mapboxMap);
marker.setRotation(endRotation);
verify(markerViewManager, times(1)).animateRotationBy(marker, animationValue);
verify(markerViewManager, times(1)).animateRotationBy(marker, endRotation);
}
@Test
public void testRotationUpdateMax() {
float startRotation = 359;
float endRotation = 0;
float animationValue = 1;
// allow calls to our mock
when(mapboxMap.getMarkerViewManager()).thenReturn(markerViewManager);
@@ -190,14 +187,13 @@ public class MarkerViewTest {
marker.setMapboxMap(mapboxMap);
marker.setRotation(endRotation);
verify(markerViewManager, times(1)).animateRotationBy(marker, animationValue);
verify(markerViewManager, times(1)).animateRotationBy(marker, 0);
}
@Test
public void testRotationUpdateMin() {
float startRotation = 0;
float endRotation = 359;
float animationValue = -1;
// allow calls to our mock
when(mapboxMap.getMarkerViewManager()).thenReturn(markerViewManager);
@@ -207,7 +203,7 @@ public class MarkerViewTest {
marker.setMapboxMap(mapboxMap);
marker.setRotation(endRotation);
verify(markerViewManager, times(1)).animateRotationBy(marker, animationValue);
verify(markerViewManager, times(1)).animateRotationBy(marker, endRotation);
}
@Test