Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update maps sdk to latest beta #384

Merged
merged 2 commits into from
Mar 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ public void whenMapCameraInitializesTilted_iconsGetPlacedWithCorrectOffset() thr
locationLayerPlugin.setRenderMode(RenderMode.NORMAL);
locationLayerPlugin.forceLocationUpdate(location);
SymbolLayer layer = mapboxMap.getLayerAs(FOREGROUND_LAYER);
uiController.loopMainThreadForAtLeast(200);
Float[] value = layer.getIconOffset().getValue();
Assert.assertEquals((-0.05 * 60), value[1], 0.1);
});
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,25 @@
import android.app.Activity;
import android.support.test.espresso.IdlingResource;

import timber.log.Timber;

import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;

import java.lang.reflect.Field;

public class OnMapReadyIdlingResource implements IdlingResource {
public class OnMapReadyIdlingResource implements IdlingResource, OnMapReadyCallback {

private final Activity activity;
private MapboxMap mapboxMap;
private IdlingResource.ResourceCallback resourceCallback;

public OnMapReadyIdlingResource(Activity activity) {
this.activity = activity;
try {
Field field = activity.getClass().getDeclaredField("mapView");
field.setAccessible(true);
((MapView) field.get(activity)).getMapAsync(this);
} catch (Exception err) {
throw new RuntimeException(err);
}
}

@Override
Expand All @@ -26,32 +31,23 @@ public String getName() {

@Override
public boolean isIdleNow() {
boolean idle = isMapboxMapReady();
if (idle && resourceCallback != null) {
resourceCallback.onTransitionToIdle();
}
return idle;
return mapboxMap != null;
}

@Override
public void registerIdleTransitionCallback(ResourceCallback resourceCallback) {
this.resourceCallback = resourceCallback;
}

private boolean isMapboxMapReady() {
try {
Field field = activity.getClass().getDeclaredField("mapboxMap");
field.setAccessible(true);
mapboxMap = (MapboxMap) field.get(activity);
Timber.e("isMapboxReady called with value " + (mapboxMap != null));
return mapboxMap != null;
} catch (Exception exception) {
Timber.e("could not reflect", exception);
return false;
}
}

public MapboxMap getMapboxMap() {
return mapboxMap;
}

@Override
public void onMapReady(MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
if (resourceCallback != null) {
resourceCallback.onTransitionToIdle();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}


switch (item.getItemId()) {
case R.id.menu_building_min_zoom:
buildingPlugin.setMinZoomLevel(14);
Expand Down
2 changes: 1 addition & 1 deletion gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ext {
]

version = [
mapboxMapSdk : '6.0.0-beta.3',
mapboxMapSdk : '6.0.0-beta.5',
mapboxGeocoding : '3.0.0-beta.3',
mapboxGeoJson : '3.0.0-beta.3',
mapboxServices : '2.2.10',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@

import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.functions.Function;
import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer;
import com.mapbox.mapboxsdk.style.light.Light;

import static com.mapbox.mapboxsdk.constants.MapboxConstants.MAXIMUM_ZOOM;
import static com.mapbox.mapboxsdk.constants.MapboxConstants.MINIMUM_ZOOM;
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.exponential;
import static com.mapbox.mapboxsdk.style.expressions.Expression.exponential;
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
import static com.mapbox.mapboxsdk.style.expressions.Expression.interpolate;
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
import static com.mapbox.mapboxsdk.style.expressions.Expression.stop;
import static com.mapbox.mapboxsdk.style.expressions.Expression.zoom;
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionColor;
Expand Down Expand Up @@ -93,13 +96,14 @@ private void initLayer(String belowLayer) {
fillExtrusionLayer.setProperties(
visibility(visible ? VISIBLE : NONE),
fillExtrusionColor(color),
fillExtrusionHeight(Function.composite(
"height",
exponential(
stop(15f, 0f, fillExtrusionHeight(0f)),
stop(16f, 0f, fillExtrusionHeight(0f)),
stop(16f, 1000f, fillExtrusionHeight(1000f))
))),
fillExtrusionHeight(
interpolate(
exponential(1f),
zoom(),
stop(15, literal(0)),
stop(16, get("height"))
)
),
fillExtrusionOpacity(opacity)
);
addLayer(fillExtrusionLayer, belowLayer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@
import static com.mapbox.mapboxsdk.plugins.locationlayer.Utils.generateShadow;
import static com.mapbox.mapboxsdk.plugins.locationlayer.Utils.getBitmapFromDrawable;
import static com.mapbox.mapboxsdk.plugins.locationlayer.Utils.getDrawable;
import static com.mapbox.mapboxsdk.style.functions.Function.zoom;
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.exponential;
import static com.mapbox.mapboxsdk.style.expressions.Expression.exponential;
import static com.mapbox.mapboxsdk.style.expressions.Expression.interpolate;
import static com.mapbox.mapboxsdk.style.expressions.Expression.stop;
import static com.mapbox.mapboxsdk.style.expressions.Expression.zoom;
import static com.mapbox.mapboxsdk.style.layers.Property.ICON_ROTATION_ALIGNMENT_MAP;
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
Expand Down Expand Up @@ -164,14 +165,14 @@ private void addSymbolLayer(String layerId, String beforeLayerId) {
layer.setProperties(
iconAllowOverlap(true),
iconIgnorePlacement(true),
iconSize(zoom(
exponential(
stop(22f, iconSize(1f)),
stop(12f, iconSize(1f)),
stop(10f, iconSize(0.6f)),
stop(0f, iconSize(0.6f))
).withBase(1f)
)),
iconSize(
interpolate(exponential(1f), zoom(),
stop(22f, 1f),
stop(12f, 1f),
stop(10f, 0.6f),
stop(0f, 0.6f)
)
),
iconRotationAlignment(ICON_ROTATION_ALIGNMENT_MAP));
addLayerToMap(layer, beforeLayerId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ private void cancelCameraCompassAnimations() {
}

private void resetCameraCompassAnimation(CameraPosition currentCameraPosition) {
if (cameraCompassBearingAnimator == null) {
if (cameraCompassBearingAnimator == null || cameraLatLngAnimator == null) {
return;
}
long duration = cameraLatLngAnimator.getDuration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void initializeOptions(LocationLayerOptions options) {
}

void setCameraMode(@CameraMode.Mode int cameraMode) {
boolean wasTracking = isLocationTracking();
final boolean wasTracking = isLocationTracking();
this.cameraMode = cameraMode;
mapboxMap.cancelTransitions();
adjustGesturesThresholds();
Expand Down Expand Up @@ -120,7 +120,7 @@ private void notifyCameraTrackingChangeListener(boolean wasTracking) {
internalCameraTrackingChangedListener.onCameraTrackingChanged(cameraMode);
if (wasTracking && !isLocationTracking()) {
mapboxMap.getUiSettings().setFocalPoint(null);
moveGestureDetector.setMoveThreshold(moveGestureDetector.getDefaultMoveThreshold());
moveGestureDetector.setMoveThreshold(0f);
internalCameraTrackingChangedListener.onCameraTrackingDismissed();
}
}
Expand Down
Loading