Merge branch 'release-boba' into master
# Conflicts: # circle.yml # include/mbgl/style/expression/let.hpp # platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngBounds.java # platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java # platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java # platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java # platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java # platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java # platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java # platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java # platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml # platform/android/gradle/dependencies.gradle # platform/android/src/example_custom_layer.cpp # platform/android/src/geojson/point.cpp # platform/darwin/src/NSPredicate+MGLAdditions.mm # platform/darwin/test/MGLExpressionTests.mm # platform/ios/Mapbox-iOS-SDK-nightly-dynamic.podspec # platform/ios/Mapbox-iOS-SDK-symbols.podspec # platform/ios/Mapbox-iOS-SDK.podspec # platform/ios/app/MBXViewController.m # src/mbgl/renderer/layers/render_custom_layer.cpp # src/mbgl/style/conversion/filter.cpp # src/mbgl/style/expression/interpolate.cpp # src/mbgl/style/expression/value.cpp # test/style/filter.test.cpp
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.maps;
|
||||
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
|
||||
/**
|
||||
* Utility class to bypass package visibility
|
||||
*/
|
||||
public class MapViewUtils {
|
||||
|
||||
public static void setDirection(MapboxMap mapboxMap, float direction) {
|
||||
mapboxMap.getTransform().setBearing(direction);
|
||||
}
|
||||
|
||||
public static float getDirection(MapboxMap mapboxMap) {
|
||||
return (float) mapboxMap.getTransform().getBearing();
|
||||
}
|
||||
|
||||
public static void setTilt(MapboxMap mapboxMap, float tilt) {
|
||||
mapboxMap.getTransform().setTilt((double) tilt);
|
||||
}
|
||||
|
||||
public static float getTilt(MapboxMap mapboxMap) {
|
||||
return (float) mapboxMap.getTransform().getTilt();
|
||||
}
|
||||
|
||||
public static void setLatLng(MapboxMap mapboxMap, LatLng latLng) {
|
||||
mapboxMap.getTransform().setCenterCoordinate(latLng);
|
||||
}
|
||||
|
||||
public static LatLng getLatLng(MapboxMap mapboxMap) {
|
||||
return mapboxMap.getTransform().getCenterCoordinate();
|
||||
}
|
||||
}
|
||||
@@ -161,16 +161,6 @@ public class MapboxMapTest extends BaseActivityTest {
|
||||
}));
|
||||
}
|
||||
|
||||
//
|
||||
// TrackingSettings
|
||||
//
|
||||
|
||||
@Test
|
||||
public void testTrackingSettings() {
|
||||
validateTestSetup();
|
||||
assertNotNull("TrackingSettings should not be null", mapboxMap.getTrackingSettings());
|
||||
}
|
||||
|
||||
//
|
||||
// InfoWindow
|
||||
//
|
||||
@@ -203,30 +193,6 @@ public class MapboxMapTest extends BaseActivityTest {
|
||||
}));
|
||||
}
|
||||
|
||||
//
|
||||
// Location
|
||||
//
|
||||
|
||||
@Test
|
||||
@Ignore /* disabled due to enabling permissions during test #7177 */
|
||||
public void testMyLocationEnabled() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
mapboxMap.setMyLocationEnabled(true);
|
||||
assertTrue("MyLocationEnabled should be true", mapboxMap.isMyLocationEnabled());
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore /* can't create handler inside thread that not called Looper.prepare() */
|
||||
public void testMyLocationDisabled() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
|
||||
mapboxMap.setMyLocationEnabled(false);
|
||||
assertFalse("MyLocationEnabled should be false", mapboxMap.isMyLocationEnabled());
|
||||
}));
|
||||
}
|
||||
|
||||
//
|
||||
// setters/getters interfaces
|
||||
//
|
||||
|
||||
@@ -1,157 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.camera;
|
||||
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.espresso.UiController;
|
||||
import android.support.test.espresso.ViewAction;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapViewUtils;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.TestConstants;
|
||||
|
||||
import org.hamcrest.Matcher;
|
||||
import org.junit.After;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Tests camera transformations that aren't part of our public API
|
||||
*/
|
||||
public class CameraInternalApiTest extends BaseActivityTest {
|
||||
|
||||
@Override
|
||||
protected Class getActivityClass() {
|
||||
return EspressoTestActivity.class;
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testBearing() {
|
||||
validateTestSetup();
|
||||
|
||||
CameraPosition initialPosition = new
|
||||
CameraPosition.Builder().target(new LatLng()).zoom(1).bearing(0).tilt(0).build();
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Default camera position should match default", cameraPosition, initialPosition);
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new BearingAction(mapboxMap));
|
||||
assertEquals("Bearing should match", 45.1f, MapViewUtils.getDirection(mapboxMap), TestConstants.BEARING_DELTA);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testTilt() {
|
||||
validateTestSetup();
|
||||
|
||||
CameraPosition initialPosition = new CameraPosition.Builder().target(
|
||||
new LatLng()).zoom(1).bearing(0).tilt(0).build();
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Default camera position should match default", cameraPosition, initialPosition);
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new TiltAction(mapboxMap));
|
||||
assertEquals("Tilt should match", 40.0f, MapViewUtils.getTilt(mapboxMap), TestConstants.TILT_DELTA);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testLatLng() {
|
||||
validateTestSetup();
|
||||
|
||||
CameraPosition initialPosition = new CameraPosition.Builder().target(
|
||||
new LatLng()).zoom(1).bearing(0).tilt(0).build();
|
||||
CameraPosition cameraPosition = mapboxMap.getCameraPosition();
|
||||
assertEquals("Default camera position should match default", cameraPosition, initialPosition);
|
||||
|
||||
onView(withId(R.id.mapView)).perform(new LatLngAction(mapboxMap));
|
||||
LatLng centerCoordinate = MapViewUtils.getLatLng(mapboxMap);
|
||||
assertEquals("Latitude should match", 1.1f, centerCoordinate.getLatitude(), TestConstants.LAT_LNG_DELTA);
|
||||
assertEquals("Longitude should match", 2.2f, centerCoordinate.getLongitude(), TestConstants.LAT_LNG_DELTA);
|
||||
}
|
||||
|
||||
@After
|
||||
public void unregisterIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
private class BearingAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
BearingAction(MapboxMap mapboxMap) {
|
||||
this.mapboxMap = mapboxMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
MapViewUtils.setDirection(mapboxMap, -45.1f);
|
||||
}
|
||||
}
|
||||
|
||||
private class TiltAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
TiltAction(MapboxMap mapboxMap) {
|
||||
this.mapboxMap = mapboxMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
MapViewUtils.setTilt(mapboxMap, 40.0f);
|
||||
}
|
||||
}
|
||||
|
||||
private class LatLngAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
LatLngAction(MapboxMap mapboxMap) {
|
||||
this.mapboxMap = mapboxMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
MapViewUtils.setLatLng(mapboxMap, new LatLng(1.1, 2.2));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,229 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.maps.widgets;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.test.espresso.UiController;
|
||||
import android.support.test.espresso.ViewAction;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.Mapbox;
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.constants.MyBearingTracking;
|
||||
import com.mapbox.mapboxsdk.constants.MyLocationTracking;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.widgets.MyLocationView;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
|
||||
/**
|
||||
* Experimental MyLocationView tests,
|
||||
* requires application to be granted with runtime location permissions.
|
||||
* <p>
|
||||
* Tests for enabling and disabling the {@link MyLocationView}.
|
||||
* Tests for enabling tracking modes and if the correct default images are shown when toggling
|
||||
* {@link com.mapbox.mapboxsdk.maps.TrackingSettings#setMyLocationTrackingMode(int)} &
|
||||
* {@link com.mapbox.mapboxsdk.maps.TrackingSettings#setMyBearingTrackingMode(int)}.
|
||||
* </p>
|
||||
*/
|
||||
public class MyLocationViewTest extends BaseActivityTest {
|
||||
|
||||
@Override
|
||||
protected Class getActivityClass() {
|
||||
return EspressoTestActivity.class;
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // requires runtime permissions, disabled for CI
|
||||
public void testEnabled() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed())));
|
||||
onView(withId(R.id.mapView)).perform(new ToggleLocationAction(mapboxMap, true));
|
||||
onView(withId(R.id.userLocationView)).check(matches(isDisplayed()));
|
||||
onView(withId(R.id.mapView)).perform(new ToggleLocationAction(mapboxMap, false));
|
||||
onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed())));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
// requires runtime permissions, disabled for CI + issue with android.support.test.espresso.AppNotIdleException:
|
||||
// Looped for 5049 iterations over 60 SECONDS.
|
||||
public void testTracking() {
|
||||
validateTestSetup();
|
||||
onView(withId(R.id.userLocationView)).check(matches(not(isDisplayed())));
|
||||
onView(withId(R.id.mapView)).perform(new EnableLocationTrackingAction(mapboxMap));
|
||||
onView(withId(R.id.userLocationView)).check(matches(isDisplayed()));
|
||||
onView(withId(R.id.userLocationView)).check(matches(new DrawableMatcher(mapboxMap,
|
||||
R.drawable.mapbox_mylocation_icon_default, false)));
|
||||
onView(withId(R.id.mapView)).perform(new EnableCompassBearingTrackingAction(mapboxMap));
|
||||
onView(withId(R.id.userLocationView)).check(matches(new DrawableMatcher(mapboxMap,
|
||||
R.drawable.mapbox_mylocation_icon_bearing, true)));
|
||||
}
|
||||
|
||||
private class ToggleLocationAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private boolean isEnabled;
|
||||
|
||||
ToggleLocationAction(MapboxMap map, boolean enable) {
|
||||
mapboxMap = map;
|
||||
isEnabled = enable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
if (isEnabled) {
|
||||
// move camera above user location
|
||||
mapboxMap.moveCamera(
|
||||
CameraUpdateFactory.newCameraPosition(
|
||||
new CameraPosition.Builder()
|
||||
.target(new LatLng(Mapbox.getLocationEngine().getLastLocation()))
|
||||
.build()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// show loction on screen
|
||||
mapboxMap.setMyLocationEnabled(isEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
private class EnableLocationTrackingAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
EnableLocationTrackingAction(MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
mapboxMap.getTrackingSettings().setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
|
||||
}
|
||||
}
|
||||
|
||||
private class EnableCompassBearingTrackingAction implements ViewAction {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
EnableCompassBearingTrackingAction(MapboxMap map) {
|
||||
mapboxMap = map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Matcher<View> getConstraints() {
|
||||
return isDisplayed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(UiController uiController, View view) {
|
||||
mapboxMap.getTrackingSettings().setMyBearingTrackingMode(MyBearingTracking.COMPASS);
|
||||
// wait for next compass update cycle
|
||||
uiController.loopMainThreadForAtLeast(500);
|
||||
}
|
||||
}
|
||||
|
||||
private class DrawableMatcher extends TypeSafeMatcher<View> {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private boolean isBearingDrawable;
|
||||
private final int expectedId;
|
||||
|
||||
DrawableMatcher(MapboxMap mapboxMap, int expectedId, boolean isBearingDrawable) {
|
||||
super(MyLocationView.class);
|
||||
this.mapboxMap = mapboxMap;
|
||||
this.expectedId = expectedId;
|
||||
this.isBearingDrawable = isBearingDrawable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean matchesSafely(View target) {
|
||||
Drawable currentDrawable = isBearingDrawable
|
||||
? mapboxMap.getMyLocationViewSettings().getForegroundBearingDrawable() :
|
||||
mapboxMap.getMyLocationViewSettings().getForegroundDrawable();
|
||||
|
||||
Resources resources = target.getContext().getResources();
|
||||
Drawable expectedDrawable = resources.getDrawable(expectedId);
|
||||
return areDrawablesIdentical(currentDrawable, expectedDrawable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("trying to match MyLocationView drawable to " + expectedId);
|
||||
}
|
||||
|
||||
boolean areDrawablesIdentical(Drawable drawableA, Drawable drawableB) {
|
||||
Drawable.ConstantState stateA = drawableA.getConstantState();
|
||||
Drawable.ConstantState stateB = drawableB.getConstantState();
|
||||
return (stateA != null && stateB != null && stateA.equals(stateB))
|
||||
|| getBitmap(drawableA).sameAs(getBitmap(drawableB));
|
||||
}
|
||||
|
||||
Bitmap getBitmap(Drawable drawable) {
|
||||
Bitmap result;
|
||||
if (drawable instanceof BitmapDrawable) {
|
||||
result = ((BitmapDrawable) drawable).getBitmap();
|
||||
} else {
|
||||
int width = drawable.getIntrinsicWidth();
|
||||
int height = drawable.getIntrinsicHeight();
|
||||
// Some drawables have no intrinsic width - e.g. solid colours.
|
||||
if (width <= 0) {
|
||||
width = 1;
|
||||
}
|
||||
if (height <= 0) {
|
||||
height = 1;
|
||||
}
|
||||
|
||||
result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(result);
|
||||
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||
drawable.draw(canvas);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,31 +3,18 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.UiController;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.functions.CompositeFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.CameraFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.SourceFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stop;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.expressions.Expression;
|
||||
import com.mapbox.mapboxsdk.style.layers.BackgroundLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.*;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
@@ -51,11 +38,8 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
|
||||
private void setupLayer() {
|
||||
Timber.i("Retrieving layer");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -64,18 +48,15 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("Visibility");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -84,16 +65,13 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-colorTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setBackgroundColorTransition(options);
|
||||
assertEquals(layer.getBackgroundColorTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setBackgroundColorTransition(options);
|
||||
assertEquals(layer.getBackgroundColorTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -102,47 +80,12 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getBackgroundColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundColorAsCameraFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
backgroundColor(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, backgroundColor("rgba(0, 0, 0, 1)"))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getBackgroundColor());
|
||||
assertNotNull(layer.getBackgroundColor().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getBackgroundColor().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getBackgroundColor().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getBackgroundColor().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getBackgroundColor().getFunction().getStops()).size());
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getBackgroundColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -151,15 +94,12 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundColor(Color.RED));
|
||||
assertEquals(layer.getBackgroundColorAsInt(), Color.RED);
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundColor(Color.RED));
|
||||
assertEquals(layer.getBackgroundColorAsInt(), Color.RED);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -168,16 +108,13 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-patternTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setBackgroundPatternTransition(options);
|
||||
assertEquals(layer.getBackgroundPatternTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setBackgroundPatternTransition(options);
|
||||
assertEquals(layer.getBackgroundPatternTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -186,46 +123,12 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-pattern");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundPattern("pedestrian-polygon"));
|
||||
assertEquals((String) layer.getBackgroundPattern().getValue(), (String) "pedestrian-polygon");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundPatternAsCameraFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-pattern");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
backgroundPattern(
|
||||
zoom(
|
||||
interval(
|
||||
stop(2, backgroundPattern("pedestrian-polygon"))
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getBackgroundPattern());
|
||||
assertNotNull(layer.getBackgroundPattern().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getBackgroundPattern().getFunction().getClass());
|
||||
assertEquals(IntervalStops.class, layer.getBackgroundPattern().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((IntervalStops) layer.getBackgroundPattern().getFunction().getStops()).size());
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundPattern("pedestrian-polygon"));
|
||||
assertEquals((String) layer.getBackgroundPattern().getValue(), (String) "pedestrian-polygon");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -234,16 +137,13 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-opacityTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setBackgroundOpacityTransition(options);
|
||||
assertEquals(layer.getBackgroundOpacityTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setBackgroundOpacityTransition(options);
|
||||
assertEquals(layer.getBackgroundOpacityTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -252,48 +152,12 @@ public class BackgroundLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-opacity");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundOpacity(0.3f));
|
||||
assertEquals((Float) layer.getBackgroundOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundOpacity(0.3f));
|
||||
assertEquals((Float) layer.getBackgroundOpacity().getValue(), (Float) 0.3f);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundOpacityAsCameraFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("background-opacity");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
backgroundOpacity(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, backgroundOpacity(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getBackgroundOpacity());
|
||||
assertNotNull(layer.getBackgroundOpacity().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getBackgroundOpacity().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getBackgroundOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getBackgroundOpacity().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getBackgroundOpacity().getFunction().getStops()).size());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,207 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.mapbox.mapboxsdk.style.expressions.Expression;
|
||||
import com.mapbox.mapboxsdk.style.layers.FillLayer;
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
|
||||
import com.mapbox.mapboxsdk.style.sources.Source;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.ResourceUtils;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
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.match;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.rgb;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.rgba;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.step;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.stop;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.string;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.toColor;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.zoom;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillAntialias;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOutlineColor;
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExpressionTest extends BaseActivityTest {
|
||||
|
||||
private FillLayer layer;
|
||||
|
||||
@Test
|
||||
public void testConstantExpressionConversion() {
|
||||
validateTestSetup();
|
||||
setupStyle();
|
||||
Timber.i("camera function");
|
||||
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
// create color expression
|
||||
Expression inputExpression = rgba(255.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
// set color expression
|
||||
layer.setProperties(
|
||||
fillColor(inputExpression)
|
||||
);
|
||||
|
||||
// get color value
|
||||
int color = layer.getFillColor().getColorInt();
|
||||
|
||||
// compare
|
||||
assertEquals("input expression should match", Color.RED, color);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetExpressionWrapping() {
|
||||
validateTestSetup();
|
||||
setupStyle();
|
||||
Timber.i("camera function");
|
||||
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
// create get expression
|
||||
Expression inputExpression = get("fill");
|
||||
|
||||
// set get expression
|
||||
layer.setProperties(
|
||||
fillColor(inputExpression)
|
||||
);
|
||||
|
||||
// get actual expression
|
||||
Expression actualExpression = layer.getFillColor().getExpression();
|
||||
|
||||
// create wrapped expected expression
|
||||
Expression expectedExpression = toColor(get("fill"));
|
||||
|
||||
// compare
|
||||
assertEquals("input expression should match", expectedExpression, actualExpression);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCameraFunction() {
|
||||
validateTestSetup();
|
||||
setupStyle();
|
||||
Timber.i("camera function");
|
||||
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
// create camera function expression
|
||||
Expression inputExpression = interpolate(
|
||||
exponential(0.5f), zoom(),
|
||||
stop(1.0f, rgba(255.0f, 0.0f, 0.0f, 1.0f)),
|
||||
stop(5.0f, rgba(0.0f, 0.0f, 255.0f, 1.0f)),
|
||||
stop(10.0f, rgba(0.0f, 255.0f, 0.0f, 1.0f))
|
||||
);
|
||||
|
||||
// set camera function expression
|
||||
layer.setProperties(
|
||||
fillColor(inputExpression)
|
||||
);
|
||||
|
||||
// get camera function expression
|
||||
Expression outputExpression = layer.getFillColor().getExpression();
|
||||
|
||||
// compare
|
||||
assertEquals("input expression should match", inputExpression, outputExpression);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSourceFunction() {
|
||||
validateTestSetup();
|
||||
setupStyle();
|
||||
Timber.i("camera function");
|
||||
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
// create camera function expression
|
||||
Expression inputExpression = toColor(get("fill"));
|
||||
|
||||
// set camera function expression
|
||||
layer.setProperties(
|
||||
fillColor(inputExpression)
|
||||
);
|
||||
|
||||
// get camera function expression
|
||||
Expression outputExpression = layer.getFillColor().getExpression();
|
||||
|
||||
// compare
|
||||
assertEquals("input expression should match", inputExpression, outputExpression);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompositeFunction() {
|
||||
validateTestSetup();
|
||||
setupStyle();
|
||||
Timber.i("camera function");
|
||||
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
// create camera function expression
|
||||
Expression inputExpression = step(zoom(),
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f),
|
||||
stop(7.0f, match(
|
||||
string(get("name")),
|
||||
literal("Westerpark"), rgba(255.0f, 0.0f, 0.0f, 1.0f),
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f)
|
||||
)),
|
||||
stop(8.0f, match(
|
||||
string(get("name")),
|
||||
literal("Westerpark"), rgba(0.0f, 0.0f, 255.0f, 1.0f),
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f)
|
||||
))
|
||||
);
|
||||
|
||||
// set camera function expression
|
||||
layer.setProperties(
|
||||
fillColor(inputExpression)
|
||||
);
|
||||
|
||||
// get camera function expression
|
||||
Expression outputExpression = layer.getFillColor().getExpression();
|
||||
|
||||
// compare
|
||||
assertEquals("input expression should match", inputExpression, outputExpression);
|
||||
});
|
||||
}
|
||||
|
||||
private void setupStyle() {
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
// Add a source
|
||||
Source source;
|
||||
try {
|
||||
source = new GeoJsonSource("amsterdam-parks-source",
|
||||
ResourceUtils.readRawResource(rule.getActivity(), R.raw.amsterdam));
|
||||
mapboxMap.addSource(source);
|
||||
} catch (IOException ioException) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add a fill layer
|
||||
mapboxMap.addLayer(layer = new FillLayer("amsterdam-parks-layer", source.getId())
|
||||
.withProperties(
|
||||
fillColor(rgba(0.0f, 0.0f, 0.0f, 0.5f)),
|
||||
fillOutlineColor(rgb(0, 0, 255)),
|
||||
fillAntialias(true)
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class getActivityClass() {
|
||||
return EspressoTestActivity.class;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,31 +3,18 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.UiController;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.functions.CompositeFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.CameraFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.SourceFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stop;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.expressions.Expression;
|
||||
import com.mapbox.mapboxsdk.style.layers.FillLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.*;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
@@ -51,17 +38,14 @@ public class FillLayerTest extends BaseActivityTest {
|
||||
|
||||
private void setupLayer() {
|
||||
Timber.i("Retrieving layer");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -71,18 +55,15 @@ public class FillLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("Visibility");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -91,67 +72,50 @@ public class FillLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("SourceLayer");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getSourceLayer(), "composite");
|
||||
// Get initial
|
||||
assertEquals(layer.getSourceLayer(), "composite");
|
||||
|
||||
// Set
|
||||
final String sourceLayer = "test";
|
||||
layer.setSourceLayer(sourceLayer);
|
||||
assertEquals(layer.getSourceLayer(), sourceLayer);
|
||||
}
|
||||
// Set
|
||||
final String sourceLayer = "test";
|
||||
layer.setSourceLayer(sourceLayer);
|
||||
assertEquals(layer.getSourceLayer(), sourceLayer);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilter() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("Filter");
|
||||
invoke(mapboxMap, (uiController, mapboxMap1) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getFilter(), null);
|
||||
|
||||
// Set
|
||||
Expression filter = eq(get("undefined"), literal(1.0));
|
||||
layer.setFilter(filter);
|
||||
assertEquals(layer.getFilter().toString(), filter.toString());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testFillAntialiasAsConstant() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-antialias");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillAntialias(true));
|
||||
assertEquals((Boolean) layer.getFillAntialias().getValue(), (Boolean) true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillAntialiasAsCameraFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-antialias");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillAntialias(
|
||||
zoom(
|
||||
interval(
|
||||
stop(2, fillAntialias(true))
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillAntialias());
|
||||
assertNotNull(layer.getFillAntialias().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getFillAntialias().getFunction().getClass());
|
||||
assertEquals(IntervalStops.class, layer.getFillAntialias().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((IntervalStops) layer.getFillAntialias().getFunction().getStops()).size());
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(fillAntialias(true));
|
||||
assertEquals((Boolean) layer.getFillAntialias().getValue(), (Boolean) true);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -160,16 +124,13 @@ public class FillLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-opacityTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setFillOpacityTransition(options);
|
||||
assertEquals(layer.getFillOpacityTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setFillOpacityTransition(options);
|
||||
assertEquals(layer.getFillOpacityTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -178,198 +139,43 @@ public class FillLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-opacity");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillOpacity(0.3f));
|
||||
assertEquals((Float) layer.getFillOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(fillOpacity(0.3f));
|
||||
assertEquals((Float) layer.getFillOpacity().getValue(), (Float) 0.3f);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOpacityAsCameraFunction() {
|
||||
public void testFillOpacityAsExpression() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-opacity");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
Timber.i("fill-opacity-expression");
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOpacity(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, fillOpacity(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOpacity());
|
||||
assertNotNull(layer.getFillOpacity().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getFillOpacity().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getFillOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getFillOpacity().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getFillOpacity().getFunction().getStops()).size());
|
||||
}
|
||||
// Set and Get
|
||||
Expression expression = number(Expression.get("undefined"));
|
||||
layer.setProperties(fillOpacity(expression));
|
||||
assertEquals(layer.getFillOpacity().getExpression(), expression);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOpacityAsIdentitySourceFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-opacity");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOpacity(property("FeaturePropertyA", Stops.<Float>identity()))
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOpacity());
|
||||
assertNotNull(layer.getFillOpacity().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillOpacity().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOpacity().getFunction()).getProperty());
|
||||
assertEquals(IdentityStops.class, layer.getFillOpacity().getFunction().getStops().getClass());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOpacityAsExponentialSourceFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-opacity");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOpacity(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
exponential(
|
||||
stop(0.3f, fillOpacity(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOpacity());
|
||||
assertNotNull(layer.getFillOpacity().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillOpacity().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOpacity().getFunction()).getProperty());
|
||||
assertEquals(ExponentialStops.class, layer.getFillOpacity().getFunction().getStops().getClass());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOpacityAsCategoricalSourceFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-opacity");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOpacity(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
categorical(
|
||||
stop(1.0f, fillOpacity(0.3f))
|
||||
)
|
||||
).withDefaultValue(fillOpacity(0.3f))
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOpacity());
|
||||
assertNotNull(layer.getFillOpacity().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillOpacity().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOpacity().getFunction()).getProperty());
|
||||
assertEquals(CategoricalStops.class, layer.getFillOpacity().getFunction().getStops().getClass());
|
||||
assertNotNull(((SourceFunction) layer.getFillOpacity().getFunction()).getDefaultValue());
|
||||
assertNotNull(((SourceFunction) layer.getFillOpacity().getFunction()).getDefaultValue().getValue());
|
||||
assertEquals(0.3f, ((SourceFunction) layer.getFillOpacity().getFunction()).getDefaultValue().getValue());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOpacityAsCompositeFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-opacity");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOpacity(
|
||||
composite(
|
||||
"FeaturePropertyA",
|
||||
exponential(
|
||||
stop(0, 0.3f, fillOpacity(0.9f))
|
||||
).withBase(0.5f)
|
||||
).withDefaultValue(fillOpacity(0.3f))
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOpacity());
|
||||
assertNotNull(layer.getFillOpacity().getFunction());
|
||||
assertEquals(CompositeFunction.class, layer.getFillOpacity().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getFillOpacity().getFunction()).getProperty());
|
||||
assertEquals(ExponentialStops.class, layer.getFillOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((ExponentialStops) layer.getFillOpacity().getFunction().getStops()).size());
|
||||
|
||||
ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops =
|
||||
(ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getFillOpacity().getFunction().getStops();
|
||||
Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next();
|
||||
assertEquals(0f, stop.in.zoom, 0.001);
|
||||
assertEquals(0.3f, stop.in.value, 0.001f);
|
||||
assertEquals(0.9f, stop.out, 0.001f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillColorTransition() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-colorTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setFillColorTransition(options);
|
||||
assertEquals(layer.getFillColorTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setFillColorTransition(options);
|
||||
assertEquals(layer.getFillColorTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -378,157 +184,42 @@ public class FillLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getFillColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(fillColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getFillColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillColorAsCameraFunction() {
|
||||
public void testFillColorAsExpression() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
Timber.i("fill-color-expression");
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillColor(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, fillColor("rgba(0, 0, 0, 1)"))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillColor());
|
||||
assertNotNull(layer.getFillColor().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getFillColor().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getFillColor().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getFillColor().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getFillColor().getFunction().getStops()).size());
|
||||
}
|
||||
// Set and Get
|
||||
Expression expression = toColor(Expression.get("undefined"));
|
||||
layer.setProperties(fillColor(expression));
|
||||
assertEquals(layer.getFillColor().getExpression(), expression);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillColorAsIdentitySourceFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillColor(property("FeaturePropertyA", Stops.<String>identity()))
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillColor());
|
||||
assertNotNull(layer.getFillColor().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillColor().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillColor().getFunction()).getProperty());
|
||||
assertEquals(IdentityStops.class, layer.getFillColor().getFunction().getStops().getClass());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillColorAsExponentialSourceFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillColor(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
exponential(
|
||||
stop(Color.RED, fillColor(Color.RED))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillColor());
|
||||
assertNotNull(layer.getFillColor().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillColor().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillColor().getFunction()).getProperty());
|
||||
assertEquals(ExponentialStops.class, layer.getFillColor().getFunction().getStops().getClass());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillColorAsCategoricalSourceFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillColor(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
categorical(
|
||||
stop("valueA", fillColor(Color.RED))
|
||||
)
|
||||
).withDefaultValue(fillColor(Color.GREEN))
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillColor());
|
||||
assertNotNull(layer.getFillColor().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillColor().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillColor().getFunction()).getProperty());
|
||||
assertEquals(CategoricalStops.class, layer.getFillColor().getFunction().getStops().getClass());
|
||||
assertNotNull(((SourceFunction) layer.getFillColor().getFunction()).getDefaultValue());
|
||||
assertNotNull(((SourceFunction) layer.getFillColor().getFunction()).getDefaultValue().getValue());
|
||||
assertEquals(Color.GREEN, (int) ((SourceFunction) layer.getFillColor().getFunction()).getDefaultValue().getColorInt());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillColorAsIntConstant() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillColor(Color.RED));
|
||||
assertEquals(layer.getFillColorAsInt(), Color.RED);
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(fillColor(Color.RED));
|
||||
assertEquals(layer.getFillColorAsInt(), Color.RED);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -537,16 +228,13 @@ public class FillLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-outline-colorTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setFillOutlineColorTransition(options);
|
||||
assertEquals(layer.getFillOutlineColorTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setFillOutlineColorTransition(options);
|
||||
assertEquals(layer.getFillOutlineColorTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -555,157 +243,42 @@ public class FillLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-outline-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillOutlineColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getFillOutlineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(fillOutlineColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getFillOutlineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOutlineColorAsCameraFunction() {
|
||||
public void testFillOutlineColorAsExpression() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-outline-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
Timber.i("fill-outline-color-expression");
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOutlineColor(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, fillOutlineColor("rgba(0, 0, 0, 1)"))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOutlineColor());
|
||||
assertNotNull(layer.getFillOutlineColor().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getFillOutlineColor().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getFillOutlineColor().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getFillOutlineColor().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getFillOutlineColor().getFunction().getStops()).size());
|
||||
}
|
||||
// Set and Get
|
||||
Expression expression = toColor(Expression.get("undefined"));
|
||||
layer.setProperties(fillOutlineColor(expression));
|
||||
assertEquals(layer.getFillOutlineColor().getExpression(), expression);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOutlineColorAsIdentitySourceFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-outline-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOutlineColor(property("FeaturePropertyA", Stops.<String>identity()))
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOutlineColor());
|
||||
assertNotNull(layer.getFillOutlineColor().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillOutlineColor().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOutlineColor().getFunction()).getProperty());
|
||||
assertEquals(IdentityStops.class, layer.getFillOutlineColor().getFunction().getStops().getClass());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOutlineColorAsExponentialSourceFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-outline-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOutlineColor(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
exponential(
|
||||
stop(Color.RED, fillOutlineColor(Color.RED))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOutlineColor());
|
||||
assertNotNull(layer.getFillOutlineColor().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillOutlineColor().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOutlineColor().getFunction()).getProperty());
|
||||
assertEquals(ExponentialStops.class, layer.getFillOutlineColor().getFunction().getStops().getClass());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOutlineColorAsCategoricalSourceFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-outline-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOutlineColor(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
categorical(
|
||||
stop("valueA", fillOutlineColor(Color.RED))
|
||||
)
|
||||
).withDefaultValue(fillOutlineColor(Color.GREEN))
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOutlineColor());
|
||||
assertNotNull(layer.getFillOutlineColor().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillOutlineColor().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOutlineColor().getFunction()).getProperty());
|
||||
assertEquals(CategoricalStops.class, layer.getFillOutlineColor().getFunction().getStops().getClass());
|
||||
assertNotNull(((SourceFunction) layer.getFillOutlineColor().getFunction()).getDefaultValue());
|
||||
assertNotNull(((SourceFunction) layer.getFillOutlineColor().getFunction()).getDefaultValue().getValue());
|
||||
assertEquals(Color.GREEN, (int) ((SourceFunction) layer.getFillOutlineColor().getFunction()).getDefaultValue().getColorInt());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOutlineColorAsIntConstant() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-outline-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillOutlineColor(Color.RED));
|
||||
assertEquals(layer.getFillOutlineColorAsInt(), Color.RED);
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(fillOutlineColor(Color.RED));
|
||||
assertEquals(layer.getFillOutlineColorAsInt(), Color.RED);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -714,16 +287,13 @@ public class FillLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-translateTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setFillTranslateTransition(options);
|
||||
assertEquals(layer.getFillTranslateTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setFillTranslateTransition(options);
|
||||
assertEquals(layer.getFillTranslateTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -732,47 +302,12 @@ public class FillLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-translate");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillTranslate(new Float[] {0f, 0f}));
|
||||
assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillTranslateAsCameraFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-translate");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillTranslate(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, fillTranslate(new Float[] {0f, 0f}))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillTranslate());
|
||||
assertNotNull(layer.getFillTranslate().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getFillTranslate().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getFillTranslate().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getFillTranslate().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getFillTranslate().getFunction().getStops()).size());
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(fillTranslate(new Float[] {0f, 0f}));
|
||||
assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -781,46 +316,12 @@ public class FillLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-translate-anchor");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP));
|
||||
assertEquals((String) layer.getFillTranslateAnchor().getValue(), (String) FILL_TRANSLATE_ANCHOR_MAP);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillTranslateAnchorAsCameraFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-translate-anchor");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillTranslateAnchor(
|
||||
zoom(
|
||||
interval(
|
||||
stop(2, fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP))
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillTranslateAnchor());
|
||||
assertNotNull(layer.getFillTranslateAnchor().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getFillTranslateAnchor().getFunction().getClass());
|
||||
assertEquals(IntervalStops.class, layer.getFillTranslateAnchor().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((IntervalStops) layer.getFillTranslateAnchor().getFunction().getStops()).size());
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP));
|
||||
assertEquals((String) layer.getFillTranslateAnchor().getValue(), (String) FILL_TRANSLATE_ANCHOR_MAP);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -829,16 +330,13 @@ public class FillLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-patternTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setFillPatternTransition(options);
|
||||
assertEquals(layer.getFillPatternTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setFillPatternTransition(options);
|
||||
assertEquals(layer.getFillPatternTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -847,47 +345,12 @@ public class FillLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-pattern");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillPattern("pedestrian-polygon"));
|
||||
assertEquals((String) layer.getFillPattern().getValue(), (String) "pedestrian-polygon");
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(fillPattern("pedestrian-polygon"));
|
||||
assertEquals((String) layer.getFillPattern().getValue(), (String) "pedestrian-polygon");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillPatternAsCameraFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("fill-pattern");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillPattern(
|
||||
zoom(
|
||||
interval(
|
||||
stop(2, fillPattern("pedestrian-polygon"))
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillPattern());
|
||||
assertNotNull(layer.getFillPattern().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getFillPattern().getFunction().getClass());
|
||||
assertEquals(IntervalStops.class, layer.getFillPattern().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((IntervalStops) layer.getFillPattern().getFunction().getStops()).size());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,31 +3,18 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.UiController;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.functions.CompositeFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.CameraFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.SourceFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stop;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.expressions.Expression;
|
||||
import com.mapbox.mapboxsdk.style.layers.HeatmapLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.*;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
@@ -51,17 +38,14 @@ public class HeatmapLayerTest extends BaseActivityTest {
|
||||
|
||||
private void setupLayer() {
|
||||
Timber.i("Retrieving layer");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new HeatmapLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new HeatmapLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -71,18 +55,15 @@ public class HeatmapLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("Visibility");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -91,37 +72,51 @@ public class HeatmapLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("SourceLayer");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getSourceLayer(), "composite");
|
||||
// Get initial
|
||||
assertEquals(layer.getSourceLayer(), "composite");
|
||||
|
||||
// Set
|
||||
final String sourceLayer = "test";
|
||||
layer.setSourceLayer(sourceLayer);
|
||||
assertEquals(layer.getSourceLayer(), sourceLayer);
|
||||
}
|
||||
// Set
|
||||
final String sourceLayer = "test";
|
||||
layer.setSourceLayer(sourceLayer);
|
||||
assertEquals(layer.getSourceLayer(), sourceLayer);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilter() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("Filter");
|
||||
invoke(mapboxMap, (uiController, mapboxMap1) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getFilter(), null);
|
||||
|
||||
// Set
|
||||
Expression filter = eq(get("undefined"), literal(1.0));
|
||||
layer.setFilter(filter);
|
||||
assertEquals(layer.getFilter().toString(), filter.toString());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testHeatmapRadiusTransition() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("heatmap-radiusTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setHeatmapRadiusTransition(options);
|
||||
assertEquals(layer.getHeatmapRadiusTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setHeatmapRadiusTransition(options);
|
||||
assertEquals(layer.getHeatmapRadiusTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -130,380 +125,73 @@ public class HeatmapLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("heatmap-radius");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(heatmapRadius(0.3f));
|
||||
assertEquals((Float) layer.getHeatmapRadius().getValue(), (Float) 0.3f);
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(heatmapRadius(0.3f));
|
||||
assertEquals((Float) layer.getHeatmapRadius().getValue(), (Float) 0.3f);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeatmapRadiusAsCameraFunction() {
|
||||
public void testHeatmapRadiusAsExpression() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("heatmap-radius");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
Timber.i("heatmap-radius-expression");
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
heatmapRadius(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, heatmapRadius(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getHeatmapRadius());
|
||||
assertNotNull(layer.getHeatmapRadius().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getHeatmapRadius().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getHeatmapRadius().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getHeatmapRadius().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getHeatmapRadius().getFunction().getStops()).size());
|
||||
}
|
||||
// Set and Get
|
||||
Expression expression = number(Expression.get("undefined"));
|
||||
layer.setProperties(heatmapRadius(expression));
|
||||
assertEquals(layer.getHeatmapRadius().getExpression(), expression);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeatmapRadiusAsIdentitySourceFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("heatmap-radius");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
heatmapRadius(property("FeaturePropertyA", Stops.<Float>identity()))
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getHeatmapRadius());
|
||||
assertNotNull(layer.getHeatmapRadius().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getHeatmapRadius().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getHeatmapRadius().getFunction()).getProperty());
|
||||
assertEquals(IdentityStops.class, layer.getHeatmapRadius().getFunction().getStops().getClass());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeatmapRadiusAsExponentialSourceFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("heatmap-radius");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
heatmapRadius(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
exponential(
|
||||
stop(0.3f, heatmapRadius(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getHeatmapRadius());
|
||||
assertNotNull(layer.getHeatmapRadius().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getHeatmapRadius().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getHeatmapRadius().getFunction()).getProperty());
|
||||
assertEquals(ExponentialStops.class, layer.getHeatmapRadius().getFunction().getStops().getClass());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeatmapRadiusAsCategoricalSourceFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("heatmap-radius");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
heatmapRadius(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
categorical(
|
||||
stop(1.0f, heatmapRadius(0.3f))
|
||||
)
|
||||
).withDefaultValue(heatmapRadius(0.3f))
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getHeatmapRadius());
|
||||
assertNotNull(layer.getHeatmapRadius().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getHeatmapRadius().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getHeatmapRadius().getFunction()).getProperty());
|
||||
assertEquals(CategoricalStops.class, layer.getHeatmapRadius().getFunction().getStops().getClass());
|
||||
assertNotNull(((SourceFunction) layer.getHeatmapRadius().getFunction()).getDefaultValue());
|
||||
assertNotNull(((SourceFunction) layer.getHeatmapRadius().getFunction()).getDefaultValue().getValue());
|
||||
assertEquals(0.3f, ((SourceFunction) layer.getHeatmapRadius().getFunction()).getDefaultValue().getValue());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeatmapRadiusAsCompositeFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("heatmap-radius");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
heatmapRadius(
|
||||
composite(
|
||||
"FeaturePropertyA",
|
||||
exponential(
|
||||
stop(0, 0.3f, heatmapRadius(0.9f))
|
||||
).withBase(0.5f)
|
||||
).withDefaultValue(heatmapRadius(0.3f))
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getHeatmapRadius());
|
||||
assertNotNull(layer.getHeatmapRadius().getFunction());
|
||||
assertEquals(CompositeFunction.class, layer.getHeatmapRadius().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getHeatmapRadius().getFunction()).getProperty());
|
||||
assertEquals(ExponentialStops.class, layer.getHeatmapRadius().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((ExponentialStops) layer.getHeatmapRadius().getFunction().getStops()).size());
|
||||
|
||||
ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops =
|
||||
(ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getHeatmapRadius().getFunction().getStops();
|
||||
Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next();
|
||||
assertEquals(0f, stop.in.zoom, 0.001);
|
||||
assertEquals(0.3f, stop.in.value, 0.001f);
|
||||
assertEquals(0.9f, stop.out, 0.001f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeatmapWeightAsConstant() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("heatmap-weight");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(heatmapWeight(0.3f));
|
||||
assertEquals((Float) layer.getHeatmapWeight().getValue(), (Float) 0.3f);
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(heatmapWeight(0.3f));
|
||||
assertEquals((Float) layer.getHeatmapWeight().getValue(), (Float) 0.3f);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeatmapWeightAsCameraFunction() {
|
||||
public void testHeatmapWeightAsExpression() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("heatmap-weight");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
Timber.i("heatmap-weight-expression");
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
heatmapWeight(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, heatmapWeight(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getHeatmapWeight());
|
||||
assertNotNull(layer.getHeatmapWeight().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getHeatmapWeight().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getHeatmapWeight().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getHeatmapWeight().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getHeatmapWeight().getFunction().getStops()).size());
|
||||
}
|
||||
// Set and Get
|
||||
Expression expression = number(Expression.get("undefined"));
|
||||
layer.setProperties(heatmapWeight(expression));
|
||||
assertEquals(layer.getHeatmapWeight().getExpression(), expression);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeatmapWeightAsIdentitySourceFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("heatmap-weight");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
heatmapWeight(property("FeaturePropertyA", Stops.<Float>identity()))
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getHeatmapWeight());
|
||||
assertNotNull(layer.getHeatmapWeight().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getHeatmapWeight().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getHeatmapWeight().getFunction()).getProperty());
|
||||
assertEquals(IdentityStops.class, layer.getHeatmapWeight().getFunction().getStops().getClass());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeatmapWeightAsExponentialSourceFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("heatmap-weight");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
heatmapWeight(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
exponential(
|
||||
stop(0.3f, heatmapWeight(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getHeatmapWeight());
|
||||
assertNotNull(layer.getHeatmapWeight().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getHeatmapWeight().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getHeatmapWeight().getFunction()).getProperty());
|
||||
assertEquals(ExponentialStops.class, layer.getHeatmapWeight().getFunction().getStops().getClass());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeatmapWeightAsCategoricalSourceFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("heatmap-weight");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
heatmapWeight(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
categorical(
|
||||
stop(1.0f, heatmapWeight(0.3f))
|
||||
)
|
||||
).withDefaultValue(heatmapWeight(0.3f))
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getHeatmapWeight());
|
||||
assertNotNull(layer.getHeatmapWeight().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getHeatmapWeight().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getHeatmapWeight().getFunction()).getProperty());
|
||||
assertEquals(CategoricalStops.class, layer.getHeatmapWeight().getFunction().getStops().getClass());
|
||||
assertNotNull(((SourceFunction) layer.getHeatmapWeight().getFunction()).getDefaultValue());
|
||||
assertNotNull(((SourceFunction) layer.getHeatmapWeight().getFunction()).getDefaultValue().getValue());
|
||||
assertEquals(0.3f, ((SourceFunction) layer.getHeatmapWeight().getFunction()).getDefaultValue().getValue());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeatmapWeightAsCompositeFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("heatmap-weight");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
heatmapWeight(
|
||||
composite(
|
||||
"FeaturePropertyA",
|
||||
exponential(
|
||||
stop(0, 0.3f, heatmapWeight(0.9f))
|
||||
).withBase(0.5f)
|
||||
).withDefaultValue(heatmapWeight(0.3f))
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getHeatmapWeight());
|
||||
assertNotNull(layer.getHeatmapWeight().getFunction());
|
||||
assertEquals(CompositeFunction.class, layer.getHeatmapWeight().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getHeatmapWeight().getFunction()).getProperty());
|
||||
assertEquals(ExponentialStops.class, layer.getHeatmapWeight().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((ExponentialStops) layer.getHeatmapWeight().getFunction().getStops()).size());
|
||||
|
||||
ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops =
|
||||
(ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getHeatmapWeight().getFunction().getStops();
|
||||
Stop<Stop.CompositeValue<Float, Float>, Float> stop = stops.iterator().next();
|
||||
assertEquals(0f, stop.in.zoom, 0.001);
|
||||
assertEquals(0.3f, stop.in.value, 0.001f);
|
||||
assertEquals(0.9f, stop.out, 0.001f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeatmapIntensityTransition() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("heatmap-intensityTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setHeatmapIntensityTransition(options);
|
||||
assertEquals(layer.getHeatmapIntensityTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setHeatmapIntensityTransition(options);
|
||||
assertEquals(layer.getHeatmapIntensityTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -512,47 +200,12 @@ public class HeatmapLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("heatmap-intensity");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(heatmapIntensity(0.3f));
|
||||
assertEquals((Float) layer.getHeatmapIntensity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeatmapIntensityAsCameraFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("heatmap-intensity");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
heatmapIntensity(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, heatmapIntensity(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getHeatmapIntensity());
|
||||
assertNotNull(layer.getHeatmapIntensity().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getHeatmapIntensity().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getHeatmapIntensity().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getHeatmapIntensity().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getHeatmapIntensity().getFunction().getStops()).size());
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(heatmapIntensity(0.3f));
|
||||
assertEquals((Float) layer.getHeatmapIntensity().getValue(), (Float) 0.3f);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -561,16 +214,13 @@ public class HeatmapLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("heatmap-opacityTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setHeatmapOpacityTransition(options);
|
||||
assertEquals(layer.getHeatmapOpacityTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setHeatmapOpacityTransition(options);
|
||||
assertEquals(layer.getHeatmapOpacityTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -579,48 +229,12 @@ public class HeatmapLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("heatmap-opacity");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(heatmapOpacity(0.3f));
|
||||
assertEquals((Float) layer.getHeatmapOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(heatmapOpacity(0.3f));
|
||||
assertEquals((Float) layer.getHeatmapOpacity().getValue(), (Float) 0.3f);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHeatmapOpacityAsCameraFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("heatmap-opacity");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
heatmapOpacity(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, heatmapOpacity(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getHeatmapOpacity());
|
||||
assertNotNull(layer.getHeatmapOpacity().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getHeatmapOpacity().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getHeatmapOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getHeatmapOpacity().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getHeatmapOpacity().getFunction().getStops()).size());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,31 +3,18 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.UiController;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.functions.CompositeFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.CameraFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.SourceFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stop;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.expressions.Expression;
|
||||
import com.mapbox.mapboxsdk.style.layers.HillshadeLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.*;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
@@ -51,17 +38,14 @@ public class HillshadeLayerTest extends BaseActivityTest {
|
||||
|
||||
private void setupLayer() {
|
||||
Timber.i("Retrieving layer");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new HillshadeLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new HillshadeLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -71,18 +55,15 @@ public class HillshadeLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("Visibility");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -91,47 +72,12 @@ public class HillshadeLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("hillshade-illumination-direction");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(hillshadeIlluminationDirection(0.3f));
|
||||
assertEquals((Float) layer.getHillshadeIlluminationDirection().getValue(), (Float) 0.3f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHillshadeIlluminationDirectionAsCameraFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("hillshade-illumination-direction");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
hillshadeIlluminationDirection(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, hillshadeIlluminationDirection(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getHillshadeIlluminationDirection());
|
||||
assertNotNull(layer.getHillshadeIlluminationDirection().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getHillshadeIlluminationDirection().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getHillshadeIlluminationDirection().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getHillshadeIlluminationDirection().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getHillshadeIlluminationDirection().getFunction().getStops()).size());
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(hillshadeIlluminationDirection(0.3f));
|
||||
assertEquals((Float) layer.getHillshadeIlluminationDirection().getValue(), (Float) 0.3f);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -140,46 +86,12 @@ public class HillshadeLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("hillshade-illumination-anchor");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(hillshadeIlluminationAnchor(HILLSHADE_ILLUMINATION_ANCHOR_MAP));
|
||||
assertEquals((String) layer.getHillshadeIlluminationAnchor().getValue(), (String) HILLSHADE_ILLUMINATION_ANCHOR_MAP);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHillshadeIlluminationAnchorAsCameraFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("hillshade-illumination-anchor");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
hillshadeIlluminationAnchor(
|
||||
zoom(
|
||||
interval(
|
||||
stop(2, hillshadeIlluminationAnchor(HILLSHADE_ILLUMINATION_ANCHOR_MAP))
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getHillshadeIlluminationAnchor());
|
||||
assertNotNull(layer.getHillshadeIlluminationAnchor().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getHillshadeIlluminationAnchor().getFunction().getClass());
|
||||
assertEquals(IntervalStops.class, layer.getHillshadeIlluminationAnchor().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((IntervalStops) layer.getHillshadeIlluminationAnchor().getFunction().getStops()).size());
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(hillshadeIlluminationAnchor(HILLSHADE_ILLUMINATION_ANCHOR_MAP));
|
||||
assertEquals((String) layer.getHillshadeIlluminationAnchor().getValue(), (String) HILLSHADE_ILLUMINATION_ANCHOR_MAP);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -188,16 +100,13 @@ public class HillshadeLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("hillshade-exaggerationTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setHillshadeExaggerationTransition(options);
|
||||
assertEquals(layer.getHillshadeExaggerationTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setHillshadeExaggerationTransition(options);
|
||||
assertEquals(layer.getHillshadeExaggerationTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -206,47 +115,12 @@ public class HillshadeLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("hillshade-exaggeration");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(hillshadeExaggeration(0.3f));
|
||||
assertEquals((Float) layer.getHillshadeExaggeration().getValue(), (Float) 0.3f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHillshadeExaggerationAsCameraFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("hillshade-exaggeration");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
hillshadeExaggeration(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, hillshadeExaggeration(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getHillshadeExaggeration());
|
||||
assertNotNull(layer.getHillshadeExaggeration().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getHillshadeExaggeration().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getHillshadeExaggeration().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getHillshadeExaggeration().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getHillshadeExaggeration().getFunction().getStops()).size());
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(hillshadeExaggeration(0.3f));
|
||||
assertEquals((Float) layer.getHillshadeExaggeration().getValue(), (Float) 0.3f);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -255,16 +129,13 @@ public class HillshadeLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("hillshade-shadow-colorTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setHillshadeShadowColorTransition(options);
|
||||
assertEquals(layer.getHillshadeShadowColorTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setHillshadeShadowColorTransition(options);
|
||||
assertEquals(layer.getHillshadeShadowColorTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -273,47 +144,12 @@ public class HillshadeLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("hillshade-shadow-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(hillshadeShadowColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getHillshadeShadowColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHillshadeShadowColorAsCameraFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("hillshade-shadow-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
hillshadeShadowColor(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, hillshadeShadowColor("rgba(0, 0, 0, 1)"))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getHillshadeShadowColor());
|
||||
assertNotNull(layer.getHillshadeShadowColor().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getHillshadeShadowColor().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getHillshadeShadowColor().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getHillshadeShadowColor().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getHillshadeShadowColor().getFunction().getStops()).size());
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(hillshadeShadowColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getHillshadeShadowColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -322,15 +158,12 @@ public class HillshadeLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("hillshade-shadow-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(hillshadeShadowColor(Color.RED));
|
||||
assertEquals(layer.getHillshadeShadowColorAsInt(), Color.RED);
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(hillshadeShadowColor(Color.RED));
|
||||
assertEquals(layer.getHillshadeShadowColorAsInt(), Color.RED);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -339,16 +172,13 @@ public class HillshadeLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("hillshade-highlight-colorTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setHillshadeHighlightColorTransition(options);
|
||||
assertEquals(layer.getHillshadeHighlightColorTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setHillshadeHighlightColorTransition(options);
|
||||
assertEquals(layer.getHillshadeHighlightColorTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -357,47 +187,12 @@ public class HillshadeLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("hillshade-highlight-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(hillshadeHighlightColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getHillshadeHighlightColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHillshadeHighlightColorAsCameraFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("hillshade-highlight-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
hillshadeHighlightColor(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, hillshadeHighlightColor("rgba(0, 0, 0, 1)"))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getHillshadeHighlightColor());
|
||||
assertNotNull(layer.getHillshadeHighlightColor().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getHillshadeHighlightColor().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getHillshadeHighlightColor().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getHillshadeHighlightColor().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getHillshadeHighlightColor().getFunction().getStops()).size());
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(hillshadeHighlightColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getHillshadeHighlightColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -406,15 +201,12 @@ public class HillshadeLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("hillshade-highlight-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(hillshadeHighlightColor(Color.RED));
|
||||
assertEquals(layer.getHillshadeHighlightColorAsInt(), Color.RED);
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(hillshadeHighlightColor(Color.RED));
|
||||
assertEquals(layer.getHillshadeHighlightColorAsInt(), Color.RED);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -423,16 +215,13 @@ public class HillshadeLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("hillshade-accent-colorTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setHillshadeAccentColorTransition(options);
|
||||
assertEquals(layer.getHillshadeAccentColorTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setHillshadeAccentColorTransition(options);
|
||||
assertEquals(layer.getHillshadeAccentColorTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -441,47 +230,12 @@ public class HillshadeLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("hillshade-accent-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(hillshadeAccentColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getHillshadeAccentColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHillshadeAccentColorAsCameraFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("hillshade-accent-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
hillshadeAccentColor(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, hillshadeAccentColor("rgba(0, 0, 0, 1)"))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getHillshadeAccentColor());
|
||||
assertNotNull(layer.getHillshadeAccentColor().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getHillshadeAccentColor().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getHillshadeAccentColor().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getHillshadeAccentColor().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getHillshadeAccentColor().getFunction().getStops()).size());
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(hillshadeAccentColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getHillshadeAccentColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -490,16 +244,12 @@ public class HillshadeLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("hillshade-accent-color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(hillshadeAccentColor(Color.RED));
|
||||
assertEquals(layer.getHillshadeAccentColorAsInt(), Color.RED);
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(hillshadeAccentColor(Color.RED));
|
||||
assertEquals(layer.getHillshadeAccentColorAsInt(), Color.RED);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,15 +6,12 @@ import android.support.test.espresso.ViewAction;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.light.Light;
|
||||
import com.mapbox.mapboxsdk.style.functions.Function;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.expressions.Expression;
|
||||
import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
|
||||
import com.mapbox.mapboxsdk.style.light.Position;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.FillExtrusionStyleTestActivity;
|
||||
|
||||
@@ -27,7 +24,7 @@ import org.junit.runner.RunWith;
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Filter.eq;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.eq;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.ANCHOR_MAP;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionBase;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionColor;
|
||||
@@ -48,14 +45,11 @@ public class LightTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLight();
|
||||
Timber.i("anchor");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
light.setAnchor(ANCHOR_MAP);
|
||||
assertEquals("Anchor should match", ANCHOR_MAP, light.getAnchor());
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
light.setAnchor(ANCHOR_MAP);
|
||||
assertEquals("Anchor should match", ANCHOR_MAP, light.getAnchor());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -64,15 +58,12 @@ public class LightTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLight();
|
||||
Timber.i("positionTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
light.setPositionTransition(options);
|
||||
assertEquals("Transition options should match", options, light.getPositionTransition());
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
light.setPositionTransition(options);
|
||||
assertEquals("Transition options should match", options, light.getPositionTransition());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -81,15 +72,12 @@ public class LightTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLight();
|
||||
Timber.i("position");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
Position position = new Position(1, 2, 3);
|
||||
light.setPosition(position);
|
||||
assertEquals("Position should match", position, light.getPosition());
|
||||
}
|
||||
invoke(mapboxMap,(uiController, mapboxMap) -> {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
Position position = new Position(1, 2, 3);
|
||||
light.setPosition(position);
|
||||
assertEquals("Position should match", position, light.getPosition());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -98,15 +86,12 @@ public class LightTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLight();
|
||||
Timber.i("colorTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
light.setColorTransition(options);
|
||||
assertEquals("Transition options should match", options, light.getColorTransition());
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
light.setColorTransition(options);
|
||||
assertEquals("Transition options should match", options, light.getColorTransition());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -115,14 +100,11 @@ public class LightTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLight();
|
||||
Timber.i("color");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
light.setColor("rgba(0, 0, 0, 1)");
|
||||
assertEquals("Color should match", "rgba(0, 0, 0, 1)".replaceAll("\\s+", ""), light.getColor());
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
light.setColor("rgba(0, 0, 0, 1)");
|
||||
assertEquals("Color should match", "rgba(0, 0, 0, 1)".replaceAll("\\s+", ""), light.getColor());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -131,15 +113,12 @@ public class LightTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLight();
|
||||
Timber.i("intensityTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
light.setIntensityTransition(options);
|
||||
assertEquals("Transition options should match", options, light.getIntensityTransition());
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
light.setIntensityTransition(options);
|
||||
assertEquals("Transition options should match", options, light.getIntensityTransition());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -148,14 +127,11 @@ public class LightTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLight();
|
||||
Timber.i("intensity");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
light.setIntensity(0.3f);
|
||||
assertEquals("Intensity should match", 0.3f, light.getIntensity());
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
light.setIntensity(0.3f);
|
||||
assertEquals("Intensity should match", 0.3f, light.getIntensity());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -176,12 +152,12 @@ public class LightTest extends BaseActivityTest {
|
||||
light = mapboxMap.getLight();
|
||||
FillExtrusionLayer fillExtrusionLayer = new FillExtrusionLayer("3d-buildings", "composite");
|
||||
fillExtrusionLayer.setSourceLayer("building");
|
||||
fillExtrusionLayer.setFilter(eq("extrude", "true"));
|
||||
fillExtrusionLayer.setFilter(eq(Expression.get("extrude"), "true"));
|
||||
fillExtrusionLayer.setMinZoom(15);
|
||||
fillExtrusionLayer.setProperties(
|
||||
fillExtrusionColor(Color.LTGRAY),
|
||||
fillExtrusionHeight(Function.property("height", new IdentityStops<Float>())),
|
||||
fillExtrusionBase(Function.property("min_height", new IdentityStops<Float>())),
|
||||
fillExtrusionHeight(Expression.get("height")),
|
||||
fillExtrusionBase(Expression.get("min_height")),
|
||||
fillExtrusionOpacity(0.6f)
|
||||
);
|
||||
mapboxMap.addLayer(fillExtrusionLayer);
|
||||
@@ -193,4 +169,4 @@ public class LightTest extends BaseActivityTest {
|
||||
protected Class getActivityClass() {
|
||||
return FillExtrusionStyleTestActivity.class;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,31 +3,18 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.UiController;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.functions.CompositeFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.CameraFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.SourceFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stop;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.expressions.Expression;
|
||||
import com.mapbox.mapboxsdk.style.layers.RasterLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.*;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
@@ -51,17 +38,14 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
|
||||
private void setupLayer() {
|
||||
Timber.i("Retrieving layer");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -71,18 +55,15 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("Visibility");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -91,16 +72,13 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-opacityTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterOpacityTransition(options);
|
||||
assertEquals(layer.getRasterOpacityTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterOpacityTransition(options);
|
||||
assertEquals(layer.getRasterOpacityTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -109,47 +87,12 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-opacity");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterOpacity(0.3f));
|
||||
assertEquals((Float) layer.getRasterOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterOpacityAsCameraFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-opacity");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterOpacity(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterOpacity(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterOpacity());
|
||||
assertNotNull(layer.getRasterOpacity().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterOpacity().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterOpacity().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterOpacity().getFunction().getStops()).size());
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(rasterOpacity(0.3f));
|
||||
assertEquals((Float) layer.getRasterOpacity().getValue(), (Float) 0.3f);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -158,16 +101,13 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-hue-rotateTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterHueRotateTransition(options);
|
||||
assertEquals(layer.getRasterHueRotateTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterHueRotateTransition(options);
|
||||
assertEquals(layer.getRasterHueRotateTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -176,47 +116,12 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-hue-rotate");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterHueRotate(0.3f));
|
||||
assertEquals((Float) layer.getRasterHueRotate().getValue(), (Float) 0.3f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterHueRotateAsCameraFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-hue-rotate");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterHueRotate(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterHueRotate(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterHueRotate());
|
||||
assertNotNull(layer.getRasterHueRotate().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterHueRotate().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterHueRotate().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterHueRotate().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterHueRotate().getFunction().getStops()).size());
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(rasterHueRotate(0.3f));
|
||||
assertEquals((Float) layer.getRasterHueRotate().getValue(), (Float) 0.3f);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -225,16 +130,13 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-brightness-minTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterBrightnessMinTransition(options);
|
||||
assertEquals(layer.getRasterBrightnessMinTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterBrightnessMinTransition(options);
|
||||
assertEquals(layer.getRasterBrightnessMinTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -243,47 +145,12 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-brightness-min");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterBrightnessMin(0.3f));
|
||||
assertEquals((Float) layer.getRasterBrightnessMin().getValue(), (Float) 0.3f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterBrightnessMinAsCameraFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-brightness-min");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterBrightnessMin(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterBrightnessMin(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterBrightnessMin());
|
||||
assertNotNull(layer.getRasterBrightnessMin().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterBrightnessMin().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterBrightnessMin().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterBrightnessMin().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterBrightnessMin().getFunction().getStops()).size());
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(rasterBrightnessMin(0.3f));
|
||||
assertEquals((Float) layer.getRasterBrightnessMin().getValue(), (Float) 0.3f);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -292,16 +159,13 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-brightness-maxTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterBrightnessMaxTransition(options);
|
||||
assertEquals(layer.getRasterBrightnessMaxTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterBrightnessMaxTransition(options);
|
||||
assertEquals(layer.getRasterBrightnessMaxTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -310,47 +174,12 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-brightness-max");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterBrightnessMax(0.3f));
|
||||
assertEquals((Float) layer.getRasterBrightnessMax().getValue(), (Float) 0.3f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterBrightnessMaxAsCameraFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-brightness-max");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterBrightnessMax(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterBrightnessMax(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterBrightnessMax());
|
||||
assertNotNull(layer.getRasterBrightnessMax().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterBrightnessMax().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterBrightnessMax().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterBrightnessMax().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterBrightnessMax().getFunction().getStops()).size());
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(rasterBrightnessMax(0.3f));
|
||||
assertEquals((Float) layer.getRasterBrightnessMax().getValue(), (Float) 0.3f);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -359,16 +188,13 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-saturationTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterSaturationTransition(options);
|
||||
assertEquals(layer.getRasterSaturationTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterSaturationTransition(options);
|
||||
assertEquals(layer.getRasterSaturationTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -377,47 +203,12 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-saturation");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterSaturation(0.3f));
|
||||
assertEquals((Float) layer.getRasterSaturation().getValue(), (Float) 0.3f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterSaturationAsCameraFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-saturation");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterSaturation(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterSaturation(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterSaturation());
|
||||
assertNotNull(layer.getRasterSaturation().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterSaturation().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterSaturation().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterSaturation().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterSaturation().getFunction().getStops()).size());
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(rasterSaturation(0.3f));
|
||||
assertEquals((Float) layer.getRasterSaturation().getValue(), (Float) 0.3f);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -426,16 +217,13 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-contrastTransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterContrastTransition(options);
|
||||
assertEquals(layer.getRasterContrastTransition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.setRasterContrastTransition(options);
|
||||
assertEquals(layer.getRasterContrastTransition(), options);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -444,47 +232,12 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-contrast");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterContrast(0.3f));
|
||||
assertEquals((Float) layer.getRasterContrast().getValue(), (Float) 0.3f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterContrastAsCameraFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-contrast");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterContrast(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterContrast(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterContrast());
|
||||
assertNotNull(layer.getRasterContrast().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterContrast().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterContrast().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterContrast().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterContrast().getFunction().getStops()).size());
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(rasterContrast(0.3f));
|
||||
assertEquals((Float) layer.getRasterContrast().getValue(), (Float) 0.3f);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -493,48 +246,12 @@ public class RasterLayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-fade-duration");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterFadeDuration(0.3f));
|
||||
assertEquals((Float) layer.getRasterFadeDuration().getValue(), (Float) 0.3f);
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(rasterFadeDuration(0.3f));
|
||||
assertEquals((Float) layer.getRasterFadeDuration().getValue(), (Float) 0.3f);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterFadeDurationAsCameraFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("raster-fade-duration");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterFadeDuration(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterFadeDuration(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterFadeDuration());
|
||||
assertNotNull(layer.getRasterFadeDuration().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterFadeDuration().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterFadeDuration().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterFadeDuration().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterFadeDuration().getFunction().getStops()).size());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
|
||||
|
||||
import android.support.test.espresso.UiController;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.espresso.EspressoTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.ResourceUtils;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Tests around style loading
|
||||
*/
|
||||
public class StyleLoaderTest extends BaseActivityTest {
|
||||
|
||||
|
||||
@Override
|
||||
protected Class getActivityClass() {
|
||||
return EspressoTestActivity.class;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetGetStyleJsonString() throws Exception {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
try {
|
||||
String expected = ResourceUtils.readRawResource(rule.getActivity(), R.raw.local_style);
|
||||
mapboxMap.setStyleJson(expected);
|
||||
String actual = mapboxMap.getStyleJson();
|
||||
assertEquals("Style json should match", expected, actual);
|
||||
} catch (IOException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultStyleLoadWithActivityLifecycleChange() throws Exception {
|
||||
validateTestSetup();
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
try {
|
||||
String expected = ResourceUtils.readRawResource(rule.getActivity(), R.raw.local_style);
|
||||
mapboxMap.setStyleJson(expected);
|
||||
|
||||
// fake activity stop/start
|
||||
MapView mapView = (MapView) rule.getActivity().findViewById(R.id.mapView);
|
||||
mapView.onPause();
|
||||
mapView.onStop();
|
||||
|
||||
mapView.onStart();
|
||||
mapView.onResume();
|
||||
|
||||
String actual = mapboxMap.getStyleJson();
|
||||
assertEquals("Style URL should be empty", "", mapboxMap.getStyleUrl());
|
||||
assertEquals("Style json should match", expected, actual);
|
||||
} catch (IOException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,31 +7,18 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.UiController;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.functions.CompositeFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.CameraFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.SourceFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stop;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.expressions.Expression;
|
||||
import com.mapbox.mapboxsdk.style.layers.<%- camelize(type) %>Layer;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.*;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
|
||||
import static com.mapbox.mapboxsdk.testapp.action.MapboxMapAction.invoke;
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
@@ -56,25 +43,19 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest {
|
||||
private void setupLayer() {
|
||||
<% if (type === 'background') { -%>
|
||||
Timber.i("Retrieving layer");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
});
|
||||
<% } else { -%>
|
||||
Timber.i("Retrieving layer");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new <%- camelize(type) %>Layer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new <%- camelize(type) %>Layer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
});
|
||||
<% } -%>
|
||||
@@ -85,18 +66,15 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("Visibility");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
});
|
||||
}
|
||||
<% if (!(type === 'background' || type === 'raster' || type === 'hillshade')) { -%>
|
||||
@@ -106,23 +84,41 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("SourceLayer");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getSourceLayer(), "composite");
|
||||
// Get initial
|
||||
assertEquals(layer.getSourceLayer(), "composite");
|
||||
|
||||
// Set
|
||||
final String sourceLayer = "test";
|
||||
layer.setSourceLayer(sourceLayer);
|
||||
assertEquals(layer.getSourceLayer(), sourceLayer);
|
||||
}
|
||||
// Set
|
||||
final String sourceLayer = "test";
|
||||
layer.setSourceLayer(sourceLayer);
|
||||
assertEquals(layer.getSourceLayer(), sourceLayer);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilter() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("Filter");
|
||||
invoke(mapboxMap, (uiController, mapboxMap1) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getFilter(), null);
|
||||
|
||||
// Set
|
||||
Expression filter = eq(get("undefined"), literal(1.0));
|
||||
layer.setFilter(filter);
|
||||
assertEquals(layer.getFilter().toString(), filter.toString());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
<% } -%>
|
||||
<% for (const property of properties) { -%>
|
||||
<% if (property.name != 'heatmap-color') { -%>
|
||||
<% if (property.transition) { -%>
|
||||
|
||||
@Test
|
||||
@@ -130,16 +126,13 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("<%- property.name %>TransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.set<%- camelize(property.name) %>Transition(options);
|
||||
assertEquals(layer.get<%- camelize(property.name) %>Transition(), options);
|
||||
}
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
layer.set<%- camelize(property.name) %>Transition(options);
|
||||
assertEquals(layer.get<%- camelize(property.name) %>Transition(), options);
|
||||
});
|
||||
}
|
||||
<% } -%>
|
||||
@@ -149,291 +142,32 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("<%- property.name %>");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>));
|
||||
assertEquals((<%- propertyType(property) %>) layer.get<%- camelize(property.name) %>().getValue(), (<%- propertyType(property) %>) <%- defaultValueJava(property) %>);
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>));
|
||||
assertEquals((<%- propertyType(property) %>) layer.get<%- camelize(property.name) %>().getValue(), (<%- propertyType(property) %>) <%- defaultValueJava(property) %>);
|
||||
});
|
||||
}
|
||||
<% if (supportsZoomFunction(property)) { -%>
|
||||
<% if (isDataDriven(property)) { -%>
|
||||
<% if (!(property.name.endsWith("-font")||property.name.endsWith("-offset"))) { -%>
|
||||
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsCameraFunction() {
|
||||
public void test<%- camelize(property.name) %>AsExpression() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("<%- property.name %>");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
Timber.i("<%- property.name %>-expression");
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
zoom(
|
||||
<% if (property.function == 'piecewise-constant') { -%>
|
||||
interval(
|
||||
stop(2, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
)
|
||||
<% } else { -%>
|
||||
exponential(
|
||||
stop(2, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
).withBase(0.5f)
|
||||
<% } -%>
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
<% if (property.function == 'piecewise-constant') { -%>
|
||||
assertEquals(IntervalStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((IntervalStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).size());
|
||||
<% } else { -%>
|
||||
assertEquals(ExponentialStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).size());
|
||||
<% } -%>
|
||||
}
|
||||
});
|
||||
}
|
||||
<% } -%>
|
||||
<% if (supportsPropertyFunction(property)) { -%>
|
||||
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsIdentitySourceFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("<%- property.name %>");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(property("FeaturePropertyA", Stops.<<%- propertyType(property) %>>identity()))
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(IdentityStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
}
|
||||
});
|
||||
}
|
||||
<% if (property.function == 'piecewise-constant') { -%>
|
||||
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsIntervalSourceFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("<%- property.name %>");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
interval(
|
||||
<% if (property.type == 'color') { -%>
|
||||
stop(Color.RED, <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED))
|
||||
<% } else {-%>
|
||||
stop(1, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
)
|
||||
<% } -%>
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(IntervalStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
}
|
||||
});
|
||||
}
|
||||
<% } else if (property.type === 'array') { -%>
|
||||
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsIntervalSourceFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("<%- property.name %>");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
interval(
|
||||
<% if (property.type == 'color') { -%>
|
||||
stop(Color.RED, <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED))
|
||||
<% } else {-%>
|
||||
stop(1, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
<% } -%>
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(IntervalStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
}
|
||||
});
|
||||
}
|
||||
<% } else { -%>
|
||||
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsExponentialSourceFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("<%- property.name %>");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
exponential(
|
||||
<% if (property.type == 'color') { -%>
|
||||
stop(Color.RED, <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED))
|
||||
<% } else {-%>
|
||||
stop(<%- defaultValueJava(property) %>, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
<% } -%>
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(ExponentialStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
}
|
||||
// Set and Get
|
||||
Expression expression = <%- defaultExpressionJava(property) %>(Expression.get("undefined"));
|
||||
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(expression));
|
||||
assertEquals(layer.get<%- camelize(property.name) %>().getExpression(), expression);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsCategoricalSourceFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("<%- property.name %>");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
categorical(
|
||||
<% if (property.type == 'color') { -%>
|
||||
stop("valueA", <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED))
|
||||
)
|
||||
).withDefaultValue(<%- camelizeWithLeadingLowercase(property.name) %>(Color.GREEN))
|
||||
<% } else {-%>
|
||||
stop(1.0f, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
)
|
||||
).withDefaultValue(<%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
<% } -%>
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(CategoricalStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
assertNotNull(((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getDefaultValue());
|
||||
assertNotNull(((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getDefaultValue().getValue());
|
||||
<% if (property.type === 'color') { -%>
|
||||
assertEquals(Color.GREEN, (int) ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getDefaultValue().getColorInt());
|
||||
<% } else { -%>
|
||||
assertEquals(<%- defaultValueJava(property) %>, ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getDefaultValue().getValue());
|
||||
<% } -%>
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
<% if (property.type !== 'color') { -%>
|
||||
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsCompositeFunction() {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("<%- property.name %>");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
composite(
|
||||
"FeaturePropertyA",
|
||||
exponential(
|
||||
stop(0, 0.3f, <%- camelizeWithLeadingLowercase(property.name) %>(0.9f))
|
||||
).withBase(0.5f)
|
||||
<% if (property.type == 'number') { -%>
|
||||
).withDefaultValue(<%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
<% } else { -%>
|
||||
)
|
||||
<% } -%>
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(CompositeFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(ExponentialStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((ExponentialStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).size());
|
||||
|
||||
ExponentialStops<Stop.CompositeValue<Float, <%- propertyType(property) %>>, <%- propertyType(property) %>> stops =
|
||||
(ExponentialStops<Stop.CompositeValue<Float, <%- propertyType(property) %>>, <%- propertyType(property) %>>) layer.get<%- camelize(property.name) %>().getFunction().getStops();
|
||||
Stop<Stop.CompositeValue<Float, <%- propertyType(property) %>>, <%- propertyType(property) %>> stop = stops.iterator().next();
|
||||
assertEquals(0f, stop.in.zoom, 0.001);
|
||||
assertEquals(0.3f, stop.in.value, 0.001f);
|
||||
assertEquals(0.9f, stop.out, 0.001f);
|
||||
}
|
||||
});
|
||||
}
|
||||
<% } -%>
|
||||
<% } -%>
|
||||
<% } -%>
|
||||
<% if (property.type == 'color') { -%>
|
||||
@@ -443,18 +177,15 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLayer();
|
||||
Timber.i("<%- property.name %>");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(layer);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(Color.RED));
|
||||
assertEquals(layer.get<%- camelize(property.name) %>AsInt(), Color.RED);
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(Color.RED));
|
||||
assertEquals(layer.get<%- camelize(property.name) %>AsInt(), Color.RED);
|
||||
});
|
||||
}
|
||||
<% } -%>
|
||||
<% } -%>
|
||||
|
||||
}
|
||||
<% } -%>
|
||||
}
|
||||
@@ -9,15 +9,12 @@ import android.support.test.espresso.ViewAction;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.light.Light;
|
||||
import com.mapbox.mapboxsdk.style.functions.Function;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.expressions.Expression;
|
||||
import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
|
||||
import com.mapbox.mapboxsdk.style.light.Position;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.action.MapboxMapAction;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.BaseActivityTest;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.FillExtrusionStyleTestActivity;
|
||||
|
||||
@@ -30,7 +27,7 @@ import org.junit.runner.RunWith;
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Filter.eq;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.eq;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.ANCHOR_MAP;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionBase;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionColor;
|
||||
@@ -53,15 +50,12 @@ public class LightTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLight();
|
||||
Timber.i("<%- property.name %>TransitionOptions");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
light.set<%- camelize(property.name) %>Transition(options);
|
||||
assertEquals("Transition options should match", options, light.get<%- camelize(property.name) %>Transition());
|
||||
}
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
TransitionOptions options = new TransitionOptions(300, 100);
|
||||
light.set<%- camelize(property.name) %>Transition(options);
|
||||
assertEquals("Transition options should match", options, light.get<%- camelize(property.name) %>Transition());
|
||||
});
|
||||
}
|
||||
<% } -%>
|
||||
@@ -72,15 +66,12 @@ public class LightTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLight();
|
||||
Timber.i("<%- property.name %>");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
Position position = new Position(1, 2, 3);
|
||||
light.set<%- camelize(property.name) %>(position);
|
||||
assertEquals("Position should match", position, light.get<%- camelize(property.name) %>());
|
||||
}
|
||||
invoke(mapboxMap,(uiController, mapboxMap) -> {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
Position position = new Position(1, 2, 3);
|
||||
light.set<%- camelize(property.name) %>(position);
|
||||
assertEquals("Position should match", position, light.get<%- camelize(property.name) %>());
|
||||
});
|
||||
}
|
||||
<% } else { -%>
|
||||
@@ -90,18 +81,15 @@ public class LightTest extends BaseActivityTest {
|
||||
validateTestSetup();
|
||||
setupLight();
|
||||
Timber.i("<%- property.name %>");
|
||||
invoke(mapboxMap, new MapboxMapAction.OnInvokeActionListener() {
|
||||
@Override
|
||||
public void onInvokeAction(UiController uiController, MapboxMap mapboxMap) {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
light.set<%- camelize(property.name) %>(<%- defaultValueJava(property) %>);
|
||||
invoke(mapboxMap, (uiController, mapboxMap) -> {
|
||||
assertNotNull(light);
|
||||
// Set and Get
|
||||
light.set<%- camelize(property.name) %>(<%- defaultValueJava(property) %>);
|
||||
<% if (property.name == 'color') { -%>
|
||||
assertEquals("<%- camelize(property.name) %> should match", <%- defaultValueJava(property) %>.replaceAll("\\s+", ""), light.get<%- camelize(property.name) %>());
|
||||
assertEquals("<%- camelize(property.name) %> should match", <%- defaultValueJava(property) %>.replaceAll("\\s+", ""), light.get<%- camelize(property.name) %>());
|
||||
<% } else { -%>
|
||||
assertEquals("<%- camelize(property.name) %> should match", <%- defaultValueJava(property) %>, light.get<%- camelize(property.name) %>());
|
||||
assertEquals("<%- camelize(property.name) %> should match", <%- defaultValueJava(property) %>, light.get<%- camelize(property.name) %>());
|
||||
<% } -%>
|
||||
}
|
||||
});
|
||||
}
|
||||
<% } -%>
|
||||
@@ -124,12 +112,12 @@ public class LightTest extends BaseActivityTest {
|
||||
light = mapboxMap.getLight();
|
||||
FillExtrusionLayer fillExtrusionLayer = new FillExtrusionLayer("3d-buildings", "composite");
|
||||
fillExtrusionLayer.setSourceLayer("building");
|
||||
fillExtrusionLayer.setFilter(eq("extrude", "true"));
|
||||
fillExtrusionLayer.setFilter(eq(Expression.get("extrude"), "true"));
|
||||
fillExtrusionLayer.setMinZoom(15);
|
||||
fillExtrusionLayer.setProperties(
|
||||
fillExtrusionColor(Color.LTGRAY),
|
||||
fillExtrusionHeight(Function.property("height", new IdentityStops<Float>())),
|
||||
fillExtrusionBase(Function.property("min_height", new IdentityStops<Float>())),
|
||||
fillExtrusionHeight(Expression.get("height")),
|
||||
fillExtrusionBase(Expression.get("min_height")),
|
||||
fillExtrusionOpacity(0.6f)
|
||||
);
|
||||
mapboxMap.addLayer(fillExtrusionLayer);
|
||||
@@ -141,4 +129,4 @@ public class LightTest extends BaseActivityTest {
|
||||
protected Class getActivityClass() {
|
||||
return FillExtrusionStyleTestActivity.class;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mapbox.mapboxsdk.testapp">
|
||||
package="com.mapbox.mapboxsdk.testapp">
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
<application
|
||||
android:name=".MapboxApplication"
|
||||
@@ -19,8 +18,9 @@
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTop">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
@@ -29,10 +29,10 @@
|
||||
android:label="@string/activity_info_window">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_infowindow"/>
|
||||
android:value="@string/category_infowindow" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.infowindow.InfoWindowAdapterActivity"
|
||||
@@ -40,10 +40,10 @@
|
||||
android:label="@string/activity_infowindow_adapter">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_infowindow"/>
|
||||
android:value="@string/category_infowindow" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.infowindow.DynamicInfoWindowAdapterActivity"
|
||||
@@ -51,10 +51,10 @@
|
||||
android:label="@string/activity_dynamic_infowindow_adapter">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_infowindow"/>
|
||||
android:value="@string/category_infowindow" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.annotation.BulkMarkerActivity"
|
||||
@@ -63,10 +63,10 @@
|
||||
android:label="@string/activity_add_bulk_markers">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_annotation"/>
|
||||
android:value="@string/category_annotation" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.annotation.AnimatedSymbolLayerActivity"
|
||||
@@ -74,10 +74,10 @@
|
||||
android:label="@string/activity_animated_symbollayer">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_style"/>
|
||||
android:value="@string/category_annotation" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.annotation.DynamicMarkerChangeActivity"
|
||||
@@ -85,10 +85,10 @@
|
||||
android:label="@string/activity_dynamic_marker">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_annotation"/>
|
||||
android:value="@string/category_annotation" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.annotation.PressForMarkerActivity"
|
||||
@@ -96,10 +96,10 @@
|
||||
android:label="@string/activity_press_for_marker">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_annotation"/>
|
||||
android:value="@string/category_annotation" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.camera.CameraAnimationTypeActivity"
|
||||
@@ -107,10 +107,10 @@
|
||||
android:label="@string/activity_camera_animation_types">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_camera"/>
|
||||
android:value="@string/category_camera" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.camera.CameraAnimatorActivity"
|
||||
@@ -118,10 +118,10 @@
|
||||
android:label="@string/activity_camera_animator">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_camera"/>
|
||||
android:value="@string/category_camera" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.camera.CameraPositionActivity"
|
||||
@@ -129,10 +129,10 @@
|
||||
android:label="@string/activity_camera_position">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_camera"/>
|
||||
android:value="@string/category_camera" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.camera.LatLngBoundsActivity"
|
||||
@@ -141,10 +141,10 @@
|
||||
android:screenOrientation="portrait">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_camera"/>
|
||||
android:value="@string/category_camera" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.fragment.MapFragmentActivity"
|
||||
@@ -152,10 +152,10 @@
|
||||
android:label="@string/activity_map_fragment">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_fragment"/>
|
||||
android:value="@string/category_fragment" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.fragment.SupportMapFragmentActivity"
|
||||
@@ -163,10 +163,10 @@
|
||||
android:label="@string/activity_map_fragment_suport">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_fragment"/>
|
||||
android:value="@string/category_fragment" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.fragment.MultiMapActivity"
|
||||
@@ -174,10 +174,10 @@
|
||||
android:label="@string/activity_multimap">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_fragment"/>
|
||||
android:value="@string/category_fragment" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.camera.ManualZoomActivity"
|
||||
@@ -185,10 +185,10 @@
|
||||
android:label="@string/activity_camera_zoom">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_camera"/>
|
||||
android:value="@string/category_camera" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.camera.MaxMinZoomActivity"
|
||||
@@ -196,10 +196,10 @@
|
||||
android:label="@string/activity_minmax_zoom">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_camera"/>
|
||||
android:value="@string/category_camera" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.customlayer.CustomLayerActivity"
|
||||
@@ -207,66 +207,10 @@
|
||||
android:label="@string/activity_custom_layer">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_custom_layer"/>
|
||||
android:value="@string/category_custom_layer" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.userlocation.MyLocationTrackingModeActivity"
|
||||
android:description="@string/description_user_location_tracking"
|
||||
android:label="@string/activity_user_tracking_mode"
|
||||
android:theme="@style/NoActionBar">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_userlocation"/>
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.userlocation.MyLocationDrawableActivity"
|
||||
android:description="@string/description_user_location_customization"
|
||||
android:label="@string/activity_user_tracking_customization">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_userlocation"/>
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.userlocation.MyLocationTintActivity"
|
||||
android:description="@string/description_user_location_dot_color"
|
||||
android:label="@string/activity_user_dot_color">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_userlocation"/>
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.userlocation.MyLocationToggleActivity"
|
||||
android:description="@string/description_user_location_toggle"
|
||||
android:label="@string/activity_user_location_toggle">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_userlocation"/>
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.userlocation.CustomLocationEngineActivity"
|
||||
android:description="@string/description_custom_location_engine"
|
||||
android:label="@string/activity_custom_location_engine">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_userlocation"/>
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.annotation.PolygonActivity"
|
||||
@@ -274,10 +218,10 @@
|
||||
android:label="@string/activity_polygon">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_annotation"/>
|
||||
android:value="@string/category_annotation" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.annotation.PolylineActivity"
|
||||
@@ -285,10 +229,10 @@
|
||||
android:label="@string/activity_polyline">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_annotation"/>
|
||||
android:value="@string/category_annotation" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.camera.ScrollByActivity"
|
||||
@@ -297,10 +241,10 @@
|
||||
android:theme="@style/NoActionBar">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_camera"/>
|
||||
android:value="@string/category_camera" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.maplayout.MapPaddingActivity"
|
||||
@@ -309,10 +253,10 @@
|
||||
android:screenOrientation="portrait">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_maplayout"/>
|
||||
android:value="@string/category_maplayout" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.maplayout.DebugModeActivity"
|
||||
@@ -321,7 +265,7 @@
|
||||
android:label="@string/activity_debug_mode">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_basic"/>
|
||||
android:value="@string/category_basic" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.offline.OfflineActivity"
|
||||
@@ -329,10 +273,10 @@
|
||||
android:label="@string/activity_offline">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_offline"/>
|
||||
android:value="@string/category_offline" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.offline.UpdateMetadataActivity"
|
||||
@@ -340,10 +284,10 @@
|
||||
android:label="@string/activity_update_metadata">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_offline"/>
|
||||
android:value="@string/category_offline" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.offline.DeleteRegionActivity"
|
||||
@@ -351,10 +295,10 @@
|
||||
android:label="@string/activity_offline_region_delete">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_offline"/>
|
||||
android:value="@string/category_offline" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.imagegenerator.SnapshotActivity"
|
||||
@@ -362,10 +306,10 @@
|
||||
android:label="@string/activity_snapshot">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_imagegenerator"/>
|
||||
android:value="@string/category_imagegenerator" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.snapshot.MapSnapshotterActivity"
|
||||
@@ -373,10 +317,10 @@
|
||||
android:label="@string/activity_map_snapshotter">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_imagegenerator"/>
|
||||
android:value="@string/category_imagegenerator" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.snapshot.MapSnapshotterReuseActivity"
|
||||
@@ -384,10 +328,10 @@
|
||||
android:label="@string/activity_map_snapshotter_reuse">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_imagegenerator"/>
|
||||
android:value="@string/category_imagegenerator" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.snapshot.MapSnapshotterMarkerActivity"
|
||||
@@ -395,10 +339,10 @@
|
||||
android:label="@string/activity_map_snapshotter_marker">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_imagegenerator"/>
|
||||
android:value="@string/category_imagegenerator" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.maplayout.DoubleMapActivity"
|
||||
@@ -406,10 +350,10 @@
|
||||
android:label="@string/activity_double_map">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_maplayout"/>
|
||||
android:value="@string/category_maplayout" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.annotation.MarkerViewActivity"
|
||||
@@ -417,10 +361,10 @@
|
||||
android:label="@string/activity_view_marker">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_annotation"/>
|
||||
android:value="@string/category_annotation" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.fragment.ViewPagerActivity"
|
||||
@@ -428,10 +372,10 @@
|
||||
android:label="@string/activity_viewpager">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_fragment"/>
|
||||
android:value="@string/category_fragment" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.maplayout.SimpleMapActivity"
|
||||
@@ -439,10 +383,10 @@
|
||||
android:label="@string/activity_simple_map">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_basic"/>
|
||||
android:value="@string/category_basic" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.maplayout.MapChangeActivity"
|
||||
@@ -450,10 +394,10 @@
|
||||
android:label="@string/activity_map_change">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_maplayout"/>
|
||||
android:value="@string/category_maplayout" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.maplayout.VisibilityChangeActivity"
|
||||
@@ -461,10 +405,10 @@
|
||||
android:label="@string/activity_map_visibility">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_maplayout"/>
|
||||
android:value="@string/category_maplayout" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.style.RuntimeStyleActivity"
|
||||
@@ -472,10 +416,10 @@
|
||||
android:label="@string/activity_runtime_style">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_style"/>
|
||||
android:value="@string/category_style" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.style.DataDrivenStyleActivity"
|
||||
@@ -483,10 +427,10 @@
|
||||
android:label="@string/activity_data_driven_style">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_style"/>
|
||||
android:value="@string/category_style" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.style.CircleLayerActivity"
|
||||
@@ -494,10 +438,10 @@
|
||||
android:label="@string/activity_circle_layer">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_style"/>
|
||||
android:value="@string/category_style" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.style.FillExtrusionActivity"
|
||||
@@ -505,10 +449,10 @@
|
||||
android:label="@string/activity_fill_extrusion_layer">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_style"/>
|
||||
android:value="@string/category_style" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.style.BuildingFillExtrusionActivity"
|
||||
@@ -516,10 +460,10 @@
|
||||
android:label="@string/activity_building_fill_extrusion_layer">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_style"/>
|
||||
android:value="@string/category_style" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.style.SymbolLayerActivity"
|
||||
@@ -527,10 +471,10 @@
|
||||
android:label="@string/activity_symbol_layer">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_style"/>
|
||||
android:value="@string/category_style" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.style.GeoJsonClusteringActivity"
|
||||
@@ -538,10 +482,10 @@
|
||||
android:label="@string/activity_geojson_clustering">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_style"/>
|
||||
android:value="@string/category_style" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.style.RealTimeGeoJsonActivity"
|
||||
@@ -549,10 +493,10 @@
|
||||
android:label="@string/activity_geojson_realtime">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_style"/>
|
||||
android:value="@string/category_style" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.style.StyleFileActivity"
|
||||
@@ -560,10 +504,10 @@
|
||||
android:label="@string/activity_style_file">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_style"/>
|
||||
android:value="@string/category_style" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.style.CustomSpriteActivity"
|
||||
@@ -571,10 +515,10 @@
|
||||
android:label="@string/activity_add_sprite">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_style"/>
|
||||
android:value="@string/category_style" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.imagegenerator.PrintActivity"
|
||||
@@ -582,10 +526,10 @@
|
||||
android:label="@string/activity_print">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_imagegenerator"/>
|
||||
android:value="@string/category_imagegenerator" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.style.AnimatedImageSourceActivity"
|
||||
@@ -593,10 +537,10 @@
|
||||
android:label="@string/activity_animated_image_source">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_style"/>
|
||||
android:value="@string/category_style" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.style.GridSourceActivity"
|
||||
@@ -604,10 +548,10 @@
|
||||
android:label="@string/activity_grid_source">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_style"/>
|
||||
android:value="@string/category_style" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<!-- Features -->
|
||||
<activity
|
||||
@@ -616,10 +560,10 @@
|
||||
android:label="@string/activity_query_rendered_feature_properties">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_features"/>
|
||||
android:value="@string/category_features" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.feature.QueryRenderedFeaturesBoxCountActivity"
|
||||
@@ -627,10 +571,10 @@
|
||||
android:label="@string/activity_query_rendered_features_box_count">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_features"/>
|
||||
android:value="@string/category_features" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.feature.QueryRenderedFeaturesBoxSymbolCountActivity"
|
||||
@@ -638,10 +582,10 @@
|
||||
android:label="@string/activity_query_rendered_features_box_symbol_count">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_features"/>
|
||||
android:value="@string/category_features" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.feature.QueryRenderedFeaturesBoxHighlightActivity"
|
||||
@@ -649,10 +593,10 @@
|
||||
android:label="@string/activity_query_rendered_features_box_highlight">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_features"/>
|
||||
android:value="@string/category_features" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.feature.QuerySourceFeaturesActivity"
|
||||
@@ -660,10 +604,10 @@
|
||||
android:label="@string/activity_query_source_features">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_features"/>
|
||||
android:value="@string/category_features" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.style.SymbolGeneratorActivity"
|
||||
@@ -671,10 +615,10 @@
|
||||
android:label="@string/activity_symbol_generator">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_style"/>
|
||||
android:value="@string/category_style" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.style.ZoomFunctionSymbolLayerActivity"
|
||||
@@ -682,10 +626,10 @@
|
||||
android:label="@string/activity_add_remove_markers">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_style"/>
|
||||
android:value="@string/category_style" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.maplayout.MapInDialogActivity"
|
||||
@@ -693,10 +637,10 @@
|
||||
android:label="@string/activity_map_in_dialog">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_maplayout"/>
|
||||
android:value="@string/category_maplayout" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.annotation.MarkerViewsInRectangleActivity"
|
||||
@@ -704,10 +648,10 @@
|
||||
android:label="@string/activity_marker_view_rectangle">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_annotation"/>
|
||||
android:value="@string/category_annotation" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.maplayout.LatLngBoundsForCameraActivity"
|
||||
@@ -715,10 +659,10 @@
|
||||
android:label="@string/activity_restricted_bounds">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_maplayout"/>
|
||||
android:value="@string/category_maplayout" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
|
||||
<!-- Storage -->
|
||||
@@ -728,10 +672,10 @@
|
||||
android:label="@string/activity_url_transform">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_storage"/>
|
||||
android:value="@string/category_storage" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.maplayout.BottomSheetActivity"
|
||||
@@ -739,7 +683,7 @@
|
||||
android:label="@string/activity_bottom_sheet">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_maplayout"/>
|
||||
android:value="@string/category_maplayout" />
|
||||
</activity>
|
||||
|
||||
<!-- TextureView -->
|
||||
@@ -749,7 +693,7 @@
|
||||
android:label="@string/activity_textureview_debug">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_textureview"/>
|
||||
android:value="@string/category_textureview" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.textureview.TextureViewResizeActivity"
|
||||
@@ -757,7 +701,18 @@
|
||||
android:label="@string/activity_textureview_resize">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_textureview"/>
|
||||
android:value="@string/category_textureview" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.textureview.TextureViewTransparentBackgroundActivity"
|
||||
android:description="@string/description_textureview_transparent"
|
||||
android:label="@string/activity_textureview_transparent">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_textureview" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.textureview.TextureViewAnimationActivity"
|
||||
@@ -765,7 +720,7 @@
|
||||
android:label="@string/activity_textureview_animate">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_textureview"/>
|
||||
android:value="@string/category_textureview" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.maplayout.LocalGlyphActivity"
|
||||
@@ -773,10 +728,10 @@
|
||||
android:label="@string/activity_local_glyph">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_maplayout"/>
|
||||
android:value="@string/category_maplayout" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.style.HillshadeLayerActivity"
|
||||
@@ -784,10 +739,10 @@
|
||||
android:label="@string/activity_hillshade">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_style"/>
|
||||
android:value="@string/category_style" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.style.HeatmapLayerActivity"
|
||||
@@ -795,32 +750,43 @@
|
||||
android:label="@string/activity_heatmaplayer">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_style"/>
|
||||
android:value="@string/category_style" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
android:value=".activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.camera.GestureDetectorActivity"
|
||||
android:label="@string/activity_gesture_detector"
|
||||
android:description="@string/description_gesture_detector">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_camera" />
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="com.mapbox.mapboxsdk.testapp.activity.FeatureOverviewActivity" />
|
||||
</activity>
|
||||
|
||||
<!-- For Instrumentation tests -->
|
||||
<activity
|
||||
android:name=".activity.style.RuntimeStyleTestActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.style.RuntimeStyleTimingTestActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.espresso.EspressoTestActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.style.FillExtrusionStyleTestActivity"
|
||||
android:screenOrientation="portrait"/>
|
||||
android:screenOrientation="portrait" />
|
||||
<!-- Configuration Settings -->
|
||||
<meta-data
|
||||
android:name="com.mapbox.TestEventsServer"
|
||||
android:value="api-events-staging.tilestream.net"/>
|
||||
android:value="api-events-staging.tilestream.net" />
|
||||
<meta-data
|
||||
android:name="com.mapbox.TestEventsAccessToken"
|
||||
android:value="pk.eyJ1IjoiYmxzdGFnaW5nIiwiYSI6ImNpdDF3OHpoaTAwMDcyeXA5Y3Z0Nmk2dzEifQ.0IfB7v5Qbm2MGVYt8Kb8fg"/>
|
||||
android:value="pk.eyJ1IjoiYmxzdGFnaW5nIiwiYSI6ImNpdDF3OHpoaTAwMDcyeXA5Y3Z0Nmk2dzEifQ.0IfB7v5Qbm2MGVYt8Kb8fg" />
|
||||
|
||||
<!-- Comment out this setting to switch to external storage (and disable internal) in your app -->
|
||||
<!-- <meta-data -->
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.os.StrictMode;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mapbox.mapboxsdk.Mapbox;
|
||||
import com.mapbox.mapboxsdk.maps.Telemetry;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.TokenUtils;
|
||||
import com.squareup.leakcanary.LeakCanary;
|
||||
|
||||
@@ -57,6 +58,8 @@ public class MapboxApplication extends Application {
|
||||
}
|
||||
|
||||
Mapbox.getInstance(getApplicationContext(), mapboxAccessToken);
|
||||
|
||||
Telemetry.updateDebugLoggingEnabled(true);
|
||||
}
|
||||
|
||||
private void initializeLogger() {
|
||||
|
||||
@@ -7,23 +7,17 @@ import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.adapter.FeatureAdapter;
|
||||
import com.mapbox.mapboxsdk.testapp.adapter.FeatureSectionAdapter;
|
||||
import com.mapbox.mapboxsdk.testapp.model.activity.Feature;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.ItemClickSupport;
|
||||
import com.mapbox.android.core.permissions.PermissionsListener;
|
||||
import com.mapbox.android.core.permissions.PermissionsManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -39,23 +33,19 @@ import timber.log.Timber;
|
||||
* It uses tags as category and description to order the different entries.
|
||||
* </p>
|
||||
*/
|
||||
public class FeatureOverviewActivity extends AppCompatActivity implements PermissionsListener {
|
||||
public class FeatureOverviewActivity extends AppCompatActivity {
|
||||
|
||||
private static final String KEY_STATE_FEATURES = "featureList";
|
||||
|
||||
private PermissionsManager permissionsManager;
|
||||
private RecyclerView recyclerView;
|
||||
private FeatureSectionAdapter sectionAdapter;
|
||||
private List<Feature> features;
|
||||
private int locationActivityInList;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_feature_overview);
|
||||
|
||||
permissionsManager = new PermissionsManager(this);
|
||||
|
||||
recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
recyclerView.addOnItemTouchListener(new RecyclerView.SimpleOnItemTouchListener());
|
||||
@@ -65,11 +55,6 @@ public class FeatureOverviewActivity extends AppCompatActivity implements Permis
|
||||
if (!sectionAdapter.isSectionHeaderPosition(position)) {
|
||||
int itemPosition = sectionAdapter.getConvertedPosition(position);
|
||||
Feature feature = features.get(itemPosition);
|
||||
if (feature.isRequiresLocationPermission()) {
|
||||
if (requestLocationPermission(itemPosition)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
startFeature(feature);
|
||||
}
|
||||
});
|
||||
@@ -118,45 +103,6 @@ public class FeatureOverviewActivity extends AppCompatActivity implements Permis
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
private boolean requestLocationPermission(final int positionInList) {
|
||||
if (isRuntimePermissionsRequired()) {
|
||||
locationActivityInList = positionInList;
|
||||
permissionsManager.requestLocationPermissions(this);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExplanationNeeded(List<String> list) {
|
||||
Snackbar.make(
|
||||
findViewById(android.R.id.content),
|
||||
TextUtils.join("", list.toArray()),
|
||||
Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPermissionResult(boolean isPermissionGranted) {
|
||||
if (isPermissionGranted) {
|
||||
startFeature(features.get(locationActivityInList));
|
||||
} else {
|
||||
Snackbar.make(
|
||||
findViewById(android.R.id.content),
|
||||
"Can't open without accepting the location permission.",
|
||||
Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
permissionsManager.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
|
||||
private boolean isRuntimePermissionsRequired() {
|
||||
return android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
@@ -178,8 +124,7 @@ public class FeatureOverviewActivity extends AppCompatActivity implements Permis
|
||||
String label = getString(info.labelRes);
|
||||
String description = resolveString(info.descriptionRes);
|
||||
String category = resolveMetaData(info.metaData, metaDataKey);
|
||||
boolean requiresLocationPermission = requiresLocationPermission(label, category);
|
||||
features.add(new Feature(info.name, label, description, category, requiresLocationPermission));
|
||||
features.add(new Feature(info.name, label, description, category));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,24 +158,6 @@ public class FeatureOverviewActivity extends AppCompatActivity implements Permis
|
||||
}
|
||||
}
|
||||
|
||||
private boolean requiresLocationPermission(String name, String category) {
|
||||
final Resources resources = getResources();
|
||||
|
||||
List<String> requiresPermissionCategories = new ArrayList<String>() {
|
||||
{
|
||||
add(resources.getString(R.string.category_userlocation));
|
||||
}
|
||||
};
|
||||
|
||||
List<String> requiresPermissionActivities = new ArrayList<String>() {
|
||||
{
|
||||
add(resources.getString(R.string.activity_double_map));
|
||||
}
|
||||
};
|
||||
|
||||
return requiresPermissionCategories.contains(category) || requiresPermissionActivities.contains(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(List<Feature> features) {
|
||||
super.onPostExecute(features);
|
||||
|
||||
@@ -1,449 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.annotation;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.TypeEvaluator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mapbox.geojson.Feature;
|
||||
import com.mapbox.geojson.FeatureCollection;
|
||||
import com.mapbox.geojson.Point;
|
||||
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.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.turf.TurfMeasurement;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.property;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconAllowOverlap;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconIgnorePlacement;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconRotate;
|
||||
|
||||
/**
|
||||
* Test activity showcasing animating MarkerViews.
|
||||
*/
|
||||
public class AnimatedSymbolLayerActivity extends AppCompatActivity {
|
||||
|
||||
private static final String PASSENGER = "passenger";
|
||||
private static final String PASSENGER_LAYER = "passenger-layer";
|
||||
private static final String PASSENGER_SOURCE = "passenger-source";
|
||||
private static final String TAXI = "taxi";
|
||||
private static final String TAXI_LAYER = "taxi-layer";
|
||||
private static final String TAXI_SOURCE = "taxi-source";
|
||||
private static final String RANDOM_CAR_LAYER = "random-car-layer";
|
||||
private static final String RANDOM_CAR_SOURCE = "random-car-source";
|
||||
private static final String RANDOM_CAR_IMAGE_ID = "random-car";
|
||||
private static final String PROPERTY_BEARING = "bearing";
|
||||
private static final String WATERWAY_LAYER_ID = "waterway-label";
|
||||
private static final int DURATION_RANDOM_MAX = 1500;
|
||||
private static final int DURATION_BASE = 3000;
|
||||
|
||||
private final Random random = new Random();
|
||||
|
||||
private MapView mapView;
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
private List<Car> randomCars = new ArrayList<>();
|
||||
private GeoJsonSource randomCarSource;
|
||||
private Car taxi;
|
||||
private GeoJsonSource taxiSource;
|
||||
private LatLng passenger;
|
||||
|
||||
private List<Animator> animators = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_animated_marker);
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(mapboxMap -> {
|
||||
AnimatedSymbolLayerActivity.this.mapboxMap = mapboxMap;
|
||||
setupCars();
|
||||
animateRandomRoutes();
|
||||
animateTaxi();
|
||||
});
|
||||
}
|
||||
|
||||
private void setupCars() {
|
||||
addRandomCars();
|
||||
addPassenger();
|
||||
addMainCar();
|
||||
}
|
||||
|
||||
private void animateRandomRoutes() {
|
||||
final Car longestDrive = getLongestDrive();
|
||||
final Random random = new Random();
|
||||
for (final Car car : randomCars) {
|
||||
final boolean isLongestDrive = longestDrive.equals(car);
|
||||
ValueAnimator valueAnimator = ValueAnimator.ofObject(new LatLngEvaluator(), car.current, car.next);
|
||||
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
|
||||
private LatLng latLng;
|
||||
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
latLng = (LatLng) animation.getAnimatedValue();
|
||||
car.current = latLng;
|
||||
if (isLongestDrive) {
|
||||
updateRandomCarSource();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (isLongestDrive) {
|
||||
valueAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
super.onAnimationEnd(animation);
|
||||
updateRandomDestinations();
|
||||
animateRandomRoutes();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
valueAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
super.onAnimationStart(animation);
|
||||
car.feature.properties().addProperty("bearing", Car.getBearing(car.current, car.next));
|
||||
}
|
||||
});
|
||||
|
||||
int offset = random.nextInt(2) == 0 ? 0 : random.nextInt(1000) + 250;
|
||||
valueAnimator.setStartDelay(offset);
|
||||
valueAnimator.setDuration(car.duration - offset);
|
||||
valueAnimator.setInterpolator(new LinearInterpolator());
|
||||
valueAnimator.start();
|
||||
|
||||
animators.add(valueAnimator);
|
||||
}
|
||||
}
|
||||
|
||||
private void animateTaxi() {
|
||||
ValueAnimator valueAnimator = ValueAnimator.ofObject(new LatLngEvaluator(), taxi.current, taxi.next);
|
||||
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
|
||||
private LatLng latLng;
|
||||
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
latLng = (LatLng) animation.getAnimatedValue();
|
||||
taxi.current = latLng;
|
||||
updateTaxiSource();
|
||||
}
|
||||
});
|
||||
|
||||
valueAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
super.onAnimationEnd(animation);
|
||||
updatePassenger();
|
||||
animateTaxi();
|
||||
}
|
||||
});
|
||||
|
||||
valueAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
super.onAnimationStart(animation);
|
||||
taxi.feature.properties().addProperty("bearing", Car.getBearing(taxi.current, taxi.next));
|
||||
}
|
||||
});
|
||||
|
||||
valueAnimator.setDuration((long) (7 * taxi.current.distanceTo(taxi.next)));
|
||||
valueAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
|
||||
valueAnimator.start();
|
||||
|
||||
animators.add(valueAnimator);
|
||||
}
|
||||
|
||||
private void updatePassenger() {
|
||||
passenger = getLatLngInBounds();
|
||||
updatePassengerSource();
|
||||
taxi.setNext(passenger);
|
||||
}
|
||||
|
||||
private void updatePassengerSource() {
|
||||
GeoJsonSource source = mapboxMap.getSourceAs(PASSENGER_SOURCE);
|
||||
FeatureCollection featureCollection = FeatureCollection.fromFeatures(new Feature[] {
|
||||
Feature.fromGeometry(
|
||||
Point.fromLngLat(
|
||||
passenger.getLongitude(),
|
||||
passenger.getLatitude()
|
||||
)
|
||||
)
|
||||
});
|
||||
source.setGeoJson(featureCollection);
|
||||
}
|
||||
|
||||
private void updateTaxiSource() {
|
||||
taxi.updateFeature();
|
||||
taxiSource.setGeoJson(taxi.feature);
|
||||
}
|
||||
|
||||
private void updateRandomDestinations() {
|
||||
for (Car randomCar : randomCars) {
|
||||
randomCar.setNext(getLatLngInBounds());
|
||||
}
|
||||
}
|
||||
|
||||
private Car getLongestDrive() {
|
||||
Car longestDrive = null;
|
||||
for (Car randomCar : randomCars) {
|
||||
if (longestDrive == null) {
|
||||
longestDrive = randomCar;
|
||||
} else if (longestDrive.duration < randomCar.duration) {
|
||||
longestDrive = randomCar;
|
||||
}
|
||||
}
|
||||
return longestDrive;
|
||||
}
|
||||
|
||||
private void updateRandomCarSource() {
|
||||
for (Car randomCarsRoute : randomCars) {
|
||||
randomCarsRoute.updateFeature();
|
||||
}
|
||||
randomCarSource.setGeoJson(featuresFromRoutes());
|
||||
}
|
||||
|
||||
private FeatureCollection featuresFromRoutes() {
|
||||
List<Feature> features = new ArrayList<>();
|
||||
for (Car randomCarsRoute : randomCars) {
|
||||
features.add(randomCarsRoute.feature);
|
||||
}
|
||||
return FeatureCollection.fromFeatures(features);
|
||||
}
|
||||
|
||||
private long getDuration() {
|
||||
return random.nextInt(DURATION_RANDOM_MAX) + DURATION_BASE;
|
||||
}
|
||||
|
||||
private void addRandomCars() {
|
||||
LatLng latLng;
|
||||
LatLng next;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
latLng = getLatLngInBounds();
|
||||
next = getLatLngInBounds();
|
||||
|
||||
JsonObject properties = new JsonObject();
|
||||
properties.addProperty(PROPERTY_BEARING, Car.getBearing(latLng, next));
|
||||
|
||||
Feature feature = Feature.fromGeometry(
|
||||
Point.fromLngLat(
|
||||
latLng.getLongitude(),
|
||||
latLng.getLatitude()
|
||||
), properties);
|
||||
|
||||
randomCars.add(
|
||||
new Car(feature, next, getDuration())
|
||||
);
|
||||
}
|
||||
|
||||
randomCarSource = new GeoJsonSource(RANDOM_CAR_SOURCE, featuresFromRoutes());
|
||||
mapboxMap.addSource(randomCarSource);
|
||||
mapboxMap.addImage(RANDOM_CAR_IMAGE_ID,
|
||||
((BitmapDrawable) getResources().getDrawable(R.drawable.ic_car_top)).getBitmap());
|
||||
|
||||
SymbolLayer symbolLayer = new SymbolLayer(RANDOM_CAR_LAYER, RANDOM_CAR_SOURCE);
|
||||
symbolLayer.withProperties(
|
||||
iconImage(RANDOM_CAR_IMAGE_ID),
|
||||
iconAllowOverlap(true),
|
||||
iconRotate(
|
||||
property(
|
||||
PROPERTY_BEARING,
|
||||
Stops.<Float>identity()
|
||||
)
|
||||
),
|
||||
iconIgnorePlacement(true)
|
||||
);
|
||||
|
||||
mapboxMap.addLayerBelow(symbolLayer, WATERWAY_LAYER_ID);
|
||||
}
|
||||
|
||||
private void addPassenger() {
|
||||
passenger = getLatLngInBounds();
|
||||
FeatureCollection featureCollection = FeatureCollection.fromFeatures(new Feature[] {
|
||||
Feature.fromGeometry(
|
||||
Point.fromLngLat(
|
||||
passenger.getLongitude(),
|
||||
passenger.getLatitude()
|
||||
)
|
||||
)
|
||||
});
|
||||
|
||||
mapboxMap.addImage(PASSENGER,
|
||||
((BitmapDrawable) getResources().getDrawable(R.drawable.icon_burned)).getBitmap());
|
||||
|
||||
GeoJsonSource geoJsonSource = new GeoJsonSource(PASSENGER_SOURCE, featureCollection);
|
||||
mapboxMap.addSource(geoJsonSource);
|
||||
|
||||
SymbolLayer symbolLayer = new SymbolLayer(PASSENGER_LAYER, PASSENGER_SOURCE);
|
||||
symbolLayer.withProperties(
|
||||
iconImage(PASSENGER),
|
||||
iconIgnorePlacement(true),
|
||||
iconAllowOverlap(true)
|
||||
);
|
||||
mapboxMap.addLayerBelow(symbolLayer, RANDOM_CAR_LAYER);
|
||||
}
|
||||
|
||||
private void addMainCar() {
|
||||
LatLng latLng = getLatLngInBounds();
|
||||
JsonObject properties = new JsonObject();
|
||||
properties.addProperty(PROPERTY_BEARING, Car.getBearing(latLng, passenger));
|
||||
Feature feature = Feature.fromGeometry(
|
||||
Point.fromLngLat(
|
||||
latLng.getLongitude(),
|
||||
latLng.getLatitude()), properties);
|
||||
FeatureCollection featureCollection = FeatureCollection.fromFeatures(new Feature[] {feature});
|
||||
|
||||
taxi = new Car(feature, passenger, getDuration());
|
||||
mapboxMap.addImage(TAXI,
|
||||
((BitmapDrawable) getResources().getDrawable(R.drawable.ic_taxi_top)).getBitmap());
|
||||
taxiSource = new GeoJsonSource(TAXI_SOURCE, featureCollection);
|
||||
mapboxMap.addSource(taxiSource);
|
||||
|
||||
SymbolLayer symbolLayer = new SymbolLayer(TAXI_LAYER, TAXI_SOURCE);
|
||||
symbolLayer.withProperties(
|
||||
iconImage(TAXI),
|
||||
iconRotate(
|
||||
property(
|
||||
PROPERTY_BEARING,
|
||||
Stops.<Float>identity()
|
||||
)
|
||||
),
|
||||
iconAllowOverlap(true),
|
||||
iconIgnorePlacement(true)
|
||||
|
||||
);
|
||||
mapboxMap.addLayer(symbolLayer);
|
||||
}
|
||||
|
||||
private LatLng getLatLngInBounds() {
|
||||
LatLngBounds bounds = mapboxMap.getProjection().getVisibleRegion().latLngBounds;
|
||||
Random generator = new Random();
|
||||
double randomLat = bounds.getLatSouth() + generator.nextDouble()
|
||||
* (bounds.getLatNorth() - bounds.getLatSouth());
|
||||
double randomLon = bounds.getLonWest() + generator.nextDouble()
|
||||
* (bounds.getLonEast() - bounds.getLonWest());
|
||||
return new LatLng(randomLat, randomLon);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mapView.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mapView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mapView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mapView.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
mapView.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
for (Animator animator : animators) {
|
||||
if (animator != null) {
|
||||
animator.removeAllListeners();
|
||||
animator.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
mapView.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
super.onLowMemory();
|
||||
mapView.onLowMemory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluator for LatLng pairs
|
||||
*/
|
||||
private static class LatLngEvaluator implements TypeEvaluator<LatLng> {
|
||||
|
||||
private LatLng latLng = new LatLng();
|
||||
|
||||
@Override
|
||||
public LatLng evaluate(float fraction, LatLng startValue, LatLng endValue) {
|
||||
latLng.setLatitude(startValue.getLatitude()
|
||||
+ ((endValue.getLatitude() - startValue.getLatitude()) * fraction));
|
||||
latLng.setLongitude(startValue.getLongitude()
|
||||
+ ((endValue.getLongitude() - startValue.getLongitude()) * fraction));
|
||||
return latLng;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class Car {
|
||||
private Feature feature;
|
||||
private LatLng next;
|
||||
private LatLng current;
|
||||
private long duration;
|
||||
|
||||
Car(Feature feature, LatLng next, long duration) {
|
||||
this.feature = feature;
|
||||
Point point = ((Point) feature.geometry());
|
||||
this.current = new LatLng(point.latitude(), point.longitude());
|
||||
this.duration = duration;
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
void setNext(LatLng next) {
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
void updateFeature() {
|
||||
feature = Feature.fromGeometry(Point.fromLngLat(
|
||||
current.getLongitude(),
|
||||
current.getLatitude())
|
||||
);
|
||||
feature.properties().addProperty("bearing", getBearing(current, next));
|
||||
}
|
||||
|
||||
private static float getBearing(LatLng from, LatLng to) {
|
||||
return (float) TurfMeasurement.bearing(
|
||||
Point.fromLngLat(from.getLongitude(), from.getLatitude()),
|
||||
Point.fromLngLat(to.getLongitude(), to.getLatitude())
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,7 +115,9 @@ public class CameraAnimatorActivity extends AppCompatActivity implements OnMapRe
|
||||
ValueAnimator latLngAnimator = ValueAnimator.ofObject(new LatLngEvaluator(), currentPosition, targetPosition);
|
||||
latLngAnimator.setDuration((long) (1000 * ANIMATION_DELAY_FACTOR));
|
||||
latLngAnimator.setInterpolator(new FastOutSlowInInterpolator());
|
||||
latLngAnimator.addUpdateListener(animation -> mapboxMap.setLatLng((LatLng) animation.getAnimatedValue()));
|
||||
latLngAnimator.addUpdateListener(animation -> mapboxMap.moveCamera(
|
||||
CameraUpdateFactory.newLatLng((LatLng) animation.getAnimatedValue()))
|
||||
);
|
||||
return latLngAnimator;
|
||||
}
|
||||
|
||||
@@ -124,7 +126,9 @@ public class CameraAnimatorActivity extends AppCompatActivity implements OnMapRe
|
||||
zoomAnimator.setDuration((long) (2200 * ANIMATION_DELAY_FACTOR));
|
||||
zoomAnimator.setStartDelay((long) (600 * ANIMATION_DELAY_FACTOR));
|
||||
zoomAnimator.setInterpolator(new AnticipateOvershootInterpolator());
|
||||
zoomAnimator.addUpdateListener(animation -> mapboxMap.setZoom((Float) animation.getAnimatedValue()));
|
||||
zoomAnimator.addUpdateListener(animation -> mapboxMap.moveCamera(
|
||||
CameraUpdateFactory.zoomTo((Float) animation.getAnimatedValue()))
|
||||
);
|
||||
return zoomAnimator;
|
||||
}
|
||||
|
||||
@@ -133,7 +137,9 @@ public class CameraAnimatorActivity extends AppCompatActivity implements OnMapRe
|
||||
bearingAnimator.setDuration((long) (1000 * ANIMATION_DELAY_FACTOR));
|
||||
bearingAnimator.setStartDelay((long) (1000 * ANIMATION_DELAY_FACTOR));
|
||||
bearingAnimator.setInterpolator(new FastOutLinearInInterpolator());
|
||||
bearingAnimator.addUpdateListener(animation -> mapboxMap.setBearing((Float) animation.getAnimatedValue()));
|
||||
bearingAnimator.addUpdateListener(animation -> mapboxMap.moveCamera(
|
||||
CameraUpdateFactory.bearingTo((Float) animation.getAnimatedValue()))
|
||||
);
|
||||
return bearingAnimator;
|
||||
}
|
||||
|
||||
@@ -141,7 +147,9 @@ public class CameraAnimatorActivity extends AppCompatActivity implements OnMapRe
|
||||
ValueAnimator tiltAnimator = ValueAnimator.ofFloat((float) currentTilt, (float) targetTilt);
|
||||
tiltAnimator.setDuration((long) (1000 * ANIMATION_DELAY_FACTOR));
|
||||
tiltAnimator.setStartDelay((long) (1500 * ANIMATION_DELAY_FACTOR));
|
||||
tiltAnimator.addUpdateListener(animation -> mapboxMap.setTilt((Float) animation.getAnimatedValue()));
|
||||
tiltAnimator.addUpdateListener(animation -> mapboxMap.moveCamera(
|
||||
CameraUpdateFactory.tiltTo((Float) animation.getAnimatedValue()))
|
||||
);
|
||||
return tiltAnimator;
|
||||
}
|
||||
|
||||
@@ -195,7 +203,9 @@ public class CameraAnimatorActivity extends AppCompatActivity implements OnMapRe
|
||||
ValueAnimator zoomAnimator = ValueAnimator.ofFloat(11.0f, 16.0f);
|
||||
zoomAnimator.setDuration((long) (duration * ANIMATION_DELAY_FACTOR));
|
||||
zoomAnimator.setInterpolator(interpolator);
|
||||
zoomAnimator.addUpdateListener(animation -> mapboxMap.setZoom((Float) animation.getAnimatedValue()));
|
||||
zoomAnimator.addUpdateListener(animation -> mapboxMap.moveCamera(
|
||||
CameraUpdateFactory.zoomTo((Float) animation.getAnimatedValue()))
|
||||
);
|
||||
return zoomAnimator;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,422 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.camera;
|
||||
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.IntDef;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mapbox.android.gestures.AndroidGesturesManager;
|
||||
import com.mapbox.android.gestures.MoveGestureDetector;
|
||||
import com.mapbox.android.gestures.RotateGestureDetector;
|
||||
import com.mapbox.android.gestures.ShoveGestureDetector;
|
||||
import com.mapbox.android.gestures.StandardScaleGestureDetector;
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
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.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.FontCache;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.ResourceUtils;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.SOURCE;
|
||||
|
||||
/**
|
||||
* Test activity showcasing APIs around gestures implementation.
|
||||
*/
|
||||
public class GestureDetectorActivity extends AppCompatActivity {
|
||||
|
||||
private static final int MAX_NUMBER_OF_ALERTS = 30;
|
||||
|
||||
private MapView mapView;
|
||||
private MapboxMap mapboxMap;
|
||||
private RecyclerView recyclerView;
|
||||
private GestureAlertsAdapter gestureAlertsAdapter;
|
||||
|
||||
private AndroidGesturesManager gesturesManager;
|
||||
|
||||
@Nullable
|
||||
private Marker marker;
|
||||
@Nullable
|
||||
private LatLng focalPointLatLng;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_gesture_detector);
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(MapboxMap mapboxMap) {
|
||||
GestureDetectorActivity.this.mapboxMap = mapboxMap;
|
||||
initializeMap();
|
||||
}
|
||||
});
|
||||
|
||||
recyclerView = (RecyclerView) findViewById(R.id.alerts_recycler);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
|
||||
gestureAlertsAdapter = new GestureAlertsAdapter();
|
||||
recyclerView.setAdapter(gestureAlertsAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mapView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
gestureAlertsAdapter.cancelUpdates();
|
||||
mapView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mapView.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mapView.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
super.onLowMemory();
|
||||
mapView.onLowMemory();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mapView.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
mapView.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
private void initializeMap() {
|
||||
gesturesManager = mapboxMap.getGesturesManager();
|
||||
|
||||
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) recyclerView.getLayoutParams();
|
||||
layoutParams.height = (int) (mapView.getHeight() / 1.75);
|
||||
layoutParams.width = (mapView.getWidth() / 3);
|
||||
recyclerView.setLayoutParams(layoutParams);
|
||||
|
||||
attachListeners();
|
||||
}
|
||||
|
||||
public void attachListeners() {
|
||||
mapboxMap.addOnMoveListener(new MapboxMap.OnMoveListener() {
|
||||
@Override
|
||||
public void onMoveBegin(MoveGestureDetector detector) {
|
||||
gestureAlertsAdapter.addAlert(new GestureAlert(GestureAlert.TYPE_START, "MOVE START"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMove(MoveGestureDetector detector) {
|
||||
gestureAlertsAdapter.addAlert(new GestureAlert(GestureAlert.TYPE_PROGRESS, "MOVE PROGRESS"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMoveEnd(MoveGestureDetector detector) {
|
||||
gestureAlertsAdapter.addAlert(new GestureAlert(GestureAlert.TYPE_END, "MOVE END"));
|
||||
}
|
||||
});
|
||||
|
||||
mapboxMap.addOnRotateListener(new MapboxMap.OnRotateListener() {
|
||||
@Override
|
||||
public void onRotateBegin(RotateGestureDetector detector) {
|
||||
gestureAlertsAdapter.addAlert(new GestureAlert(GestureAlert.TYPE_START, "ROTATE START"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRotate(RotateGestureDetector detector) {
|
||||
gestureAlertsAdapter.addAlert(new GestureAlert(GestureAlert.TYPE_PROGRESS, "ROTATE PROGRESS"));
|
||||
recalculateFocalPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRotateEnd(RotateGestureDetector detector) {
|
||||
gestureAlertsAdapter.addAlert(new GestureAlert(GestureAlert.TYPE_END, "ROTATE END"));
|
||||
}
|
||||
});
|
||||
|
||||
mapboxMap.addOnScaleListener(new MapboxMap.OnScaleListener() {
|
||||
@Override
|
||||
public void onScaleBegin(StandardScaleGestureDetector detector) {
|
||||
gestureAlertsAdapter.addAlert(new GestureAlert(GestureAlert.TYPE_START, "SCALE START"));
|
||||
if (focalPointLatLng != null) {
|
||||
gestureAlertsAdapter.addAlert(new GestureAlert(GestureAlert.TYPE_OTHER, "INCREASING MOVE THRESHOLD"));
|
||||
gesturesManager.getMoveGestureDetector().setMoveThreshold(
|
||||
ResourceUtils.convertDpToPx(GestureDetectorActivity.this, 175));
|
||||
|
||||
gestureAlertsAdapter.addAlert(new GestureAlert(GestureAlert.TYPE_OTHER, "MANUALLY INTERRUPTING MOVE"));
|
||||
gesturesManager.getMoveGestureDetector().interrupt();
|
||||
}
|
||||
recalculateFocalPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScale(StandardScaleGestureDetector detector) {
|
||||
gestureAlertsAdapter.addAlert(new GestureAlert(GestureAlert.TYPE_PROGRESS, "SCALE PROGRESS"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScaleEnd(StandardScaleGestureDetector detector) {
|
||||
gestureAlertsAdapter.addAlert(new GestureAlert(GestureAlert.TYPE_END, "SCALE END"));
|
||||
|
||||
if (focalPointLatLng != null) {
|
||||
gestureAlertsAdapter.addAlert(new GestureAlert(GestureAlert.TYPE_OTHER, "REVERTING MOVE THRESHOLD"));
|
||||
gesturesManager.getMoveGestureDetector().setMoveThreshold(0f);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mapboxMap.addOnShoveListener(new MapboxMap.OnShoveListener() {
|
||||
@Override
|
||||
public void onShoveBegin(ShoveGestureDetector detector) {
|
||||
gestureAlertsAdapter.addAlert(new GestureAlert(GestureAlert.TYPE_START, "SHOVE START"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShove(ShoveGestureDetector detector) {
|
||||
gestureAlertsAdapter.addAlert(new GestureAlert(GestureAlert.TYPE_PROGRESS, "SHOVE PROGRESS"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShoveEnd(ShoveGestureDetector detector) {
|
||||
gestureAlertsAdapter.addAlert(new GestureAlert(GestureAlert.TYPE_END, "SHOVE END"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_gestures, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
resetModes();
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_gesture_none:
|
||||
return true;
|
||||
case R.id.menu_gesture_focus_point:
|
||||
focalPointLatLng = new LatLng(51.50325, -0.12968);
|
||||
marker = mapboxMap.addMarker(new MarkerOptions().position(focalPointLatLng));
|
||||
mapboxMap.easeCamera(CameraUpdateFactory.newLatLngZoom(focalPointLatLng, 16));
|
||||
mapboxMap.getUiSettings().setFocalPoint(mapboxMap.getProjection().toScreenLocation(focalPointLatLng));
|
||||
return true;
|
||||
case R.id.menu_gesture_animation:
|
||||
mapboxMap.getUiSettings().setAllVelocityAnimationsEnabled(false);
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private void resetModes() {
|
||||
focalPointLatLng = null;
|
||||
mapboxMap.getUiSettings().setFocalPoint(null);
|
||||
gesturesManager.getMoveGestureDetector().setMoveThreshold(0f);
|
||||
mapboxMap.getUiSettings().setAllVelocityAnimationsEnabled(true);
|
||||
|
||||
if (marker != null) {
|
||||
mapboxMap.removeMarker(marker);
|
||||
marker = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void recalculateFocalPoint() {
|
||||
if (focalPointLatLng != null) {
|
||||
mapboxMap.getUiSettings().setFocalPoint(
|
||||
mapboxMap.getProjection().toScreenLocation(focalPointLatLng)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private static class GestureAlertsAdapter extends RecyclerView.Adapter<GestureAlertsAdapter.ViewHolder> {
|
||||
|
||||
private boolean isUpdating;
|
||||
private final Handler updateHandler = new Handler();
|
||||
private final List<GestureAlert> alerts = new ArrayList<>();
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
TextView alertMessageTv;
|
||||
|
||||
@ColorInt
|
||||
public int textColor;
|
||||
|
||||
ViewHolder(View view) {
|
||||
super(view);
|
||||
Typeface typeface = FontCache.get("Roboto-Regular.ttf", view.getContext());
|
||||
alertMessageTv = (TextView) view.findViewById(R.id.alert_message);
|
||||
alertMessageTv.setTypeface(typeface);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_gesture_alert, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
GestureAlert alert = alerts.get(position);
|
||||
holder.alertMessageTv.setText(alert.getMessage());
|
||||
holder.alertMessageTv.setTextColor(
|
||||
ContextCompat.getColor(holder.alertMessageTv.getContext(), alert.getColor()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return alerts.size();
|
||||
}
|
||||
|
||||
void addAlert(GestureAlert alert) {
|
||||
for (GestureAlert gestureAlert : alerts) {
|
||||
if (gestureAlert.getAlertType() != GestureAlert.TYPE_PROGRESS) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (alert.getAlertType() == GestureAlert.TYPE_PROGRESS && gestureAlert.equals(alert)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (getItemCount() >= MAX_NUMBER_OF_ALERTS) {
|
||||
alerts.remove(getItemCount() - 1);
|
||||
}
|
||||
|
||||
alerts.add(0, alert);
|
||||
if (!isUpdating) {
|
||||
isUpdating = true;
|
||||
updateHandler.postDelayed(updateRunnable, 250);
|
||||
}
|
||||
}
|
||||
|
||||
private Runnable updateRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
notifyDataSetChanged();
|
||||
isUpdating = false;
|
||||
}
|
||||
};
|
||||
|
||||
void cancelUpdates() {
|
||||
updateHandler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
}
|
||||
|
||||
private static class GestureAlert {
|
||||
@Retention(SOURCE)
|
||||
@IntDef( {TYPE_NONE, TYPE_START, TYPE_PROGRESS, TYPE_END, TYPE_OTHER})
|
||||
@interface Type {
|
||||
}
|
||||
|
||||
static final int TYPE_NONE = 0;
|
||||
static final int TYPE_START = 1;
|
||||
static final int TYPE_END = 2;
|
||||
static final int TYPE_PROGRESS = 3;
|
||||
static final int TYPE_OTHER = 4;
|
||||
|
||||
@Type
|
||||
private int alertType;
|
||||
|
||||
private String message;
|
||||
|
||||
@ColorInt
|
||||
private int color;
|
||||
|
||||
GestureAlert(@Type int alertType, String message) {
|
||||
this.alertType = alertType;
|
||||
this.message = message;
|
||||
|
||||
switch (alertType) {
|
||||
case TYPE_NONE:
|
||||
color = android.R.color.black;
|
||||
break;
|
||||
case TYPE_END:
|
||||
color = android.R.color.holo_red_dark;
|
||||
break;
|
||||
case TYPE_OTHER:
|
||||
color = android.R.color.holo_purple;
|
||||
break;
|
||||
case TYPE_PROGRESS:
|
||||
color = android.R.color.holo_orange_dark;
|
||||
break;
|
||||
case TYPE_START:
|
||||
color = android.R.color.holo_green_dark;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int getAlertType() {
|
||||
return alertType;
|
||||
}
|
||||
|
||||
String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
int getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GestureAlert that = (GestureAlert) o;
|
||||
|
||||
if (alertType != that.alertType) {
|
||||
return false;
|
||||
}
|
||||
return message != null ? message.equals(that.message) : that.message == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = alertType;
|
||||
result = 31 * result + (message != null ? message.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,11 +58,7 @@ public class CustomLayerActivity extends AppCompatActivity {
|
||||
fab.setImageResource(R.drawable.ic_layers);
|
||||
} else {
|
||||
customLayer = new CustomLayer("custom",
|
||||
ExampleCustomLayer.createContext(),
|
||||
ExampleCustomLayer.InitializeFunction,
|
||||
ExampleCustomLayer.RenderFunction,
|
||||
ExampleCustomLayer.ContextLostFunction, // Optional
|
||||
ExampleCustomLayer.DeinitializeFunction);
|
||||
ExampleCustomLayer.createContext());
|
||||
mapboxMap.addLayerBelow(customLayer, "building");
|
||||
fab.setImageResource(R.drawable.ic_layers_clear);
|
||||
}
|
||||
|
||||
@@ -11,16 +11,19 @@ import com.mapbox.geojson.Feature;
|
||||
import com.mapbox.geojson.FeatureCollection;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.expressions.Expression;
|
||||
import com.mapbox.mapboxsdk.style.layers.FillLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.Filter;
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.lt;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.toNumber;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillColor;
|
||||
|
||||
/**
|
||||
@@ -58,7 +61,9 @@ public class QueryRenderedFeaturesBoxHighlightActivity extends AppCompatActivity
|
||||
int left = selectionBox.getLeft() - mapView.getLeft();
|
||||
RectF box = new RectF(left, top, left + selectionBox.getWidth(), top + selectionBox.getHeight());
|
||||
Timber.i("Querying box %s for buildings", box);
|
||||
List<Feature> features = mapboxMap.queryRenderedFeatures(box, Filter.lt("height", 10), "building");
|
||||
|
||||
Expression filter = lt(toNumber(get("height")), literal(10));
|
||||
List<Feature> features = mapboxMap.queryRenderedFeatures(box, filter, "building");
|
||||
|
||||
// Show count
|
||||
Toast.makeText(
|
||||
|
||||
@@ -11,13 +11,16 @@ import com.mapbox.geojson.Point;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.Filter;
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.eq;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.neq;
|
||||
|
||||
/**
|
||||
* Test activity showcasing using the query source features API to query feature counts
|
||||
*/
|
||||
@@ -31,8 +34,6 @@ public class QuerySourceFeaturesActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_query_source_features);
|
||||
|
||||
final float density = getResources().getDisplayMetrics().density;
|
||||
|
||||
// Initialize map as normal
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
@@ -47,12 +48,12 @@ public class QuerySourceFeaturesActivity extends AppCompatActivity {
|
||||
}));
|
||||
mapboxMap.addSource(source);
|
||||
|
||||
mapboxMap.addLayer(new CircleLayer("test-layer", source.getId()).withFilter(Filter.neq("key1", "value1")));
|
||||
mapboxMap.addLayer(new CircleLayer("test-layer", source.getId()).withFilter(neq(get("key1"), literal("value1"))));
|
||||
|
||||
// Add a click listener
|
||||
mapboxMap.setOnMapClickListener(point -> {
|
||||
// Query
|
||||
List<Feature> features = source.querySourceFeatures(Filter.eq("key1", "value1"));
|
||||
List<Feature> features = source.querySourceFeatures(eq(get("key1"), literal("value1")));
|
||||
Toast.makeText(QuerySourceFeaturesActivity.this, String.format("Found %s features",
|
||||
features.size()), Toast.LENGTH_SHORT).show();
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.imagegenerator;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
@@ -16,6 +17,8 @@ import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
/**
|
||||
* Test activity showcasing the Snapshot API to create and display a bitmap of the current shown Map.
|
||||
*/
|
||||
@@ -75,6 +78,12 @@ public class SnapshotActivity extends AppCompatActivity implements OnMapReadyCal
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mapboxMap.snapshot(new MapboxMap.SnapshotReadyCallback() {
|
||||
@Override
|
||||
public void onSnapshotReady(Bitmap snapshot) {
|
||||
Timber.e("Regression test for https://github.com/mapbox/mapbox-gl-native/pull/11358");
|
||||
}
|
||||
});
|
||||
mapView.onPause();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.maplayout;
|
||||
|
||||
import android.content.Context;
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
@@ -151,10 +150,7 @@ public class BottomSheetActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
public void onMapReady(MapboxMap mapboxMap) {
|
||||
Location location = mapboxMap.getMyLocation();
|
||||
if (location != null) {
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 15));
|
||||
}
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(37.760545, -122.436055), 15));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -207,7 +203,6 @@ public class BottomSheetActivity extends AppCompatActivity {
|
||||
public static BottomSheetFragment newInstance() {
|
||||
BottomSheetFragment mapFragment = new BottomSheetFragment();
|
||||
MapboxMapOptions mapboxMapOptions = new MapboxMapOptions();
|
||||
mapboxMapOptions.locationEnabled(true);
|
||||
mapboxMapOptions.renderSurfaceOnTop(true);
|
||||
mapboxMapOptions.styleUrl(Style.LIGHT);
|
||||
mapFragment.setArguments(MapFragmentUtils.createFragmentArgs(mapboxMapOptions));
|
||||
@@ -230,10 +225,7 @@ public class BottomSheetActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
public void onMapReady(MapboxMap mapboxMap) {
|
||||
Location location = mapboxMap.getMyLocation();
|
||||
if (location != null) {
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 15));
|
||||
}
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(37.760545, -122.436055), 15));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,11 +11,9 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.constants.MyLocationTracking;
|
||||
import com.mapbox.mapboxsdk.constants.Style;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.TrackingSettings;
|
||||
import com.mapbox.mapboxsdk.maps.UiSettings;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
@@ -50,14 +48,6 @@ public class DoubleMapActivity extends AppCompatActivity {
|
||||
mapboxMap = map;
|
||||
mapboxMap.setStyleUrl(Style.DARK);
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(18));
|
||||
try {
|
||||
mapboxMap.setMyLocationEnabled(true);
|
||||
TrackingSettings settings = mapboxMap.getTrackingSettings();
|
||||
settings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
|
||||
} catch (SecurityException securityException) {
|
||||
// permission is handled in MainActivity
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,15 +96,6 @@ public class DoubleMapActivity extends AppCompatActivity {
|
||||
uiSettings.setAttributionEnabled(false);
|
||||
uiSettings.setLogoEnabled(false);
|
||||
|
||||
try {
|
||||
mapboxMap.setMyLocationEnabled(true);
|
||||
TrackingSettings settings = mapboxMap.getTrackingSettings();
|
||||
settings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
|
||||
} catch (SecurityException securityException) {
|
||||
// permission is handled in MainActivity
|
||||
getActivity().finish();
|
||||
}
|
||||
|
||||
mapboxMap.setOnMapClickListener(point -> {
|
||||
// test if we can open 2 activities after each other
|
||||
startActivity(new Intent(mapViewMini.getContext(), DoubleMapActivity.class));
|
||||
|
||||
@@ -8,18 +8,13 @@ import android.view.MenuItem;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.constants.MyLocationTracking;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.TrackingSettings;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
/**
|
||||
* Test activity showcasing using the map padding API.
|
||||
* <p>
|
||||
* This activity tests for correct padding around a marker (Bangalore) and correct padding around MyLocationView.
|
||||
* </p>
|
||||
*/
|
||||
public class MapPaddingActivity extends AppCompatActivity {
|
||||
|
||||
@@ -96,24 +91,7 @@ public class MapPaddingActivity extends AppCompatActivity {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void toggleGps(boolean enable) {
|
||||
try {
|
||||
// Enable user location
|
||||
mapboxMap.setMyLocationEnabled(enable);
|
||||
|
||||
TrackingSettings trackingSettings = mapboxMap.getTrackingSettings();
|
||||
trackingSettings.setDismissLocationTrackingOnGesture(false);
|
||||
trackingSettings.setMyLocationTrackingMode(
|
||||
enable ? MyLocationTracking.TRACKING_FOLLOW : MyLocationTracking.TRACKING_NONE);
|
||||
} catch (SecurityException securityException) {
|
||||
// permission not granted is handled in FeatureOverviewActivity
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
private void moveToBangalore() {
|
||||
toggleGps(false);
|
||||
|
||||
LatLng bangalore = new LatLng(12.9810816, 77.6368034);
|
||||
CameraPosition cameraPosition = new CameraPosition.Builder()
|
||||
.zoom(16)
|
||||
@@ -129,11 +107,6 @@ public class MapPaddingActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_user_tracking:
|
||||
if (mapboxMap != null) {
|
||||
toggleGps(true);
|
||||
}
|
||||
return true;
|
||||
|
||||
case R.id.action_bangalore:
|
||||
if (mapboxMap != null) {
|
||||
|
||||
@@ -8,8 +8,7 @@ import android.view.MenuItem;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.functions.Function;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.expressions.Expression;
|
||||
import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.Property;
|
||||
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
|
||||
@@ -17,7 +16,9 @@ import com.mapbox.mapboxsdk.style.light.Light;
|
||||
import com.mapbox.mapboxsdk.style.light.Position;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.Filter.eq;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.eq;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionBase;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionHeight;
|
||||
@@ -53,12 +54,12 @@ public class BuildingFillExtrusionActivity extends AppCompatActivity {
|
||||
private void setupBuildings() {
|
||||
FillExtrusionLayer fillExtrusionLayer = new FillExtrusionLayer("3d-buildings", "composite");
|
||||
fillExtrusionLayer.setSourceLayer("building");
|
||||
fillExtrusionLayer.setFilter(eq("extrude", "true"));
|
||||
fillExtrusionLayer.setFilter(eq(get("extrude"), literal("true")));
|
||||
fillExtrusionLayer.setMinZoom(15);
|
||||
fillExtrusionLayer.setProperties(
|
||||
fillExtrusionColor(Color.LTGRAY),
|
||||
fillExtrusionHeight(Function.property("height", new IdentityStops<Float>())),
|
||||
fillExtrusionBase(Function.property("min_height", new IdentityStops<Float>())),
|
||||
fillExtrusionHeight(Expression.get("height")),
|
||||
fillExtrusionBase(Expression.get("min_height")),
|
||||
fillExtrusionOpacity(0.9f)
|
||||
);
|
||||
mapboxMap.addLayer(fillExtrusionLayer);
|
||||
|
||||
@@ -13,6 +13,7 @@ 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.style.expressions.Expression;
|
||||
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.LineLayer;
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
|
||||
@@ -23,7 +24,10 @@ import java.net.URL;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.Filter.in;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.array;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.has;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius;
|
||||
|
||||
@@ -117,7 +121,7 @@ public class CircleLayerActivity extends AppCompatActivity implements View.OnCli
|
||||
}
|
||||
|
||||
private void applyBusRouteFilterToBusStopSource() {
|
||||
layer.setFilter(in("number", (Object[]) Data.STOPS_FOR_ROUTE));
|
||||
layer.setFilter(has(Expression.toString(get("number")), array(literal(Data.STOPS_FOR_ROUTE))));
|
||||
}
|
||||
|
||||
private void addBusRouteSource() {
|
||||
|
||||
@@ -23,16 +23,18 @@ import java.io.IOException;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.color;
|
||||
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.linear;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.match;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.rgb;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.rgba;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.step;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.stop;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.zoom;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.color;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillAntialias;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOpacity;
|
||||
@@ -165,7 +167,6 @@ public class DataDrivenStyleActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void addExponentialZoomFunction() {
|
||||
Timber.i("Add exponential zoom function");
|
||||
FillLayer layer = mapboxMap.getLayerAs("water");
|
||||
@@ -191,10 +192,10 @@ public class DataDrivenStyleActivity extends AppCompatActivity {
|
||||
layer.setProperties(
|
||||
fillColor(
|
||||
step(zoom(),
|
||||
color(Color.CYAN),
|
||||
stop(1, color(Color.RED)),
|
||||
stop(5, color(Color.BLUE)),
|
||||
stop(10, color(Color.GREEN))
|
||||
rgba(0.0f, 255.0f, 255.0f, 1.0f),
|
||||
stop(1, rgba(255.0f, 0.0f, 0.0f, 1.0f)),
|
||||
stop(5, rgba(0.0f, 0.0f, 255.0f, 1.0f)),
|
||||
stop(10, rgba(0.0f, 255.0f, 0.0f, 1.0f))
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -211,9 +212,9 @@ public class DataDrivenStyleActivity extends AppCompatActivity {
|
||||
interpolate(
|
||||
exponential(0.5f),
|
||||
get("stroke-width"),
|
||||
stop(1f, color(Color.RED)),
|
||||
stop(5f, color(Color.BLUE)),
|
||||
stop(10f, color(Color.GREEN))
|
||||
stop(1f, rgba(255.0f, 0.0f, 0.0f, 1.0f)),
|
||||
stop(5f, rgba(0.0f, 0.0f, 255.0f, 1.0f)),
|
||||
stop(10f, rgba(0.0f, 255.0f, 0.0f, 1.0f))
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -229,10 +230,10 @@ public class DataDrivenStyleActivity extends AppCompatActivity {
|
||||
fillColor(
|
||||
match(
|
||||
get("name"),
|
||||
literal("Westerpark"), color(Color.RED),
|
||||
literal("Jordaan"), color(Color.BLUE),
|
||||
literal("Prinseneiland"), color(Color.GREEN),
|
||||
color(Color.CYAN)
|
||||
literal("Westerpark"), rgba(255.0f, 0.0f, 0.0f, 1.0f),
|
||||
literal("Jordaan"), rgba(0.0f, 0.0f, 255.0f, 1.0f),
|
||||
literal("Prinseneiland"), rgba(0.0f, 255.0f, 0.0f, 1.0f),
|
||||
rgba(0.0f, 255.0f, 255.0f, 1.0f)
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -261,10 +262,10 @@ public class DataDrivenStyleActivity extends AppCompatActivity {
|
||||
fillColor(
|
||||
step(
|
||||
get("stroke-width"),
|
||||
color(Color.CYAN),
|
||||
stop(1f, color(Color.RED)),
|
||||
stop(2f, color(Color.BLUE)),
|
||||
stop(3f, color(Color.GREEN))
|
||||
rgba(0.0f, 255.0f, 255.0f, 1.0f),
|
||||
stop(1f, rgba(255.0f, 0.0f, 0.0f, 1.0f)),
|
||||
stop(2f, rgba(0.0f, 0.0f, 255.0f, 1.0f)),
|
||||
stop(3f, rgba(0.0f, 255.0f, 0.0f, 1.0f))
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -283,24 +284,24 @@ public class DataDrivenStyleActivity extends AppCompatActivity {
|
||||
zoom(),
|
||||
stop(12, step(
|
||||
get("stroke-width"),
|
||||
color(Color.BLACK),
|
||||
stop(1f, color(Color.RED)),
|
||||
stop(2f, color(Color.WHITE)),
|
||||
stop(3f, color(Color.BLUE))
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f),
|
||||
stop(1f, rgba(255.0f, 0.0f, 0.0f, 1.0f)),
|
||||
stop(2f, rgba(0.0f, 0.0f, 0.0f, 1.0f)),
|
||||
stop(3f, rgba(0.0f, 0.0f, 255.0f, 1.0f))
|
||||
)),
|
||||
stop(15, step(
|
||||
get("stroke-width"),
|
||||
color(Color.BLACK),
|
||||
stop(1f, color(Color.YELLOW)),
|
||||
stop(2f, color(Color.LTGRAY)),
|
||||
stop(3f, color(Color.CYAN))
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f),
|
||||
stop(1f, rgba(255.0f, 255.0f, 0.0f, 1.0f)),
|
||||
stop(2f, rgba(211.0f, 211.0f, 211.0f, 1.0f)),
|
||||
stop(3f, rgba(0.0f, 255.0f, 255.0f, 1.0f))
|
||||
)),
|
||||
stop(18, step(
|
||||
get("stroke-width"),
|
||||
color(Color.BLACK),
|
||||
stop(1f, color(Color.WHITE)),
|
||||
stop(2f, color(Color.GRAY)),
|
||||
stop(3f, color(Color.GREEN)))
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f),
|
||||
stop(1f, rgba(0.0f, 0.0f, 0.0f, 1.0f)),
|
||||
stop(2f, rgba(128.0f, 128.0f, 128.0f, 1.0f)),
|
||||
stop(3f, rgba(0.0f, 255.0f, 0.0f, 1.0f)))
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -320,24 +321,24 @@ public class DataDrivenStyleActivity extends AppCompatActivity {
|
||||
zoom(),
|
||||
stop(12, step(
|
||||
get("stroke-width"),
|
||||
color(Color.BLACK),
|
||||
stop(1f, color(Color.RED)),
|
||||
stop(2f, color(Color.WHITE)),
|
||||
stop(3f, color(Color.BLUE))
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f),
|
||||
stop(1f, rgba(255.0f, 0.0f, 0.0f, 1.0f)),
|
||||
stop(2f, rgba(0.0f, 0.0f, 0.0f, 1.0f)),
|
||||
stop(3f, rgba(0.0f, 0.0f, 255.0f, 1.0f))
|
||||
)),
|
||||
stop(15, step(
|
||||
get("stroke-width"),
|
||||
color(Color.BLACK),
|
||||
stop(1f, color(Color.YELLOW)),
|
||||
stop(2f, color(Color.LTGRAY)),
|
||||
stop(3f, color(Color.CYAN))
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f),
|
||||
stop(1f, rgba(255.0f, 255.0f, 0.0f, 1.0f)),
|
||||
stop(2f, rgba(211.0f, 211.0f, 211.0f, 1.0f)),
|
||||
stop(3f, rgba(0.0f, 255.0f, 255.0f, 1.0f))
|
||||
)),
|
||||
stop(18, step(
|
||||
get("stroke-width"),
|
||||
color(Color.BLACK),
|
||||
stop(1f, color(Color.WHITE)),
|
||||
stop(2f, color(Color.GRAY)),
|
||||
stop(3f, color(Color.GREEN))
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f),
|
||||
stop(1f, rgba(0.0f, 0.0f, 0.0f, 1.0f)),
|
||||
stop(2f, rgba(128.0f, 128.0f, 128.0f, 1.0f)),
|
||||
stop(3f, rgba(0.0f, 255.0f, 0.0f, 1.0f))
|
||||
))
|
||||
)
|
||||
)
|
||||
@@ -353,89 +354,89 @@ public class DataDrivenStyleActivity extends AppCompatActivity {
|
||||
layer.setProperties(
|
||||
fillColor(
|
||||
step(zoom(),
|
||||
color(Color.BLACK),
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f),
|
||||
stop(7f, match(
|
||||
get("name"),
|
||||
literal("Westerpark"), color(Color.RED),
|
||||
color(Color.BLACK)
|
||||
literal("Westerpark"), rgba(255.0f, 0.0f, 0.0f, 1.0f),
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f)
|
||||
)),
|
||||
stop(8f, match(
|
||||
get("name"),
|
||||
literal("Westerpark"), color(Color.BLUE),
|
||||
color(Color.BLACK)
|
||||
literal("Westerpark"), rgba(0.0f, 0.0f, 255.0f, 1.0f),
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f)
|
||||
)),
|
||||
stop(9f, match(
|
||||
get("name"),
|
||||
literal("Westerpark"), color(Color.RED),
|
||||
color(Color.BLACK)
|
||||
literal("Westerpark"), rgba(255.0f, 0.0f, 0.0f, 1.0f),
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f)
|
||||
)),
|
||||
stop(10f, match(
|
||||
get("name"),
|
||||
literal("Westerpark"), color(Color.BLUE),
|
||||
color(Color.BLACK)
|
||||
literal("Westerpark"), rgba(0.0f, 0.0f, 255.0f, 1.0f),
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f)
|
||||
)),
|
||||
stop(11f, match(
|
||||
get("name"),
|
||||
literal("Westerpark"), color(Color.RED),
|
||||
color(Color.BLACK)
|
||||
literal("Westerpark"), rgba(255.0f, 0.0f, 0.0f, 1.0f),
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f)
|
||||
)),
|
||||
stop(12f, match(
|
||||
get("name"),
|
||||
literal("Westerpark"), color(Color.BLUE),
|
||||
color(Color.BLACK)
|
||||
literal("Westerpark"), rgba(0.0f, 0.0f, 255.0f, 1.0f),
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f)
|
||||
)),
|
||||
stop(13f, match(
|
||||
get("name"),
|
||||
literal("Westerpark"), color(Color.RED),
|
||||
color(Color.BLACK)
|
||||
literal("Westerpark"), rgba(255.0f, 0.0f, 0.0f, 1.0f),
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f)
|
||||
)),
|
||||
stop(14f, match(
|
||||
get("name"),
|
||||
literal("Westerpark"), color(Color.BLUE),
|
||||
literal("Jordaan"), color(Color.GREEN),
|
||||
literal("PrinsenEiland"), color(Color.WHITE),
|
||||
color(Color.BLACK)
|
||||
literal("Westerpark"), rgba(0.0f, 0.0f, 255.0f, 1.0f),
|
||||
literal("Jordaan"), rgba(0.0f, 255.0f, 0.0f, 1.0f),
|
||||
literal("PrinsenEiland"), rgba(0.0f, 0.0f, 0.0f, 1.0f),
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f)
|
||||
)),
|
||||
stop(15f, match(
|
||||
get("name"),
|
||||
literal("Westerpark"), color(Color.RED),
|
||||
color(Color.BLACK)
|
||||
literal("Westerpark"), rgba(255.0f, 0.0f, 0.0f, 1.0f),
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f)
|
||||
)),
|
||||
stop(16f, match(
|
||||
get("name"),
|
||||
literal("Westerpark"), color(Color.BLUE),
|
||||
color(Color.BLACK)
|
||||
literal("Westerpark"), rgba(0.0f, 0.0f, 255.0f, 1.0f),
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f)
|
||||
)),
|
||||
stop(17f, match(
|
||||
get("name"),
|
||||
literal("Westerpark"), color(Color.RED),
|
||||
color(Color.BLACK)
|
||||
literal("Westerpark"), rgba(255.0f, 0.0f, 0.0f, 1.0f),
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f)
|
||||
)),
|
||||
stop(18f, match(
|
||||
get("name"),
|
||||
literal("Westerpark"), color(Color.BLUE),
|
||||
literal("Jordaan"), color(Color.CYAN),
|
||||
color(Color.BLACK)
|
||||
literal("Westerpark"), rgba(0.0f, 0.0f, 255.0f, 1.0f),
|
||||
literal("Jordaan"), rgba(0.0f, 255.0f, 255.0f, 1.0f),
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f)
|
||||
)),
|
||||
stop(19f, match(
|
||||
get("name"),
|
||||
literal("Westerpark"), color(Color.RED),
|
||||
color(Color.BLACK)
|
||||
literal("Westerpark"), rgba(255.0f, 0.0f, 0.0f, 1.0f),
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f)
|
||||
)),
|
||||
stop(20f, match(
|
||||
get("name"),
|
||||
literal("Westerpark"), color(Color.BLUE),
|
||||
color(Color.BLACK)
|
||||
literal("Westerpark"), rgba(0.0f, 0.0f, 255.0f, 1.0f),
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f)
|
||||
)),
|
||||
stop(21f, match(
|
||||
get("name"),
|
||||
literal("Westerpark"), color(Color.RED),
|
||||
color(Color.BLACK)
|
||||
literal("Westerpark"), rgba(255.0f, 0.0f, 0.0f, 1.0f),
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f)
|
||||
)),
|
||||
stop(22f, match(
|
||||
get("name"),
|
||||
literal("Westerpark"), color(Color.BLUE),
|
||||
color(Color.BLACK)
|
||||
literal("Westerpark"), rgba(0.0f, 0.0f, 255.0f, 1.0f),
|
||||
rgba(255.0f, 255.0f, 255.0f, 1.0f)
|
||||
))
|
||||
)
|
||||
)
|
||||
@@ -461,8 +462,8 @@ public class DataDrivenStyleActivity extends AppCompatActivity {
|
||||
// Add a fill layer
|
||||
mapboxMap.addLayer(new FillLayer(AMSTERDAM_PARKS_LAYER, source.getId())
|
||||
.withProperties(
|
||||
fillColor(Color.BLACK),
|
||||
fillOutlineColor(Color.BLUE),
|
||||
fillColor(color(Color.GREEN)),
|
||||
fillOutlineColor(rgb(0, 0, 255)),
|
||||
fillAntialias(true)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.mapbox.geojson.Point;
|
||||
import com.mapbox.mapboxsdk.camera.CameraPosition;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
@@ -14,6 +15,9 @@ import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.geojson.Polygon;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionHeight;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionOpacity;
|
||||
@@ -35,30 +39,17 @@ public class FillExtrusionActivity extends AppCompatActivity {
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(map -> {
|
||||
mapboxMap = map;
|
||||
Polygon domTower = Polygon.fromLngLats(new double[][][] {
|
||||
new double[][] {
|
||||
new double[] {
|
||||
5.12112557888031,
|
||||
52.09071040847704
|
||||
},
|
||||
new double[] {
|
||||
5.121227502822875,
|
||||
52.09053901776669
|
||||
},
|
||||
new double[] {
|
||||
5.121484994888306,
|
||||
52.090601641371805
|
||||
},
|
||||
new double[] {
|
||||
5.1213884353637695,
|
||||
52.090766439912635
|
||||
},
|
||||
new double[] {
|
||||
5.12112557888031,
|
||||
52.09071040847704
|
||||
}
|
||||
}
|
||||
});
|
||||
List<List<Point>> lngLats = Arrays.asList(
|
||||
Arrays.asList(
|
||||
Point.fromLngLat(5.12112557888031, 52.09071040847704),
|
||||
Point.fromLngLat(5.121227502822875, 52.09053901776669),
|
||||
Point.fromLngLat(5.121484994888306, 52.090601641371805),
|
||||
Point.fromLngLat(5.1213884353637695, 52.090766439912635),
|
||||
Point.fromLngLat(5.12112557888031, 52.09071040847704)
|
||||
)
|
||||
);
|
||||
|
||||
Polygon domTower = Polygon.fromLngLats(lngLats);
|
||||
|
||||
GeoJsonSource source = new GeoJsonSource("extrusion-source", domTower);
|
||||
map.addSource(source);
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.expressions.Expression;
|
||||
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonOptions;
|
||||
@@ -21,9 +22,12 @@ import java.net.URL;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.Filter.all;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Filter.gte;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Filter.lt;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.all;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.gte;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.lt;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.toNumber;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage;
|
||||
@@ -124,7 +128,7 @@ public class GeoJsonClusteringActivity extends AppCompatActivity {
|
||||
)
|
||||
);
|
||||
} catch (MalformedURLException malformedUrlException) {
|
||||
Timber.e(malformedUrlException,"That's not an url... ");
|
||||
Timber.e(malformedUrlException, "That's not an url... ");
|
||||
}
|
||||
|
||||
// Add unclustered layer
|
||||
@@ -145,10 +149,15 @@ public class GeoJsonClusteringActivity extends AppCompatActivity {
|
||||
circleColor(layers[i][1]),
|
||||
circleRadius(18f)
|
||||
);
|
||||
|
||||
Expression pointCount = toNumber(get("point_count"));
|
||||
circles.setFilter(
|
||||
i == 0
|
||||
? gte("point_count", layers[i][0]) :
|
||||
all(gte("point_count", layers[i][0]), lt("point_count", layers[i - 1][0]))
|
||||
? gte(pointCount, literal(layers[i][0])) :
|
||||
all(
|
||||
gte(pointCount, literal(layers[i][0])),
|
||||
lt(pointCount, literal(layers[i - 1][0]))
|
||||
)
|
||||
);
|
||||
mapboxMap.addLayer(circles);
|
||||
}
|
||||
@@ -156,7 +165,7 @@ public class GeoJsonClusteringActivity extends AppCompatActivity {
|
||||
// Add the count labels
|
||||
SymbolLayer count = new SymbolLayer("count", "earthquakes");
|
||||
count.setProperties(
|
||||
textField("{point_count}"),
|
||||
textField(get("point_count")),
|
||||
textSize(12f),
|
||||
textColor(Color.WHITE)
|
||||
);
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.net.URL;
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.heatmapDensity;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.interpolate;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.linear;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
|
||||
@@ -28,6 +29,7 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleOpacity;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleStrokeColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleStrokeWidth;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.heatmapColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.heatmapIntensity;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.heatmapOpacity;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.heatmapRadius;
|
||||
@@ -51,7 +53,6 @@ public class HeatmapLayerActivity extends AppCompatActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_heatmaplayer);
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(map -> {
|
||||
@@ -76,11 +77,20 @@ public class HeatmapLayerActivity extends AppCompatActivity {
|
||||
layer.setSourceLayer(HEATMAP_LAYER_SOURCE);
|
||||
layer.setProperties(
|
||||
|
||||
// TODO add heatmap color https://github.com/mapbox/mapbox-gl-native/issues/11172
|
||||
// Color ramp for heatmap. Domain is 0 (low) to 1 (high).
|
||||
// Begin color ramp at 0-stop with a 0-transparancy color
|
||||
// to create a blur-like effect.
|
||||
//heatmapColor(),
|
||||
heatmapColor(
|
||||
interpolate(
|
||||
linear(), heatmapDensity(),
|
||||
literal(0), rgba(33, 102, 172, 0),
|
||||
literal(0.2), rgb(103, 169, 207),
|
||||
literal(0.4), rgb(209, 229, 240),
|
||||
literal(0.6), rgb(253, 219, 199),
|
||||
literal(0.8), rgb(239, 138, 98),
|
||||
literal(1), rgb(178, 24, 43)
|
||||
)
|
||||
),
|
||||
|
||||
// Increase the heatmap weight based on frequency and property magnitude
|
||||
heatmapWeight(
|
||||
|
||||
@@ -31,7 +31,6 @@ import com.mapbox.mapboxsdk.style.sources.VectorSource;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.ResourceUtils;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -39,15 +38,18 @@ import java.util.List;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.all;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.color;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.eq;
|
||||
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.gte;
|
||||
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.lt;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.stop;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.toNumber;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.zoom;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Filter.all;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Filter.eq;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Filter.gte;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Filter.lt;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.FILL_TRANSLATE_ANCHOR_MAP;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.SYMBOL_PLACEMENT_POINT;
|
||||
@@ -295,7 +297,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
|
||||
);
|
||||
|
||||
// Only show me parks (except westerpark with stroke-width == 3)
|
||||
layer.setFilter(all(eq("type", "park"), eq("stroke-width", 2)));
|
||||
layer.setFilter(all(eq(get("type"), literal("park")), eq(get("stroke-width"), literal(3))));
|
||||
|
||||
mapboxMap.addLayerBelow(layer, "building");
|
||||
// layer.setPaintProperty(fillColor(Color.RED)); // XXX But not after the object is attached
|
||||
@@ -345,7 +347,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
|
||||
);
|
||||
|
||||
// Only show me parks
|
||||
layer.setFilter(all(eq("type", "park")));
|
||||
layer.setFilter(all(eq(get("type"), literal("park"))));
|
||||
|
||||
mapboxMap.addLayer(layer);
|
||||
|
||||
@@ -499,7 +501,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
|
||||
FillLayer states = (FillLayer) mapboxMap.getLayer("states");
|
||||
|
||||
if (states != null) {
|
||||
states.setFilter(eq("name", "Texas"));
|
||||
states.setFilter(eq(get("name"), literal("Texas")));
|
||||
states.setFillOpacityTransition(new TransitionOptions(2500, 0));
|
||||
states.setFillColorTransition(new TransitionOptions(2500, 0));
|
||||
states.setProperties(
|
||||
@@ -527,7 +529,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
|
||||
LineLayer counties = (LineLayer) mapboxMap.getLayer("counties");
|
||||
|
||||
if (counties != null) {
|
||||
counties.setFilter(eq("NAME10", "Washington"));
|
||||
counties.setFilter(eq(get("NAME10"), "Washington"));
|
||||
|
||||
counties.setProperties(
|
||||
lineColor(Color.RED),
|
||||
@@ -555,7 +557,10 @@ public class RuntimeStyleActivity extends AppCompatActivity {
|
||||
FillLayer regions = (FillLayer) mapboxMap.getLayer("regions");
|
||||
|
||||
if (regions != null) {
|
||||
regions.setFilter(all(gte("HRRNUM", 200), lt("HRRNUM", 300)));
|
||||
regions.setFilter(all(
|
||||
gte(toNumber(get("HRRNUM")), literal(200)),
|
||||
lt(toNumber(get("HRRNUM")), literal(300)))
|
||||
);
|
||||
|
||||
regions.setProperties(
|
||||
fillColor(Color.BLUE),
|
||||
|
||||
@@ -20,15 +20,15 @@ import com.mapbox.geojson.FeatureCollection;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.style.layers.Filter;
|
||||
import com.mapbox.mapboxsdk.style.expressions.Expression;
|
||||
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
|
||||
import com.mapbox.mapboxsdk.style.sources.Source;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.ResourceUtils;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -37,11 +37,19 @@ import timber.log.Timber;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.concat;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.division;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.downcase;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.eq;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.match;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.number;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.pi;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.product;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.rgba;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.step;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.stop;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.string;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.upcase;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.zoom;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.ICON_ANCHOR_BOTTOM;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_ANCHOR_TOP;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconAllowOverlap;
|
||||
@@ -50,6 +58,7 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconOffset;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconSize;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textAnchor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textField;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textSize;
|
||||
|
||||
@@ -115,8 +124,8 @@ public class SymbolGeneratorActivity extends AppCompatActivity implements OnMapR
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.menu_action_filter) {
|
||||
SymbolLayer layer = mapboxMap.getLayerAs(LAYER_ID);
|
||||
layer.setFilter(Filter.eq(FEATURE_RANK, 1));
|
||||
//layer.setFilter(eq(get(FEATURE_RANK), 1));
|
||||
layer.setFilter(eq(get(FEATURE_RANK), literal(1)));
|
||||
Timber.e("Filter that was set: %s", layer.getFilter());
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
@@ -196,27 +205,32 @@ public class SymbolGeneratorActivity extends AppCompatActivity implements OnMapR
|
||||
|
||||
private static class LoadDataTask extends AsyncTask<Void, Void, FeatureCollection> {
|
||||
|
||||
private SymbolGeneratorActivity activity;
|
||||
private WeakReference<SymbolGeneratorActivity> activity;
|
||||
|
||||
LoadDataTask(SymbolGeneratorActivity activity) {
|
||||
this.activity = activity;
|
||||
this.activity = new WeakReference<>(activity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FeatureCollection doInBackground(Void... params) {
|
||||
try {
|
||||
// read local geojson from raw folder
|
||||
String tinyCountriesJson = ResourceUtils.readRawResource(activity, R.raw.tiny_countries);
|
||||
return FeatureCollection.fromJson(tinyCountriesJson);
|
||||
Context context = activity.get();
|
||||
if (context != null) {
|
||||
try {
|
||||
// read local geojson from raw folder
|
||||
String tinyCountriesJson = ResourceUtils.readRawResource(context, R.raw.tiny_countries);
|
||||
return FeatureCollection.fromJson(tinyCountriesJson);
|
||||
|
||||
} catch (IOException exception) {
|
||||
return null;
|
||||
} catch (IOException exception) {
|
||||
Timber.e(exception);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(FeatureCollection featureCollection) {
|
||||
super.onPostExecute(featureCollection);
|
||||
SymbolGeneratorActivity activity = this.activity.get();
|
||||
if (featureCollection == null || activity == null) {
|
||||
return;
|
||||
}
|
||||
@@ -226,37 +240,74 @@ public class SymbolGeneratorActivity extends AppCompatActivity implements OnMapR
|
||||
}
|
||||
|
||||
public void onDataLoaded(@NonNull FeatureCollection featureCollection) {
|
||||
// add a geojson to the map
|
||||
// create expressions
|
||||
Expression iconImageExpression = string(get(literal(FEATURE_ID)));
|
||||
Expression iconSizeExpression = division(number(get(literal(FEATURE_RANK))), literal(2.0f));
|
||||
Expression textSizeExpression = product(get(literal(FEATURE_RANK)), pi());
|
||||
Expression textFieldExpression = concat(upcase(literal("a ")), upcase(string(get(literal(FEATURE_TYPE)))),
|
||||
downcase(literal(" IN ")), string(get(literal(FEATURE_REGION)))
|
||||
);
|
||||
Expression textColorExpression = match(get(literal(FEATURE_RANK)),
|
||||
literal(1), rgba(255, 0, 0, 1.0f),
|
||||
literal(2), rgba(0, 0, 255.0f, 1.0f),
|
||||
rgba(0.0f, 255.0f, 0.0f, 1.0f)
|
||||
);
|
||||
|
||||
rgba(
|
||||
division(literal(255), get(FEATURE_RANK)),
|
||||
literal(0.0f),
|
||||
literal(0.0f),
|
||||
literal(1.0f)
|
||||
);
|
||||
|
||||
// create symbol layer
|
||||
SymbolLayer symbolLayer = new SymbolLayer(LAYER_ID, SOURCE_ID)
|
||||
.withProperties(
|
||||
// icon configuration
|
||||
iconImage(iconImageExpression),
|
||||
iconAllowOverlap(false),
|
||||
iconSize(iconSizeExpression),
|
||||
iconAnchor(ICON_ANCHOR_BOTTOM),
|
||||
iconOffset(step(zoom(), literal(new float[] {0f, 0f}),
|
||||
stop(1, new Float[] {0f, 0f}),
|
||||
stop(10, new Float[] {0f, -35f})
|
||||
)),
|
||||
|
||||
// text field configuration
|
||||
textField(textFieldExpression),
|
||||
textSize(textSizeExpression),
|
||||
textAnchor(TEXT_ANCHOR_TOP),
|
||||
textColor(textColorExpression)
|
||||
);
|
||||
|
||||
// add a geojson source to the map
|
||||
Source source = new GeoJsonSource(SOURCE_ID, featureCollection);
|
||||
mapboxMap.addSource(source);
|
||||
|
||||
// create layer use
|
||||
mapboxMap.addLayer(new SymbolLayer(LAYER_ID, SOURCE_ID)
|
||||
.withProperties(
|
||||
// add symbol layer
|
||||
mapboxMap.addLayer(symbolLayer);
|
||||
|
||||
// icon configuration
|
||||
iconImage(get(literal(FEATURE_ID))),
|
||||
iconAllowOverlap(false),
|
||||
iconSize(
|
||||
division(get(literal(FEATURE_RANK)), literal(2))
|
||||
),
|
||||
iconAnchor(ICON_ANCHOR_BOTTOM),
|
||||
iconOffset(new Float[] {0.0f, -5.0f}),
|
||||
// get expressions
|
||||
Expression iconImageExpressionResult = symbolLayer.getIconImage().getExpression();
|
||||
Expression iconSizeExpressionResult = symbolLayer.getIconSize().getExpression();
|
||||
Expression textSizeExpressionResult = symbolLayer.getTextSize().getExpression();
|
||||
Expression textFieldExpressionResult = symbolLayer.getTextField().getExpression();
|
||||
Expression textColorExpressionResult = symbolLayer.getTextColor().getExpression();
|
||||
|
||||
// text field configuration
|
||||
textField(
|
||||
concat(
|
||||
upcase(literal("a ")),
|
||||
get(literal(FEATURE_TYPE)),
|
||||
downcase(literal(" IN ")),
|
||||
get(literal(FEATURE_REGION))
|
||||
)
|
||||
),
|
||||
textSize(
|
||||
product(get(literal(FEATURE_RANK)), pi())
|
||||
),
|
||||
textAnchor(TEXT_ANCHOR_TOP)
|
||||
)
|
||||
// log expressions
|
||||
Timber.e(iconImageExpressionResult.toString());
|
||||
Timber.e(iconSizeExpressionResult.toString());
|
||||
Timber.e(textSizeExpressionResult.toString());
|
||||
Timber.e(textFieldExpressionResult.toString());
|
||||
Timber.e(textColorExpressionResult.toString());
|
||||
|
||||
// reset expressions
|
||||
symbolLayer.setProperties(
|
||||
iconImage(iconImageExpressionResult),
|
||||
iconSize(iconSizeExpressionResult),
|
||||
textSize(textSizeExpressionResult),
|
||||
textField(textFieldExpressionResult),
|
||||
textColor(textColorExpressionResult)
|
||||
);
|
||||
|
||||
new GenerateSymbolTask(mapboxMap, this).execute(featureCollection);
|
||||
@@ -265,27 +316,29 @@ public class SymbolGeneratorActivity extends AppCompatActivity implements OnMapR
|
||||
private static class GenerateSymbolTask extends AsyncTask<FeatureCollection, Void, HashMap<String, Bitmap>> {
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private Context context;
|
||||
private WeakReference<Context> context;
|
||||
|
||||
GenerateSymbolTask(MapboxMap mapboxMap, Context context) {
|
||||
this.mapboxMap = mapboxMap;
|
||||
this.context = context;
|
||||
this.context = new WeakReference<>(context);
|
||||
}
|
||||
|
||||
@SuppressWarnings("WrongThread")
|
||||
@Override
|
||||
protected HashMap<String, Bitmap> doInBackground(FeatureCollection... params) {
|
||||
FeatureCollection featureCollection = params[0];
|
||||
|
||||
HashMap<String, Bitmap> imagesMap = new HashMap<>();
|
||||
for (Feature feature : featureCollection.features()) {
|
||||
String countryName = feature.getStringProperty(FEATURE_ID);
|
||||
TextView textView = new TextView(context);
|
||||
textView.setBackgroundColor(context.getResources().getColor(R.color.blueAccent));
|
||||
textView.setPadding(10, 5, 10, 5);
|
||||
textView.setTextColor(Color.WHITE);
|
||||
textView.setText(countryName);
|
||||
imagesMap.put(countryName, SymbolGenerator.generate(textView));
|
||||
Context context = this.context.get();
|
||||
List<Feature> features = params[0].features();
|
||||
if (context != null && features != null) {
|
||||
for (Feature feature : features) {
|
||||
String countryName = feature.getStringProperty(FEATURE_ID);
|
||||
TextView textView = new TextView(context);
|
||||
textView.setBackgroundColor(context.getResources().getColor(R.color.blueAccent));
|
||||
textView.setPadding(10, 5, 10, 5);
|
||||
textView.setTextColor(Color.WHITE);
|
||||
textView.setText(countryName);
|
||||
imagesMap.put(countryName, SymbolGenerator.generate(textView));
|
||||
}
|
||||
}
|
||||
return imagesMap;
|
||||
}
|
||||
|
||||
@@ -22,11 +22,13 @@ import java.util.List;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.property;
|
||||
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.categorical;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.interval;
|
||||
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.linear;
|
||||
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.switchCase;
|
||||
import static com.mapbox.mapboxsdk.style.expressions.Expression.zoom;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconAllowOverlap;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconSize;
|
||||
@@ -101,20 +103,16 @@ public class ZoomFunctionSymbolLayerActivity extends AppCompatActivity {
|
||||
layer = new SymbolLayer(LAYER_ID, SOURCE_ID);
|
||||
layer.setProperties(
|
||||
iconImage(
|
||||
zoom(
|
||||
interval(
|
||||
stop(ZOOM_STOP_MIN_VALUE, iconImage(BUS_MAKI_ICON_ID)),
|
||||
stop(ZOOM_STOP_MAX_VALUE, iconImage(CAFE_MAKI_ICON_ID))
|
||||
)
|
||||
)
|
||||
interpolate(
|
||||
linear(), zoom(),
|
||||
stop(ZOOM_STOP_MIN_VALUE, BUS_MAKI_ICON_ID),
|
||||
stop(ZOOM_STOP_MAX_VALUE, CAFE_MAKI_ICON_ID)
|
||||
)
|
||||
),
|
||||
iconSize(
|
||||
property(
|
||||
KEY_PROPERTY_SELECTED,
|
||||
categorical(
|
||||
stop(true, iconSize(3.0f)),
|
||||
stop(false, iconSize(1.0f))
|
||||
)
|
||||
switchCase(
|
||||
get(KEY_PROPERTY_SELECTED), literal(3.0f),
|
||||
literal(1.0f)
|
||||
)
|
||||
),
|
||||
iconAllowOverlap(true)
|
||||
|
||||
@@ -95,4 +95,4 @@ public class TextureViewResizeActivity extends AppCompatActivity {
|
||||
mapView.onLowMemory();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,49 +1,52 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.userlocation;
|
||||
package com.mapbox.mapboxsdk.testapp.activity.textureview;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.ResourceUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
/**
|
||||
* Test activity showcasing toggling the user location on the map.
|
||||
* Example showcasing how to create a TextureView with a transparent background.
|
||||
*/
|
||||
public class MyLocationToggleActivity extends BaseLocationActivity {
|
||||
public class TextureViewTransparentBackgroundActivity extends AppCompatActivity {
|
||||
|
||||
private MapView mapView;
|
||||
private MapboxMap mapboxMap;
|
||||
private FloatingActionButton locationToggleFab;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_my_location_toggle);
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(map -> mapboxMap = map);
|
||||
|
||||
locationToggleFab = (FloatingActionButton) findViewById(R.id.fabLocationToggle);
|
||||
locationToggleFab.setOnClickListener(view -> {
|
||||
if (mapboxMap != null) {
|
||||
toggleGps(!mapboxMap.isMyLocationEnabled());
|
||||
}
|
||||
});
|
||||
setContentView(R.layout.activity_textureview_transparent);
|
||||
setupBackground();
|
||||
setupMapView(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void enableLocation(boolean enabled) {
|
||||
Timber.e("Enabling location: %s", enabled);
|
||||
mapboxMap.setMyLocationEnabled(enabled);
|
||||
if (enabled) {
|
||||
locationToggleFab.setImageResource(R.drawable.ic_location_disabled);
|
||||
} else {
|
||||
locationToggleFab.setImageResource(R.drawable.ic_my_location);
|
||||
}
|
||||
private void setupBackground() {
|
||||
ImageView imageView = (ImageView) findViewById(R.id.imageView);
|
||||
imageView.setImageResource(R.drawable.water);
|
||||
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||
}
|
||||
|
||||
private void setupMapView(Bundle savedInstanceState) {
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(map -> {
|
||||
mapboxMap = map;
|
||||
|
||||
try {
|
||||
map.setStyleJson(ResourceUtils.readRawResource(getApplicationContext(), R.raw.no_bg_style));
|
||||
} catch (IOException exception) {
|
||||
Timber.e(exception);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,4 +91,4 @@ public class MyLocationToggleActivity extends BaseLocationActivity {
|
||||
mapView.onLowMemory();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.userlocation;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.UiThread;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mapbox.android.core.permissions.PermissionsListener;
|
||||
import com.mapbox.android.core.permissions.PermissionsManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Base class for location aware activities.
|
||||
*/
|
||||
public abstract class BaseLocationActivity extends AppCompatActivity implements PermissionsListener {
|
||||
|
||||
private PermissionsManager permissionsManager;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
permissionsManager = new PermissionsManager(this);
|
||||
}
|
||||
|
||||
@UiThread
|
||||
protected final void toggleGps(boolean enableGps) {
|
||||
if (enableGps) {
|
||||
if (!isRuntimePermissionsRequired()) {
|
||||
permissionsManager.requestLocationPermissions(this);
|
||||
} else {
|
||||
enableLocation(true);
|
||||
}
|
||||
} else {
|
||||
enableLocation(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExplanationNeeded(List<String> list) {
|
||||
Snackbar.make(
|
||||
findViewById(android.R.id.content),
|
||||
TextUtils.join("", list.toArray()),
|
||||
Snackbar.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPermissionResult(boolean isPermissionAccepted) {
|
||||
enableLocation(isPermissionAccepted);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
permissionsManager.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
|
||||
private boolean isRuntimePermissionsRequired() {
|
||||
return android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
|
||||
}
|
||||
|
||||
protected abstract void enableLocation(boolean enabled);
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.userlocation;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.mapbox.mapboxsdk.Mapbox;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
/**
|
||||
* Test activity showcasing using a custom location engine.
|
||||
*/
|
||||
public class CustomLocationEngineActivity extends BaseLocationActivity {
|
||||
|
||||
private MapView mapView;
|
||||
private MapboxMap mapboxMap;
|
||||
private FloatingActionButton locationToggleFab;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_custom_location_engine);
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(map -> {
|
||||
mapboxMap = map;
|
||||
mapboxMap.setLocationSource(MockLocationEngine.getInstance());
|
||||
});
|
||||
|
||||
locationToggleFab = (FloatingActionButton) findViewById(R.id.fabLocationToggle);
|
||||
locationToggleFab.setOnClickListener(view -> {
|
||||
if (mapboxMap != null) {
|
||||
enableLocation(!mapboxMap.isMyLocationEnabled());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void enableLocation(boolean enabled) {
|
||||
mapboxMap.setMyLocationEnabled(enabled);
|
||||
if (enabled) {
|
||||
locationToggleFab.setImageResource(R.drawable.ic_location_disabled);
|
||||
} else {
|
||||
locationToggleFab.setImageResource(R.drawable.ic_my_location);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_location_engine, menu);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (mapboxMap != null) {
|
||||
int itemId = item.getItemId();
|
||||
if (itemId == R.id.action_id_location_source_lost) {
|
||||
mapboxMap.setLocationSource(Mapbox.getLocationEngine());
|
||||
return true;
|
||||
} else if (itemId == R.id.action_id_location_source_mock) {
|
||||
mapboxMap.setLocationSource(MockLocationEngine.getInstance());
|
||||
return true;
|
||||
} else if (itemId == R.id.action_id_location_source_null) {
|
||||
mapboxMap.setLocationSource(null);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mapView.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mapView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mapView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mapView.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
mapView.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mapView.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
super.onLowMemory();
|
||||
mapView.onLowMemory();
|
||||
}
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.userlocation;
|
||||
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.TypeEvaluator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.location.Location;
|
||||
|
||||
import com.mapbox.android.core.location.LocationEngine;
|
||||
import com.mapbox.android.core.location.LocationEngineListener;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
/**
|
||||
* Sample LocationEngine that provides mocked LOCATIONS simulating GPS updates
|
||||
*/
|
||||
public class MockLocationEngine extends LocationEngine {
|
||||
private static MockLocationEngine INSTANCE;
|
||||
|
||||
private final LocationAnimator locationAnimator;
|
||||
private boolean running;
|
||||
private static int counter;
|
||||
|
||||
MockLocationEngine(Location start, Location end) {
|
||||
locationAnimator = new LocationAnimator(start, end, animation -> {
|
||||
for (LocationEngineListener listener : locationListeners) {
|
||||
listener.onLocationChanged((Location) animation.getAnimatedValue());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static synchronized MockLocationEngine getInstance() {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = new MockLocationEngine(
|
||||
MockLocationEngine.createLocation(40.416913, -3.703861),
|
||||
MockLocationEngine.createLocation(39.461643, -0.368041)
|
||||
);
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public static Location createLocation(double latitude, double longitude) {
|
||||
Location location = new Location(MockLocationEngine.class.getSimpleName());
|
||||
location.setLatitude(latitude);
|
||||
location.setLongitude(longitude);
|
||||
return location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activate() {
|
||||
// "Connection" is immediate here
|
||||
for (LocationEngineListener listener : locationListeners) {
|
||||
listener.onConnected();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deactivate() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
return true; // Always connected
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLastLocation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestLocationUpdates() {
|
||||
if (!running) {
|
||||
locationAnimator.start();
|
||||
running = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLocationUpdates() {
|
||||
if (running) {
|
||||
locationAnimator.stop();
|
||||
running = false;
|
||||
Timber.e("LOC %s", counter);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type obtainType() {
|
||||
return Type.MOCK;
|
||||
}
|
||||
|
||||
private static class LocationAnimator extends AnimatorListenerAdapter {
|
||||
|
||||
private static final long DURATION_ANIMATION = 10000;
|
||||
private final ValueAnimator locationAnimator;
|
||||
private long animationTime;
|
||||
|
||||
LocationAnimator(Location start, Location end, ValueAnimator.AnimatorUpdateListener listener) {
|
||||
locationAnimator = ValueAnimator.ofObject(new LocationEvaluator(), start, end);
|
||||
locationAnimator.setDuration(DURATION_ANIMATION);
|
||||
locationAnimator.addUpdateListener(listener);
|
||||
locationAnimator.addListener(this);
|
||||
}
|
||||
|
||||
void start() {
|
||||
locationAnimator.start();
|
||||
locationAnimator.setCurrentPlayTime(animationTime);
|
||||
}
|
||||
|
||||
void stop() {
|
||||
animationTime = locationAnimator.getCurrentPlayTime();
|
||||
locationAnimator.cancel();
|
||||
}
|
||||
|
||||
private static class LocationEvaluator implements TypeEvaluator<Location> {
|
||||
|
||||
private Location location = new Location(MockLocationEngine.class.getSimpleName());
|
||||
|
||||
@Override
|
||||
public Location evaluate(float fraction, Location startValue, Location endValue) {
|
||||
counter++;
|
||||
location.setLatitude(startValue.getLatitude()
|
||||
+ ((endValue.getLatitude() - startValue.getLatitude()) * fraction));
|
||||
location.setLongitude(startValue.getLongitude()
|
||||
+ ((endValue.getLongitude() - startValue.getLongitude()) * fraction));
|
||||
return location;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.userlocation;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
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.MapboxMapOptions;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.android.core.location.LocationEngineListener;
|
||||
|
||||
/**
|
||||
* Test activity showcasing how to change the MyLocationView drawable.
|
||||
*/
|
||||
public class MyLocationDrawableActivity extends BaseLocationActivity implements LocationEngineListener {
|
||||
|
||||
private MapView mapView;
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_my_location_customization);
|
||||
findViewById(R.id.progress).setVisibility(View.GONE);
|
||||
|
||||
MapboxMapOptions mapboxMapOptions = new MapboxMapOptions();
|
||||
mapboxMapOptions.styleUrl(Style.MAPBOX_STREETS);
|
||||
mapboxMapOptions.myLocationForegroundDrawable(ContextCompat.getDrawable(this, R.drawable.ic_android));
|
||||
mapboxMapOptions.myLocationBackgroundDrawable(ContextCompat.getDrawable(this, R.drawable.ic_android));
|
||||
mapboxMapOptions.myLocationForegroundTintColor(Color.GREEN);
|
||||
mapboxMapOptions.myLocationBackgroundTintColor(Color.YELLOW);
|
||||
mapboxMapOptions.myLocationBackgroundPadding(new int[] {0, 0,
|
||||
(int) getResources().getDimension(R.dimen.locationview_background_drawable_padding),
|
||||
(int) getResources().getDimension(R.dimen.locationview_background_drawable_padding)});
|
||||
mapboxMapOptions.myLocationAccuracyTint(Color.RED);
|
||||
mapboxMapOptions.myLocationAccuracyAlpha(155);
|
||||
|
||||
mapView = new MapView(this, mapboxMapOptions);
|
||||
mapView.setId(R.id.mapView);
|
||||
ViewGroup parent = (ViewGroup) findViewById(android.R.id.content);
|
||||
parent.addView(mapView);
|
||||
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(map -> {
|
||||
mapboxMap = map;
|
||||
toggleGps(true);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void enableLocation(boolean enabled) {
|
||||
mapboxMap.setMyLocationEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnected() {
|
||||
// Nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 14));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mapView.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mapView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mapView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mapView.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
mapView.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mapView.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
super.onLowMemory();
|
||||
mapView.onLowMemory();
|
||||
}
|
||||
}
|
||||
@@ -1,181 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.userlocation;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Color;
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.IdRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.View;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.constants.MyLocationTracking;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.TrackingSettings;
|
||||
import com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.android.core.location.LocationEngineListener;
|
||||
|
||||
/**
|
||||
* Test activity showcasing how to tint the MyLocationView.
|
||||
*/
|
||||
public class MyLocationTintActivity extends BaseLocationActivity implements LocationEngineListener {
|
||||
|
||||
private MapView mapView;
|
||||
private MapboxMap mapboxMap;
|
||||
private boolean firstRun;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_my_location_dot_color);
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(map -> {
|
||||
mapboxMap = map;
|
||||
|
||||
// enable location updates
|
||||
toggleGps(true);
|
||||
|
||||
// add some padding
|
||||
final MyLocationViewSettings myLocationViewSettings = mapboxMap.getMyLocationViewSettings();
|
||||
myLocationViewSettings.setPadding(0, 500, 0, 0);
|
||||
|
||||
// enable tracking
|
||||
TrackingSettings settings = mapboxMap.getTrackingSettings();
|
||||
settings.setDismissLocationTrackingOnGesture(false);
|
||||
settings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
|
||||
|
||||
// handle default button clicks
|
||||
ViewUtils.attachClickListener(
|
||||
MyLocationTintActivity.this,
|
||||
R.id.default_user_dot_coloring_button,
|
||||
view -> {
|
||||
myLocationViewSettings.setAccuracyTintColor(ContextCompat.getColor(
|
||||
MyLocationTintActivity.this, R.color.mapbox_blue));
|
||||
myLocationViewSettings.setForegroundTintColor(ContextCompat.getColor(
|
||||
MyLocationTintActivity.this, R.color.mapbox_blue));
|
||||
myLocationViewSettings.setBackgroundTintColor(Color.WHITE);
|
||||
});
|
||||
|
||||
// handle tint user dot button clicks
|
||||
ViewUtils.attachClickListener(
|
||||
MyLocationTintActivity.this,
|
||||
R.id.tint_user_dot_button,
|
||||
view -> {
|
||||
myLocationViewSettings.setAccuracyTintColor(
|
||||
ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapboxGreen));
|
||||
myLocationViewSettings.setForegroundTintColor(
|
||||
ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapboxGreen));
|
||||
myLocationViewSettings.setBackgroundTintColor(Color.WHITE);
|
||||
});
|
||||
|
||||
// handle tint accuracy ring button clicks
|
||||
ViewUtils.attachClickListener(
|
||||
MyLocationTintActivity.this,
|
||||
R.id.user_accuracy_ring_tint_button,
|
||||
view -> {
|
||||
myLocationViewSettings.setAccuracyTintColor(
|
||||
ContextCompat.getColor(MyLocationTintActivity.this, R.color.accent));
|
||||
myLocationViewSettings.setForegroundTintColor(
|
||||
ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapbox_blue));
|
||||
myLocationViewSettings.setBackgroundTintColor(Color.WHITE);
|
||||
});
|
||||
|
||||
ViewUtils.attachClickListener(
|
||||
MyLocationTintActivity.this,
|
||||
R.id.user_dot_transparent_button,
|
||||
view -> {
|
||||
myLocationViewSettings.setForegroundTintColor(Color.TRANSPARENT);
|
||||
myLocationViewSettings.setBackgroundTintColor(Color.TRANSPARENT);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnected() {
|
||||
// Nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
if (mapboxMap != null && firstRun) {
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 15));
|
||||
firstRun = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mapView.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mapView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
mapView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mapView.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
super.onLowMemory();
|
||||
mapView.onLowMemory();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mapView.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
mapView.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void enableLocation(boolean enabled) {
|
||||
if (enabled) {
|
||||
mapboxMap.setMyLocationEnabled(true);
|
||||
if (mapboxMap.getMyLocation() != null) {
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
|
||||
new LatLng(mapboxMap.getMyLocation().getLatitude(),
|
||||
mapboxMap.getMyLocation().getLongitude()), 15));
|
||||
}
|
||||
} else {
|
||||
mapboxMap.setMyLocationEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
private static class ViewUtils {
|
||||
|
||||
public static void attachClickListener(
|
||||
@NonNull Activity activity, @IdRes int buttonId, @Nullable View.OnClickListener clickListener) {
|
||||
View view = activity.findViewById(buttonId);
|
||||
if (view != null) {
|
||||
view.setOnClickListener(clickListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,296 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.userlocation;
|
||||
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mapbox.mapboxsdk.Mapbox;
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.constants.MyBearingTracking;
|
||||
import com.mapbox.mapboxsdk.constants.MyLocationTracking;
|
||||
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.TrackingSettings;
|
||||
import com.mapbox.mapboxsdk.maps.UiSettings;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.android.core.location.LocationEngineListener;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
/**
|
||||
* Test activity showcasing the different tracking modes the SDK exposes.
|
||||
* <p>
|
||||
* This includes MyLocationTracking/MyLocationBearingTracking and how the components can be configured to be dismissed
|
||||
* using gesture configurations.
|
||||
* </p>
|
||||
*/
|
||||
public class MyLocationTrackingModeActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener,
|
||||
OnMapReadyCallback, LocationEngineListener {
|
||||
|
||||
public static final int TRACKING_NONE_INDEX = 0;
|
||||
public static final int TRACKING_FOLLOW_INDEX = 1;
|
||||
public static final int BEARING_NONE_INDEX = 0;
|
||||
public static final int BEARING_GPS_INDEX = 1;
|
||||
public static final int BEARING_COMPASS_INDEX = 2;
|
||||
|
||||
private MapView mapView;
|
||||
private MapboxMap mapboxMap;
|
||||
private Spinner locationSpinner;
|
||||
private Spinner bearingSpinner;
|
||||
private boolean firstRun = true;
|
||||
|
||||
private MenuItem dismissLocationTrackingOnGestureItem;
|
||||
private MenuItem dismissBearingTrackingOnGestureItem;
|
||||
private MenuItem enableRotateGesturesItem;
|
||||
private MenuItem enableScrollGesturesItem;
|
||||
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_my_location_tracking);
|
||||
setupToolbar();
|
||||
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
mapView.getMapAsync(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapReady(MapboxMap mapboxMap) {
|
||||
MyLocationTrackingModeActivity.this.mapboxMap = mapboxMap;
|
||||
|
||||
mapboxMap.setMyLocationEnabled(true);
|
||||
Mapbox.getLocationEngine().addLocationEngineListener(this);
|
||||
Mapbox.getLocationEngine().requestLocationUpdates();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnected() {
|
||||
// Nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
Timber.e("Location changed %s", location);
|
||||
if (firstRun) {
|
||||
setInitialLocation(location, 16);
|
||||
}
|
||||
}
|
||||
|
||||
private void setInitialLocation(Location location, double zoom) {
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), zoom));
|
||||
mapboxMap.setMyLocationEnabled(true);
|
||||
setupSpinners(mapboxMap);
|
||||
firstRun = false;
|
||||
}
|
||||
|
||||
private void setupToolbar() {
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
final ActionBar actionBar = getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setDisplayShowTitleEnabled(false);
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
actionBar.setDisplayShowHomeEnabled(true);
|
||||
|
||||
locationSpinner = (Spinner) findViewById(R.id.spinner_location);
|
||||
ArrayAdapter<CharSequence> locationTrackingAdapter = ArrayAdapter.createFromResource(
|
||||
actionBar.getThemedContext(), R.array.user_tracking_mode, android.R.layout.simple_spinner_item);
|
||||
locationTrackingAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
locationSpinner.setAdapter(locationTrackingAdapter);
|
||||
|
||||
bearingSpinner = (Spinner) findViewById(R.id.spinner_bearing);
|
||||
ArrayAdapter<CharSequence> bearingTrackingAdapter = ArrayAdapter.createFromResource(
|
||||
actionBar.getThemedContext(), R.array.user_bearing_mode, android.R.layout.simple_spinner_item);
|
||||
bearingTrackingAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
bearingSpinner.setAdapter(bearingTrackingAdapter);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupSpinners(@NonNull MapboxMap mapboxMap) {
|
||||
locationSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this);
|
||||
bearingSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this);
|
||||
setCheckBoxes();
|
||||
|
||||
mapboxMap.setOnMyLocationTrackingModeChangeListener(myLocationTrackingMode -> {
|
||||
locationSpinner.setOnItemSelectedListener(null);
|
||||
switch (myLocationTrackingMode) {
|
||||
case MyLocationTracking.TRACKING_NONE:
|
||||
locationSpinner.setSelection(TRACKING_NONE_INDEX);
|
||||
break;
|
||||
case MyLocationTracking.TRACKING_FOLLOW:
|
||||
locationSpinner.setSelection(TRACKING_FOLLOW_INDEX);
|
||||
break;
|
||||
}
|
||||
locationSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this);
|
||||
});
|
||||
|
||||
mapboxMap.setOnMyBearingTrackingModeChangeListener(myBearingTrackingMode -> {
|
||||
bearingSpinner.setOnItemSelectedListener(null);
|
||||
switch (myBearingTrackingMode) {
|
||||
case MyBearingTracking.NONE:
|
||||
bearingSpinner.setSelection(BEARING_NONE_INDEX);
|
||||
break;
|
||||
|
||||
case MyBearingTracking.GPS:
|
||||
bearingSpinner.setSelection(BEARING_GPS_INDEX);
|
||||
break;
|
||||
|
||||
case MyBearingTracking.COMPASS:
|
||||
bearingSpinner.setSelection(BEARING_COMPASS_INDEX);
|
||||
break;
|
||||
}
|
||||
bearingSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) throws SecurityException {
|
||||
TrackingSettings trackingSettings = mapboxMap.getTrackingSettings();
|
||||
if (parent.getId() == R.id.spinner_location) {
|
||||
switch (position) {
|
||||
case TRACKING_NONE_INDEX:
|
||||
trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_NONE);
|
||||
break;
|
||||
|
||||
case TRACKING_FOLLOW_INDEX:
|
||||
trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
|
||||
break;
|
||||
}
|
||||
} else if (parent.getId() == R.id.spinner_bearing) {
|
||||
switch (position) {
|
||||
case BEARING_NONE_INDEX:
|
||||
trackingSettings.setMyBearingTrackingMode(MyBearingTracking.NONE);
|
||||
break;
|
||||
|
||||
case BEARING_GPS_INDEX:
|
||||
trackingSettings.setMyBearingTrackingMode(MyBearingTracking.GPS);
|
||||
break;
|
||||
|
||||
case BEARING_COMPASS_INDEX:
|
||||
trackingSettings.setMyBearingTrackingMode(MyBearingTracking.COMPASS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mapView.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mapView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mapView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
Mapbox.getLocationEngine().removeLocationEngineListener(this);
|
||||
Mapbox.getLocationEngine().removeLocationUpdates();
|
||||
mapView.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
mapView.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mapView.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
super.onLowMemory();
|
||||
mapView.onLowMemory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_tracking, menu);
|
||||
dismissLocationTrackingOnGestureItem = menu.findItem(R.id.action_toggle_dismissible_location);
|
||||
dismissBearingTrackingOnGestureItem = menu.findItem(R.id.action_toggle_dismissible_bearing);
|
||||
enableRotateGesturesItem = menu.findItem(R.id.action_toggle_rotate_gesture_enabled);
|
||||
enableScrollGesturesItem = menu.findItem(R.id.action_toggle_scroll_gesture_enabled);
|
||||
setCheckBoxes();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setCheckBoxes() {
|
||||
if (mapboxMap != null && dismissBearingTrackingOnGestureItem != null) {
|
||||
TrackingSettings trackingSettings = mapboxMap.getTrackingSettings();
|
||||
UiSettings uiSettings = mapboxMap.getUiSettings();
|
||||
dismissBearingTrackingOnGestureItem.setChecked(trackingSettings.isDismissBearingTrackingOnGesture());
|
||||
dismissLocationTrackingOnGestureItem.setChecked(trackingSettings.isDismissLocationTrackingOnGesture());
|
||||
enableRotateGesturesItem.setChecked(uiSettings.isRotateGesturesEnabled());
|
||||
enableScrollGesturesItem.setChecked(uiSettings.isScrollGesturesEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
boolean state;
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
onBackPressed();
|
||||
return true;
|
||||
case R.id.action_toggle_dismissible_location:
|
||||
state = !item.isChecked();
|
||||
mapboxMap.getTrackingSettings().setDismissLocationTrackingOnGesture(state);
|
||||
Toast.makeText(this, "Dismiss tracking mode on gesture = " + state, Toast.LENGTH_SHORT).show();
|
||||
item.setChecked(state);
|
||||
return true;
|
||||
case R.id.action_toggle_dismissible_bearing:
|
||||
state = !item.isChecked();
|
||||
mapboxMap.getTrackingSettings().setDismissBearingTrackingOnGesture(state);
|
||||
Toast.makeText(this, "Dismiss bearing mode on gesture = " + state, Toast.LENGTH_SHORT).show();
|
||||
item.setChecked(state);
|
||||
return true;
|
||||
case R.id.action_toggle_rotate_gesture_enabled:
|
||||
state = !item.isChecked();
|
||||
mapboxMap.getUiSettings().setRotateGesturesEnabled(state);
|
||||
Toast.makeText(this, "Rotate gesture enabled = " + state, Toast.LENGTH_SHORT).show();
|
||||
item.setChecked(state);
|
||||
return true;
|
||||
case R.id.action_toggle_scroll_gesture_enabled:
|
||||
state = !item.isChecked();
|
||||
mapboxMap.getUiSettings().setScrollGesturesEnabled(state);
|
||||
Toast.makeText(this, "Scroll gesture enabled = " + state, Toast.LENGTH_SHORT).show();
|
||||
item.setChecked(state);
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,14 +9,12 @@ public class Feature implements Parcelable {
|
||||
private String label;
|
||||
private String description;
|
||||
private String category;
|
||||
private boolean requiresLocationPermission;
|
||||
|
||||
public Feature(String name, String label, String description, String category, boolean requiresLocationPermission) {
|
||||
public Feature(String name, String label, String description, String category) {
|
||||
this.name = name;
|
||||
this.label = label;
|
||||
this.description = description;
|
||||
this.category = category;
|
||||
this.requiresLocationPermission = requiresLocationPermission;
|
||||
}
|
||||
|
||||
private Feature(Parcel in) {
|
||||
@@ -24,7 +22,6 @@ public class Feature implements Parcelable {
|
||||
label = in.readString();
|
||||
description = in.readString();
|
||||
category = in.readString();
|
||||
requiresLocationPermission = in.readByte() != 0;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@@ -48,10 +45,6 @@ public class Feature implements Parcelable {
|
||||
return category;
|
||||
}
|
||||
|
||||
public boolean isRequiresLocationPermission() {
|
||||
return requiresLocationPermission;
|
||||
}
|
||||
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
@@ -61,7 +54,6 @@ public class Feature implements Parcelable {
|
||||
out.writeString(label);
|
||||
out.writeString(description);
|
||||
out.writeString(category);
|
||||
out.writeByte((byte) (requiresLocationPermission ? 1 : 0));
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<Feature> CREATOR
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.testapp.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.RawRes;
|
||||
import android.util.TypedValue;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
@@ -16,21 +17,23 @@ public class ResourceUtils {
|
||||
public static String readRawResource(Context context, @RawRes int rawResource) throws IOException {
|
||||
String json = "";
|
||||
if (context != null) {
|
||||
InputStream is = context.getResources().openRawResource(rawResource);
|
||||
Writer writer = new StringWriter();
|
||||
char[] buffer = new char[1024];
|
||||
try {
|
||||
try (InputStream is = context.getResources().openRawResource(rawResource)) {
|
||||
Reader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
||||
int numRead;
|
||||
while ((numRead = reader.read(buffer)) != -1) {
|
||||
writer.write(buffer, 0, numRead);
|
||||
}
|
||||
} finally {
|
||||
is.close();
|
||||
}
|
||||
json = writer.toString();
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
||||
public static float convertDpToPx(Context context, float dp) {
|
||||
return TypedValue.applyDimension(
|
||||
TypedValue.COMPLEX_UNIT_DIP, dp, context.getResources().getDisplayMetrics());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 162 KiB |
@@ -1,9 +0,0 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M20.94,11c-0.46,-4.17 -3.77,-7.48 -7.94,-7.94L13,1h-2v2.06c-1.13,0.12 -2.19,0.46 -3.16,0.97l1.5,1.5C10.16,5.19 11.06,5 12,5c3.87,0 7,3.13 7,7 0,0.94 -0.19,1.84 -0.52,2.65l1.5,1.5c0.5,-0.96 0.84,-2.02 0.97,-3.15L23,13v-2h-2.06zM3,4.27l2.04,2.04C3.97,7.62 3.25,9.23 3.06,11L1,11v2h2.06c0.46,4.17 3.77,7.48 7.94,7.94L11,23h2v-2.06c1.77,-0.2 3.38,-0.91 4.69,-1.98L19.73,21 21,19.73 4.27,3 3,4.27zM16.27,17.54C15.09,18.45 13.61,19 12,19c-3.87,0 -7,-3.13 -7,-7 0,-1.61 0.55,-3.09 1.46,-4.27l9.81,9.81z"/>
|
||||
</vector>
|
||||
@@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@id/coordinator_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.mapbox.mapboxsdk.maps.MapView
|
||||
android:id="@id/mapView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:mapbox_cameraTargetLat="40.416872"
|
||||
app:mapbox_cameraTargetLng="-3.703807"
|
||||
app:mapbox_cameraZoom="4"/>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/fabLocationToggle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|bottom"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
android:src="@drawable/ic_my_location"
|
||||
tools:backgroundTint="@color/primary"/>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="com.mapbox.mapboxsdk.testapp.activity.camera.GestureDetectorActivity">
|
||||
|
||||
<com.mapbox.mapboxsdk.maps.MapView
|
||||
android:id="@id/mapView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:mapbox_cameraTargetLat="51.50325"
|
||||
app:mapbox_cameraTargetLng="-0.11968"
|
||||
app:mapbox_cameraZoom="15" />
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/alerts_recycler"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="#97cdcfd3" />
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<android.support.v4.widget.ContentLoadingProgressBar
|
||||
android:id="@id/progress"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"/>
|
||||
|
||||
</merge>
|
||||
@@ -1,62 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:mapbox="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.mapbox.mapboxsdk.maps.MapView
|
||||
android:id="@id/mapView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
mapbox:mapbox_uiAttribution="false"
|
||||
mapbox:mapbox_uiLogo="false"/>
|
||||
|
||||
<LinearLayout
|
||||
style="?android:attr/buttonBarStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@color/accent"
|
||||
android:orientation="horizontal"
|
||||
android:weightSum="4">
|
||||
|
||||
<Button
|
||||
android:id="@+id/default_user_dot_coloring_button"
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/button_user_dot_default"
|
||||
android:textColor="@color/white"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/tint_user_dot_button"
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/button_user_dot_tint"
|
||||
android:textColor="@color/white"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/user_accuracy_ring_tint_button"
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/button_user_accuracy_ring_tint"
|
||||
android:textColor="@color/white"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/user_dot_transparent_button"
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/button_user_transparent_tint"
|
||||
android:textColor="@color/white"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@id/coordinator_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.mapbox.mapboxsdk.maps.MapView
|
||||
android:id="@id/mapView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/fabLocationToggle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|bottom"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
android:src="@drawable/ic_my_location"
|
||||
tools:backgroundTint="@color/primary"/>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
@@ -1,50 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="@color/primary"
|
||||
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:weightSum="2">
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spinner_location"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spinner_bearing"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
<com.mapbox.mapboxsdk.maps.MapView
|
||||
android:id="@+id/mapView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:mapbox_myLocationTintColor="@color/primary"
|
||||
app:mapbox_myLocationAccuracyTintColor="@color/primary"
|
||||
app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"
|
||||
app:mapbox_cameraZoom="8" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -7,7 +7,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
|
||||
<com.mapbox.mapboxsdk.maps.MapView
|
||||
android:id="@+id/mapView"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/coordinator_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:contentDescription="@null"/>
|
||||
|
||||
<com.mapbox.mapboxsdk.maps.MapView
|
||||
android:id="@+id/mapView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:mapbox_cameraTargetLat="48.507879"
|
||||
app:mapbox_cameraTargetLng="8.363795"
|
||||
app:mapbox_cameraZoom="2"
|
||||
app:mapbox_renderTextureMode="true"
|
||||
app:mapbox_renderTextureTranslucentSurface="true"
|
||||
app:mapbox_styleUrl="mapbox://styles/agerace-globant/cja02de7193b02suvy4gpbt2c"/>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/alert_message"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="2dp"
|
||||
android:paddingTop="2dp"
|
||||
android:textSize="9sp" />
|
||||
|
||||
</FrameLayout>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/menu_gesture_none"
|
||||
android:title="None" />
|
||||
<item
|
||||
android:id="@+id/menu_gesture_focus_point"
|
||||
android:title="Focus on a point" />
|
||||
<item
|
||||
android:id="@+id/menu_gesture_animation"
|
||||
android:title="Turn off velocity animations" />
|
||||
</menu>
|
||||
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:mapbox="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_id_location_source_lost"
|
||||
android:title="@string/menuitem_title_change_location_source_lost"
|
||||
mapbox:showAsAction="never"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_id_location_source_mock"
|
||||
android:title="@string/menuitem_title_change_location_source_mock"
|
||||
mapbox:showAsAction="never"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_id_location_source_null"
|
||||
android:title="@string/menuitem_title_change_location_source_null"
|
||||
mapbox:showAsAction="never"/>
|
||||
|
||||
</menu>
|
||||
@@ -1,10 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:mapbox="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/action_user_tracking"
|
||||
android:title="@string/my_location_tracking"
|
||||
mapbox:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/action_bangalore"
|
||||
android:title="@string/bangalore"
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<group android:checkableBehavior="all">
|
||||
<item
|
||||
android:id="@+id/action_toggle_dismissible_location"
|
||||
android:checkable="true"
|
||||
android:checked="false"
|
||||
android:title="@string/menuitem_title_tracking_mode_dismiss_on_gesture"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/action_toggle_dismissible_bearing"
|
||||
android:checkable="true"
|
||||
android:checked="false"
|
||||
android:title="@string/menuitem_title_bearing_mode_dismiss_on_gesture"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/action_toggle_rotate_gesture_enabled"
|
||||
android:checkable="true"
|
||||
android:checked="false"
|
||||
android:title="@string/menuitem_title_rotate_gesture_enabled"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/action_toggle_scroll_gesture_enabled"
|
||||
android:checkable="true"
|
||||
android:checked="false"
|
||||
android:title="@string/menuitem_title_scroll_gesture_enabled"
|
||||
app:showAsAction="never" />
|
||||
</group>
|
||||
|
||||
</menu>
|
||||
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"version": 8,
|
||||
"name": "Land",
|
||||
"metadata": {
|
||||
"mapbox:autocomposite": true,
|
||||
},
|
||||
"sources": {
|
||||
"composite": {
|
||||
"url": "mapbox://mapbox.mapbox-terrain-v2",
|
||||
"type": "vector"
|
||||
}
|
||||
},
|
||||
"sprite": "mapbox://sprites/mapbox/mapbox-terrain-v2",
|
||||
"glyphs": "mapbox://fonts/mapbox/{fontstack}/{range}.pbf",
|
||||
"layers": [
|
||||
{
|
||||
"layout": {
|
||||
"visibility": "visible"
|
||||
},
|
||||
"type": "fill",
|
||||
"source": "composite",
|
||||
"id": "admin",
|
||||
"paint": {
|
||||
"fill-color": "hsl(359, 100%, 50%)",
|
||||
"fill-opacity": 1
|
||||
},
|
||||
"source-layer": "landcover"
|
||||
},
|
||||
{
|
||||
"layout": {
|
||||
"visibility": "visible"
|
||||
},
|
||||
"type": "fill",
|
||||
"source": "composite",
|
||||
"id": "layer-0",
|
||||
"paint": {
|
||||
"fill-opacity": 1,
|
||||
"fill-color": "hsl(359, 100%, 50%)"
|
||||
},
|
||||
"source-layer": "Layer_0"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2,14 +2,7 @@
|
||||
<resources>
|
||||
<string name="menuitem_title_concurrent_infowindow">Concurrent Open InfoWindows</string>
|
||||
<string name="menuitem_title_deselect_markers_on_tap">Deselect Markers On Tap</string>
|
||||
<string name="menuitem_title_tracking_mode_dismiss_on_gesture">Dismiss location tracking on gesture</string>
|
||||
<string name="menuitem_title_bearing_mode_dismiss_on_gesture">Dismiss bearing tracking on gesture</string>
|
||||
<string name="menuitem_title_reset">Reset</string>
|
||||
<string name="menuitem_title_rotate_gesture_enabled">Enable rotate gestures</string>
|
||||
<string name="menuitem_title_scroll_gesture_enabled">Enable scroll gestures</string>
|
||||
<string name="menuitem_title_change_location_source_lost">Change to LOST location source</string>
|
||||
<string name="menuitem_title_change_location_source_mock">Change to mock location source</string>
|
||||
<string name="menuitem_title_change_location_source_null">Reset location source to null</string>
|
||||
<string name="menuitem_change_icon_overlap">Toggle icon overlap</string>
|
||||
<string name="menuitem_filter">Filter layer</string>
|
||||
<string name="menuitem_change_location">Change location</string>
|
||||
@@ -21,10 +14,6 @@
|
||||
<string name="button_camera_move">Move</string>
|
||||
<string name="button_camera_ease">Ease</string>
|
||||
<string name="button_camera_animate">Animate</string>
|
||||
<string name="button_user_dot_default">Default</string>
|
||||
<string name="button_user_dot_tint">Tint dot</string>
|
||||
<string name="button_user_accuracy_ring_tint">Tint ring</string>
|
||||
<string name="button_user_transparent_tint">tran</string>
|
||||
<string name="button_open_dialog">Open dialog</string>
|
||||
<string name="button_download_region">Download region</string>
|
||||
<string name="button_list_regions">List regions</string>
|
||||
@@ -73,7 +62,6 @@
|
||||
<string name="add_a_composite_categorical_function">Add a composite, categorical function</string>
|
||||
<string name="add_a_composite_exponential_function">Add a composite, exponential function</string>
|
||||
<string name="add_a_composite_interval_function">Add a composite, interval function</string>
|
||||
<string name="my_location_tracking">My Location Tracking</string>
|
||||
<string name="bangalore">Bangalore</string>
|
||||
<string name="list_all_layers_in_the_style">List all layers in the style</string>
|
||||
<string name="list_all_sources_in_the_style">List all sources in the style</string>
|
||||
|
||||
@@ -7,16 +7,4 @@
|
||||
<item>1000</item>
|
||||
<item>10000</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="user_tracking_mode">
|
||||
<item>Disabled</item>
|
||||
<item>Follow tracking</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="user_bearing_mode">
|
||||
<item>Disabled</item>
|
||||
<item>GPS bearing</item>
|
||||
<item>Compass bearing</item>
|
||||
<!--<item>Combined mode</item>-->
|
||||
</string-array>
|
||||
</resources>
|
||||
@@ -10,7 +10,6 @@
|
||||
<string name="category_infowindow">Info Window</string>
|
||||
<string name="category_maplayout">Map Layout</string>
|
||||
<string name="category_offline">Offline</string>
|
||||
<string name="category_userlocation">User Location</string>
|
||||
<string name="category_style">Styling</string>
|
||||
<string name="category_features">Features</string>
|
||||
<string name="category_storage">Storage</string>
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="description_user_location_tracking">Tracks the location of the user</string>
|
||||
<string name="description_user_location_customization">Customize the location of the user</string>
|
||||
<string name="description_user_location_dot_color">Customize the user location color</string>
|
||||
<string name="description_user_location_toggle">Toggle location of the user on and off</string>
|
||||
<string name="description_custom_location_engine">Customize location engine</string>
|
||||
<string name="description_custom_layer">Overlay a custom native layer on the map</string>
|
||||
<string name="description_info_window_adapter">Learn how to create a custom InfoWindow</string>
|
||||
<string name="description_cameraposition">CameraPosition capabilities</string>
|
||||
@@ -67,8 +62,10 @@
|
||||
<string name="description_textureview_debug">Use TextureView to render the map</string>
|
||||
<string name="description_textureview_resize">Resize a map rendered on a TextureView</string>
|
||||
<string name="description_textureview_animate">Animate a map rendered on a TextureView</string>
|
||||
<string name="description_textureview_transparent">Enable a transparent surface on TextureView</string>
|
||||
<string name="description_grid_source">Example Custom Geometry Source</string>
|
||||
<string name="description_local_glyph">Suzhou using Droid Sans for Chinese glyphs</string>
|
||||
<string name="description_hillshade">Example raster-dem source and hillshade layer</string>
|
||||
<string name="description_heatmaplayer">Use HeatmapLayer to visualise earthquakes</string>
|
||||
<string name="description_gesture_detector">Manipulate gestures detector\'s settings</string>
|
||||
</resources>
|
||||
|
||||
@@ -6,6 +6,5 @@
|
||||
<dimen name="map_padding_bottom">256dp</dimen>
|
||||
<dimen name="map_padding_right">32dp</dimen>
|
||||
<dimen name="map_padding_top">0dp</dimen>
|
||||
<dimen name="locationview_background_drawable_padding">2dp</dimen>
|
||||
<dimen name="navigation_drawer_width">240dp</dimen>
|
||||
</resources>
|
||||
|
||||
@@ -21,11 +21,6 @@
|
||||
<string name="activity_scroll_by">Scroll By Method</string>
|
||||
<string name="activity_double_map">Double Map Activity</string>
|
||||
<string name="activity_snapshot">Snapshot Activity</string>
|
||||
<string name="activity_user_tracking_mode">User tracking mode</string>
|
||||
<string name="activity_user_tracking_customization">User location drawable</string>
|
||||
<string name="activity_user_dot_color">User location tint color</string>
|
||||
<string name="activity_user_location_toggle">User location toggle</string>
|
||||
<string name="activity_custom_location_engine">Custom location engine</string>
|
||||
<string name="activity_custom_layer">Custom Layer</string>
|
||||
<string name="activity_map_padding">Map Padding</string>
|
||||
<string name="activity_debug_mode">Debug Mode</string>
|
||||
@@ -67,8 +62,10 @@
|
||||
<string name="activity_textureview_debug">TextureView debug</string>
|
||||
<string name="activity_textureview_resize">TextureView resize</string>
|
||||
<string name="activity_textureview_animate">TextureView animation</string>
|
||||
<string name="activity_textureview_transparent">TextureView transparent background</string>
|
||||
<string name="activity_grid_source">Grid Source</string>
|
||||
<string name="activity_local_glyph">Local CJK glyph generation</string>
|
||||
<string name="activity_hillshade">Hillshade</string>
|
||||
<string name="activity_heatmaplayer">Heatmap layer</string>
|
||||
<string name="activity_gesture_detector">Gestures detector</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user