diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDKTestApp/src')
241 files changed, 7663 insertions, 8329 deletions
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java index 330de1e9c8..2cd077f510 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapTest.java @@ -107,6 +107,7 @@ public class MapboxMapTest { } @Test + @Ignore public void testInitialZoomLevels() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = activity.getMapboxMap(); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraAnimateTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraAnimateTest.java index 5ead54eb7b..d4b0dbad72 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraAnimateTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraAnimateTest.java @@ -22,6 +22,7 @@ import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; import org.hamcrest.Matcher; import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; @@ -44,6 +45,7 @@ public class CameraAnimateTest { } @Test + @Ignore public void testAnimateToCameraPositionTarget() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); @@ -66,6 +68,7 @@ public class CameraAnimateTest { } @Test + @Ignore public void testAnimateToCameraPositionTargetZoom() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); @@ -114,6 +117,7 @@ public class CameraAnimateTest { } @Test + @Ignore public void testAnimateToBounds() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); @@ -142,6 +146,7 @@ public class CameraAnimateTest { } @Test + @Ignore public void testAnimateToMoveBy() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); @@ -161,6 +166,7 @@ public class CameraAnimateTest { } @Test + @Ignore public void testAnimateToZoomIn() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); @@ -175,6 +181,7 @@ public class CameraAnimateTest { } @Test + @Ignore public void testAnimateToZoomOut() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); @@ -190,6 +197,7 @@ public class CameraAnimateTest { } @Test + @Ignore public void testAnimateToZoomBy() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); @@ -205,6 +213,7 @@ public class CameraAnimateTest { } @Test + @Ignore public void testAnimateToZoomTo() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraEaseTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraEaseTest.java index 22af72cebb..83e7d6084c 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraEaseTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraEaseTest.java @@ -22,6 +22,7 @@ import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; import org.hamcrest.Matcher; import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; @@ -44,6 +45,7 @@ public class CameraEaseTest { } @Test + @Ignore public void testEaseToCameraPositionTarget() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); @@ -66,6 +68,7 @@ public class CameraEaseTest { } @Test + @Ignore public void testEaseToCameraPositionTargetZoom() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); @@ -84,6 +87,7 @@ public class CameraEaseTest { } @Test + @Ignore public void testEaseToCameraPosition() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); @@ -114,6 +118,7 @@ public class CameraEaseTest { } @Test + @Ignore public void testEaseToBounds() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); @@ -142,6 +147,7 @@ public class CameraEaseTest { } @Test + @Ignore public void testEaseToMoveBy() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); @@ -161,6 +167,7 @@ public class CameraEaseTest { } @Test + @Ignore public void testEaseToZoomIn() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); @@ -175,6 +182,7 @@ public class CameraEaseTest { } @Test + @Ignore public void testEaseToZoomOut() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); @@ -189,6 +197,7 @@ public class CameraEaseTest { } @Test + @Ignore public void testEaseToZoomBy() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); @@ -204,6 +213,7 @@ public class CameraEaseTest { } @Test + @Ignore public void testEaseToZoomTo() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalApiTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalApiTest.java index 3ca61f7e9d..2d01347d22 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalApiTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraInternalApiTest.java @@ -19,6 +19,7 @@ import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; import org.hamcrest.Matcher; import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; @@ -44,6 +45,7 @@ public class CameraInternalApiTest { } @Test + @Ignore public void testBearing() { ViewUtils.checkViewIsDisplayed(R.id.mapView); EspressoTestActivity activity = rule.getActivity(); @@ -59,6 +61,7 @@ public class CameraInternalApiTest { } @Test + @Ignore public void testTilt() { ViewUtils.checkViewIsDisplayed(R.id.mapView); EspressoTestActivity activity = rule.getActivity(); @@ -74,6 +77,7 @@ public class CameraInternalApiTest { } @Test + @Ignore public void testLatLng() { ViewUtils.checkViewIsDisplayed(R.id.mapView); EspressoTestActivity activity = rule.getActivity(); @@ -166,4 +170,4 @@ public class CameraInternalApiTest { MapViewUtils.setLatLng(mapboxMap, new LatLng(1.1, 2.2)); } } -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraMoveTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraMoveTest.java index b3a7fe0d11..becf9db7cb 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraMoveTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/camera/CameraMoveTest.java @@ -22,6 +22,7 @@ import com.mapbox.mapboxsdk.testapp.utils.ViewUtils; import org.hamcrest.Matcher; import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; @@ -44,6 +45,7 @@ public class CameraMoveTest { } @Test + @Ignore public void testMoveToCameraPositionTarget() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); @@ -66,6 +68,7 @@ public class CameraMoveTest { } @Test + @Ignore public void testMoveToCameraPositionTargetZoom() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); @@ -84,6 +87,7 @@ public class CameraMoveTest { } @Test + @Ignore public void testMoveToCameraPosition() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); @@ -114,6 +118,7 @@ public class CameraMoveTest { } @Test + @Ignore public void testMoveToBounds() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); @@ -142,6 +147,7 @@ public class CameraMoveTest { } @Test + @Ignore public void testMoveToMoveBy() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); @@ -161,6 +167,7 @@ public class CameraMoveTest { } @Test + @Ignore public void testMoveToZoomIn() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); @@ -175,6 +182,7 @@ public class CameraMoveTest { } @Test + @Ignore public void testMoveToZoomOut() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); @@ -190,6 +198,7 @@ public class CameraMoveTest { } @Test + @Ignore public void testMoveToZoomBy() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); @@ -205,6 +214,7 @@ public class CameraMoveTest { } @Test + @Ignore public void testMoveToZoomTo() { ViewUtils.checkViewIsDisplayed(R.id.mapView); final MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesBoxCountTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesBoxCountTest.java index b4be73be7a..f49296a164 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesBoxCountTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesBoxCountTest.java @@ -58,4 +58,4 @@ public class QueryRenderedFeaturesBoxCountTest { Espresso.unregisterIdlingResources(idlingResource); } -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesHighlightTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesHighlightTest.java index b8cd46e612..0333aba191 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesHighlightTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesHighlightTest.java @@ -78,4 +78,4 @@ public class QueryRenderedFeaturesHighlightTest { }, Press.FINGER); } -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesPropertiesTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesPropertiesTest.java index 3b86397603..01eb9c8b44 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesPropertiesTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/feature/QueryRenderedFeaturesPropertiesTest.java @@ -75,4 +75,4 @@ public class QueryRenderedFeaturesPropertiesTest { }, Press.FINGER); } -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java index ac10d11922..c8a983351b 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/MyLocationViewTest.java @@ -16,7 +16,7 @@ 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.location.LocationServices; +import com.mapbox.mapboxsdk.location.LocationSource; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.widgets.MyLocationView; import com.mapbox.mapboxsdk.testapp.R; @@ -123,7 +123,7 @@ public class MyLocationViewTest { mapboxMap.moveCamera( CameraUpdateFactory.newCameraPosition( new CameraPosition.Builder() - .target(new LatLng(LocationServices.getLocationServices(view.getContext()).getLastLocation())) + .target(new LatLng(LocationSource.getLocationEngine(view.getContext()).getLastLocation())) .build() ) ); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerStyleTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerStyleTest.java deleted file mode 100644 index 68ed5cb05d..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerStyleTest.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.style; -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. - -import android.graphics.Color; -import android.support.test.espresso.Espresso; -import android.support.test.rule.ActivityTestRule; -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.style.layers.BackgroundLayer; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity; -import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; - -import timber.log.Timber; - -import static com.mapbox.mapboxsdk.style.layers.Property.NONE; -import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundColor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundOpacity; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundPattern; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -/** - * Basic smoke tests for BackgroundLayer - */ -@RunWith(AndroidJUnit4.class) -public class BackgroundLayerStyleTest extends BaseStyleTest { - - @Rule - public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); - - private BackgroundLayer layer; - - private OnMapReadyIdlingResource idlingResource; - - private MapboxMap mapboxMap; - - @Before - public void setup() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } - - @Test - public void testSetVisibility() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - Timber.i("Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); - Timber.i("visibility"); - assertNotNull(layer); - - //Get initial - assertEquals(layer.getVisibility().getValue(), VISIBLE); - - //Set - layer.setProperties(visibility(NONE)); - assertEquals(layer.getVisibility().getValue(), NONE); - } - - @Test - public void testBackgroundColor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - Timber.i("Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); - Timber.i("background-color"); - 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 testBackgroundColorAsInt() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - Timber.i("Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); - Timber.i("background-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(backgroundColor(Color.RED)); - assertEquals(layer.getBackgroundColorAsInt(), Color.RED); - } - - @Test - public void testBackgroundPattern() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - Timber.i("Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); - Timber.i("background-pattern"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(backgroundPattern("pedestrian-polygon")); - assertEquals((String) layer.getBackgroundPattern().getValue(), (String) "pedestrian-polygon"); - } - - @Test - public void testBackgroundOpacity() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - Timber.i("Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); - Timber.i("background-opacity"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(backgroundOpacity(0.3f)); - assertEquals((Float) layer.getBackgroundOpacity().getValue(), (Float) 0.3f); - } - - - @After - public void unregisterIntentServiceIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java index ab53ae0487..510f477bce 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java @@ -1,12 +1,23 @@ -package com.mapbox.mapboxsdk.testapp.style; // This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. +package com.mapbox.mapboxsdk.testapp.style; + import android.graphics.Color; import android.support.test.espresso.Espresso; import android.support.test.rule.ActivityTestRule; 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.layers.BackgroundLayer; import com.mapbox.mapboxsdk.testapp.R; import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity; @@ -18,16 +29,12 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import timber.log.Timber; - -import static com.mapbox.mapboxsdk.style.layers.Property.NONE; -import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundColor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundOpacity; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundPattern; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +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 org.junit.Assert.*; +import static com.mapbox.mapboxsdk.style.layers.Property.*; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; /** * Basic smoke tests for BackgroundLayer @@ -48,91 +55,147 @@ public class BackgroundLayerTest extends BaseStyleTest { public void setup() { idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); Espresso.registerIdlingResources(idlingResource); + mapboxMap = rule.getActivity().getMapboxMap(); + + Timber.i("Retrieving layer"); + layer = mapboxMap.getLayerAs("background"); } @Test public void testSetVisibility() { checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - Timber.i("Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); - Timber.i("visibility"); + Timber.i("Visibility"); assertNotNull(layer); - //Get initial + // Get initial assertEquals(layer.getVisibility().getValue(), VISIBLE); - //Set + // Set layer.setProperties(visibility(NONE)); assertEquals(layer.getVisibility().getValue(), NONE); } @Test - public void testBackgroundColor() { + public void testBackgroundColorAsConstant() { checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - Timber.i("Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); Timber.i("background-color"); assertNotNull(layer); - //Set and Get + // 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 testBackgroundColorAsInt() { + public void testBackgroundColorAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("background-color"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // 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()); + } - Timber.i("Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); + @Test + public void testBackgroundColorAsIntConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("background-color"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(backgroundColor(Color.RED)); assertEquals(layer.getBackgroundColorAsInt(), Color.RED); } @Test - public void testBackgroundPattern() { + public void testBackgroundPatternAsConstant() { checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - Timber.i("Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); Timber.i("background-pattern"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(backgroundPattern("pedestrian-polygon")); assertEquals((String) layer.getBackgroundPattern().getValue(), (String) "pedestrian-polygon"); } @Test - public void testBackgroundOpacity() { + public void testBackgroundPatternAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("background-pattern"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // 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()); + } - Timber.i("Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); + @Test + public void testBackgroundOpacityAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("background-opacity"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(backgroundOpacity(0.3f)); assertEquals((Float) layer.getBackgroundOpacity().getValue(), (Float) 0.3f); } + @Test + public void testBackgroundOpacityAsCameraFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("background-opacity"); + 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()); + } + @After public void unregisterIntentServiceIdlingResource() { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerStyleTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerStyleTest.java deleted file mode 100644 index 58fda51f07..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerStyleTest.java +++ /dev/null @@ -1,265 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.style; -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. - -import android.graphics.Color; -import android.support.test.espresso.Espresso; -import android.support.test.rule.ActivityTestRule; -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.style.layers.CircleLayer; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity; -import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; - -import timber.log.Timber; - -import static com.mapbox.mapboxsdk.style.layers.Property.CIRCLE_PITCH_SCALE_MAP; -import static com.mapbox.mapboxsdk.style.layers.Property.CIRCLE_TRANSLATE_ANCHOR_MAP; -import static com.mapbox.mapboxsdk.style.layers.Property.NONE; -import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleBlur; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleOpacity; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circlePitchScale; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleTranslate; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleTranslateAnchor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -/** - * Basic smoke tests for CircleLayer - */ -@RunWith(AndroidJUnit4.class) -public class CircleLayerStyleTest extends BaseStyleTest { - - @Rule - public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); - - private CircleLayer layer; - - private OnMapReadyIdlingResource idlingResource; - - private MapboxMap mapboxMap; - - @Before - public void setup() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } - - @Test - public void testSetVisibility() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("visibility"); - assertNotNull(layer); - - //Get initial - assertEquals(layer.getVisibility().getValue(), VISIBLE); - - //Set - layer.setProperties(visibility(NONE)); - assertEquals(layer.getVisibility().getValue(), NONE); - } - - @Test - public void testCircleRadius() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-radius"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circleRadius(0.3f)); - assertEquals((Float) layer.getCircleRadius().getValue(), (Float) 0.3f); - } - - @Test - public void testCircleColor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circleColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getCircleColor().getValue(), (String) "rgba(0, 0, 0, 1)"); - } - - @Test - public void testCircleColorAsInt() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circleColor(Color.RED)); - assertEquals(layer.getCircleColorAsInt(), Color.RED); - } - - @Test - public void testCircleBlur() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-blur"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circleBlur(0.3f)); - assertEquals((Float) layer.getCircleBlur().getValue(), (Float) 0.3f); - } - - @Test - public void testCircleOpacity() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-opacity"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circleOpacity(0.3f)); - assertEquals((Float) layer.getCircleOpacity().getValue(), (Float) 0.3f); - } - - @Test - public void testCircleTranslate() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-translate"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circleTranslate(new Float[] {0f, 0f})); - assertEquals((Float[]) layer.getCircleTranslate().getValue(), (Float[]) new Float[] {0f, 0f}); - } - - @Test - public void testCircleTranslateAnchor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-translate-anchor"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circleTranslateAnchor(CIRCLE_TRANSLATE_ANCHOR_MAP)); - assertEquals((String) layer.getCircleTranslateAnchor().getValue(), (String) CIRCLE_TRANSLATE_ANCHOR_MAP); - } - - @Test - public void testCirclePitchScale() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("circle-pitch-scale"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(circlePitchScale(CIRCLE_PITCH_SCALE_MAP)); - assertEquals((String) layer.getCirclePitchScale().getValue(), (String) CIRCLE_PITCH_SCALE_MAP); - } - - - @After - public void unregisterIntentServiceIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerTest.java index 782598a0b2..c48a6f1d68 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerTest.java @@ -1,12 +1,23 @@ -package com.mapbox.mapboxsdk.testapp.style; // This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. +package com.mapbox.mapboxsdk.testapp.style; + import android.graphics.Color; import android.support.test.espresso.Espresso; import android.support.test.rule.ActivityTestRule; 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.layers.CircleLayer; import com.mapbox.mapboxsdk.testapp.R; import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity; @@ -18,25 +29,12 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import timber.log.Timber; - -import static com.mapbox.mapboxsdk.style.layers.Property.CIRCLE_PITCH_SCALE_MAP; -import static com.mapbox.mapboxsdk.style.layers.Property.CIRCLE_TRANSLATE_ANCHOR_MAP; -import static com.mapbox.mapboxsdk.style.layers.Property.NONE; -import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleBlur; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleOpacity; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circlePitchScale; -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.circleStrokeOpacity; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleStrokeWidth; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleTranslate; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleTranslateAnchor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +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 org.junit.Assert.*; +import static com.mapbox.mapboxsdk.style.layers.Property.*; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; /** * Basic smoke tests for CircleLayer @@ -57,12 +55,6 @@ public class CircleLayerTest extends BaseStyleTest { public void setup() { idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); Espresso.registerIdlingResources(idlingResource); - } - - @Test - public void testSetVisibility() { - checkViewIsDisplayed(R.id.mapView); - mapboxMap = rule.getActivity().getMapboxMap(); if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { @@ -70,284 +62,1087 @@ public class CircleLayerTest extends BaseStyleTest { layer = new CircleLayer("my-layer", "composite"); layer.setSourceLayer("composite"); mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference + // Layer reference is now stale, get new reference layer = mapboxMap.getLayerAs("my-layer"); } - Timber.i("visibility"); + } + + @Test + public void testSetVisibility() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("Visibility"); assertNotNull(layer); - //Get initial + // Get initial assertEquals(layer.getVisibility().getValue(), VISIBLE); - //Set + // Set layer.setProperties(visibility(NONE)); assertEquals(layer.getVisibility().getValue(), NONE); } @Test - public void testCircleRadius() { + public void testCircleRadiusAsConstant() { checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } Timber.i("circle-radius"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(circleRadius(0.3f)); assertEquals((Float) layer.getCircleRadius().getValue(), (Float) 0.3f); } @Test - public void testCircleColor() { + public void testCircleRadiusAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-radius"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + circleRadius( + zoom( + exponential( + stop(2, circleRadius(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleRadius()); + assertNotNull(layer.getCircleRadius().getFunction()); + assertEquals(CameraFunction.class, layer.getCircleRadius().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getCircleRadius().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getCircleRadius().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getCircleRadius().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testCircleRadiusAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-radius"); + assertNotNull(layer); + + // Set + layer.setProperties( + circleRadius(property("FeaturePropertyA", Stops.<Float>identity())) + ); + + // Verify + assertNotNull(layer.getCircleRadius()); + assertNotNull(layer.getCircleRadius().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleRadius().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleRadius().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getCircleRadius().getFunction().getStops().getClass()); + } + + @Test + public void testCircleRadiusAsExponentialSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-radius"); + assertNotNull(layer); + + // Set + layer.setProperties( + circleRadius( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, circleRadius(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleRadius()); + assertNotNull(layer.getCircleRadius().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleRadius().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleRadius().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getCircleRadius().getFunction().getStops().getClass()); + } + + @Test + public void testCircleRadiusAsCategoricalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-radius"); + assertNotNull(layer); + + // Set + layer.setProperties( + circleRadius( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, circleRadius(0.3f)) + ) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getCircleRadius()); + assertNotNull(layer.getCircleRadius().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleRadius().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleRadius().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getCircleRadius().getFunction().getStops().getClass()); + assertEquals(0.3f, ((SourceFunction) layer.getCircleRadius().getFunction()).getDefaultValue()); + } + + @Test + public void testCircleRadiusAsCompositeFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-radius"); + assertNotNull(layer); + + // Set + layer.setProperties( + circleRadius( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, circleRadius(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getCircleRadius()); + assertNotNull(layer.getCircleRadius().getFunction()); + assertEquals(CompositeFunction.class, layer.getCircleRadius().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getCircleRadius().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getCircleRadius().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getCircleRadius().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getCircleRadius().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 testCircleColorAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("circle-color"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(circleColor("rgba(0, 0, 0, 1)")); assertEquals((String) layer.getCircleColor().getValue(), (String) "rgba(0, 0, 0, 1)"); } @Test - public void testCircleColorAsInt() { + public void testCircleColorAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-color"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + circleColor( + zoom( + exponential( + stop(2, circleColor("rgba(0, 0, 0, 1)")) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleColor()); + assertNotNull(layer.getCircleColor().getFunction()); + assertEquals(CameraFunction.class, layer.getCircleColor().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getCircleColor().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getCircleColor().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getCircleColor().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testCircleColorAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); Timber.i("circle-color"); assertNotNull(layer); - //Set and Get - layer.setProperties(circleColor(Color.RED)); - assertEquals(layer.getCircleColorAsInt(), Color.RED); + // Set + layer.setProperties( + circleColor(property("FeaturePropertyA", Stops.<String>identity())) + ); + + // Verify + assertNotNull(layer.getCircleColor()); + assertNotNull(layer.getCircleColor().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleColor().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getCircleColor().getFunction().getStops().getClass()); } @Test - public void testCircleBlur() { + public void testCircleColorAsExponentialSourceFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-color"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + circleColor( + property( + "FeaturePropertyA", + exponential( + stop(Color.RED, circleColor(Color.RED)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleColor()); + assertNotNull(layer.getCircleColor().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleColor().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getCircleColor().getFunction().getStops().getClass()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testCircleColorAsCategoricalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-color"); + assertNotNull(layer); + + // Set + layer.setProperties( + circleColor( + property( + "FeaturePropertyA", + categorical( + stop("valueA", circleColor(Color.RED)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleColor()); + assertNotNull(layer.getCircleColor().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleColor().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getCircleColor().getFunction().getStops().getClass()); + } + + @Test + public void testCircleColorAsIntConstant() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-color"); + assertNotNull(layer); + + // Set and Get + layer.setProperties(circleColor(Color.RED)); + assertEquals(layer.getCircleColorAsInt(), Color.RED); + } + + @Test + public void testCircleBlurAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("circle-blur"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(circleBlur(0.3f)); assertEquals((Float) layer.getCircleBlur().getValue(), (Float) 0.3f); } @Test - public void testCircleOpacity() { + public void testCircleBlurAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-blur"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + circleBlur( + zoom( + exponential( + stop(2, circleBlur(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleBlur()); + assertNotNull(layer.getCircleBlur().getFunction()); + assertEquals(CameraFunction.class, layer.getCircleBlur().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getCircleBlur().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getCircleBlur().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getCircleBlur().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testCircleBlurAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-blur"); + assertNotNull(layer); + + // Set + layer.setProperties( + circleBlur(property("FeaturePropertyA", Stops.<Float>identity())) + ); + + // Verify + assertNotNull(layer.getCircleBlur()); + assertNotNull(layer.getCircleBlur().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleBlur().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getCircleBlur().getFunction().getStops().getClass()); + } + + @Test + public void testCircleBlurAsExponentialSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-blur"); + assertNotNull(layer); + + // Set + layer.setProperties( + circleBlur( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, circleBlur(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleBlur()); + assertNotNull(layer.getCircleBlur().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleBlur().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getCircleBlur().getFunction().getStops().getClass()); + } + + @Test + public void testCircleBlurAsCategoricalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-blur"); + assertNotNull(layer); + + // Set + layer.setProperties( + circleBlur( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, circleBlur(0.3f)) + ) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getCircleBlur()); + assertNotNull(layer.getCircleBlur().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleBlur().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getCircleBlur().getFunction().getStops().getClass()); + assertEquals(0.3f, ((SourceFunction) layer.getCircleBlur().getFunction()).getDefaultValue()); + } + + @Test + public void testCircleBlurAsCompositeFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-blur"); + assertNotNull(layer); + + // Set + layer.setProperties( + circleBlur( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, circleBlur(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getCircleBlur()); + assertNotNull(layer.getCircleBlur().getFunction()); + assertEquals(CompositeFunction.class, layer.getCircleBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getCircleBlur().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getCircleBlur().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getCircleBlur().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getCircleBlur().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 testCircleOpacityAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("circle-opacity"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(circleOpacity(0.3f)); assertEquals((Float) layer.getCircleOpacity().getValue(), (Float) 0.3f); } @Test - public void testCircleTranslate() { + public void testCircleOpacityAsCameraFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-opacity"); + assertNotNull(layer); + + // Set + layer.setProperties( + circleOpacity( + zoom( + exponential( + stop(2, circleOpacity(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleOpacity()); + assertNotNull(layer.getCircleOpacity().getFunction()); + assertEquals(CameraFunction.class, layer.getCircleOpacity().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getCircleOpacity().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getCircleOpacity().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getCircleOpacity().getFunction().getStops()).size()); + } + + @Test + public void testCircleOpacityAsIdentitySourceFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-opacity"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + circleOpacity(property("FeaturePropertyA", Stops.<Float>identity())) + ); + + // Verify + assertNotNull(layer.getCircleOpacity()); + assertNotNull(layer.getCircleOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleOpacity().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getCircleOpacity().getFunction().getStops().getClass()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testCircleOpacityAsExponentialSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-opacity"); + assertNotNull(layer); + + // Set + layer.setProperties( + circleOpacity( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, circleOpacity(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleOpacity()); + assertNotNull(layer.getCircleOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleOpacity().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getCircleOpacity().getFunction().getStops().getClass()); + } + + @Test + public void testCircleOpacityAsCategoricalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-opacity"); + assertNotNull(layer); + + // Set + layer.setProperties( + circleOpacity( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, circleOpacity(0.3f)) + ) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getCircleOpacity()); + assertNotNull(layer.getCircleOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleOpacity().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getCircleOpacity().getFunction().getStops().getClass()); + assertEquals(0.3f, ((SourceFunction) layer.getCircleOpacity().getFunction()).getDefaultValue()); + } + + @Test + public void testCircleOpacityAsCompositeFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-opacity"); + assertNotNull(layer); + + // Set + layer.setProperties( + circleOpacity( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, circleOpacity(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getCircleOpacity()); + assertNotNull(layer.getCircleOpacity().getFunction()); + assertEquals(CompositeFunction.class, layer.getCircleOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getCircleOpacity().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getCircleOpacity().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getCircleOpacity().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getCircleOpacity().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 testCircleTranslateAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("circle-translate"); assertNotNull(layer); - //Set and Get - layer.setProperties(circleTranslate(new Float[] {0f, 0f})); - assertEquals((Float[]) layer.getCircleTranslate().getValue(), (Float[]) new Float[] {0f, 0f}); + // Set and Get + layer.setProperties(circleTranslate(new Float[]{0f,0f})); + assertEquals((Float[]) layer.getCircleTranslate().getValue(), (Float[]) new Float[]{0f,0f}); } @Test - public void testCircleTranslateAnchor() { + public void testCircleTranslateAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-translate"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + circleTranslate( + zoom( + exponential( + stop(2, circleTranslate(new Float[]{0f,0f})) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleTranslate()); + assertNotNull(layer.getCircleTranslate().getFunction()); + assertEquals(CameraFunction.class, layer.getCircleTranslate().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getCircleTranslate().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getCircleTranslate().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getCircleTranslate().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testCircleTranslateAnchorAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("circle-translate-anchor"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(circleTranslateAnchor(CIRCLE_TRANSLATE_ANCHOR_MAP)); assertEquals((String) layer.getCircleTranslateAnchor().getValue(), (String) CIRCLE_TRANSLATE_ANCHOR_MAP); } @Test - public void testCirclePitchScale() { + public void testCircleTranslateAnchorAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-translate-anchor"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + circleTranslateAnchor( + zoom( + interval( + stop(2, circleTranslateAnchor(CIRCLE_TRANSLATE_ANCHOR_MAP)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleTranslateAnchor()); + assertNotNull(layer.getCircleTranslateAnchor().getFunction()); + assertEquals(CameraFunction.class, layer.getCircleTranslateAnchor().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getCircleTranslateAnchor().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getCircleTranslateAnchor().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testCirclePitchScaleAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("circle-pitch-scale"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(circlePitchScale(CIRCLE_PITCH_SCALE_MAP)); assertEquals((String) layer.getCirclePitchScale().getValue(), (String) CIRCLE_PITCH_SCALE_MAP); } @Test - public void testCircleStrokeWidth() { + public void testCirclePitchScaleAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-pitch-scale"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + circlePitchScale( + zoom( + interval( + stop(2, circlePitchScale(CIRCLE_PITCH_SCALE_MAP)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getCirclePitchScale()); + assertNotNull(layer.getCirclePitchScale().getFunction()); + assertEquals(CameraFunction.class, layer.getCirclePitchScale().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getCirclePitchScale().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getCirclePitchScale().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testCircleStrokeWidthAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("circle-stroke-width"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(circleStrokeWidth(0.3f)); assertEquals((Float) layer.getCircleStrokeWidth().getValue(), (Float) 0.3f); } @Test - public void testCircleStrokeColor() { + public void testCircleStrokeWidthAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-stroke-width"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + circleStrokeWidth( + zoom( + exponential( + stop(2, circleStrokeWidth(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleStrokeWidth()); + assertNotNull(layer.getCircleStrokeWidth().getFunction()); + assertEquals(CameraFunction.class, layer.getCircleStrokeWidth().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getCircleStrokeWidth().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getCircleStrokeWidth().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getCircleStrokeWidth().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testCircleStrokeWidthAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-stroke-width"); + assertNotNull(layer); + + // Set + layer.setProperties( + circleStrokeWidth(property("FeaturePropertyA", Stops.<Float>identity())) + ); + + // Verify + assertNotNull(layer.getCircleStrokeWidth()); + assertNotNull(layer.getCircleStrokeWidth().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleStrokeWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeWidth().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getCircleStrokeWidth().getFunction().getStops().getClass()); + } + + @Test + public void testCircleStrokeWidthAsExponentialSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-stroke-width"); + assertNotNull(layer); + + // Set + layer.setProperties( + circleStrokeWidth( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, circleStrokeWidth(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleStrokeWidth()); + assertNotNull(layer.getCircleStrokeWidth().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleStrokeWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeWidth().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getCircleStrokeWidth().getFunction().getStops().getClass()); + } + + @Test + public void testCircleStrokeWidthAsCategoricalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-stroke-width"); + assertNotNull(layer); + + // Set + layer.setProperties( + circleStrokeWidth( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, circleStrokeWidth(0.3f)) + ) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getCircleStrokeWidth()); + assertNotNull(layer.getCircleStrokeWidth().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleStrokeWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeWidth().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getCircleStrokeWidth().getFunction().getStops().getClass()); + assertEquals(0.3f, ((SourceFunction) layer.getCircleStrokeWidth().getFunction()).getDefaultValue()); + } + + @Test + public void testCircleStrokeWidthAsCompositeFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-stroke-width"); + assertNotNull(layer); + + // Set + layer.setProperties( + circleStrokeWidth( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, circleStrokeWidth(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getCircleStrokeWidth()); + assertNotNull(layer.getCircleStrokeWidth().getFunction()); + assertEquals(CompositeFunction.class, layer.getCircleStrokeWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getCircleStrokeWidth().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getCircleStrokeWidth().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getCircleStrokeWidth().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getCircleStrokeWidth().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 testCircleStrokeColorAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("circle-stroke-color"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(circleStrokeColor("rgba(0, 0, 0, 1)")); assertEquals((String) layer.getCircleStrokeColor().getValue(), (String) "rgba(0, 0, 0, 1)"); } @Test - public void testCircleStrokeColorAsInt() { + public void testCircleStrokeColorAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-stroke-color"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + circleStrokeColor( + zoom( + exponential( + stop(2, circleStrokeColor("rgba(0, 0, 0, 1)")) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleStrokeColor()); + assertNotNull(layer.getCircleStrokeColor().getFunction()); + assertEquals(CameraFunction.class, layer.getCircleStrokeColor().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getCircleStrokeColor().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getCircleStrokeColor().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getCircleStrokeColor().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testCircleStrokeColorAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); Timber.i("circle-stroke-color"); assertNotNull(layer); - //Set and Get - layer.setProperties(circleStrokeColor(Color.RED)); - assertEquals(layer.getCircleStrokeColorAsInt(), Color.RED); + // Set + layer.setProperties( + circleStrokeColor(property("FeaturePropertyA", Stops.<String>identity())) + ); + + // Verify + assertNotNull(layer.getCircleStrokeColor()); + assertNotNull(layer.getCircleStrokeColor().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleStrokeColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeColor().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getCircleStrokeColor().getFunction().getStops().getClass()); } @Test - public void testCircleStrokeOpacity() { + public void testCircleStrokeColorAsExponentialSourceFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-stroke-color"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + circleStrokeColor( + property( + "FeaturePropertyA", + exponential( + stop(Color.RED, circleStrokeColor(Color.RED)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleStrokeColor()); + assertNotNull(layer.getCircleStrokeColor().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleStrokeColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeColor().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getCircleStrokeColor().getFunction().getStops().getClass()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new CircleLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testCircleStrokeColorAsCategoricalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-stroke-color"); + assertNotNull(layer); + + // Set + layer.setProperties( + circleStrokeColor( + property( + "FeaturePropertyA", + categorical( + stop("valueA", circleStrokeColor(Color.RED)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleStrokeColor()); + assertNotNull(layer.getCircleStrokeColor().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleStrokeColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeColor().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getCircleStrokeColor().getFunction().getStops().getClass()); + } + + @Test + public void testCircleStrokeColorAsIntConstant() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-stroke-color"); + assertNotNull(layer); + + // Set and Get + layer.setProperties(circleStrokeColor(Color.RED)); + assertEquals(layer.getCircleStrokeColorAsInt(), Color.RED); + } + + @Test + public void testCircleStrokeOpacityAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("circle-stroke-opacity"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(circleStrokeOpacity(0.3f)); assertEquals((Float) layer.getCircleStrokeOpacity().getValue(), (Float) 0.3f); } + @Test + public void testCircleStrokeOpacityAsCameraFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-stroke-opacity"); + assertNotNull(layer); + + // Set + layer.setProperties( + circleStrokeOpacity( + zoom( + exponential( + stop(2, circleStrokeOpacity(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleStrokeOpacity()); + assertNotNull(layer.getCircleStrokeOpacity().getFunction()); + assertEquals(CameraFunction.class, layer.getCircleStrokeOpacity().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getCircleStrokeOpacity().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getCircleStrokeOpacity().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getCircleStrokeOpacity().getFunction().getStops()).size()); + } + + @Test + public void testCircleStrokeOpacityAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-stroke-opacity"); + assertNotNull(layer); + + // Set + layer.setProperties( + circleStrokeOpacity(property("FeaturePropertyA", Stops.<Float>identity())) + ); + + // Verify + assertNotNull(layer.getCircleStrokeOpacity()); + assertNotNull(layer.getCircleStrokeOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleStrokeOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeOpacity().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getCircleStrokeOpacity().getFunction().getStops().getClass()); + } + + @Test + public void testCircleStrokeOpacityAsExponentialSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-stroke-opacity"); + assertNotNull(layer); + + // Set + layer.setProperties( + circleStrokeOpacity( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, circleStrokeOpacity(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getCircleStrokeOpacity()); + assertNotNull(layer.getCircleStrokeOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleStrokeOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeOpacity().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getCircleStrokeOpacity().getFunction().getStops().getClass()); + } + + @Test + public void testCircleStrokeOpacityAsCategoricalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-stroke-opacity"); + assertNotNull(layer); + + // Set + layer.setProperties( + circleStrokeOpacity( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, circleStrokeOpacity(0.3f)) + ) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getCircleStrokeOpacity()); + assertNotNull(layer.getCircleStrokeOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getCircleStrokeOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getCircleStrokeOpacity().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getCircleStrokeOpacity().getFunction().getStops().getClass()); + assertEquals(0.3f, ((SourceFunction) layer.getCircleStrokeOpacity().getFunction()).getDefaultValue()); + } + + @Test + public void testCircleStrokeOpacityAsCompositeFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("circle-stroke-opacity"); + assertNotNull(layer); + + // Set + layer.setProperties( + circleStrokeOpacity( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, circleStrokeOpacity(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getCircleStrokeOpacity()); + assertNotNull(layer.getCircleStrokeOpacity().getFunction()); + assertEquals(CompositeFunction.class, layer.getCircleStrokeOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getCircleStrokeOpacity().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getCircleStrokeOpacity().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getCircleStrokeOpacity().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getCircleStrokeOpacity().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); + } + @After public void unregisterIntentServiceIdlingResource() { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerStyleTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerStyleTest.java deleted file mode 100644 index c8668fa407..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerStyleTest.java +++ /dev/null @@ -1,286 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.style; -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. - -import android.graphics.Color; -import android.support.test.espresso.Espresso; -import android.support.test.rule.ActivityTestRule; -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.style.layers.FillLayer; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity; -import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; - -import timber.log.Timber; - -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.VISIBLE; -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; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOutlineColor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillPattern; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillTranslate; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillTranslateAnchor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -/** - * Basic smoke tests for FillLayer - */ -@RunWith(AndroidJUnit4.class) -public class FillLayerStyleTest extends BaseStyleTest { - - @Rule - public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); - - private FillLayer layer; - - private OnMapReadyIdlingResource idlingResource; - - private MapboxMap mapboxMap; - - @Before - public void setup() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } - - @Test - public void testSetVisibility() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - 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"); - } - Timber.i("visibility"); - assertNotNull(layer); - - //Get initial - assertEquals(layer.getVisibility().getValue(), VISIBLE); - - //Set - layer.setProperties(visibility(NONE)); - assertEquals(layer.getVisibility().getValue(), NONE); - } - - @Test - public void testFillAntialias() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - 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"); - } - Timber.i("fill-antialias"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(fillAntialias(true)); - assertEquals((Boolean) layer.getFillAntialias().getValue(), (Boolean) true); - } - - @Test - public void testFillOpacity() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - 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"); - } - Timber.i("fill-opacity"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(fillOpacity(0.3f)); - assertEquals((Float) layer.getFillOpacity().getValue(), (Float) 0.3f); - } - - @Test - public void testFillColor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - 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"); - } - Timber.i("fill-color"); - assertNotNull(layer); - - //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 testFillColorAsInt() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - 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"); - } - Timber.i("fill-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(fillColor(Color.RED)); - assertEquals(layer.getFillColorAsInt(), Color.RED); - } - - @Test - public void testFillOutlineColor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - 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"); - } - Timber.i("fill-outline-color"); - assertNotNull(layer); - - //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 testFillOutlineColorAsInt() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - 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"); - } - Timber.i("fill-outline-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(fillOutlineColor(Color.RED)); - assertEquals(layer.getFillOutlineColorAsInt(), Color.RED); - } - - @Test - public void testFillTranslate() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - 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"); - } - Timber.i("fill-translate"); - 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 testFillTranslateAnchor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - 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"); - } - Timber.i("fill-translate-anchor"); - 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 testFillPattern() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - 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"); - } - Timber.i("fill-pattern"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(fillPattern("pedestrian-polygon")); - assertEquals((String) layer.getFillPattern().getValue(), (String) "pedestrian-polygon"); - } - - - @After - public void unregisterIntentServiceIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java index 95360e1273..dd59b97525 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java @@ -1,12 +1,23 @@ -package com.mapbox.mapboxsdk.testapp.style; // This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. +package com.mapbox.mapboxsdk.testapp.style; + import android.graphics.Color; import android.support.test.espresso.Espresso; import android.support.test.rule.ActivityTestRule; 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.layers.FillLayer; import com.mapbox.mapboxsdk.testapp.R; import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity; @@ -18,21 +29,12 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import timber.log.Timber; - -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.VISIBLE; -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; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOutlineColor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillPattern; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillTranslate; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillTranslateAnchor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +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 org.junit.Assert.*; +import static com.mapbox.mapboxsdk.style.layers.Property.*; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; /** * Basic smoke tests for FillLayer @@ -53,12 +55,6 @@ public class FillLayerTest extends BaseStyleTest { public void setup() { idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); Espresso.registerIdlingResources(idlingResource); - } - - @Test - public void testSetVisibility() { - checkViewIsDisplayed(R.id.mapView); - mapboxMap = rule.getActivity().getMapboxMap(); if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { @@ -66,218 +62,551 @@ public class FillLayerTest extends BaseStyleTest { layer = new FillLayer("my-layer", "composite"); layer.setSourceLayer("composite"); mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference + // Layer reference is now stale, get new reference layer = mapboxMap.getLayerAs("my-layer"); } - Timber.i("visibility"); + } + + @Test + public void testSetVisibility() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("Visibility"); assertNotNull(layer); - //Get initial + // Get initial assertEquals(layer.getVisibility().getValue(), VISIBLE); - //Set + // Set layer.setProperties(visibility(NONE)); assertEquals(layer.getVisibility().getValue(), NONE); } @Test - public void testFillAntialias() { + public void testFillAntialiasAsConstant() { checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - 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"); - } Timber.i("fill-antialias"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(fillAntialias(true)); assertEquals((Boolean) layer.getFillAntialias().getValue(), (Boolean) true); } @Test - public void testFillOpacity() { + public void testFillAntialiasAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("fill-antialias"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // 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()); + } - 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"); - } + @Test + public void testFillOpacityAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("fill-opacity"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(fillOpacity(0.3f)); assertEquals((Float) layer.getFillOpacity().getValue(), (Float) 0.3f); } @Test - public void testFillColor() { + public void testFillOpacityAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("fill-opacity"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // 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()); + } - 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"); - } + @Test + public void testFillOpacityAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("fill-opacity"); + 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() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("fill-opacity"); + 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() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("fill-opacity"); + assertNotNull(layer); + + // Set + layer.setProperties( + fillOpacity( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, fillOpacity(0.3f)) + ) + ).withDefaultValue(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()); + assertEquals(0.3f, ((SourceFunction) layer.getFillOpacity().getFunction()).getDefaultValue()); + } + + @Test + public void testFillOpacityAsCompositeFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("fill-opacity"); + assertNotNull(layer); + + // Set + layer.setProperties( + fillOpacity( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, fillOpacity(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(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 testFillColorAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("fill-color"); assertNotNull(layer); - //Set and Get + // 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 testFillColorAsInt() { + public void testFillColorAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("fill-color"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // 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()); + } - 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"); - } + @Test + public void testFillColorAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); Timber.i("fill-color"); assertNotNull(layer); - //Set and Get - layer.setProperties(fillColor(Color.RED)); - assertEquals(layer.getFillColorAsInt(), Color.RED); + // 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 testFillOutlineColor() { + public void testFillColorAsExponentialSourceFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("fill-color"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // 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()); + } - 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"); - } + @Test + public void testFillColorAsCategoricalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("fill-color"); + assertNotNull(layer); + + // Set + layer.setProperties( + fillColor( + property( + "FeaturePropertyA", + categorical( + stop("valueA", fillColor(Color.RED)) + ) + ) + ) + ); + + // 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()); + } + + @Test + public void testFillColorAsIntConstant() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("fill-color"); + assertNotNull(layer); + + // Set and Get + layer.setProperties(fillColor(Color.RED)); + assertEquals(layer.getFillColorAsInt(), Color.RED); + } + + @Test + public void testFillOutlineColorAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("fill-outline-color"); assertNotNull(layer); - //Set and Get + // 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 testFillOutlineColorAsInt() { + public void testFillOutlineColorAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("fill-outline-color"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // 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()); + } - 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"); - } + @Test + public void testFillOutlineColorAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); Timber.i("fill-outline-color"); assertNotNull(layer); - //Set and Get - layer.setProperties(fillOutlineColor(Color.RED)); - assertEquals(layer.getFillOutlineColorAsInt(), Color.RED); + // 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 testFillTranslate() { + public void testFillOutlineColorAsExponentialSourceFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("fill-outline-color"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // 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()); + } - 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"); - } + @Test + public void testFillOutlineColorAsCategoricalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("fill-outline-color"); + assertNotNull(layer); + + // Set + layer.setProperties( + fillOutlineColor( + property( + "FeaturePropertyA", + categorical( + stop("valueA", fillOutlineColor(Color.RED)) + ) + ) + ) + ); + + // 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()); + } + + @Test + public void testFillOutlineColorAsIntConstant() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("fill-outline-color"); + assertNotNull(layer); + + // Set and Get + layer.setProperties(fillOutlineColor(Color.RED)); + assertEquals(layer.getFillOutlineColorAsInt(), Color.RED); + } + + @Test + public void testFillTranslateAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("fill-translate"); assertNotNull(layer); - //Set and Get - layer.setProperties(fillTranslate(new Float[] {0f, 0f})); - assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[] {0f, 0f}); + // Set and Get + layer.setProperties(fillTranslate(new Float[]{0f,0f})); + assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[]{0f,0f}); } @Test - public void testFillTranslateAnchor() { + public void testFillTranslateAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("fill-translate"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // 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()); + } - 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"); - } + @Test + public void testFillTranslateAnchorAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("fill-translate-anchor"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP)); assertEquals((String) layer.getFillTranslateAnchor().getValue(), (String) FILL_TRANSLATE_ANCHOR_MAP); } @Test - public void testFillPattern() { + public void testFillTranslateAnchorAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("fill-translate-anchor"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // 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()); + } - 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"); - } + @Test + public void testFillPatternAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("fill-pattern"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(fillPattern("pedestrian-polygon")); assertEquals((String) layer.getFillPattern().getValue(), (String) "pedestrian-polygon"); } + @Test + public void testFillPatternAsCameraFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("fill-pattern"); + 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()); + } + @After public void unregisterIntentServiceIdlingResource() { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerStyleTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerStyleTest.java deleted file mode 100644 index 47a38a11ab..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerStyleTest.java +++ /dev/null @@ -1,427 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.style; -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. - -import android.graphics.Color; -import android.support.test.espresso.Espresso; -import android.support.test.rule.ActivityTestRule; -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.style.layers.LineLayer; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity; -import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; - -import timber.log.Timber; - -import static com.mapbox.mapboxsdk.style.layers.Property.LINE_CAP_BUTT; -import static com.mapbox.mapboxsdk.style.layers.Property.LINE_JOIN_BEVEL; -import static com.mapbox.mapboxsdk.style.layers.Property.LINE_TRANSLATE_ANCHOR_MAP; -import static com.mapbox.mapboxsdk.style.layers.Property.NONE; -import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineBlur; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineCap; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineColor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineDasharray; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineGapWidth; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineJoin; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineMiterLimit; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineOffset; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineOpacity; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.linePattern; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineRoundLimit; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineTranslate; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineTranslateAnchor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineWidth; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -/** - * Basic smoke tests for LineLayer - */ -@RunWith(AndroidJUnit4.class) -public class LineLayerStyleTest extends BaseStyleTest { - - @Rule - public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); - - private LineLayer layer; - - private OnMapReadyIdlingResource idlingResource; - - private MapboxMap mapboxMap; - - @Before - public void setup() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } - - @Test - public void testSetVisibility() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("visibility"); - assertNotNull(layer); - - //Get initial - assertEquals(layer.getVisibility().getValue(), VISIBLE); - - //Set - layer.setProperties(visibility(NONE)); - assertEquals(layer.getVisibility().getValue(), NONE); - } - - @Test - public void testLineCap() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-cap"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineCap(LINE_CAP_BUTT)); - assertEquals((String) layer.getLineCap().getValue(), (String) LINE_CAP_BUTT); - } - - @Test - public void testLineJoin() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-join"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineJoin(LINE_JOIN_BEVEL)); - assertEquals((String) layer.getLineJoin().getValue(), (String) LINE_JOIN_BEVEL); - } - - @Test - public void testLineMiterLimit() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-miter-limit"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineMiterLimit(0.3f)); - assertEquals((Float) layer.getLineMiterLimit().getValue(), (Float) 0.3f); - } - - @Test - public void testLineRoundLimit() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-round-limit"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineRoundLimit(0.3f)); - assertEquals((Float) layer.getLineRoundLimit().getValue(), (Float) 0.3f); - } - - @Test - public void testLineOpacity() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-opacity"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineOpacity(0.3f)); - assertEquals((Float) layer.getLineOpacity().getValue(), (Float) 0.3f); - } - - @Test - public void testLineColor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getLineColor().getValue(), (String) "rgba(0, 0, 0, 1)"); - } - - @Test - public void testLineColorAsInt() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineColor(Color.RED)); - assertEquals(layer.getLineColorAsInt(), Color.RED); - } - - @Test - public void testLineTranslate() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-translate"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineTranslate(new Float[] {0f, 0f})); - assertEquals((Float[]) layer.getLineTranslate().getValue(), (Float[]) new Float[] {0f, 0f}); - } - - @Test - public void testLineTranslateAnchor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-translate-anchor"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineTranslateAnchor(LINE_TRANSLATE_ANCHOR_MAP)); - assertEquals((String) layer.getLineTranslateAnchor().getValue(), (String) LINE_TRANSLATE_ANCHOR_MAP); - } - - @Test - public void testLineWidth() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-width"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineWidth(0.3f)); - assertEquals((Float) layer.getLineWidth().getValue(), (Float) 0.3f); - } - - @Test - public void testLineGapWidth() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-gap-width"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineGapWidth(0.3f)); - assertEquals((Float) layer.getLineGapWidth().getValue(), (Float) 0.3f); - } - - @Test - public void testLineOffset() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-offset"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineOffset(0.3f)); - assertEquals((Float) layer.getLineOffset().getValue(), (Float) 0.3f); - } - - @Test - public void testLineBlur() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-blur"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineBlur(0.3f)); - assertEquals((Float) layer.getLineBlur().getValue(), (Float) 0.3f); - } - - @Test - public void testLineDasharray() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-dasharray"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(lineDasharray(new Float[] {})); - assertEquals((Float[]) layer.getLineDasharray().getValue(), (Float[]) new Float[] {}); - } - - @Test - public void testLinePattern() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("line-pattern"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(linePattern("pedestrian-polygon")); - assertEquals((String) layer.getLinePattern().getValue(), (String) "pedestrian-polygon"); - } - - - @After - public void unregisterIntentServiceIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java index ad091c78b3..740393ad36 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java @@ -1,12 +1,23 @@ -package com.mapbox.mapboxsdk.testapp.style; // This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. +package com.mapbox.mapboxsdk.testapp.style; + import android.graphics.Color; import android.support.test.espresso.Espresso; import android.support.test.rule.ActivityTestRule; 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.layers.LineLayer; import com.mapbox.mapboxsdk.testapp.R; import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity; @@ -18,30 +29,12 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import timber.log.Timber; - -import static com.mapbox.mapboxsdk.style.layers.Property.LINE_CAP_BUTT; -import static com.mapbox.mapboxsdk.style.layers.Property.LINE_JOIN_BEVEL; -import static com.mapbox.mapboxsdk.style.layers.Property.LINE_TRANSLATE_ANCHOR_MAP; -import static com.mapbox.mapboxsdk.style.layers.Property.NONE; -import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineBlur; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineCap; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineColor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineDasharray; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineGapWidth; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineJoin; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineMiterLimit; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineOffset; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineOpacity; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.linePattern; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineRoundLimit; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineTranslate; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineTranslateAnchor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineWidth; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +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 org.junit.Assert.*; +import static com.mapbox.mapboxsdk.style.layers.Property.*; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; /** * Basic smoke tests for LineLayer @@ -62,12 +55,6 @@ public class LineLayerTest extends BaseStyleTest { public void setup() { idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); Espresso.registerIdlingResources(idlingResource); - } - - @Test - public void testSetVisibility() { - checkViewIsDisplayed(R.id.mapView); - mapboxMap = rule.getActivity().getMapboxMap(); if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { @@ -75,350 +62,1044 @@ public class LineLayerTest extends BaseStyleTest { layer = new LineLayer("my-layer", "composite"); layer.setSourceLayer("composite"); mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference + // Layer reference is now stale, get new reference layer = mapboxMap.getLayerAs("my-layer"); } - Timber.i("visibility"); + } + + @Test + public void testSetVisibility() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("Visibility"); assertNotNull(layer); - //Get initial + // Get initial assertEquals(layer.getVisibility().getValue(), VISIBLE); - //Set + // Set layer.setProperties(visibility(NONE)); assertEquals(layer.getVisibility().getValue(), NONE); } @Test - public void testLineCap() { + public void testLineCapAsConstant() { checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } Timber.i("line-cap"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(lineCap(LINE_CAP_BUTT)); assertEquals((String) layer.getLineCap().getValue(), (String) LINE_CAP_BUTT); } @Test - public void testLineJoin() { + public void testLineCapAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("line-cap"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + lineCap( + zoom( + interval( + stop(2, lineCap(LINE_CAP_BUTT)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getLineCap()); + assertNotNull(layer.getLineCap().getFunction()); + assertEquals(CameraFunction.class, layer.getLineCap().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getLineCap().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getLineCap().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testLineJoinAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("line-join"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(lineJoin(LINE_JOIN_BEVEL)); assertEquals((String) layer.getLineJoin().getValue(), (String) LINE_JOIN_BEVEL); } @Test - public void testLineMiterLimit() { + public void testLineJoinAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("line-join"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + lineJoin( + zoom( + interval( + stop(2, lineJoin(LINE_JOIN_BEVEL)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getLineJoin()); + assertNotNull(layer.getLineJoin().getFunction()); + assertEquals(CameraFunction.class, layer.getLineJoin().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getLineJoin().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getLineJoin().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testLineMiterLimitAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("line-miter-limit"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(lineMiterLimit(0.3f)); assertEquals((Float) layer.getLineMiterLimit().getValue(), (Float) 0.3f); } @Test - public void testLineRoundLimit() { + public void testLineMiterLimitAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("line-miter-limit"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + lineMiterLimit( + zoom( + exponential( + stop(2, lineMiterLimit(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getLineMiterLimit()); + assertNotNull(layer.getLineMiterLimit().getFunction()); + assertEquals(CameraFunction.class, layer.getLineMiterLimit().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getLineMiterLimit().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getLineMiterLimit().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getLineMiterLimit().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testLineRoundLimitAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("line-round-limit"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(lineRoundLimit(0.3f)); assertEquals((Float) layer.getLineRoundLimit().getValue(), (Float) 0.3f); } @Test - public void testLineOpacity() { + public void testLineRoundLimitAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("line-round-limit"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + lineRoundLimit( + zoom( + exponential( + stop(2, lineRoundLimit(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getLineRoundLimit()); + assertNotNull(layer.getLineRoundLimit().getFunction()); + assertEquals(CameraFunction.class, layer.getLineRoundLimit().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getLineRoundLimit().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getLineRoundLimit().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getLineRoundLimit().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testLineOpacityAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("line-opacity"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(lineOpacity(0.3f)); assertEquals((Float) layer.getLineOpacity().getValue(), (Float) 0.3f); } @Test - public void testLineColor() { + public void testLineOpacityAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("line-opacity"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + lineOpacity( + zoom( + exponential( + stop(2, lineOpacity(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getLineOpacity()); + assertNotNull(layer.getLineOpacity().getFunction()); + assertEquals(CameraFunction.class, layer.getLineOpacity().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getLineOpacity().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getLineOpacity().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getLineOpacity().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testLineOpacityAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("line-opacity"); + assertNotNull(layer); + + // Set + layer.setProperties( + lineOpacity(property("FeaturePropertyA", Stops.<Float>identity())) + ); + + // Verify + assertNotNull(layer.getLineOpacity()); + assertNotNull(layer.getLineOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getLineOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineOpacity().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getLineOpacity().getFunction().getStops().getClass()); + } + + @Test + public void testLineOpacityAsExponentialSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("line-opacity"); + assertNotNull(layer); + + // Set + layer.setProperties( + lineOpacity( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, lineOpacity(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getLineOpacity()); + assertNotNull(layer.getLineOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getLineOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineOpacity().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getLineOpacity().getFunction().getStops().getClass()); + } + + @Test + public void testLineOpacityAsCategoricalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("line-opacity"); + assertNotNull(layer); + + // Set + layer.setProperties( + lineOpacity( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, lineOpacity(0.3f)) + ) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getLineOpacity()); + assertNotNull(layer.getLineOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getLineOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineOpacity().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getLineOpacity().getFunction().getStops().getClass()); + assertEquals(0.3f, ((SourceFunction) layer.getLineOpacity().getFunction()).getDefaultValue()); + } + + @Test + public void testLineOpacityAsCompositeFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("line-opacity"); + assertNotNull(layer); + + // Set + layer.setProperties( + lineOpacity( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, lineOpacity(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getLineOpacity()); + assertNotNull(layer.getLineOpacity().getFunction()); + assertEquals(CompositeFunction.class, layer.getLineOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getLineOpacity().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getLineOpacity().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getLineOpacity().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getLineOpacity().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 testLineColorAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("line-color"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(lineColor("rgba(0, 0, 0, 1)")); assertEquals((String) layer.getLineColor().getValue(), (String) "rgba(0, 0, 0, 1)"); } @Test - public void testLineColorAsInt() { + public void testLineColorAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("line-color"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + lineColor( + zoom( + exponential( + stop(2, lineColor("rgba(0, 0, 0, 1)")) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getLineColor()); + assertNotNull(layer.getLineColor().getFunction()); + assertEquals(CameraFunction.class, layer.getLineColor().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getLineColor().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getLineColor().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getLineColor().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testLineColorAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); Timber.i("line-color"); assertNotNull(layer); - //Set and Get - layer.setProperties(lineColor(Color.RED)); - assertEquals(layer.getLineColorAsInt(), Color.RED); + // Set + layer.setProperties( + lineColor(property("FeaturePropertyA", Stops.<String>identity())) + ); + + // Verify + assertNotNull(layer.getLineColor()); + assertNotNull(layer.getLineColor().getFunction()); + assertEquals(SourceFunction.class, layer.getLineColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineColor().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getLineColor().getFunction().getStops().getClass()); } @Test - public void testLineTranslate() { + public void testLineColorAsExponentialSourceFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("line-color"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + lineColor( + property( + "FeaturePropertyA", + exponential( + stop(Color.RED, lineColor(Color.RED)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getLineColor()); + assertNotNull(layer.getLineColor().getFunction()); + assertEquals(SourceFunction.class, layer.getLineColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineColor().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getLineColor().getFunction().getStops().getClass()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testLineColorAsCategoricalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("line-color"); + assertNotNull(layer); + + // Set + layer.setProperties( + lineColor( + property( + "FeaturePropertyA", + categorical( + stop("valueA", lineColor(Color.RED)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getLineColor()); + assertNotNull(layer.getLineColor().getFunction()); + assertEquals(SourceFunction.class, layer.getLineColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineColor().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getLineColor().getFunction().getStops().getClass()); + } + + @Test + public void testLineColorAsIntConstant() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("line-color"); + assertNotNull(layer); + + // Set and Get + layer.setProperties(lineColor(Color.RED)); + assertEquals(layer.getLineColorAsInt(), Color.RED); + } + + @Test + public void testLineTranslateAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("line-translate"); assertNotNull(layer); - //Set and Get - layer.setProperties(lineTranslate(new Float[] {0f, 0f})); - assertEquals((Float[]) layer.getLineTranslate().getValue(), (Float[]) new Float[] {0f, 0f}); + // Set and Get + layer.setProperties(lineTranslate(new Float[]{0f,0f})); + assertEquals((Float[]) layer.getLineTranslate().getValue(), (Float[]) new Float[]{0f,0f}); } @Test - public void testLineTranslateAnchor() { + public void testLineTranslateAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("line-translate"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + lineTranslate( + zoom( + exponential( + stop(2, lineTranslate(new Float[]{0f,0f})) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getLineTranslate()); + assertNotNull(layer.getLineTranslate().getFunction()); + assertEquals(CameraFunction.class, layer.getLineTranslate().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getLineTranslate().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getLineTranslate().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getLineTranslate().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testLineTranslateAnchorAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("line-translate-anchor"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(lineTranslateAnchor(LINE_TRANSLATE_ANCHOR_MAP)); assertEquals((String) layer.getLineTranslateAnchor().getValue(), (String) LINE_TRANSLATE_ANCHOR_MAP); } @Test - public void testLineWidth() { + public void testLineTranslateAnchorAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("line-translate-anchor"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + lineTranslateAnchor( + zoom( + interval( + stop(2, lineTranslateAnchor(LINE_TRANSLATE_ANCHOR_MAP)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getLineTranslateAnchor()); + assertNotNull(layer.getLineTranslateAnchor().getFunction()); + assertEquals(CameraFunction.class, layer.getLineTranslateAnchor().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getLineTranslateAnchor().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getLineTranslateAnchor().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testLineWidthAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("line-width"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(lineWidth(0.3f)); assertEquals((Float) layer.getLineWidth().getValue(), (Float) 0.3f); } @Test - public void testLineGapWidth() { + public void testLineWidthAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("line-width"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + lineWidth( + zoom( + exponential( + stop(2, lineWidth(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getLineWidth()); + assertNotNull(layer.getLineWidth().getFunction()); + assertEquals(CameraFunction.class, layer.getLineWidth().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getLineWidth().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getLineWidth().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getLineWidth().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testLineGapWidthAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("line-gap-width"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(lineGapWidth(0.3f)); assertEquals((Float) layer.getLineGapWidth().getValue(), (Float) 0.3f); } @Test - public void testLineOffset() { + public void testLineGapWidthAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("line-gap-width"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + lineGapWidth( + zoom( + exponential( + stop(2, lineGapWidth(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getLineGapWidth()); + assertNotNull(layer.getLineGapWidth().getFunction()); + assertEquals(CameraFunction.class, layer.getLineGapWidth().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getLineGapWidth().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getLineGapWidth().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getLineGapWidth().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testLineGapWidthAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("line-gap-width"); + assertNotNull(layer); + + // Set + layer.setProperties( + lineGapWidth(property("FeaturePropertyA", Stops.<Float>identity())) + ); + + // Verify + assertNotNull(layer.getLineGapWidth()); + assertNotNull(layer.getLineGapWidth().getFunction()); + assertEquals(SourceFunction.class, layer.getLineGapWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineGapWidth().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getLineGapWidth().getFunction().getStops().getClass()); + } + + @Test + public void testLineGapWidthAsExponentialSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("line-gap-width"); + assertNotNull(layer); + + // Set + layer.setProperties( + lineGapWidth( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, lineGapWidth(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getLineGapWidth()); + assertNotNull(layer.getLineGapWidth().getFunction()); + assertEquals(SourceFunction.class, layer.getLineGapWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineGapWidth().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getLineGapWidth().getFunction().getStops().getClass()); + } + + @Test + public void testLineGapWidthAsCategoricalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("line-gap-width"); + assertNotNull(layer); + + // Set + layer.setProperties( + lineGapWidth( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, lineGapWidth(0.3f)) + ) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getLineGapWidth()); + assertNotNull(layer.getLineGapWidth().getFunction()); + assertEquals(SourceFunction.class, layer.getLineGapWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineGapWidth().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getLineGapWidth().getFunction().getStops().getClass()); + assertEquals(0.3f, ((SourceFunction) layer.getLineGapWidth().getFunction()).getDefaultValue()); + } + + @Test + public void testLineGapWidthAsCompositeFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("line-gap-width"); + assertNotNull(layer); + + // Set + layer.setProperties( + lineGapWidth( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, lineGapWidth(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getLineGapWidth()); + assertNotNull(layer.getLineGapWidth().getFunction()); + assertEquals(CompositeFunction.class, layer.getLineGapWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getLineGapWidth().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getLineGapWidth().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getLineGapWidth().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getLineGapWidth().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 testLineOffsetAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("line-offset"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(lineOffset(0.3f)); assertEquals((Float) layer.getLineOffset().getValue(), (Float) 0.3f); } @Test - public void testLineBlur() { + public void testLineOffsetAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("line-offset"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + lineOffset( + zoom( + exponential( + stop(2, lineOffset(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getLineOffset()); + assertNotNull(layer.getLineOffset().getFunction()); + assertEquals(CameraFunction.class, layer.getLineOffset().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getLineOffset().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getLineOffset().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getLineOffset().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testLineOffsetAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("line-offset"); + assertNotNull(layer); + + // Set + layer.setProperties( + lineOffset(property("FeaturePropertyA", Stops.<Float>identity())) + ); + + // Verify + assertNotNull(layer.getLineOffset()); + assertNotNull(layer.getLineOffset().getFunction()); + assertEquals(SourceFunction.class, layer.getLineOffset().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineOffset().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getLineOffset().getFunction().getStops().getClass()); + } + + @Test + public void testLineOffsetAsExponentialSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("line-offset"); + assertNotNull(layer); + + // Set + layer.setProperties( + lineOffset( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, lineOffset(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getLineOffset()); + assertNotNull(layer.getLineOffset().getFunction()); + assertEquals(SourceFunction.class, layer.getLineOffset().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineOffset().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getLineOffset().getFunction().getStops().getClass()); + } + + @Test + public void testLineOffsetAsCategoricalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("line-offset"); + assertNotNull(layer); + + // Set + layer.setProperties( + lineOffset( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, lineOffset(0.3f)) + ) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getLineOffset()); + assertNotNull(layer.getLineOffset().getFunction()); + assertEquals(SourceFunction.class, layer.getLineOffset().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineOffset().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getLineOffset().getFunction().getStops().getClass()); + assertEquals(0.3f, ((SourceFunction) layer.getLineOffset().getFunction()).getDefaultValue()); + } + + @Test + public void testLineOffsetAsCompositeFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("line-offset"); + assertNotNull(layer); + + // Set + layer.setProperties( + lineOffset( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, lineOffset(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getLineOffset()); + assertNotNull(layer.getLineOffset().getFunction()); + assertEquals(CompositeFunction.class, layer.getLineOffset().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getLineOffset().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getLineOffset().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getLineOffset().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getLineOffset().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 testLineBlurAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("line-blur"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(lineBlur(0.3f)); assertEquals((Float) layer.getLineBlur().getValue(), (Float) 0.3f); } @Test - public void testLineDasharray() { + public void testLineBlurAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("line-blur"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + lineBlur( + zoom( + exponential( + stop(2, lineBlur(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getLineBlur()); + assertNotNull(layer.getLineBlur().getFunction()); + assertEquals(CameraFunction.class, layer.getLineBlur().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getLineBlur().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getLineBlur().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getLineBlur().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testLineBlurAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("line-blur"); + assertNotNull(layer); + + // Set + layer.setProperties( + lineBlur(property("FeaturePropertyA", Stops.<Float>identity())) + ); + + // Verify + assertNotNull(layer.getLineBlur()); + assertNotNull(layer.getLineBlur().getFunction()); + assertEquals(SourceFunction.class, layer.getLineBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineBlur().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getLineBlur().getFunction().getStops().getClass()); + } + + @Test + public void testLineBlurAsExponentialSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("line-blur"); + assertNotNull(layer); + + // Set + layer.setProperties( + lineBlur( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, lineBlur(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getLineBlur()); + assertNotNull(layer.getLineBlur().getFunction()); + assertEquals(SourceFunction.class, layer.getLineBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineBlur().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getLineBlur().getFunction().getStops().getClass()); + } + + @Test + public void testLineBlurAsCategoricalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("line-blur"); + assertNotNull(layer); + + // Set + layer.setProperties( + lineBlur( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, lineBlur(0.3f)) + ) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getLineBlur()); + assertNotNull(layer.getLineBlur().getFunction()); + assertEquals(SourceFunction.class, layer.getLineBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getLineBlur().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getLineBlur().getFunction().getStops().getClass()); + assertEquals(0.3f, ((SourceFunction) layer.getLineBlur().getFunction()).getDefaultValue()); + } + + @Test + public void testLineBlurAsCompositeFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("line-blur"); + assertNotNull(layer); + + // Set + layer.setProperties( + lineBlur( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, lineBlur(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getLineBlur()); + assertNotNull(layer.getLineBlur().getFunction()); + assertEquals(CompositeFunction.class, layer.getLineBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getLineBlur().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getLineBlur().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getLineBlur().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getLineBlur().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 testLineDasharrayAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("line-dasharray"); assertNotNull(layer); - //Set and Get - layer.setProperties(lineDasharray(new Float[] {})); - assertEquals((Float[]) layer.getLineDasharray().getValue(), (Float[]) new Float[] {}); + // Set and Get + layer.setProperties(lineDasharray(new Float[]{})); + assertEquals((Float[]) layer.getLineDasharray().getValue(), (Float[]) new Float[]{}); } @Test - public void testLinePattern() { + public void testLineDasharrayAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("line-dasharray"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + lineDasharray( + zoom( + interval( + stop(2, lineDasharray(new Float[]{})) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getLineDasharray()); + assertNotNull(layer.getLineDasharray().getFunction()); + assertEquals(CameraFunction.class, layer.getLineDasharray().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getLineDasharray().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getLineDasharray().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new LineLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testLinePatternAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("line-pattern"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(linePattern("pedestrian-polygon")); assertEquals((String) layer.getLinePattern().getValue(), (String) "pedestrian-polygon"); } + @Test + public void testLinePatternAsCameraFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("line-pattern"); + assertNotNull(layer); + + // Set + layer.setProperties( + linePattern( + zoom( + interval( + stop(2, linePattern("pedestrian-polygon")) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getLinePattern()); + assertNotNull(layer.getLinePattern().getFunction()); + assertEquals(CameraFunction.class, layer.getLinePattern().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getLinePattern().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getLinePattern().getFunction().getStops()).size()); + } + @After public void unregisterIntentServiceIdlingResource() { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerStyleTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerStyleTest.java deleted file mode 100644 index eb67b48f7a..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerStyleTest.java +++ /dev/null @@ -1,240 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.style; -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. - -import android.support.test.espresso.Espresso; -import android.support.test.rule.ActivityTestRule; -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.style.layers.RasterLayer; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity; -import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; - -import timber.log.Timber; - -import static com.mapbox.mapboxsdk.style.layers.Property.NONE; -import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterBrightnessMax; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterBrightnessMin; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterContrast; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterFadeDuration; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterHueRotate; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterOpacity; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterSaturation; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -/** - * Basic smoke tests for RasterLayer - */ -@RunWith(AndroidJUnit4.class) -public class RasterLayerStyleTest extends BaseStyleTest { - - @Rule - public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); - - private RasterLayer layer; - - private OnMapReadyIdlingResource idlingResource; - - private MapboxMap mapboxMap; - - @Before - public void setup() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } - - @Test - public void testSetVisibility() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - 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"); - } - Timber.i("visibility"); - assertNotNull(layer); - - //Get initial - assertEquals(layer.getVisibility().getValue(), VISIBLE); - - //Set - layer.setProperties(visibility(NONE)); - assertEquals(layer.getVisibility().getValue(), NONE); - } - - @Test - public void testRasterOpacity() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - 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"); - } - Timber.i("raster-opacity"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(rasterOpacity(0.3f)); - assertEquals((Float) layer.getRasterOpacity().getValue(), (Float) 0.3f); - } - - @Test - public void testRasterHueRotate() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - 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"); - } - Timber.i("raster-hue-rotate"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(rasterHueRotate(0.3f)); - assertEquals((Float) layer.getRasterHueRotate().getValue(), (Float) 0.3f); - } - - @Test - public void testRasterBrightnessMin() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - 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"); - } - Timber.i("raster-brightness-min"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(rasterBrightnessMin(0.3f)); - assertEquals((Float) layer.getRasterBrightnessMin().getValue(), (Float) 0.3f); - } - - @Test - public void testRasterBrightnessMax() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - 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"); - } - Timber.i("raster-brightness-max"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(rasterBrightnessMax(0.3f)); - assertEquals((Float) layer.getRasterBrightnessMax().getValue(), (Float) 0.3f); - } - - @Test - public void testRasterSaturation() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - 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"); - } - Timber.i("raster-saturation"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(rasterSaturation(0.3f)); - assertEquals((Float) layer.getRasterSaturation().getValue(), (Float) 0.3f); - } - - @Test - public void testRasterContrast() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - 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"); - } - Timber.i("raster-contrast"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(rasterContrast(0.3f)); - assertEquals((Float) layer.getRasterContrast().getValue(), (Float) 0.3f); - } - - @Test - public void testRasterFadeDuration() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - 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"); - } - Timber.i("raster-fade-duration"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(rasterFadeDuration(0.3f)); - assertEquals((Float) layer.getRasterFadeDuration().getValue(), (Float) 0.3f); - } - - - @After - public void unregisterIntentServiceIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java index 169d747b9c..eb2155f545 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java @@ -1,11 +1,23 @@ -package com.mapbox.mapboxsdk.testapp.style; // This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. +package com.mapbox.mapboxsdk.testapp.style; + +import android.graphics.Color; import android.support.test.espresso.Espresso; import android.support.test.rule.ActivityTestRule; 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.layers.RasterLayer; import com.mapbox.mapboxsdk.testapp.R; import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity; @@ -17,20 +29,12 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import timber.log.Timber; - -import static com.mapbox.mapboxsdk.style.layers.Property.NONE; -import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterBrightnessMax; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterBrightnessMin; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterContrast; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterFadeDuration; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterHueRotate; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterOpacity; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterSaturation; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +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 org.junit.Assert.*; +import static com.mapbox.mapboxsdk.style.layers.Property.*; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; /** * Basic smoke tests for RasterLayer @@ -51,12 +55,6 @@ public class RasterLayerTest extends BaseStyleTest { public void setup() { idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); Espresso.registerIdlingResources(idlingResource); - } - - @Test - public void testSetVisibility() { - checkViewIsDisplayed(R.id.mapView); - mapboxMap = rule.getActivity().getMapboxMap(); if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { @@ -64,174 +62,284 @@ public class RasterLayerTest extends BaseStyleTest { layer = new RasterLayer("my-layer", "composite"); layer.setSourceLayer("composite"); mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference + // Layer reference is now stale, get new reference layer = mapboxMap.getLayerAs("my-layer"); } - Timber.i("visibility"); + } + + @Test + public void testSetVisibility() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("Visibility"); assertNotNull(layer); - //Get initial + // Get initial assertEquals(layer.getVisibility().getValue(), VISIBLE); - //Set + // Set layer.setProperties(visibility(NONE)); assertEquals(layer.getVisibility().getValue(), NONE); } @Test - public void testRasterOpacity() { + public void testRasterOpacityAsConstant() { checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - 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"); - } Timber.i("raster-opacity"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(rasterOpacity(0.3f)); assertEquals((Float) layer.getRasterOpacity().getValue(), (Float) 0.3f); } @Test - public void testRasterHueRotate() { + public void testRasterOpacityAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("raster-opacity"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // 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()); + } - 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"); - } + @Test + public void testRasterHueRotateAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("raster-hue-rotate"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(rasterHueRotate(0.3f)); assertEquals((Float) layer.getRasterHueRotate().getValue(), (Float) 0.3f); } @Test - public void testRasterBrightnessMin() { + public void testRasterHueRotateAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("raster-hue-rotate"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // 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()); + } - 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"); - } + @Test + public void testRasterBrightnessMinAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("raster-brightness-min"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(rasterBrightnessMin(0.3f)); assertEquals((Float) layer.getRasterBrightnessMin().getValue(), (Float) 0.3f); } @Test - public void testRasterBrightnessMax() { + public void testRasterBrightnessMinAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("raster-brightness-min"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // 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()); + } - 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"); - } + @Test + public void testRasterBrightnessMaxAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("raster-brightness-max"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(rasterBrightnessMax(0.3f)); assertEquals((Float) layer.getRasterBrightnessMax().getValue(), (Float) 0.3f); } @Test - public void testRasterSaturation() { + public void testRasterBrightnessMaxAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("raster-brightness-max"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // 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()); + } - 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"); - } + @Test + public void testRasterSaturationAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("raster-saturation"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(rasterSaturation(0.3f)); assertEquals((Float) layer.getRasterSaturation().getValue(), (Float) 0.3f); } @Test - public void testRasterContrast() { + public void testRasterSaturationAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("raster-saturation"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // 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()); + } - 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"); - } + @Test + public void testRasterContrastAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("raster-contrast"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(rasterContrast(0.3f)); assertEquals((Float) layer.getRasterContrast().getValue(), (Float) 0.3f); } @Test - public void testRasterFadeDuration() { + public void testRasterContrastAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("raster-contrast"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // 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()); + } - 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"); - } + @Test + public void testRasterFadeDurationAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("raster-fade-duration"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(rasterFadeDuration(0.3f)); assertEquals((Float) layer.getRasterFadeDuration().getValue(), (Float) 0.3f); } + @Test + public void testRasterFadeDurationAsCameraFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("raster-fade-duration"); + 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()); + } + @After public void unregisterIntentServiceIdlingResource() { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleBackgroundLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleBackgroundLayerTest.java index 762ae4f846..c95c959644 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleBackgroundLayerTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleBackgroundLayerTest.java @@ -44,10 +44,10 @@ public class RuntimeStyleBackgroundLayerTest BackgroundLayer layer = mapboxMap.getLayerAs("background"); assertNotNull(layer); - //Get initial + // Get initial assertEquals(layer.getVisibility().getValue(), Property.VISIBLE); - //Set + // Set layer.setProperties(PropertyFactory.visibility(Property.NONE)); assertEquals(layer.getVisibility().getValue(), Property.NONE); } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java index eec00bdde9..bf90949ffd 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java @@ -1,6 +1,7 @@ package com.mapbox.mapboxsdk.testapp.style; import android.graphics.Color; +import android.graphics.PointF; import android.support.test.espresso.Espresso; import android.support.test.espresso.UiController; import android.support.test.espresso.ViewAction; @@ -10,12 +11,12 @@ import android.view.View; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.style.layers.CannotAddLayerException; +import com.mapbox.mapboxsdk.style.layers.CircleLayer; import com.mapbox.mapboxsdk.style.layers.FillLayer; -import com.mapbox.mapboxsdk.style.layers.NoSuchLayerException; +import com.mapbox.mapboxsdk.style.layers.Layer; import com.mapbox.mapboxsdk.style.layers.Property; import com.mapbox.mapboxsdk.style.layers.PropertyFactory; import com.mapbox.mapboxsdk.style.sources.CannotAddSourceException; -import com.mapbox.mapboxsdk.style.sources.NoSuchSourceException; import com.mapbox.mapboxsdk.style.sources.Source; import com.mapbox.mapboxsdk.style.sources.VectorSource; import com.mapbox.mapboxsdk.testapp.R; @@ -32,12 +33,18 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; +import java.util.List; + +import timber.log.Timber; + 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 junit.framework.Assert.fail; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; /** * Basic smoke tests for Layer and Source @@ -57,139 +64,255 @@ public class RuntimeStyleTests { } @Test + public void testListLayers() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + onView(withId(R.id.mapView)).perform(new BaseViewAction() { + + @Override + public void perform(UiController uiController, View view) { + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + List<Layer> layers = mapboxMap.getLayers(); + assertNotNull(layers); + assertTrue(layers.size() > 0); + for (Layer layer : layers) { + assertNotNull(layer); + } + } + + }); + } + + @Test public void testGetAddRemoveLayer() { ViewUtils.checkViewIsDisplayed(R.id.mapView); onView(withId(R.id.mapView)).perform(new AddRemoveLayerAction()); } @Test + public void testAddLayerAbove() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + onView(withId(R.id.mapView)).perform(new BaseViewAction() { + @Override + public void perform(UiController uiController, View view) { + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + List<Layer> layers = mapboxMap.getLayers(); + Source source = mapboxMap.getSources().get(0); + + // Test inserting with invalid above-id + try { + mapboxMap.addLayerAbove(new CircleLayer("invalid-id-layer-test", source.getId()), "no-such-layer-here-man"); + fail("Should have thrown exception"); + } catch (CannotAddLayerException ex) { + // Yeah + assertNotNull(ex.getMessage()); + } + + // Insert as last + CircleLayer last = new CircleLayer("this is the last one", source.getId()); + mapboxMap.addLayerAbove(last, layers.get(layers.size() - 1).getId()); + layers = mapboxMap.getLayers(); + assertEquals(last.getId(), layers.get(layers.size() - 1).getId()); + + // Insert + CircleLayer second = new CircleLayer("this is the second one", source.getId()); + mapboxMap.addLayerAbove(second, layers.get(0).getId()); + layers = mapboxMap.getLayers(); + assertEquals(second.getId(), layers.get(1).getId()); + } + }); + } + + @Test + public void testRemoveLayerAt() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + onView(withId(R.id.mapView)).perform(new BaseViewAction() { + + @Override + public void perform(UiController uiController, View view) { + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + // Remove by index + Layer firstLayer = mapboxMap.getLayers().get(0); + Layer removed = mapboxMap.removeLayerAt(0); + assertNotNull(removed); + assertNotNull(removed.getId()); + assertEquals(firstLayer.getId(), removed.getId()); + + // Test remove by index bounds checks + Timber.i("Remove layer at index > size"); + assertNull(mapboxMap.removeLayerAt(Integer.MAX_VALUE)); + } + }); + } + + public void testAddLayerAt() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + onView(withId(R.id.mapView)).perform(new BaseViewAction() { + @Override + public void perform(UiController uiController, View view) { + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + List<Layer> layers = mapboxMap.getLayers(); + Source source = mapboxMap.getSources().get(0); + + // Test inserting out of range + try { + mapboxMap.addLayerAt(new CircleLayer("invalid-id-layer-test", source.getId()), layers.size()); + fail("Should have thrown exception"); + } catch (CannotAddLayerException ex) { + // Yeah + assertNotNull(ex.getMessage()); + } + + // Insert at current last position + CircleLayer last = new CircleLayer("this is the last one", source.getId()); + mapboxMap.addLayerAt(last, layers.size() - 1); + layers = mapboxMap.getLayers(); + assertEquals(last.getId(), layers.get(layers.size() - 2).getId()); + + // Insert at start + CircleLayer second = new CircleLayer("this is the first one", source.getId()); + mapboxMap.addLayerAt(second, 0); + layers = mapboxMap.getLayers(); + assertEquals(second.getId(), layers.get(0).getId()); + } + }); + } + + + @Test + public void testListSources() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + onView(withId(R.id.mapView)).perform(new BaseViewAction() { + + @Override + public void perform(UiController uiController, View view) { + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + + List<Source> sources = mapboxMap.getSources(); + assertNotNull(sources); + assertTrue(sources.size() > 0); + for (Source source : sources) { + assertNotNull(source); + } + } + + }); + } + + @Test public void testAddRemoveSource() { ViewUtils.checkViewIsDisplayed(R.id.mapView); MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2")); - try { - mapboxMap.removeSource("my-source"); - } catch (NoSuchSourceException noSuchSourceException) { - // it's ok.. - } + mapboxMap.removeSource("my-source"); onView(withId(R.id.mapView)).perform(new AddRemoveSourceAction()); } - private class AddRemoveLayerAction implements ViewAction { + /** + * https://github.com/mapbox/mapbox-gl-native/issues/7973 + */ + @Test + public void testQueryRenderedFeaturesInputHandling() { + ViewUtils.checkViewIsDisplayed(R.id.mapView); + onView(withId(R.id.mapView)).perform(new BaseViewAction() { + + @Override + public void perform(UiController uiController, View view) { + MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); + String[] layerIds = new String[600]; + for (int i = 0; i < layerIds.length; i++) { + layerIds[i] = "layer-" + i; + } + mapboxMap.queryRenderedFeatures(new PointF(100, 100), layerIds); + } - @Override - public Matcher<View> getConstraints() { - return isDisplayed(); - } + }); + } - @Override - public String getDescription() { - return getClass().getSimpleName(); - } + private class AddRemoveLayerAction extends BaseViewAction { @Override public void perform(UiController uiController, View view) { MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - //Get initial + // Get initial assertNotNull(mapboxMap.getLayer("building")); - //Remove - try { - mapboxMap.removeLayer("building"); - } catch (NoSuchLayerException noSuchSourceException) { - fail("Definitively exists: " + noSuchSourceException.getMessage()); - } + // Remove + Layer building = mapboxMap.removeLayer("building"); + assertNotNull(building); assertNull(mapboxMap.getLayer("building")); - //Add + // Add FillLayer layer = new FillLayer("building", "composite"); layer.setSourceLayer("building"); mapboxMap.addLayer(layer); assertNotNull(mapboxMap.getLayer("building")); - //Assure the reference still works + // Assure the reference still works layer.setProperties(PropertyFactory.visibility(Property.VISIBLE)); - //Remove, preserving the reference - try { - mapboxMap.removeLayer(layer); - } catch (NoSuchLayerException noSuchSourceException) { - fail("Definitively exists: " + noSuchSourceException.getMessage()); - } + // Remove, preserving the reference + mapboxMap.removeLayer(layer); - //Property setters should still work + // Property setters should still work layer.setProperties(PropertyFactory.fillColor(Color.RED)); - //Re-add the reference... + // Re-add the reference... mapboxMap.addLayer(layer); - //Ensure it's there + // Ensure it's there Assert.assertNotNull(mapboxMap.getLayer(layer.getId())); - //Test adding a duplicate layer + // Test adding a duplicate layer try { mapboxMap.addLayer(new FillLayer("building", "composite")); fail("Should not have been allowed to add a layer with a duplicate id"); } catch (CannotAddLayerException cannotAddLayerException) { - //OK + // OK } } } - private class AddRemoveSourceAction implements ViewAction { - - @Override - public Matcher<View> getConstraints() { - return isDisplayed(); - } - - @Override - public String getDescription() { - return getClass().getSimpleName(); - } + private class AddRemoveSourceAction extends BaseViewAction { @Override public void perform(UiController uiController, View view) { MapboxMap mapboxMap = rule.getActivity().getMapboxMap(); - //Add initial source + // Add initial source mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2")); - //Remove - try { - mapboxMap.removeSource("my-source"); - } catch (NoSuchSourceException noSuchSourceException) { - fail("Definitively exists: " + noSuchSourceException.getMessage()); - } + // Remove + Source mySource = mapboxMap.removeSource("my-source"); + assertNotNull(mySource); assertNull(mapboxMap.getLayer("my-source")); - //Add + // Add Source source = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"); mapboxMap.addSource(source); - //Remove, preserving the reference - try { - mapboxMap.removeSource(source); - } catch (NoSuchSourceException noSuchSourceException) { - fail("Definitively exists: " + noSuchSourceException.getMessage()); - } + // Remove, preserving the reference + mapboxMap.removeSource(source); - //Re-add the reference... + // Re-add the reference... mapboxMap.addSource(source); - //Ensure it's there + // Ensure it's there Assert.assertNotNull(mapboxMap.getSource(source.getId())); - //Test adding a duplicate source + // Test adding a duplicate source try { Source source2 = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"); mapboxMap.addSource(source2); fail("Should not have been allowed to add a source with a duplicate id"); } catch (CannotAddSourceException cannotAddSourceException) { - //OK + // OK } } } @@ -198,4 +321,18 @@ public class RuntimeStyleTests { public void unregisterIntentServiceIdlingResource() { Espresso.unregisterIdlingResources(idlingResource); } + + public abstract class BaseViewAction implements ViewAction { + + @Override + public Matcher<View> getConstraints() { + return isDisplayed(); + } + + @Override + public String getDescription() { + return getClass().getSimpleName(); + } + + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTimingTests.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTimingTests.java index 57b0fe72ff..400c5fbc3c 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTimingTests.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTimingTests.java @@ -35,7 +35,7 @@ public class RuntimeStyleTimingTests extends BaseStyleTest { @Test public void testGetAddRemoveLayer() { checkViewIsDisplayed(R.id.mapView); - //We're good if it didn't crash + // We're good if it didn't crash } @After diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerStyleTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerStyleTest.java deleted file mode 100644 index 5b59d4ceae..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerStyleTest.java +++ /dev/null @@ -1,1283 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.style; -// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`. - -import android.graphics.Color; -import android.support.test.espresso.Espresso; -import android.support.test.rule.ActivityTestRule; -import android.support.test.runner.AndroidJUnit4; - -import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.style.layers.SymbolLayer; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity; -import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; - -import timber.log.Timber; - -import static com.mapbox.mapboxsdk.style.layers.Property.ICON_ROTATION_ALIGNMENT_MAP; -import static com.mapbox.mapboxsdk.style.layers.Property.ICON_TEXT_FIT_NONE; -import static com.mapbox.mapboxsdk.style.layers.Property.ICON_TRANSLATE_ANCHOR_MAP; -import static com.mapbox.mapboxsdk.style.layers.Property.NONE; -import static com.mapbox.mapboxsdk.style.layers.Property.SYMBOL_PLACEMENT_POINT; -import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_ANCHOR_CENTER; -import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_JUSTIFY_LEFT; -import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_PITCH_ALIGNMENT_MAP; -import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_ROTATION_ALIGNMENT_MAP; -import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_TRANSFORM_NONE; -import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_TRANSLATE_ANCHOR_MAP; -import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconAllowOverlap; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconColor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconHaloBlur; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconHaloColor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconHaloWidth; -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.iconKeepUpright; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconOffset; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconOpacity; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconOptional; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconPadding; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconRotate; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconRotationAlignment; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconSize; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTextFit; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTextFitPadding; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTranslate; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTranslateAnchor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.symbolAvoidEdges; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.symbolPlacement; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.symbolSpacing; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textAllowOverlap; -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.textFont; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textHaloBlur; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textHaloColor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textHaloWidth; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textIgnorePlacement; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textJustify; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textKeepUpright; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textLetterSpacing; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textLineHeight; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textMaxAngle; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textMaxWidth; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textOffset; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textOpacity; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textOptional; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textPadding; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textPitchAlignment; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textRotate; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textRotationAlignment; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textSize; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textTransform; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textTranslate; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textTranslateAnchor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -/** - * Basic smoke tests for SymbolLayer - */ -@RunWith(AndroidJUnit4.class) -public class SymbolLayerStyleTest extends BaseStyleTest { - - @Rule - public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); - - private SymbolLayer layer; - - private OnMapReadyIdlingResource idlingResource; - - private MapboxMap mapboxMap; - - @Before - public void setup() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); - } - - @Test - public void testSetVisibility() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("visibility"); - assertNotNull(layer); - - //Get initial - assertEquals(layer.getVisibility().getValue(), VISIBLE); - - //Set - layer.setProperties(visibility(NONE)); - assertEquals(layer.getVisibility().getValue(), NONE); - } - - @Test - public void testSymbolPlacement() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("symbol-placement"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(symbolPlacement(SYMBOL_PLACEMENT_POINT)); - assertEquals((String) layer.getSymbolPlacement().getValue(), (String) SYMBOL_PLACEMENT_POINT); - } - - @Test - public void testSymbolSpacing() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("symbol-spacing"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(symbolSpacing(0.3f)); - assertEquals((Float) layer.getSymbolSpacing().getValue(), (Float) 0.3f); - } - - @Test - public void testSymbolAvoidEdges() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("symbol-avoid-edges"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(symbolAvoidEdges(true)); - assertEquals((Boolean) layer.getSymbolAvoidEdges().getValue(), (Boolean) true); - } - - @Test - public void testIconAllowOverlap() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-allow-overlap"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconAllowOverlap(true)); - assertEquals((Boolean) layer.getIconAllowOverlap().getValue(), (Boolean) true); - } - - @Test - public void testIconIgnorePlacement() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-ignore-placement"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconIgnorePlacement(true)); - assertEquals((Boolean) layer.getIconIgnorePlacement().getValue(), (Boolean) true); - } - - @Test - public void testIconOptional() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-optional"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconOptional(true)); - assertEquals((Boolean) layer.getIconOptional().getValue(), (Boolean) true); - } - - @Test - public void testIconRotationAlignment() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-rotation-alignment"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconRotationAlignment(ICON_ROTATION_ALIGNMENT_MAP)); - assertEquals((String) layer.getIconRotationAlignment().getValue(), (String) ICON_ROTATION_ALIGNMENT_MAP); - } - - @Test - public void testIconSize() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-size"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconSize(0.3f)); - assertEquals((Float) layer.getIconSize().getValue(), (Float) 0.3f); - } - - @Test - public void testIconTextFit() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-text-fit"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconTextFit(ICON_TEXT_FIT_NONE)); - assertEquals((String) layer.getIconTextFit().getValue(), (String) ICON_TEXT_FIT_NONE); - } - - @Test - public void testIconTextFitPadding() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-text-fit-padding"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconTextFitPadding(new Float[] {0f, 0f, 0f, 0f})); - assertEquals((Float[]) layer.getIconTextFitPadding().getValue(), (Float[]) new Float[] {0f, 0f, 0f, 0f}); - } - - @Test - public void testIconImage() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-image"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconImage("undefined")); - assertEquals((String) layer.getIconImage().getValue(), (String) "undefined"); - } - - @Test - public void testIconRotate() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-rotate"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconRotate(0.3f)); - assertEquals((Float) layer.getIconRotate().getValue(), (Float) 0.3f); - } - - @Test - public void testIconPadding() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-padding"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconPadding(0.3f)); - assertEquals((Float) layer.getIconPadding().getValue(), (Float) 0.3f); - } - - @Test - public void testIconKeepUpright() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-keep-upright"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconKeepUpright(true)); - assertEquals((Boolean) layer.getIconKeepUpright().getValue(), (Boolean) true); - } - - @Test - public void testIconOffset() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-offset"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconOffset(new Float[] {0f, 0f})); - assertEquals((Float[]) layer.getIconOffset().getValue(), (Float[]) new Float[] {0f, 0f}); - } - - @Test - public void testTextPitchAlignment() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-pitch-alignment"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textPitchAlignment(TEXT_PITCH_ALIGNMENT_MAP)); - assertEquals((String) layer.getTextPitchAlignment().getValue(), (String) TEXT_PITCH_ALIGNMENT_MAP); - } - - @Test - public void testTextRotationAlignment() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-rotation-alignment"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textRotationAlignment(TEXT_ROTATION_ALIGNMENT_MAP)); - assertEquals((String) layer.getTextRotationAlignment().getValue(), (String) TEXT_ROTATION_ALIGNMENT_MAP); - } - - @Test - public void testTextField() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-field"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textField("")); - assertEquals((String) layer.getTextField().getValue(), (String) ""); - } - - @Test - public void testTextFont() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-font"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textFont(new String[] {"Open Sans Regular", "Arial Unicode MS Regular"})); - assertEquals((String[]) layer.getTextFont().getValue(), (String[]) new String[] {"Open Sans Regular", - "Arial Unicode MS Regular"}); - } - - @Test - public void testTextSize() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-size"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textSize(0.3f)); - assertEquals((Float) layer.getTextSize().getValue(), (Float) 0.3f); - } - - @Test - public void testTextMaxWidth() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-max-width"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textMaxWidth(0.3f)); - assertEquals((Float) layer.getTextMaxWidth().getValue(), (Float) 0.3f); - } - - @Test - public void testTextLineHeight() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-line-height"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textLineHeight(0.3f)); - assertEquals((Float) layer.getTextLineHeight().getValue(), (Float) 0.3f); - } - - @Test - public void testTextLetterSpacing() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-letter-spacing"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textLetterSpacing(0.3f)); - assertEquals((Float) layer.getTextLetterSpacing().getValue(), (Float) 0.3f); - } - - @Test - public void testTextJustify() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-justify"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textJustify(TEXT_JUSTIFY_LEFT)); - assertEquals((String) layer.getTextJustify().getValue(), (String) TEXT_JUSTIFY_LEFT); - } - - @Test - public void testTextAnchor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-anchor"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textAnchor(TEXT_ANCHOR_CENTER)); - assertEquals((String) layer.getTextAnchor().getValue(), (String) TEXT_ANCHOR_CENTER); - } - - @Test - public void testTextMaxAngle() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-max-angle"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textMaxAngle(0.3f)); - assertEquals((Float) layer.getTextMaxAngle().getValue(), (Float) 0.3f); - } - - @Test - public void testTextRotate() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-rotate"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textRotate(0.3f)); - assertEquals((Float) layer.getTextRotate().getValue(), (Float) 0.3f); - } - - @Test - public void testTextPadding() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-padding"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textPadding(0.3f)); - assertEquals((Float) layer.getTextPadding().getValue(), (Float) 0.3f); - } - - @Test - public void testTextKeepUpright() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-keep-upright"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textKeepUpright(true)); - assertEquals((Boolean) layer.getTextKeepUpright().getValue(), (Boolean) true); - } - - @Test - public void testTextTransform() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-transform"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textTransform(TEXT_TRANSFORM_NONE)); - assertEquals((String) layer.getTextTransform().getValue(), (String) TEXT_TRANSFORM_NONE); - } - - @Test - public void testTextOffset() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-offset"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textOffset(new Float[] {0f, 0f})); - assertEquals((Float[]) layer.getTextOffset().getValue(), (Float[]) new Float[] {0f, 0f}); - } - - @Test - public void testTextAllowOverlap() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-allow-overlap"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textAllowOverlap(true)); - assertEquals((Boolean) layer.getTextAllowOverlap().getValue(), (Boolean) true); - } - - @Test - public void testTextIgnorePlacement() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-ignore-placement"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textIgnorePlacement(true)); - assertEquals((Boolean) layer.getTextIgnorePlacement().getValue(), (Boolean) true); - } - - @Test - public void testTextOptional() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-optional"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textOptional(true)); - assertEquals((Boolean) layer.getTextOptional().getValue(), (Boolean) true); - } - - @Test - public void testIconOpacity() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-opacity"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconOpacity(0.3f)); - assertEquals((Float) layer.getIconOpacity().getValue(), (Float) 0.3f); - } - - @Test - public void testIconColor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getIconColor().getValue(), (String) "rgba(0, 0, 0, 1)"); - } - - @Test - public void testIconColorAsInt() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconColor(Color.RED)); - assertEquals(layer.getIconColorAsInt(), Color.RED); - } - - @Test - public void testIconHaloColor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-halo-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconHaloColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getIconHaloColor().getValue(), (String) "rgba(0, 0, 0, 1)"); - } - - @Test - public void testIconHaloColorAsInt() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-halo-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconHaloColor(Color.RED)); - assertEquals(layer.getIconHaloColorAsInt(), Color.RED); - } - - @Test - public void testIconHaloWidth() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-halo-width"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconHaloWidth(0.3f)); - assertEquals((Float) layer.getIconHaloWidth().getValue(), (Float) 0.3f); - } - - @Test - public void testIconHaloBlur() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-halo-blur"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconHaloBlur(0.3f)); - assertEquals((Float) layer.getIconHaloBlur().getValue(), (Float) 0.3f); - } - - @Test - public void testIconTranslate() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-translate"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconTranslate(new Float[] {0f, 0f})); - assertEquals((Float[]) layer.getIconTranslate().getValue(), (Float[]) new Float[] {0f, 0f}); - } - - @Test - public void testIconTranslateAnchor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("icon-translate-anchor"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(iconTranslateAnchor(ICON_TRANSLATE_ANCHOR_MAP)); - assertEquals((String) layer.getIconTranslateAnchor().getValue(), (String) ICON_TRANSLATE_ANCHOR_MAP); - } - - @Test - public void testTextOpacity() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-opacity"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textOpacity(0.3f)); - assertEquals((Float) layer.getTextOpacity().getValue(), (Float) 0.3f); - } - - @Test - public void testTextColor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getTextColor().getValue(), (String) "rgba(0, 0, 0, 1)"); - } - - @Test - public void testTextColorAsInt() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textColor(Color.RED)); - assertEquals(layer.getTextColorAsInt(), Color.RED); - } - - @Test - public void testTextHaloColor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-halo-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textHaloColor("rgba(0, 0, 0, 1)")); - assertEquals((String) layer.getTextHaloColor().getValue(), (String) "rgba(0, 0, 0, 1)"); - } - - @Test - public void testTextHaloColorAsInt() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-halo-color"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textHaloColor(Color.RED)); - assertEquals(layer.getTextHaloColorAsInt(), Color.RED); - } - - @Test - public void testTextHaloWidth() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-halo-width"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textHaloWidth(0.3f)); - assertEquals((Float) layer.getTextHaloWidth().getValue(), (Float) 0.3f); - } - - @Test - public void testTextHaloBlur() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-halo-blur"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textHaloBlur(0.3f)); - assertEquals((Float) layer.getTextHaloBlur().getValue(), (Float) 0.3f); - } - - @Test - public void testTextTranslate() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-translate"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textTranslate(new Float[] {0f, 0f})); - assertEquals((Float[]) layer.getTextTranslate().getValue(), (Float[]) new Float[] {0f, 0f}); - } - - @Test - public void testTextTranslateAnchor() { - checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } - Timber.i("text-translate-anchor"); - assertNotNull(layer); - - //Set and Get - layer.setProperties(textTranslateAnchor(TEXT_TRANSLATE_ANCHOR_MAP)); - assertEquals((String) layer.getTextTranslateAnchor().getValue(), (String) TEXT_TRANSLATE_ANCHOR_MAP); - } - - - @After - public void unregisterIntentServiceIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java index f4c50a2ffb..3b3bc9c8b5 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java @@ -1,12 +1,23 @@ -package com.mapbox.mapboxsdk.testapp.style; // This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. +package com.mapbox.mapboxsdk.testapp.style; + import android.graphics.Color; import android.support.test.espresso.Espresso; import android.support.test.rule.ActivityTestRule; 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.layers.SymbolLayer; import com.mapbox.mapboxsdk.testapp.R; import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity; @@ -18,71 +29,12 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import timber.log.Timber; - -import static com.mapbox.mapboxsdk.style.layers.Property.ICON_ROTATION_ALIGNMENT_MAP; -import static com.mapbox.mapboxsdk.style.layers.Property.ICON_TEXT_FIT_NONE; -import static com.mapbox.mapboxsdk.style.layers.Property.ICON_TRANSLATE_ANCHOR_MAP; -import static com.mapbox.mapboxsdk.style.layers.Property.NONE; -import static com.mapbox.mapboxsdk.style.layers.Property.SYMBOL_PLACEMENT_POINT; -import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_ANCHOR_CENTER; -import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_JUSTIFY_LEFT; -import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_PITCH_ALIGNMENT_MAP; -import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_ROTATION_ALIGNMENT_MAP; -import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_TRANSFORM_NONE; -import static com.mapbox.mapboxsdk.style.layers.Property.TEXT_TRANSLATE_ANCHOR_MAP; -import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconAllowOverlap; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconColor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconHaloBlur; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconHaloColor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconHaloWidth; -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.iconKeepUpright; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconOffset; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconOpacity; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconOptional; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconPadding; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconRotate; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconRotationAlignment; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconSize; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTextFit; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTextFitPadding; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTranslate; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTranslateAnchor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.symbolAvoidEdges; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.symbolPlacement; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.symbolSpacing; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textAllowOverlap; -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.textFont; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textHaloBlur; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textHaloColor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textHaloWidth; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textIgnorePlacement; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textJustify; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textKeepUpright; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textLetterSpacing; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textLineHeight; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textMaxAngle; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textMaxWidth; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textOffset; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textOpacity; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textOptional; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textPadding; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textPitchAlignment; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textRotate; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textRotationAlignment; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textSize; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textTransform; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textTranslate; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textTranslateAnchor; -import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +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 org.junit.Assert.*; +import static com.mapbox.mapboxsdk.style.layers.Property.*; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; /** * Basic smoke tests for SymbolLayer @@ -103,12 +55,6 @@ public class SymbolLayerTest extends BaseStyleTest { public void setup() { idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); Espresso.registerIdlingResources(idlingResource); - } - - @Test - public void testSetVisibility() { - checkViewIsDisplayed(R.id.mapView); - mapboxMap = rule.getActivity().getMapboxMap(); if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { @@ -116,1165 +62,2984 @@ public class SymbolLayerTest extends BaseStyleTest { layer = new SymbolLayer("my-layer", "composite"); layer.setSourceLayer("composite"); mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference + // Layer reference is now stale, get new reference layer = mapboxMap.getLayerAs("my-layer"); } - Timber.i("visibility"); + } + + @Test + public void testSetVisibility() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("Visibility"); assertNotNull(layer); - //Get initial + // Get initial assertEquals(layer.getVisibility().getValue(), VISIBLE); - //Set + // Set layer.setProperties(visibility(NONE)); assertEquals(layer.getVisibility().getValue(), NONE); } @Test - public void testSymbolPlacement() { + public void testSymbolPlacementAsConstant() { checkViewIsDisplayed(R.id.mapView); - - mapboxMap = rule.getActivity().getMapboxMap(); - - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } Timber.i("symbol-placement"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(symbolPlacement(SYMBOL_PLACEMENT_POINT)); assertEquals((String) layer.getSymbolPlacement().getValue(), (String) SYMBOL_PLACEMENT_POINT); } @Test - public void testSymbolSpacing() { + public void testSymbolPlacementAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("symbol-placement"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + symbolPlacement( + zoom( + interval( + stop(2, symbolPlacement(SYMBOL_PLACEMENT_POINT)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getSymbolPlacement()); + assertNotNull(layer.getSymbolPlacement().getFunction()); + assertEquals(CameraFunction.class, layer.getSymbolPlacement().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getSymbolPlacement().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getSymbolPlacement().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testSymbolSpacingAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("symbol-spacing"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(symbolSpacing(0.3f)); assertEquals((Float) layer.getSymbolSpacing().getValue(), (Float) 0.3f); } @Test - public void testSymbolAvoidEdges() { + public void testSymbolSpacingAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("symbol-spacing"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + symbolSpacing( + zoom( + exponential( + stop(2, symbolSpacing(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getSymbolSpacing()); + assertNotNull(layer.getSymbolSpacing().getFunction()); + assertEquals(CameraFunction.class, layer.getSymbolSpacing().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getSymbolSpacing().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getSymbolSpacing().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getSymbolSpacing().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testSymbolAvoidEdgesAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("symbol-avoid-edges"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(symbolAvoidEdges(true)); assertEquals((Boolean) layer.getSymbolAvoidEdges().getValue(), (Boolean) true); } @Test - public void testIconAllowOverlap() { + public void testSymbolAvoidEdgesAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("symbol-avoid-edges"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + symbolAvoidEdges( + zoom( + interval( + stop(2, symbolAvoidEdges(true)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getSymbolAvoidEdges()); + assertNotNull(layer.getSymbolAvoidEdges().getFunction()); + assertEquals(CameraFunction.class, layer.getSymbolAvoidEdges().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getSymbolAvoidEdges().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getSymbolAvoidEdges().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testIconAllowOverlapAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("icon-allow-overlap"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(iconAllowOverlap(true)); assertEquals((Boolean) layer.getIconAllowOverlap().getValue(), (Boolean) true); } @Test - public void testIconIgnorePlacement() { + public void testIconAllowOverlapAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-allow-overlap"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + iconAllowOverlap( + zoom( + interval( + stop(2, iconAllowOverlap(true)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconAllowOverlap()); + assertNotNull(layer.getIconAllowOverlap().getFunction()); + assertEquals(CameraFunction.class, layer.getIconAllowOverlap().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getIconAllowOverlap().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getIconAllowOverlap().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testIconIgnorePlacementAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("icon-ignore-placement"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(iconIgnorePlacement(true)); assertEquals((Boolean) layer.getIconIgnorePlacement().getValue(), (Boolean) true); } @Test - public void testIconOptional() { + public void testIconIgnorePlacementAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-ignore-placement"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + iconIgnorePlacement( + zoom( + interval( + stop(2, iconIgnorePlacement(true)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconIgnorePlacement()); + assertNotNull(layer.getIconIgnorePlacement().getFunction()); + assertEquals(CameraFunction.class, layer.getIconIgnorePlacement().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getIconIgnorePlacement().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getIconIgnorePlacement().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testIconOptionalAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("icon-optional"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(iconOptional(true)); assertEquals((Boolean) layer.getIconOptional().getValue(), (Boolean) true); } @Test - public void testIconRotationAlignment() { + public void testIconOptionalAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-optional"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + iconOptional( + zoom( + interval( + stop(2, iconOptional(true)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconOptional()); + assertNotNull(layer.getIconOptional().getFunction()); + assertEquals(CameraFunction.class, layer.getIconOptional().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getIconOptional().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getIconOptional().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testIconRotationAlignmentAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("icon-rotation-alignment"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(iconRotationAlignment(ICON_ROTATION_ALIGNMENT_MAP)); assertEquals((String) layer.getIconRotationAlignment().getValue(), (String) ICON_ROTATION_ALIGNMENT_MAP); } @Test - public void testIconSize() { + public void testIconRotationAlignmentAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-rotation-alignment"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + iconRotationAlignment( + zoom( + interval( + stop(2, iconRotationAlignment(ICON_ROTATION_ALIGNMENT_MAP)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconRotationAlignment()); + assertNotNull(layer.getIconRotationAlignment().getFunction()); + assertEquals(CameraFunction.class, layer.getIconRotationAlignment().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getIconRotationAlignment().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getIconRotationAlignment().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testIconSizeAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("icon-size"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(iconSize(0.3f)); assertEquals((Float) layer.getIconSize().getValue(), (Float) 0.3f); } @Test - public void testIconTextFit() { + public void testIconSizeAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-size"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + iconSize( + zoom( + exponential( + stop(2, iconSize(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconSize()); + assertNotNull(layer.getIconSize().getFunction()); + assertEquals(CameraFunction.class, layer.getIconSize().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getIconSize().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getIconSize().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getIconSize().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testIconTextFitAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("icon-text-fit"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(iconTextFit(ICON_TEXT_FIT_NONE)); assertEquals((String) layer.getIconTextFit().getValue(), (String) ICON_TEXT_FIT_NONE); } @Test - public void testIconTextFitPadding() { + public void testIconTextFitAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-text-fit"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + iconTextFit( + zoom( + interval( + stop(2, iconTextFit(ICON_TEXT_FIT_NONE)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconTextFit()); + assertNotNull(layer.getIconTextFit().getFunction()); + assertEquals(CameraFunction.class, layer.getIconTextFit().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getIconTextFit().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getIconTextFit().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testIconTextFitPaddingAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("icon-text-fit-padding"); assertNotNull(layer); - //Set and Get - layer.setProperties(iconTextFitPadding(new Float[] {0f, 0f, 0f, 0f})); - assertEquals((Float[]) layer.getIconTextFitPadding().getValue(), (Float[]) new Float[] {0f, 0f, 0f, 0f}); + // Set and Get + layer.setProperties(iconTextFitPadding(new Float[]{0f,0f,0f,0f})); + assertEquals((Float[]) layer.getIconTextFitPadding().getValue(), (Float[]) new Float[]{0f,0f,0f,0f}); } @Test - public void testIconImage() { + public void testIconTextFitPaddingAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-text-fit-padding"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + iconTextFitPadding( + zoom( + exponential( + stop(2, iconTextFitPadding(new Float[]{0f,0f,0f,0f})) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconTextFitPadding()); + assertNotNull(layer.getIconTextFitPadding().getFunction()); + assertEquals(CameraFunction.class, layer.getIconTextFitPadding().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getIconTextFitPadding().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getIconTextFitPadding().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getIconTextFitPadding().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testIconImageAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("icon-image"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(iconImage("undefined")); assertEquals((String) layer.getIconImage().getValue(), (String) "undefined"); } @Test - public void testIconRotate() { + public void testIconImageAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-image"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + iconImage( + zoom( + interval( + stop(2, iconImage("undefined")) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconImage()); + assertNotNull(layer.getIconImage().getFunction()); + assertEquals(CameraFunction.class, layer.getIconImage().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getIconImage().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getIconImage().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testIconRotateAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("icon-rotate"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(iconRotate(0.3f)); assertEquals((Float) layer.getIconRotate().getValue(), (Float) 0.3f); } @Test - public void testIconPadding() { + public void testIconRotateAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-rotate"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + iconRotate( + zoom( + exponential( + stop(2, iconRotate(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconRotate()); + assertNotNull(layer.getIconRotate().getFunction()); + assertEquals(CameraFunction.class, layer.getIconRotate().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getIconRotate().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getIconRotate().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getIconRotate().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testIconRotateAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-rotate"); + assertNotNull(layer); + + // Set + layer.setProperties( + iconRotate(property("FeaturePropertyA", Stops.<Float>identity())) + ); + + // Verify + assertNotNull(layer.getIconRotate()); + assertNotNull(layer.getIconRotate().getFunction()); + assertEquals(SourceFunction.class, layer.getIconRotate().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconRotate().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getIconRotate().getFunction().getStops().getClass()); + } + + @Test + public void testIconRotateAsExponentialSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-rotate"); + assertNotNull(layer); + + // Set + layer.setProperties( + iconRotate( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, iconRotate(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconRotate()); + assertNotNull(layer.getIconRotate().getFunction()); + assertEquals(SourceFunction.class, layer.getIconRotate().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconRotate().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getIconRotate().getFunction().getStops().getClass()); + } + + @Test + public void testIconRotateAsCategoricalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-rotate"); + assertNotNull(layer); + + // Set + layer.setProperties( + iconRotate( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, iconRotate(0.3f)) + ) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getIconRotate()); + assertNotNull(layer.getIconRotate().getFunction()); + assertEquals(SourceFunction.class, layer.getIconRotate().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconRotate().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getIconRotate().getFunction().getStops().getClass()); + assertEquals(0.3f, ((SourceFunction) layer.getIconRotate().getFunction()).getDefaultValue()); + } + + @Test + public void testIconRotateAsCompositeFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-rotate"); + assertNotNull(layer); + + // Set + layer.setProperties( + iconRotate( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, iconRotate(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getIconRotate()); + assertNotNull(layer.getIconRotate().getFunction()); + assertEquals(CompositeFunction.class, layer.getIconRotate().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getIconRotate().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getIconRotate().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getIconRotate().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getIconRotate().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 testIconPaddingAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("icon-padding"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(iconPadding(0.3f)); assertEquals((Float) layer.getIconPadding().getValue(), (Float) 0.3f); } @Test - public void testIconKeepUpright() { + public void testIconPaddingAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-padding"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + iconPadding( + zoom( + exponential( + stop(2, iconPadding(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconPadding()); + assertNotNull(layer.getIconPadding().getFunction()); + assertEquals(CameraFunction.class, layer.getIconPadding().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getIconPadding().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getIconPadding().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getIconPadding().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testIconKeepUprightAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("icon-keep-upright"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(iconKeepUpright(true)); assertEquals((Boolean) layer.getIconKeepUpright().getValue(), (Boolean) true); } @Test - public void testIconOffset() { + public void testIconKeepUprightAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-keep-upright"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + iconKeepUpright( + zoom( + interval( + stop(2, iconKeepUpright(true)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconKeepUpright()); + assertNotNull(layer.getIconKeepUpright().getFunction()); + assertEquals(CameraFunction.class, layer.getIconKeepUpright().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getIconKeepUpright().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getIconKeepUpright().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testIconOffsetAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("icon-offset"); assertNotNull(layer); - //Set and Get - layer.setProperties(iconOffset(new Float[] {0f, 0f})); - assertEquals((Float[]) layer.getIconOffset().getValue(), (Float[]) new Float[] {0f, 0f}); + // Set and Get + layer.setProperties(iconOffset(new Float[]{0f,0f})); + assertEquals((Float[]) layer.getIconOffset().getValue(), (Float[]) new Float[]{0f,0f}); } @Test - public void testTextPitchAlignment() { + public void testIconOffsetAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-offset"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + iconOffset( + zoom( + exponential( + stop(2, iconOffset(new Float[]{0f,0f})) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconOffset()); + assertNotNull(layer.getIconOffset().getFunction()); + assertEquals(CameraFunction.class, layer.getIconOffset().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getIconOffset().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getIconOffset().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getIconOffset().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testIconOffsetAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-offset"); + assertNotNull(layer); + + // Set + layer.setProperties( + iconOffset(property("FeaturePropertyA", Stops.<Float[]>identity())) + ); + + // Verify + assertNotNull(layer.getIconOffset()); + assertNotNull(layer.getIconOffset().getFunction()); + assertEquals(SourceFunction.class, layer.getIconOffset().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconOffset().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getIconOffset().getFunction().getStops().getClass()); + } + + @Test + public void testIconOffsetAsIntervalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-offset"); + assertNotNull(layer); + + // Set + layer.setProperties( + iconOffset( + property( + "FeaturePropertyA", + interval( + stop(1, iconOffset(new Float[]{0f,0f})) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconOffset()); + assertNotNull(layer.getIconOffset().getFunction()); + assertEquals(SourceFunction.class, layer.getIconOffset().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconOffset().getFunction()).getProperty()); + assertEquals(IntervalStops.class, layer.getIconOffset().getFunction().getStops().getClass()); + } + + @Test + public void testTextPitchAlignmentAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-pitch-alignment"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(textPitchAlignment(TEXT_PITCH_ALIGNMENT_MAP)); assertEquals((String) layer.getTextPitchAlignment().getValue(), (String) TEXT_PITCH_ALIGNMENT_MAP); } @Test - public void testTextRotationAlignment() { + public void testTextPitchAlignmentAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-pitch-alignment"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textPitchAlignment( + zoom( + interval( + stop(2, textPitchAlignment(TEXT_PITCH_ALIGNMENT_MAP)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextPitchAlignment()); + assertNotNull(layer.getTextPitchAlignment().getFunction()); + assertEquals(CameraFunction.class, layer.getTextPitchAlignment().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getTextPitchAlignment().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getTextPitchAlignment().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextRotationAlignmentAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-rotation-alignment"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(textRotationAlignment(TEXT_ROTATION_ALIGNMENT_MAP)); assertEquals((String) layer.getTextRotationAlignment().getValue(), (String) TEXT_ROTATION_ALIGNMENT_MAP); } @Test - public void testTextField() { + public void testTextRotationAlignmentAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-rotation-alignment"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textRotationAlignment( + zoom( + interval( + stop(2, textRotationAlignment(TEXT_ROTATION_ALIGNMENT_MAP)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextRotationAlignment()); + assertNotNull(layer.getTextRotationAlignment().getFunction()); + assertEquals(CameraFunction.class, layer.getTextRotationAlignment().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getTextRotationAlignment().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getTextRotationAlignment().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextFieldAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-field"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(textField("")); assertEquals((String) layer.getTextField().getValue(), (String) ""); } @Test - public void testTextFont() { + public void testTextFieldAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-field"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textField( + zoom( + interval( + stop(2, textField("")) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextField()); + assertNotNull(layer.getTextField().getFunction()); + assertEquals(CameraFunction.class, layer.getTextField().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getTextField().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getTextField().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextFieldAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("text-field"); + assertNotNull(layer); + + // Set + layer.setProperties( + textField(property("FeaturePropertyA", Stops.<String>identity())) + ); + + // Verify + assertNotNull(layer.getTextField()); + assertNotNull(layer.getTextField().getFunction()); + assertEquals(SourceFunction.class, layer.getTextField().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextField().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getTextField().getFunction().getStops().getClass()); + } + + @Test + public void testTextFieldAsIntervalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("text-field"); + assertNotNull(layer); + + // Set + layer.setProperties( + textField( + property( + "FeaturePropertyA", + interval( + stop(1, textField("")) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextField()); + assertNotNull(layer.getTextField().getFunction()); + assertEquals(SourceFunction.class, layer.getTextField().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextField().getFunction()).getProperty()); + assertEquals(IntervalStops.class, layer.getTextField().getFunction().getStops().getClass()); + } + + @Test + public void testTextFontAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-font"); assertNotNull(layer); - //Set and Get - layer.setProperties(textFont(new String[] {"Open Sans Regular", "Arial Unicode MS Regular"})); - assertEquals((String[]) layer.getTextFont().getValue(), (String[]) new String[] {"Open Sans Regular", - "Arial Unicode MS Regular"}); + // Set and Get + layer.setProperties(textFont(new String[]{"Open Sans Regular", "Arial Unicode MS Regular"})); + assertEquals((String[]) layer.getTextFont().getValue(), (String[]) new String[]{"Open Sans Regular", "Arial Unicode MS Regular"}); } @Test - public void testTextSize() { + public void testTextFontAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-font"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textFont( + zoom( + interval( + stop(2, textFont(new String[]{"Open Sans Regular", "Arial Unicode MS Regular"})) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextFont()); + assertNotNull(layer.getTextFont().getFunction()); + assertEquals(CameraFunction.class, layer.getTextFont().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getTextFont().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getTextFont().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextSizeAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-size"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(textSize(0.3f)); assertEquals((Float) layer.getTextSize().getValue(), (Float) 0.3f); } @Test - public void testTextMaxWidth() { + public void testTextSizeAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-size"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textSize( + zoom( + exponential( + stop(2, textSize(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextSize()); + assertNotNull(layer.getTextSize().getFunction()); + assertEquals(CameraFunction.class, layer.getTextSize().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextSize().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextSize().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextSize().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextMaxWidthAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-max-width"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(textMaxWidth(0.3f)); assertEquals((Float) layer.getTextMaxWidth().getValue(), (Float) 0.3f); } @Test - public void testTextLineHeight() { + public void testTextMaxWidthAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-max-width"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textMaxWidth( + zoom( + exponential( + stop(2, textMaxWidth(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextMaxWidth()); + assertNotNull(layer.getTextMaxWidth().getFunction()); + assertEquals(CameraFunction.class, layer.getTextMaxWidth().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextMaxWidth().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextMaxWidth().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextMaxWidth().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextLineHeightAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-line-height"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(textLineHeight(0.3f)); assertEquals((Float) layer.getTextLineHeight().getValue(), (Float) 0.3f); } @Test - public void testTextLetterSpacing() { + public void testTextLineHeightAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-line-height"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textLineHeight( + zoom( + exponential( + stop(2, textLineHeight(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextLineHeight()); + assertNotNull(layer.getTextLineHeight().getFunction()); + assertEquals(CameraFunction.class, layer.getTextLineHeight().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextLineHeight().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextLineHeight().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextLineHeight().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextLetterSpacingAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-letter-spacing"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(textLetterSpacing(0.3f)); assertEquals((Float) layer.getTextLetterSpacing().getValue(), (Float) 0.3f); } @Test - public void testTextJustify() { + public void testTextLetterSpacingAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-letter-spacing"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textLetterSpacing( + zoom( + exponential( + stop(2, textLetterSpacing(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextLetterSpacing()); + assertNotNull(layer.getTextLetterSpacing().getFunction()); + assertEquals(CameraFunction.class, layer.getTextLetterSpacing().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextLetterSpacing().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextLetterSpacing().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextLetterSpacing().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextJustifyAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-justify"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(textJustify(TEXT_JUSTIFY_LEFT)); assertEquals((String) layer.getTextJustify().getValue(), (String) TEXT_JUSTIFY_LEFT); } @Test - public void testTextAnchor() { + public void testTextJustifyAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-justify"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textJustify( + zoom( + interval( + stop(2, textJustify(TEXT_JUSTIFY_LEFT)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextJustify()); + assertNotNull(layer.getTextJustify().getFunction()); + assertEquals(CameraFunction.class, layer.getTextJustify().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getTextJustify().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getTextJustify().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextAnchorAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-anchor"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(textAnchor(TEXT_ANCHOR_CENTER)); assertEquals((String) layer.getTextAnchor().getValue(), (String) TEXT_ANCHOR_CENTER); } @Test - public void testTextMaxAngle() { + public void testTextAnchorAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-anchor"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textAnchor( + zoom( + interval( + stop(2, textAnchor(TEXT_ANCHOR_CENTER)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextAnchor()); + assertNotNull(layer.getTextAnchor().getFunction()); + assertEquals(CameraFunction.class, layer.getTextAnchor().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getTextAnchor().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getTextAnchor().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextMaxAngleAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-max-angle"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(textMaxAngle(0.3f)); assertEquals((Float) layer.getTextMaxAngle().getValue(), (Float) 0.3f); } @Test - public void testTextRotate() { + public void testTextMaxAngleAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-max-angle"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textMaxAngle( + zoom( + exponential( + stop(2, textMaxAngle(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextMaxAngle()); + assertNotNull(layer.getTextMaxAngle().getFunction()); + assertEquals(CameraFunction.class, layer.getTextMaxAngle().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextMaxAngle().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextMaxAngle().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextMaxAngle().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextRotateAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-rotate"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(textRotate(0.3f)); assertEquals((Float) layer.getTextRotate().getValue(), (Float) 0.3f); } @Test - public void testTextPadding() { + public void testTextRotateAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-rotate"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textRotate( + zoom( + exponential( + stop(2, textRotate(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextRotate()); + assertNotNull(layer.getTextRotate().getFunction()); + assertEquals(CameraFunction.class, layer.getTextRotate().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextRotate().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextRotate().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextRotate().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextPaddingAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-padding"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(textPadding(0.3f)); assertEquals((Float) layer.getTextPadding().getValue(), (Float) 0.3f); } @Test - public void testTextKeepUpright() { + public void testTextPaddingAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-padding"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textPadding( + zoom( + exponential( + stop(2, textPadding(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextPadding()); + assertNotNull(layer.getTextPadding().getFunction()); + assertEquals(CameraFunction.class, layer.getTextPadding().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextPadding().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextPadding().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextPadding().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextKeepUprightAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-keep-upright"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(textKeepUpright(true)); assertEquals((Boolean) layer.getTextKeepUpright().getValue(), (Boolean) true); } @Test - public void testTextTransform() { + public void testTextKeepUprightAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-keep-upright"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textKeepUpright( + zoom( + interval( + stop(2, textKeepUpright(true)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextKeepUpright()); + assertNotNull(layer.getTextKeepUpright().getFunction()); + assertEquals(CameraFunction.class, layer.getTextKeepUpright().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getTextKeepUpright().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getTextKeepUpright().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextTransformAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-transform"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(textTransform(TEXT_TRANSFORM_NONE)); assertEquals((String) layer.getTextTransform().getValue(), (String) TEXT_TRANSFORM_NONE); } @Test - public void testTextOffset() { + public void testTextTransformAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-transform"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textTransform( + zoom( + interval( + stop(2, textTransform(TEXT_TRANSFORM_NONE)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextTransform()); + assertNotNull(layer.getTextTransform().getFunction()); + assertEquals(CameraFunction.class, layer.getTextTransform().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getTextTransform().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getTextTransform().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextTransformAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("text-transform"); + assertNotNull(layer); + + // Set + layer.setProperties( + textTransform(property("FeaturePropertyA", Stops.<String>identity())) + ); + + // Verify + assertNotNull(layer.getTextTransform()); + assertNotNull(layer.getTextTransform().getFunction()); + assertEquals(SourceFunction.class, layer.getTextTransform().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextTransform().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getTextTransform().getFunction().getStops().getClass()); + } + + @Test + public void testTextTransformAsIntervalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("text-transform"); + assertNotNull(layer); + + // Set + layer.setProperties( + textTransform( + property( + "FeaturePropertyA", + interval( + stop(1, textTransform(TEXT_TRANSFORM_NONE)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextTransform()); + assertNotNull(layer.getTextTransform().getFunction()); + assertEquals(SourceFunction.class, layer.getTextTransform().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextTransform().getFunction()).getProperty()); + assertEquals(IntervalStops.class, layer.getTextTransform().getFunction().getStops().getClass()); + } + + @Test + public void testTextOffsetAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-offset"); assertNotNull(layer); - //Set and Get - layer.setProperties(textOffset(new Float[] {0f, 0f})); - assertEquals((Float[]) layer.getTextOffset().getValue(), (Float[]) new Float[] {0f, 0f}); + // Set and Get + layer.setProperties(textOffset(new Float[]{0f,0f})); + assertEquals((Float[]) layer.getTextOffset().getValue(), (Float[]) new Float[]{0f,0f}); } @Test - public void testTextAllowOverlap() { + public void testTextOffsetAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-offset"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textOffset( + zoom( + exponential( + stop(2, textOffset(new Float[]{0f,0f})) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextOffset()); + assertNotNull(layer.getTextOffset().getFunction()); + assertEquals(CameraFunction.class, layer.getTextOffset().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextOffset().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextOffset().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextOffset().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextAllowOverlapAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-allow-overlap"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(textAllowOverlap(true)); assertEquals((Boolean) layer.getTextAllowOverlap().getValue(), (Boolean) true); } @Test - public void testTextIgnorePlacement() { + public void testTextAllowOverlapAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-allow-overlap"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textAllowOverlap( + zoom( + interval( + stop(2, textAllowOverlap(true)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextAllowOverlap()); + assertNotNull(layer.getTextAllowOverlap().getFunction()); + assertEquals(CameraFunction.class, layer.getTextAllowOverlap().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getTextAllowOverlap().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getTextAllowOverlap().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextIgnorePlacementAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-ignore-placement"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(textIgnorePlacement(true)); assertEquals((Boolean) layer.getTextIgnorePlacement().getValue(), (Boolean) true); } @Test - public void testTextOptional() { + public void testTextIgnorePlacementAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-ignore-placement"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textIgnorePlacement( + zoom( + interval( + stop(2, textIgnorePlacement(true)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextIgnorePlacement()); + assertNotNull(layer.getTextIgnorePlacement().getFunction()); + assertEquals(CameraFunction.class, layer.getTextIgnorePlacement().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getTextIgnorePlacement().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getTextIgnorePlacement().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextOptionalAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-optional"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(textOptional(true)); assertEquals((Boolean) layer.getTextOptional().getValue(), (Boolean) true); } @Test - public void testIconOpacity() { + public void testTextOptionalAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-optional"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textOptional( + zoom( + interval( + stop(2, textOptional(true)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextOptional()); + assertNotNull(layer.getTextOptional().getFunction()); + assertEquals(CameraFunction.class, layer.getTextOptional().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getTextOptional().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getTextOptional().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testIconOpacityAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("icon-opacity"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(iconOpacity(0.3f)); assertEquals((Float) layer.getIconOpacity().getValue(), (Float) 0.3f); } @Test - public void testIconColor() { + public void testIconOpacityAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-opacity"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + iconOpacity( + zoom( + exponential( + stop(2, iconOpacity(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconOpacity()); + assertNotNull(layer.getIconOpacity().getFunction()); + assertEquals(CameraFunction.class, layer.getIconOpacity().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getIconOpacity().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getIconOpacity().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getIconOpacity().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testIconOpacityAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-opacity"); + assertNotNull(layer); + + // Set + layer.setProperties( + iconOpacity(property("FeaturePropertyA", Stops.<Float>identity())) + ); + + // Verify + assertNotNull(layer.getIconOpacity()); + assertNotNull(layer.getIconOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getIconOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconOpacity().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getIconOpacity().getFunction().getStops().getClass()); + } + + @Test + public void testIconOpacityAsExponentialSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-opacity"); + assertNotNull(layer); + + // Set + layer.setProperties( + iconOpacity( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, iconOpacity(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconOpacity()); + assertNotNull(layer.getIconOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getIconOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconOpacity().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getIconOpacity().getFunction().getStops().getClass()); + } + + @Test + public void testIconOpacityAsCategoricalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-opacity"); + assertNotNull(layer); + + // Set + layer.setProperties( + iconOpacity( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, iconOpacity(0.3f)) + ) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getIconOpacity()); + assertNotNull(layer.getIconOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getIconOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconOpacity().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getIconOpacity().getFunction().getStops().getClass()); + assertEquals(0.3f, ((SourceFunction) layer.getIconOpacity().getFunction()).getDefaultValue()); + } + + @Test + public void testIconOpacityAsCompositeFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-opacity"); + assertNotNull(layer); + + // Set + layer.setProperties( + iconOpacity( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, iconOpacity(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getIconOpacity()); + assertNotNull(layer.getIconOpacity().getFunction()); + assertEquals(CompositeFunction.class, layer.getIconOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getIconOpacity().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getIconOpacity().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getIconOpacity().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getIconOpacity().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 testIconColorAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("icon-color"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(iconColor("rgba(0, 0, 0, 1)")); assertEquals((String) layer.getIconColor().getValue(), (String) "rgba(0, 0, 0, 1)"); } @Test - public void testIconColorAsInt() { + public void testIconColorAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-color"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + iconColor( + zoom( + exponential( + stop(2, iconColor("rgba(0, 0, 0, 1)")) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconColor()); + assertNotNull(layer.getIconColor().getFunction()); + assertEquals(CameraFunction.class, layer.getIconColor().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getIconColor().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getIconColor().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getIconColor().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testIconColorAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); Timber.i("icon-color"); assertNotNull(layer); - //Set and Get - layer.setProperties(iconColor(Color.RED)); - assertEquals(layer.getIconColorAsInt(), Color.RED); + // Set + layer.setProperties( + iconColor(property("FeaturePropertyA", Stops.<String>identity())) + ); + + // Verify + assertNotNull(layer.getIconColor()); + assertNotNull(layer.getIconColor().getFunction()); + assertEquals(SourceFunction.class, layer.getIconColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconColor().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getIconColor().getFunction().getStops().getClass()); } @Test - public void testIconHaloColor() { + public void testIconColorAsExponentialSourceFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-color"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + iconColor( + property( + "FeaturePropertyA", + exponential( + stop(Color.RED, iconColor(Color.RED)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconColor()); + assertNotNull(layer.getIconColor().getFunction()); + assertEquals(SourceFunction.class, layer.getIconColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconColor().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getIconColor().getFunction().getStops().getClass()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testIconColorAsCategoricalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-color"); + assertNotNull(layer); + + // Set + layer.setProperties( + iconColor( + property( + "FeaturePropertyA", + categorical( + stop("valueA", iconColor(Color.RED)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconColor()); + assertNotNull(layer.getIconColor().getFunction()); + assertEquals(SourceFunction.class, layer.getIconColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconColor().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getIconColor().getFunction().getStops().getClass()); + } + + @Test + public void testIconColorAsIntConstant() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-color"); + assertNotNull(layer); + + // Set and Get + layer.setProperties(iconColor(Color.RED)); + assertEquals(layer.getIconColorAsInt(), Color.RED); + } + + @Test + public void testIconHaloColorAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("icon-halo-color"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(iconHaloColor("rgba(0, 0, 0, 1)")); assertEquals((String) layer.getIconHaloColor().getValue(), (String) "rgba(0, 0, 0, 1)"); } @Test - public void testIconHaloColorAsInt() { + public void testIconHaloColorAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-halo-color"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + iconHaloColor( + zoom( + exponential( + stop(2, iconHaloColor("rgba(0, 0, 0, 1)")) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconHaloColor()); + assertNotNull(layer.getIconHaloColor().getFunction()); + assertEquals(CameraFunction.class, layer.getIconHaloColor().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getIconHaloColor().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getIconHaloColor().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getIconHaloColor().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testIconHaloColorAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); Timber.i("icon-halo-color"); assertNotNull(layer); - //Set and Get - layer.setProperties(iconHaloColor(Color.RED)); - assertEquals(layer.getIconHaloColorAsInt(), Color.RED); + // Set + layer.setProperties( + iconHaloColor(property("FeaturePropertyA", Stops.<String>identity())) + ); + + // Verify + assertNotNull(layer.getIconHaloColor()); + assertNotNull(layer.getIconHaloColor().getFunction()); + assertEquals(SourceFunction.class, layer.getIconHaloColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloColor().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getIconHaloColor().getFunction().getStops().getClass()); } @Test - public void testIconHaloWidth() { + public void testIconHaloColorAsExponentialSourceFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-halo-color"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + iconHaloColor( + property( + "FeaturePropertyA", + exponential( + stop(Color.RED, iconHaloColor(Color.RED)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconHaloColor()); + assertNotNull(layer.getIconHaloColor().getFunction()); + assertEquals(SourceFunction.class, layer.getIconHaloColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloColor().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getIconHaloColor().getFunction().getStops().getClass()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testIconHaloColorAsCategoricalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-halo-color"); + assertNotNull(layer); + + // Set + layer.setProperties( + iconHaloColor( + property( + "FeaturePropertyA", + categorical( + stop("valueA", iconHaloColor(Color.RED)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconHaloColor()); + assertNotNull(layer.getIconHaloColor().getFunction()); + assertEquals(SourceFunction.class, layer.getIconHaloColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloColor().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getIconHaloColor().getFunction().getStops().getClass()); + } + + @Test + public void testIconHaloColorAsIntConstant() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-halo-color"); + assertNotNull(layer); + + // Set and Get + layer.setProperties(iconHaloColor(Color.RED)); + assertEquals(layer.getIconHaloColorAsInt(), Color.RED); + } + + @Test + public void testIconHaloWidthAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("icon-halo-width"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(iconHaloWidth(0.3f)); assertEquals((Float) layer.getIconHaloWidth().getValue(), (Float) 0.3f); } @Test - public void testIconHaloBlur() { + public void testIconHaloWidthAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-halo-width"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + iconHaloWidth( + zoom( + exponential( + stop(2, iconHaloWidth(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconHaloWidth()); + assertNotNull(layer.getIconHaloWidth().getFunction()); + assertEquals(CameraFunction.class, layer.getIconHaloWidth().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getIconHaloWidth().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getIconHaloWidth().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getIconHaloWidth().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testIconHaloWidthAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-halo-width"); + assertNotNull(layer); + + // Set + layer.setProperties( + iconHaloWidth(property("FeaturePropertyA", Stops.<Float>identity())) + ); + + // Verify + assertNotNull(layer.getIconHaloWidth()); + assertNotNull(layer.getIconHaloWidth().getFunction()); + assertEquals(SourceFunction.class, layer.getIconHaloWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloWidth().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getIconHaloWidth().getFunction().getStops().getClass()); + } + + @Test + public void testIconHaloWidthAsExponentialSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-halo-width"); + assertNotNull(layer); + + // Set + layer.setProperties( + iconHaloWidth( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, iconHaloWidth(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconHaloWidth()); + assertNotNull(layer.getIconHaloWidth().getFunction()); + assertEquals(SourceFunction.class, layer.getIconHaloWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloWidth().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getIconHaloWidth().getFunction().getStops().getClass()); + } + + @Test + public void testIconHaloWidthAsCategoricalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-halo-width"); + assertNotNull(layer); + + // Set + layer.setProperties( + iconHaloWidth( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, iconHaloWidth(0.3f)) + ) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getIconHaloWidth()); + assertNotNull(layer.getIconHaloWidth().getFunction()); + assertEquals(SourceFunction.class, layer.getIconHaloWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloWidth().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getIconHaloWidth().getFunction().getStops().getClass()); + assertEquals(0.3f, ((SourceFunction) layer.getIconHaloWidth().getFunction()).getDefaultValue()); + } + + @Test + public void testIconHaloWidthAsCompositeFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-halo-width"); + assertNotNull(layer); + + // Set + layer.setProperties( + iconHaloWidth( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, iconHaloWidth(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getIconHaloWidth()); + assertNotNull(layer.getIconHaloWidth().getFunction()); + assertEquals(CompositeFunction.class, layer.getIconHaloWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getIconHaloWidth().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getIconHaloWidth().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getIconHaloWidth().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getIconHaloWidth().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 testIconHaloBlurAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("icon-halo-blur"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(iconHaloBlur(0.3f)); assertEquals((Float) layer.getIconHaloBlur().getValue(), (Float) 0.3f); } @Test - public void testIconTranslate() { + public void testIconHaloBlurAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-halo-blur"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + iconHaloBlur( + zoom( + exponential( + stop(2, iconHaloBlur(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconHaloBlur()); + assertNotNull(layer.getIconHaloBlur().getFunction()); + assertEquals(CameraFunction.class, layer.getIconHaloBlur().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getIconHaloBlur().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getIconHaloBlur().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getIconHaloBlur().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testIconHaloBlurAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-halo-blur"); + assertNotNull(layer); + + // Set + layer.setProperties( + iconHaloBlur(property("FeaturePropertyA", Stops.<Float>identity())) + ); + + // Verify + assertNotNull(layer.getIconHaloBlur()); + assertNotNull(layer.getIconHaloBlur().getFunction()); + assertEquals(SourceFunction.class, layer.getIconHaloBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloBlur().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getIconHaloBlur().getFunction().getStops().getClass()); + } + + @Test + public void testIconHaloBlurAsExponentialSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-halo-blur"); + assertNotNull(layer); + + // Set + layer.setProperties( + iconHaloBlur( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, iconHaloBlur(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconHaloBlur()); + assertNotNull(layer.getIconHaloBlur().getFunction()); + assertEquals(SourceFunction.class, layer.getIconHaloBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloBlur().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getIconHaloBlur().getFunction().getStops().getClass()); + } + + @Test + public void testIconHaloBlurAsCategoricalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-halo-blur"); + assertNotNull(layer); + + // Set + layer.setProperties( + iconHaloBlur( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, iconHaloBlur(0.3f)) + ) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getIconHaloBlur()); + assertNotNull(layer.getIconHaloBlur().getFunction()); + assertEquals(SourceFunction.class, layer.getIconHaloBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getIconHaloBlur().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getIconHaloBlur().getFunction().getStops().getClass()); + assertEquals(0.3f, ((SourceFunction) layer.getIconHaloBlur().getFunction()).getDefaultValue()); + } + + @Test + public void testIconHaloBlurAsCompositeFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-halo-blur"); + assertNotNull(layer); + + // Set + layer.setProperties( + iconHaloBlur( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, iconHaloBlur(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getIconHaloBlur()); + assertNotNull(layer.getIconHaloBlur().getFunction()); + assertEquals(CompositeFunction.class, layer.getIconHaloBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getIconHaloBlur().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getIconHaloBlur().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getIconHaloBlur().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getIconHaloBlur().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 testIconTranslateAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("icon-translate"); assertNotNull(layer); - //Set and Get - layer.setProperties(iconTranslate(new Float[] {0f, 0f})); - assertEquals((Float[]) layer.getIconTranslate().getValue(), (Float[]) new Float[] {0f, 0f}); + // Set and Get + layer.setProperties(iconTranslate(new Float[]{0f,0f})); + assertEquals((Float[]) layer.getIconTranslate().getValue(), (Float[]) new Float[]{0f,0f}); } @Test - public void testIconTranslateAnchor() { + public void testIconTranslateAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-translate"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + iconTranslate( + zoom( + exponential( + stop(2, iconTranslate(new Float[]{0f,0f})) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconTranslate()); + assertNotNull(layer.getIconTranslate().getFunction()); + assertEquals(CameraFunction.class, layer.getIconTranslate().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getIconTranslate().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getIconTranslate().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getIconTranslate().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testIconTranslateAnchorAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("icon-translate-anchor"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(iconTranslateAnchor(ICON_TRANSLATE_ANCHOR_MAP)); assertEquals((String) layer.getIconTranslateAnchor().getValue(), (String) ICON_TRANSLATE_ANCHOR_MAP); } @Test - public void testTextOpacity() { + public void testIconTranslateAnchorAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("icon-translate-anchor"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + iconTranslateAnchor( + zoom( + interval( + stop(2, iconTranslateAnchor(ICON_TRANSLATE_ANCHOR_MAP)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getIconTranslateAnchor()); + assertNotNull(layer.getIconTranslateAnchor().getFunction()); + assertEquals(CameraFunction.class, layer.getIconTranslateAnchor().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getIconTranslateAnchor().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getIconTranslateAnchor().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextOpacityAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-opacity"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(textOpacity(0.3f)); assertEquals((Float) layer.getTextOpacity().getValue(), (Float) 0.3f); } @Test - public void testTextColor() { + public void testTextOpacityAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-opacity"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textOpacity( + zoom( + exponential( + stop(2, textOpacity(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextOpacity()); + assertNotNull(layer.getTextOpacity().getFunction()); + assertEquals(CameraFunction.class, layer.getTextOpacity().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextOpacity().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextOpacity().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextOpacity().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextOpacityAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("text-opacity"); + assertNotNull(layer); + + // Set + layer.setProperties( + textOpacity(property("FeaturePropertyA", Stops.<Float>identity())) + ); + + // Verify + assertNotNull(layer.getTextOpacity()); + assertNotNull(layer.getTextOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getTextOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextOpacity().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getTextOpacity().getFunction().getStops().getClass()); + } + + @Test + public void testTextOpacityAsExponentialSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("text-opacity"); + assertNotNull(layer); + + // Set + layer.setProperties( + textOpacity( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, textOpacity(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextOpacity()); + assertNotNull(layer.getTextOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getTextOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextOpacity().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getTextOpacity().getFunction().getStops().getClass()); + } + + @Test + public void testTextOpacityAsCategoricalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("text-opacity"); + assertNotNull(layer); + + // Set + layer.setProperties( + textOpacity( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, textOpacity(0.3f)) + ) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getTextOpacity()); + assertNotNull(layer.getTextOpacity().getFunction()); + assertEquals(SourceFunction.class, layer.getTextOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextOpacity().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getTextOpacity().getFunction().getStops().getClass()); + assertEquals(0.3f, ((SourceFunction) layer.getTextOpacity().getFunction()).getDefaultValue()); + } + + @Test + public void testTextOpacityAsCompositeFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("text-opacity"); + assertNotNull(layer); + + // Set + layer.setProperties( + textOpacity( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, textOpacity(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getTextOpacity()); + assertNotNull(layer.getTextOpacity().getFunction()); + assertEquals(CompositeFunction.class, layer.getTextOpacity().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getTextOpacity().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getTextOpacity().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getTextOpacity().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getTextOpacity().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 testTextColorAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-color"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(textColor("rgba(0, 0, 0, 1)")); assertEquals((String) layer.getTextColor().getValue(), (String) "rgba(0, 0, 0, 1)"); } @Test - public void testTextColorAsInt() { + public void testTextColorAsCameraFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("text-color"); + assertNotNull(layer); + + // Set + layer.setProperties( + textColor( + zoom( + exponential( + stop(2, textColor("rgba(0, 0, 0, 1)")) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextColor()); + assertNotNull(layer.getTextColor().getFunction()); + assertEquals(CameraFunction.class, layer.getTextColor().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextColor().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextColor().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextColor().getFunction().getStops()).size()); + } + + @Test + public void testTextColorAsIdentitySourceFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-color"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textColor(property("FeaturePropertyA", Stops.<String>identity())) + ); + + // Verify + assertNotNull(layer.getTextColor()); + assertNotNull(layer.getTextColor().getFunction()); + assertEquals(SourceFunction.class, layer.getTextColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextColor().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getTextColor().getFunction().getStops().getClass()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextColorAsExponentialSourceFunction() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-color"); assertNotNull(layer); - //Set and Get - layer.setProperties(textColor(Color.RED)); - assertEquals(layer.getTextColorAsInt(), Color.RED); + // Set + layer.setProperties( + textColor( + property( + "FeaturePropertyA", + exponential( + stop(Color.RED, textColor(Color.RED)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextColor()); + assertNotNull(layer.getTextColor().getFunction()); + assertEquals(SourceFunction.class, layer.getTextColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextColor().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getTextColor().getFunction().getStops().getClass()); } @Test - public void testTextHaloColor() { + public void testTextColorAsCategoricalSourceFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-color"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textColor( + property( + "FeaturePropertyA", + categorical( + stop("valueA", textColor(Color.RED)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextColor()); + assertNotNull(layer.getTextColor().getFunction()); + assertEquals(SourceFunction.class, layer.getTextColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextColor().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getTextColor().getFunction().getStops().getClass()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextColorAsIntConstant() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("text-color"); + assertNotNull(layer); + + // Set and Get + layer.setProperties(textColor(Color.RED)); + assertEquals(layer.getTextColorAsInt(), Color.RED); + } + + @Test + public void testTextHaloColorAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-halo-color"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(textHaloColor("rgba(0, 0, 0, 1)")); assertEquals((String) layer.getTextHaloColor().getValue(), (String) "rgba(0, 0, 0, 1)"); } @Test - public void testTextHaloColorAsInt() { + public void testTextHaloColorAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-halo-color"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textHaloColor( + zoom( + exponential( + stop(2, textHaloColor("rgba(0, 0, 0, 1)")) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextHaloColor()); + assertNotNull(layer.getTextHaloColor().getFunction()); + assertEquals(CameraFunction.class, layer.getTextHaloColor().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextHaloColor().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextHaloColor().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextHaloColor().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextHaloColorAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-halo-color"); assertNotNull(layer); - //Set and Get - layer.setProperties(textHaloColor(Color.RED)); - assertEquals(layer.getTextHaloColorAsInt(), Color.RED); + // Set + layer.setProperties( + textHaloColor(property("FeaturePropertyA", Stops.<String>identity())) + ); + + // Verify + assertNotNull(layer.getTextHaloColor()); + assertNotNull(layer.getTextHaloColor().getFunction()); + assertEquals(SourceFunction.class, layer.getTextHaloColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloColor().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getTextHaloColor().getFunction().getStops().getClass()); } @Test - public void testTextHaloWidth() { + public void testTextHaloColorAsExponentialSourceFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-halo-color"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textHaloColor( + property( + "FeaturePropertyA", + exponential( + stop(Color.RED, textHaloColor(Color.RED)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextHaloColor()); + assertNotNull(layer.getTextHaloColor().getFunction()); + assertEquals(SourceFunction.class, layer.getTextHaloColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloColor().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getTextHaloColor().getFunction().getStops().getClass()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextHaloColorAsCategoricalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("text-halo-color"); + assertNotNull(layer); + + // Set + layer.setProperties( + textHaloColor( + property( + "FeaturePropertyA", + categorical( + stop("valueA", textHaloColor(Color.RED)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextHaloColor()); + assertNotNull(layer.getTextHaloColor().getFunction()); + assertEquals(SourceFunction.class, layer.getTextHaloColor().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloColor().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getTextHaloColor().getFunction().getStops().getClass()); + } + + @Test + public void testTextHaloColorAsIntConstant() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("text-halo-color"); + assertNotNull(layer); + + // Set and Get + layer.setProperties(textHaloColor(Color.RED)); + assertEquals(layer.getTextHaloColorAsInt(), Color.RED); + } + + @Test + public void testTextHaloWidthAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-halo-width"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(textHaloWidth(0.3f)); assertEquals((Float) layer.getTextHaloWidth().getValue(), (Float) 0.3f); } @Test - public void testTextHaloBlur() { + public void testTextHaloWidthAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-halo-width"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textHaloWidth( + zoom( + exponential( + stop(2, textHaloWidth(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextHaloWidth()); + assertNotNull(layer.getTextHaloWidth().getFunction()); + assertEquals(CameraFunction.class, layer.getTextHaloWidth().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextHaloWidth().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextHaloWidth().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextHaloWidth().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextHaloWidthAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("text-halo-width"); + assertNotNull(layer); + + // Set + layer.setProperties( + textHaloWidth(property("FeaturePropertyA", Stops.<Float>identity())) + ); + + // Verify + assertNotNull(layer.getTextHaloWidth()); + assertNotNull(layer.getTextHaloWidth().getFunction()); + assertEquals(SourceFunction.class, layer.getTextHaloWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloWidth().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getTextHaloWidth().getFunction().getStops().getClass()); + } + + @Test + public void testTextHaloWidthAsExponentialSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("text-halo-width"); + assertNotNull(layer); + + // Set + layer.setProperties( + textHaloWidth( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, textHaloWidth(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextHaloWidth()); + assertNotNull(layer.getTextHaloWidth().getFunction()); + assertEquals(SourceFunction.class, layer.getTextHaloWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloWidth().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getTextHaloWidth().getFunction().getStops().getClass()); + } + + @Test + public void testTextHaloWidthAsCategoricalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("text-halo-width"); + assertNotNull(layer); + + // Set + layer.setProperties( + textHaloWidth( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, textHaloWidth(0.3f)) + ) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getTextHaloWidth()); + assertNotNull(layer.getTextHaloWidth().getFunction()); + assertEquals(SourceFunction.class, layer.getTextHaloWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloWidth().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getTextHaloWidth().getFunction().getStops().getClass()); + assertEquals(0.3f, ((SourceFunction) layer.getTextHaloWidth().getFunction()).getDefaultValue()); + } + + @Test + public void testTextHaloWidthAsCompositeFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("text-halo-width"); + assertNotNull(layer); + + // Set + layer.setProperties( + textHaloWidth( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, textHaloWidth(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getTextHaloWidth()); + assertNotNull(layer.getTextHaloWidth().getFunction()); + assertEquals(CompositeFunction.class, layer.getTextHaloWidth().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getTextHaloWidth().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getTextHaloWidth().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getTextHaloWidth().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getTextHaloWidth().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 testTextHaloBlurAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-halo-blur"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(textHaloBlur(0.3f)); assertEquals((Float) layer.getTextHaloBlur().getValue(), (Float) 0.3f); } @Test - public void testTextTranslate() { + public void testTextHaloBlurAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-halo-blur"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textHaloBlur( + zoom( + exponential( + stop(2, textHaloBlur(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextHaloBlur()); + assertNotNull(layer.getTextHaloBlur().getFunction()); + assertEquals(CameraFunction.class, layer.getTextHaloBlur().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextHaloBlur().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextHaloBlur().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextHaloBlur().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextHaloBlurAsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("text-halo-blur"); + assertNotNull(layer); + + // Set + layer.setProperties( + textHaloBlur(property("FeaturePropertyA", Stops.<Float>identity())) + ); + + // Verify + assertNotNull(layer.getTextHaloBlur()); + assertNotNull(layer.getTextHaloBlur().getFunction()); + assertEquals(SourceFunction.class, layer.getTextHaloBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloBlur().getFunction()).getProperty()); + assertEquals(IdentityStops.class, layer.getTextHaloBlur().getFunction().getStops().getClass()); + } + + @Test + public void testTextHaloBlurAsExponentialSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("text-halo-blur"); + assertNotNull(layer); + + // Set + layer.setProperties( + textHaloBlur( + property( + "FeaturePropertyA", + exponential( + stop(0.3f, textHaloBlur(0.3f)) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextHaloBlur()); + assertNotNull(layer.getTextHaloBlur().getFunction()); + assertEquals(SourceFunction.class, layer.getTextHaloBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloBlur().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getTextHaloBlur().getFunction().getStops().getClass()); + } + + @Test + public void testTextHaloBlurAsCategoricalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("text-halo-blur"); + assertNotNull(layer); + + // Set + layer.setProperties( + textHaloBlur( + property( + "FeaturePropertyA", + categorical( + stop(1.0f, textHaloBlur(0.3f)) + ) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getTextHaloBlur()); + assertNotNull(layer.getTextHaloBlur().getFunction()); + assertEquals(SourceFunction.class, layer.getTextHaloBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((SourceFunction) layer.getTextHaloBlur().getFunction()).getProperty()); + assertEquals(CategoricalStops.class, layer.getTextHaloBlur().getFunction().getStops().getClass()); + assertEquals(0.3f, ((SourceFunction) layer.getTextHaloBlur().getFunction()).getDefaultValue()); + } + + @Test + public void testTextHaloBlurAsCompositeFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("text-halo-blur"); + assertNotNull(layer); + + // Set + layer.setProperties( + textHaloBlur( + composite( + "FeaturePropertyA", + exponential( + stop(0, 0.3f, textHaloBlur(0.9f)) + ).withBase(0.5f) + ).withDefaultValue(0.3f) + ) + ); + + // Verify + assertNotNull(layer.getTextHaloBlur()); + assertNotNull(layer.getTextHaloBlur().getFunction()); + assertEquals(CompositeFunction.class, layer.getTextHaloBlur().getFunction().getClass()); + assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getTextHaloBlur().getFunction()).getProperty()); + assertEquals(ExponentialStops.class, layer.getTextHaloBlur().getFunction().getStops().getClass()); + assertEquals(1, ((ExponentialStops) layer.getTextHaloBlur().getFunction().getStops()).size()); + + ExponentialStops<Stop.CompositeValue<Float, Float>, Float> stops = + (ExponentialStops<Stop.CompositeValue<Float, Float>, Float>) layer.getTextHaloBlur().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 testTextTranslateAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-translate"); assertNotNull(layer); - //Set and Get - layer.setProperties(textTranslate(new Float[] {0f, 0f})); - assertEquals((Float[]) layer.getTextTranslate().getValue(), (Float[]) new Float[] {0f, 0f}); + // Set and Get + layer.setProperties(textTranslate(new Float[]{0f,0f})); + assertEquals((Float[]) layer.getTextTranslate().getValue(), (Float[]) new Float[]{0f,0f}); } @Test - public void testTextTranslateAnchor() { + public void testTextTranslateAsCameraFunction() { checkViewIsDisplayed(R.id.mapView); + Timber.i("text-translate"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Set + layer.setProperties( + textTranslate( + zoom( + exponential( + stop(2, textTranslate(new Float[]{0f,0f})) + ).withBase(0.5f) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextTranslate()); + assertNotNull(layer.getTextTranslate().getFunction()); + assertEquals(CameraFunction.class, layer.getTextTranslate().getFunction().getClass()); + assertEquals(ExponentialStops.class, layer.getTextTranslate().getFunction().getStops().getClass()); + assertEquals(0.5f, ((ExponentialStops) layer.getTextTranslate().getFunction().getStops()).getBase(), 0.001); + assertEquals(1, ((ExponentialStops) layer.getTextTranslate().getFunction().getStops()).size()); + } - if ((layer = mapboxMap.getLayerAs("my-layer")) == null) { - Timber.i("Adding layer"); - layer = new SymbolLayer("my-layer", "composite"); - layer.setSourceLayer("composite"); - mapboxMap.addLayer(layer); - //Layer reference is now stale, get new reference - layer = mapboxMap.getLayerAs("my-layer"); - } + @Test + public void testTextTranslateAnchorAsConstant() { + checkViewIsDisplayed(R.id.mapView); Timber.i("text-translate-anchor"); assertNotNull(layer); - //Set and Get + // Set and Get layer.setProperties(textTranslateAnchor(TEXT_TRANSLATE_ANCHOR_MAP)); assertEquals((String) layer.getTextTranslateAnchor().getValue(), (String) TEXT_TRANSLATE_ANCHOR_MAP); } + @Test + public void testTextTranslateAnchorAsCameraFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("text-translate-anchor"); + assertNotNull(layer); + + // Set + layer.setProperties( + textTranslateAnchor( + zoom( + interval( + stop(2, textTranslateAnchor(TEXT_TRANSLATE_ANCHOR_MAP)) + ) + ) + ) + ); + + // Verify + assertNotNull(layer.getTextTranslateAnchor()); + assertNotNull(layer.getTextTranslateAnchor().getFunction()); + assertEquals(CameraFunction.class, layer.getTextTranslateAnchor().getFunction().getClass()); + assertEquals(IntervalStops.class, layer.getTextTranslateAnchor().getFunction().getStops().getClass()); + assertEquals(1, ((IntervalStops) layer.getTextTranslateAnchor().getFunction().getStops()).size()); + } + @After public void unregisterIntentServiceIdlingResource() { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs index 3b81b0805b..f1d68caa24 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs @@ -3,6 +3,7 @@ const properties = locals.properties; -%> // This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`. + package com.mapbox.mapboxsdk.testapp.style; import android.graphics.Color; @@ -12,6 +13,15 @@ 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.layers.<%- camelize(type) %>Layer; import com.mapbox.mapboxsdk.testapp.R; import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity; @@ -23,6 +33,9 @@ import org.junit.Rule; 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 org.junit.Assert.*; import static com.mapbox.mapboxsdk.style.layers.Property.*; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; @@ -33,112 +46,308 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; @RunWith(AndroidJUnit4.class) public class <%- camelize(type) %>LayerTest extends BaseStyleTest { - @Rule - public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + @Rule + public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class); + + private <%- camelize(type) %>Layer layer; - private <%- camelize(type) %>Layer layer; + private OnMapReadyIdlingResource idlingResource; - private OnMapReadyIdlingResource idlingResource; + private MapboxMap mapboxMap; - private MapboxMap mapboxMap; + @Before + public void setup() { + idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); + Espresso.registerIdlingResources(idlingResource); + mapboxMap = rule.getActivity().getMapboxMap(); - @Before - public void setup() { - idlingResource = new OnMapReadyIdlingResource(rule.getActivity()); - Espresso.registerIdlingResources(idlingResource); +<% if (type === 'background') { -%> + Timber.i("Retrieving layer"); + layer = mapboxMap.getLayerAs("background"); +<% } else { -%> + 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"); } +<% } -%> + } - @Test - public void testSetVisibility() { - checkViewIsDisplayed(R.id.mapView); + @Test + public void testSetVisibility() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("Visibility"); + assertNotNull(layer); - mapboxMap = rule.getActivity().getMapboxMap(); + // Get initial + assertEquals(layer.getVisibility().getValue(), VISIBLE); -<% if (type === 'background') { -%> - Timber.i("Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); + // Set + layer.setProperties(visibility(NONE)); + assertEquals(layer.getVisibility().getValue(), NONE); + } + +<% for (const property of properties) { -%> + @Test + public void test<%- camelize(property.name) %>AsConstant() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("<%- property.name %>"); + 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) %>); + } +<% if (supportsZoomFunction(property)) { -%> + + @Test + public void test<%- camelize(property.name) %>AsCameraFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("<%- property.name %>"); + assertNotNull(layer); + + // Set + layer.setProperties( + <%- camelizeWithLeadingLowercase(property.name) %>( + zoom( +<% if (property.function == 'piecewise-constant') { -%> + interval( + stop(2, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>)) + ) <% } else { -%> - 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"); - } + exponential( + stop(2, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>)) + ).withBase(0.5f) <% } -%> - Timber.i("visibility"); - assertNotNull(layer); + ) + ) + ); - //Get initial - assertEquals(layer.getVisibility().getValue(), VISIBLE); + // 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)) { -%> - //Set - layer.setProperties(visibility(NONE)); - assertEquals(layer.getVisibility().getValue(), NONE); - } + @Test + public void test<%- camelize(property.name) %>AsIdentitySourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("<%- property.name %>"); + assertNotNull(layer); -<% for (const property of properties) { -%> - @Test - public void test<%- camelize(property.name) %>() { - checkViewIsDisplayed(R.id.mapView); + // Set + layer.setProperties( + <%- camelizeWithLeadingLowercase(property.name) %>(property("FeaturePropertyA", Stops.<<%- propertyType(property) %>>identity())) + ); - mapboxMap = rule.getActivity().getMapboxMap(); + // 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') { -%> -<% if (type === 'background') { -%> - Timber.i("Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); + @Test + public void test<%- camelize(property.name) %>AsIntervalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("<%- property.name %>"); + 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() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("<%- property.name %>"); + 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 ((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"); - } + + @Test + public void test<%- camelize(property.name) %>AsExponentialSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("<%- property.name %>"); + 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) %>)) <% } -%> - Timber.i("<%- property.name %>"); - assertNotNull(layer); + ).withBase(0.5f) + ) + ) + ); - //Set and Get - layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>)); - assertEquals((<%- propertyType(property) %>) layer.get<%- camelize(property.name) %>().getValue(), (<%- propertyType(property) %>) <%- 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(ExponentialStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass()); + } + + @Test + public void test<%- camelize(property.name) %>AsCategoricalSourceFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("<%- property.name %>"); + assertNotNull(layer); + + // Set + layer.setProperties( + <%- camelizeWithLeadingLowercase(property.name) %>( + property( + "FeaturePropertyA", + categorical( <% if (property.type == 'color') { -%> + stop("valueA", <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED)) + ) + ) +<% } else {-%> + stop(1.0f, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>)) + ) + ).withDefaultValue(<%- defaultValueJava(property) %>) +<% } -%> + ) + ); - @Test - public void test<%- camelize(property.name) %>AsInt() { - checkViewIsDisplayed(R.id.mapView); + // 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()); +<% if (property.type !== 'color') { -%> + assertEquals(<%- defaultValueJava(property) %>, ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getDefaultValue()); +<% } -%> + } +<% if (property.type !== 'color') { -%> - mapboxMap = rule.getActivity().getMapboxMap(); + @Test + public void test<%- camelize(property.name) %>AsCompositeFunction() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("<%- property.name %>"); + assertNotNull(layer); -<% if (type === 'background') { -%> - Timber.i("Retrieving layer"); - layer = mapboxMap.getLayerAs("background"); + // 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(<%- defaultValueJava(property) %>) <% } else { -%> - 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"); - } + ) <% } -%> - Timber.i("<%- property.name %>"); - assertNotNull(layer); + ) + ); - //Set and Get - layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(Color.RED)); - assertEquals(layer.get<%- camelize(property.name) %>AsInt(), Color.RED); - } + // 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') { -%> + + @Test + public void test<%- camelize(property.name) %>AsIntConstant() { + checkViewIsDisplayed(R.id.mapView); + Timber.i("<%- property.name %>"); + assertNotNull(layer); + + // Set and Get + layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(Color.RED)); + assertEquals(layer.get<%- camelize(property.name) %>AsInt(), Color.RED); + } <% } -%> <% } -%> - @After - public void unregisterIntentServiceIdlingResource() { - Espresso.unregisterIdlingResources(idlingResource); - } + @After + public void unregisterIntentServiceIdlingResource() { + Espresso.unregisterIdlingResources(idlingResource); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml index 684633bad1..9aeb0282b9 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml @@ -1,28 +1,29 @@ <?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.INTERNET" /> - <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> - <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> - <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> - <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> + <uses-permission android:name="android.permission.INTERNET"/> + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <application android:name=".MapboxApplication" android:allowBackup="true" android:fullBackupContent="true" android:icon="@drawable/icon" - android:roundIcon="@drawable/ic_launcher_round" android:label="@string/app_name" + android:roundIcon="@drawable/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".activity.FeatureOverviewActivity" - android:label="@string/app_name"> + 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 @@ -31,7 +32,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"/> </activity> <activity android:name=".activity.infowindow.InfoWindowAdapterActivity" @@ -39,7 +43,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"/> </activity> <activity android:name=".activity.infowindow.DynamicInfoWindowAdapterActivity" @@ -47,7 +54,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"/> </activity> <activity android:name=".activity.annotation.BulkMarkerActivity" @@ -56,7 +66,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"/> </activity> <activity android:name=".activity.annotation.AnimatedMarkerActivity" @@ -64,7 +77,10 @@ android:label="@string/activity_animated_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"/> </activity> <activity android:name=".activity.annotation.DynamicMarkerChangeActivity" @@ -72,7 +88,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"/> </activity> <activity android:name=".activity.annotation.PressForMarkerActivity" @@ -80,7 +99,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"/> </activity> <activity android:name=".activity.camera.CameraAnimationTypeActivity" @@ -88,7 +110,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"/> </activity> <activity android:name=".activity.camera.CameraPositionActivity" @@ -96,7 +121,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"/> </activity> <activity android:name=".activity.camera.LatLngBoundsActivity" @@ -105,7 +133,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"/> </activity> <activity android:name=".activity.fragment.MapFragmentActivity" @@ -113,7 +144,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"/> </activity> <activity android:name=".activity.fragment.SupportMapFragmentActivity" @@ -121,7 +155,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"/> </activity> <activity android:name=".activity.fragment.MultiMapActivity" @@ -129,7 +166,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"/> </activity> <activity android:name=".activity.camera.ManualZoomActivity" @@ -137,7 +177,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"/> </activity> <activity android:name=".activity.camera.MaxMinZoomActivity" @@ -145,7 +188,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"/> </activity> <activity android:name=".activity.customlayer.CustomLayerActivity" @@ -153,15 +199,22 @@ 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:label="@string/activity_user_tracking_mode" + android:theme="@style/NoActionBar"> <meta-data android:name="@string/category" - android:value="@string/category_userlocation" /> + android:value="@string/category_userlocation"/> + <meta-data + android:name="android.support.PARENT_ACTIVITY" + android:value=".activity.FeatureOverviewActivity"/> </activity> <activity android:name=".activity.userlocation.MyLocationDrawableActivity" @@ -169,7 +222,10 @@ android:label="@string/activity_user_tracking_customization"> <meta-data android:name="@string/category" - android:value="@string/category_userlocation" /> + android:value="@string/category_userlocation"/> + <meta-data + android:name="android.support.PARENT_ACTIVITY" + android:value=".activity.FeatureOverviewActivity"/> </activity> <activity android:name=".activity.userlocation.MyLocationTintActivity" @@ -177,7 +233,10 @@ android:label="@string/activity_user_dot_color"> <meta-data android:name="@string/category" - android:value="@string/category_userlocation" /> + android:value="@string/category_userlocation"/> + <meta-data + android:name="android.support.PARENT_ACTIVITY" + android:value=".activity.FeatureOverviewActivity"/> </activity> <activity android:name=".activity.userlocation.MyLocationToggleActivity" @@ -185,7 +244,10 @@ android:label="@string/activity_user_location_toggle"> <meta-data android:name="@string/category" - android:value="@string/category_userlocation" /> + android:value="@string/category_userlocation"/> + <meta-data + android:name="android.support.PARENT_ACTIVITY" + android:value=".activity.FeatureOverviewActivity"/> </activity> <activity android:name=".activity.annotation.PolygonActivity" @@ -193,7 +255,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"/> </activity> <activity android:name=".activity.annotation.PolylineActivity" @@ -201,31 +266,22 @@ android:label="@string/activity_polyline"> <meta-data android:name="@string/category" - android:value="@string/category_annotation" /> - </activity> - <activity - android:name=".activity.directions.DirectionsActivity" - android:description="@string/description_directions" - android:label="@string/activity_directions"> + android:value="@string/category_annotation"/> <meta-data - android:name="@string/category" - android:value="@string/category_directions" /> - </activity> - <activity - android:name=".activity.geocoding.GeocoderActivity" - android:description="@string/description_geocoder" - android:label="@string/activity_geocoder"> - <meta-data - android:name="@string/category" - android:value="@string/category_geocoding" /> + android:name="android.support.PARENT_ACTIVITY" + android:value=".activity.FeatureOverviewActivity"/> </activity> <activity android:name=".activity.camera.ScrollByActivity" android:description="@string/description_scroll_by" - android:label="@string/activity_scroll_by"> + android:label="@string/activity_scroll_by" + 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"/> </activity> <activity android:name=".activity.maplayout.MapPaddingActivity" @@ -234,7 +290,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"/> </activity> <activity android:name=".activity.maplayout.DebugModeActivity" @@ -242,7 +301,10 @@ android:label="@string/activity_debug_mode"> <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"/> </activity> <activity android:name=".activity.offline.OfflineActivity" @@ -250,7 +312,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"/> </activity> <activity android:name=".activity.offline.UpdateMetadataActivity" @@ -258,7 +323,21 @@ 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"/> + </activity> + <activity + android:name=".activity.offline.DeleteRegionActivity" + android:description="@string/description_offline_region_delete" + android:label="@string/activity_offline_region_delete"> + <meta-data + android:name="@string/category" + android:value="@string/category_offline"/> + <meta-data + android:name="android.support.PARENT_ACTIVITY" + android:value=".activity.FeatureOverviewActivity"/> </activity> <activity android:name=".activity.imagegenerator.SnapshotActivity" @@ -266,7 +345,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"/> </activity> <activity android:name=".activity.maplayout.DoubleMapActivity" @@ -274,7 +356,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"/> </activity> <activity android:name=".activity.annotation.MarkerViewActivity" @@ -282,23 +367,10 @@ android:label="@string/activity_view_marker"> <meta-data android:name="@string/category" - android:value="@string/category_annotation" /> - </activity> - <activity - android:name=".activity.annotation.MarkerViewScaleActivity" - android:description="@string/description_view_marker_scale" - android:label="@string/activity_view_marker_scale"> + android:value="@string/category_annotation"/> <meta-data - android:name="@string/category" - android:value="@string/category_annotation" /> - </activity> - <activity - android:name=".activity.navigation.LocationPickerActivity" - android:description="@string/description_location_picker" - android:label="@string/activity_location_picker"> - <meta-data - android:name="@string/category" - android:value="@string/category_navigation" /> + android:name="android.support.PARENT_ACTIVITY" + android:value=".activity.FeatureOverviewActivity"/> </activity> <activity android:name=".activity.fragment.ViewPagerActivity" @@ -306,7 +378,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"/> </activity> <activity android:name=".activity.maplayout.NavigationDrawerActivity" @@ -315,7 +390,10 @@ android:theme="@style/AppTheme.ActionBar.Transparent"> <meta-data android:name="@string/category" - android:value="@string/category_fragment" /> + android:value="@string/category_maplayout"/> + <meta-data + android:name="android.support.PARENT_ACTIVITY" + android:value=".activity.FeatureOverviewActivity"/> </activity> <activity android:name=".activity.maplayout.SimpleMapActivity" @@ -323,7 +401,10 @@ android:label="@string/activity_simple_map"> <meta-data android:name="@string/category" - android:value="@string/category_maplayout" /> + android:value="@string/category_basic"/> + <meta-data + android:name="android.support.PARENT_ACTIVITY" + android:value=".activity.FeatureOverviewActivity"/> </activity> <activity android:name=".activity.style.RuntimeStyleActivity" @@ -331,7 +412,21 @@ 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"/> + </activity> + <activity + android:name=".activity.style.DataDrivenStyleActivity" + android:description="@string/description_data_driven_style" + android:label="@string/activity_data_driven_style"> + <meta-data + android:name="@string/category" + android:value="@string/category_style"/> + <meta-data + android:name="android.support.PARENT_ACTIVITY" + android:value=".activity.FeatureOverviewActivity"/> </activity> <activity android:name=".activity.style.CircleLayerActivity" @@ -340,6 +435,20 @@ <meta-data android:name="@string/category" android:value="@string/category_style"/> + <meta-data + android:name="android.support.PARENT_ACTIVITY" + android:value=".activity.FeatureOverviewActivity"/> + </activity> + <activity + android:name=".activity.style.SymbolLayerActivity" + android:description="@string/description_symbol_layer" + android:label="@string/activity_symbol_layer"> + <meta-data + android:name="@string/category" + android:value="@string/category_style"/> + <meta-data + android:name="android.support.PARENT_ACTIVITY" + android:value=".activity.FeatureOverviewActivity"/> </activity> <activity android:name=".activity.style.GeoJsonClusteringActivity" @@ -347,14 +456,21 @@ 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"/> </activity> - <activity android:name=".activity.style.RealTimeGeoJsonActivity" + <activity + android:name=".activity.style.RealTimeGeoJsonActivity" android:description="@string/description_geojson_realtime" 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"/> </activity> <activity android:name=".activity.style.StyleFileActivity" @@ -362,7 +478,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"/> </activity> <activity android:name=".activity.style.CustomSpriteActivity" @@ -370,7 +489,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"/> </activity> <activity android:name=".activity.imagegenerator.PrintActivity" @@ -378,7 +500,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"/> </activity> <!-- Features --> @@ -388,7 +513,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"/> </activity> <activity android:name=".activity.feature.QueryRenderedFeaturesBoxCountActivity" @@ -396,7 +524,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"/> </activity> <activity android:name=".activity.feature.QueryRenderedFeaturesBoxSymbolCountActivity" @@ -404,7 +535,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"/> </activity> <activity android:name=".activity.feature.QueryRenderedFeaturesBoxHighlightActivity" @@ -412,15 +546,10 @@ android:label="@string/activity_query_rendered_features_box_highlight"> <meta-data android:name="@string/category" - android:value="@string/category_features" /> - </activity> - <activity - android:name=".activity.navigation.CarDrivingActivity" - android:description="@string/description_car_driving" - android:label="@string/activity_car_driving"> + android:value="@string/category_features"/> <meta-data - android:name="@string/category" - android:value="@string/category_navigation" /> + android:name="android.support.PARENT_ACTIVITY" + android:value=".activity.FeatureOverviewActivity"/> </activity> <activity android:name=".activity.annotation.AddRemoveMarkerActivity" @@ -428,7 +557,10 @@ android:label="@string/activity_add_remove_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"/> </activity> <activity android:name=".activity.maplayout.MapInDialogActivity" @@ -436,7 +568,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"/> </activity> <activity android:name=".activity.annotation.MarkerViewsInRectangleActivity" @@ -444,28 +579,35 @@ 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"/> </activity> <!-- For Instrumentation tests --> - <activity android:name=".activity.style.RuntimeStyleTestActivity" /> - <activity android:name=".activity.style.RuntimeStyleTimingTestActivity" /> - <activity android:name=".activity.espresso.EspressoTestActivity" /> + <activity + android:name=".activity.style.RuntimeStyleTestActivity" + android:screenOrientation="portrait"/> + <activity android:name=".activity.style.RuntimeStyleTimingTestActivity" + android:screenOrientation="portrait"/> + <activity android:name=".activity.espresso.EspressoTestActivity" + android:screenOrientation="portrait"/> <!-- Configuration Settings --> <meta-data android:name="com.mapbox.TestEventsServer" - android:value="https://cloudfront-staging.tilestream.net" /> + android:value="https://cloudfront-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 --> <!-- android:name="com.mapbox.SetStorageExternal" --> <!-- android:value="true" /> --> - <service android:name="com.mapbox.mapboxsdk.telemetry.TelemetryService" /> + <service android:name="com.mapbox.services.android.telemetry.service.TelemetryService"/> </application> -</manifest>
\ No newline at end of file +</manifest> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MapboxApplication.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MapboxApplication.java index a10c6eaad3..e344343627 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MapboxApplication.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MapboxApplication.java @@ -10,6 +10,12 @@ import timber.log.Timber; import static timber.log.Timber.DebugTree; +/** + * Application class of the test application. + * <p> + * Initialises components as LeakCanary, Strictmode, Timber and Mapbox + * </p> + */ public class MapboxApplication extends Application { @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/FeatureOverviewActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/FeatureOverviewActivity.java index 9ba51e2694..e8e1c17816 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/FeatureOverviewActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/FeatureOverviewActivity.java @@ -14,14 +14,9 @@ import android.support.annotation.StringRes; import android.support.design.widget.Snackbar; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; -import android.support.v7.widget.Toolbar; - -import timber.log.Timber; - import android.view.View; import com.mapbox.mapboxsdk.testapp.R; @@ -35,6 +30,15 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; +import timber.log.Timber; + +/** + * Activity shown when application is started + * <p> + * This activity will generate data for RecyclerView based on the AndroidManifest entries. + * It uses tags as category and description to order the different entries. + * </p> + */ public class FeatureOverviewActivity extends AppCompatActivity { private static final String KEY_STATE_FEATURES = "featureList"; @@ -46,16 +50,7 @@ public class FeatureOverviewActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - toolbar.setTitle(getString(R.string.app_name)); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setElevation(getResources().getDimension(R.dimen.toolbar_shadow)); - } + setContentView(R.layout.activity_feature_overview); recyclerView = (RecyclerView) findViewById(R.id.recyclerView); recyclerView.setLayoutManager(new LinearLayoutManager(this)); @@ -218,8 +213,6 @@ public class FeatureOverviewActivity extends AppCompatActivity { List<String> requiresPermissionActvities = new ArrayList<String>() { { add(resources.getString(R.string.activity_double_map)); - add(getString(R.string.activity_location_picker)); - add(getString(R.string.activity_car_driving)); } }; @@ -232,4 +225,4 @@ public class FeatureOverviewActivity extends AppCompatActivity { onFeaturesLoaded(features); } } -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AddRemoveMarkerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AddRemoveMarkerActivity.java index 6c56aa4a7a..abadc3e5d9 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AddRemoveMarkerActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AddRemoveMarkerActivity.java @@ -1,16 +1,10 @@ package com.mapbox.mapboxsdk.testapp.activity.annotation; import android.os.Bundle; -import android.support.v7.app.ActionBar; +import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; - -import timber.log.Timber; - -import android.view.MenuItem; import com.mapbox.mapboxsdk.annotations.Icon; -import com.mapbox.mapboxsdk.annotations.IconFactory; import com.mapbox.mapboxsdk.annotations.Marker; import com.mapbox.mapboxsdk.annotations.MarkerOptions; import com.mapbox.mapboxsdk.camera.CameraPosition; @@ -20,7 +14,13 @@ 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.IconUtils; +import timber.log.Timber; + +/** + * Test activity showcasing updating a Marker image when changing zoom levels + */ public class AddRemoveMarkerActivity extends AppCompatActivity { public static final double THRESHOLD = 5.0; @@ -40,24 +40,20 @@ public class AddRemoveMarkerActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_add_remove_marker); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); + // ShapeDrawable to Icon + final Icon shapeDrawableIcon = IconUtils.drawableToIcon(this, R.drawable.ic_circle, + ContextCompat.getColor(this, R.color.redAccent)); - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - - final Icon icon1 = IconFactory.getInstance(this).fromResource(R.drawable.ic_arsenal); - final Icon icon2 = IconFactory.getInstance(this).fromResource(R.drawable.ic_chelsea); + // VectorDrawable to Icon + final Icon vectorDrawableIcon = IconUtils.drawableToIcon(this, R.drawable.ic_layers, + ContextCompat.getColor(this, R.color.blueAccent)); lowThresholdMarker = new MarkerOptions() - .icon(icon1) + .icon(shapeDrawableIcon) .position(new LatLng(-0.1, 0)); highThresholdMarker = new MarkerOptions() - .icon(icon2) + .icon(vectorDrawableIcon) .position(new LatLng(0.1, 0)); mapView = (MapView) findViewById(R.id.mapView); @@ -170,14 +166,4 @@ public class AddRemoveMarkerActivity extends AppCompatActivity { super.onDestroy(); mapView.onDestroy(); } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - } - return super.onOptionsItemSelected(item); - } -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AnimatedMarkerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AnimatedMarkerActivity.java index 50e6c44b6e..52181cee0c 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AnimatedMarkerActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AnimatedMarkerActivity.java @@ -8,10 +8,9 @@ import android.animation.ValueAnimator; import android.os.Bundle; import android.support.annotation.DrawableRes; import android.support.annotation.NonNull; -import android.support.v7.app.ActionBar; +import android.support.v4.content.res.ResourcesCompat; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.MenuItem; +import android.view.View; import android.view.animation.AccelerateDecelerateInterpolator; import com.mapbox.mapboxsdk.annotations.Icon; @@ -27,11 +26,17 @@ 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.services.commons.models.Position; +import com.mapbox.mapboxsdk.testapp.utils.IconUtils; import com.mapbox.services.api.utils.turf.TurfMeasurement; +import com.mapbox.services.commons.models.Position; +import java.util.ArrayList; +import java.util.List; import java.util.Random; +/** + * Test activity showcasing animating MarkerViews. + */ public class AnimatedMarkerActivity extends AppCompatActivity { private MapView mapView; @@ -42,20 +47,16 @@ public class AnimatedMarkerActivity extends AppCompatActivity { private Marker passengerMarker = null; private MarkerView carMarker = null; + private Runnable animationRunnable; + + private List<MarkerView> markerViews = new ArrayList<>(); + private boolean stopped; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_animated_marker); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @@ -64,7 +65,8 @@ public class AnimatedMarkerActivity extends AppCompatActivity { public void onMapReady(@NonNull final MapboxMap mapboxMap) { AnimatedMarkerActivity.this.mapboxMap = mapboxMap; setupMap(); - mapView.post(new Runnable() { + + animationRunnable = new Runnable() { @Override public void run() { for (int i = 0; i < 10; i++) { @@ -73,7 +75,8 @@ public class AnimatedMarkerActivity extends AppCompatActivity { addPassenger(); addMainCar(); } - }); + }; + mapView.post(animationRunnable); } }); } @@ -87,11 +90,15 @@ public class AnimatedMarkerActivity extends AppCompatActivity { } private void addPassenger() { + if (isActivityStopped()) { + return; + } + LatLng randomLatLng = getLatLngInBounds(); if (passengerMarker == null) { - Icon icon = IconFactory.getInstance(AnimatedMarkerActivity.this) - .fromResource(R.drawable.ic_directions_run_black_24dp); + Icon icon = IconUtils.drawableToIcon(this, R.drawable.ic_directions_run_black, + ResourcesCompat.getColor(getResources(), R.color.blueAccent, getTheme())); passengerMarker = mapboxMap.addMarker(new MarkerViewOptions() .position(randomLatLng) .icon(icon)); @@ -101,6 +108,10 @@ public class AnimatedMarkerActivity extends AppCompatActivity { } private void addMainCar() { + if (isActivityStopped()) { + return; + } + LatLng randomLatLng = getLatLngInBounds(); if (carMarker == null) { @@ -113,13 +124,17 @@ public class AnimatedMarkerActivity extends AppCompatActivity { animateMoveToPassenger(carMarker); } }); - + markerViews.add(carMarker); } else { carMarker.setPosition(randomLatLng); } } private void animateMoveToPassenger(final MarkerView car) { + if (isActivityStopped()) { + return; + } + ValueAnimator animator = animateMoveMarker(car, passengerMarker.getPosition()); animator.addListener(new AnimatorListenerAdapter() { @Override @@ -131,18 +146,23 @@ public class AnimatedMarkerActivity extends AppCompatActivity { } protected void addRandomCar() { - createCarMarker(getLatLngInBounds(), R.drawable.ic_car_top, new MarkerViewManager.OnMarkerViewAddedListener() { - @Override - public void onViewAdded(@NonNull MarkerView markerView) { - randomlyMoveMarker(markerView); - } - }); + markerViews.add(createCarMarker(getLatLngInBounds(), R.drawable.ic_car_top, + new MarkerViewManager.OnMarkerViewAddedListener() { + @Override + public void onViewAdded(@NonNull MarkerView markerView) { + randomlyMoveMarker(markerView); + } + })); } private void randomlyMoveMarker(final MarkerView marker) { + if (isActivityStopped()) { + return; + } + ValueAnimator animator = animateMoveMarker(marker, getLatLngInBounds()); - //Add listener to restart animation on end + // Add listener to restart animation on end animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { @@ -170,12 +190,12 @@ public class AnimatedMarkerActivity extends AppCompatActivity { Icon icon = IconFactory.getInstance(AnimatedMarkerActivity.this) .fromResource(carResource); - //View Markers + // View Markers return mapboxMap.addMarker(new MarkerViewOptions() .position(start) .icon(icon), listener); - //GL Markers + // GL Markers // return mapboxMap.addMarker(new MarkerOptions() // .position(start) // .icon(icon)); @@ -193,17 +213,6 @@ public class AnimatedMarkerActivity extends AppCompatActivity { } @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - - @Override protected void onStart() { super.onStart(); mapView.onStart(); @@ -224,7 +233,21 @@ public class AnimatedMarkerActivity extends AppCompatActivity { @Override protected void onStop() { super.onStop(); + + stopped = true; + + // Stop ongoing animations, prevent memory lekas + MarkerViewManager markerViewManager = mapboxMap.getMarkerViewManager(); + for (MarkerView markerView : markerViews) { + View view = markerViewManager.getView(markerView); + if (view != null) { + view.animate().cancel(); + } + } + + // onStop mapView.onStop(); + mapView.removeCallbacks(animationRunnable); } @Override @@ -268,4 +291,8 @@ public class AnimatedMarkerActivity extends AppCompatActivity { Position.fromCoordinates(to.getLongitude(), to.getLatitude()) ); } + + private boolean isActivityStopped() { + return stopped; + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/BulkMarkerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/BulkMarkerActivity.java index 0d97289e56..8b238e49a8 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/BulkMarkerActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/BulkMarkerActivity.java @@ -3,19 +3,13 @@ package com.mapbox.mapboxsdk.testapp.activity.annotation; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.app.ProgressDialog; -import android.graphics.PorterDuff; -import android.graphics.drawable.Drawable; import android.os.AsyncTask; import android.os.Bundle; import android.support.annotation.NonNull; -import android.support.v4.content.ContextCompat; import android.support.v4.content.res.ResourcesCompat; -import android.support.v7.app.ActionBar; +import android.support.v4.view.MenuItemCompat; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; - -import timber.log.Timber; - +import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; @@ -25,7 +19,6 @@ import android.widget.TextView; import android.widget.Toast; import com.mapbox.mapboxsdk.annotations.Icon; -import com.mapbox.mapboxsdk.annotations.IconFactory; import com.mapbox.mapboxsdk.annotations.Marker; import com.mapbox.mapboxsdk.annotations.MarkerOptions; import com.mapbox.mapboxsdk.annotations.MarkerViewOptions; @@ -35,6 +28,7 @@ import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.testapp.R; import com.mapbox.mapboxsdk.testapp.utils.GeoParseUtil; +import com.mapbox.mapboxsdk.testapp.utils.IconUtils; import org.json.JSONException; @@ -42,8 +36,14 @@ import java.io.IOException; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.Random; +import timber.log.Timber; + +/** + * Test activity showcasing adding a large amount of Markers or MarkerViews. + */ public class BulkMarkerActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener { private MapboxMap mapboxMap; @@ -56,31 +56,12 @@ public class BulkMarkerActivity extends AppCompatActivity implements AdapterView super.onCreate(savedInstanceState); setContentView(R.layout.activity_marker_bulk); - 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); - } - mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(@NonNull MapboxMap mapboxMap) { BulkMarkerActivity.this.mapboxMap = mapboxMap; - - if (actionBar != null) { - ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource( - actionBar.getThemedContext(), R.array.bulk_marker_list, android.R.layout.simple_spinner_item); - spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - Spinner spinner = (Spinner) findViewById(R.id.spinner); - spinner.setAdapter(spinnerAdapter); - spinner.setOnItemSelectedListener(BulkMarkerActivity.this); - } } }); @@ -91,6 +72,19 @@ public class BulkMarkerActivity extends AppCompatActivity implements AdapterView } @Override + public boolean onCreateOptionsMenu(Menu menu) { + ArrayAdapter<CharSequence> spinnerAdapter = ArrayAdapter.createFromResource( + this, R.array.bulk_marker_list, android.R.layout.simple_spinner_item); + spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + getMenuInflater().inflate(R.menu.menu_bulk_marker, menu); + MenuItem item = menu.findItem(R.id.spinner); + Spinner spinner = (Spinner) MenuItemCompat.getActionView(item); + spinner.setAdapter(spinnerAdapter); + spinner.setOnItemSelectedListener(BulkMarkerActivity.this); + return true; + } + + @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { int amount = Integer.valueOf(getResources().getStringArray(R.array.bulk_marker_list)[position]); if (locations == null) { @@ -124,11 +118,8 @@ public class BulkMarkerActivity extends AppCompatActivity implements AdapterView Random random = new Random(); int randomIndex; - Drawable drawable = ContextCompat.getDrawable(BulkMarkerActivity.this, R.drawable.ic_droppin_24dp); - - int redColor = ResourcesCompat.getColor(getResources(), android.R.color.holo_red_dark, getTheme()); - drawable.setColorFilter(redColor, PorterDuff.Mode.SRC_IN); - Icon icon = IconFactory.getInstance(this).fromDrawable(drawable); + int color = ResourcesCompat.getColor(getResources(), R.color.redAccent, getTheme()); + Icon icon = IconUtils.drawableToIcon(this, R.drawable.ic_droppin, color); List<MarkerViewOptions> markerOptionsList = new ArrayList<>(); for (int i = 0; i < amount; i++) { @@ -209,18 +200,10 @@ public class BulkMarkerActivity extends AppCompatActivity implements AdapterView mapView.onLowMemory(); } - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - private class FabClickListener implements View.OnClickListener { + + private TextView viewCountView; + @Override public void onClick(final View view) { if (mapboxMap != null) { @@ -243,13 +226,15 @@ public class BulkMarkerActivity extends AppCompatActivity implements AdapterView showMarkers(amount); } + viewCountView = (TextView) findViewById(R.id.countView); + mapView.addOnMapChangedListener(new MapView.OnMapChangedListener() { @Override public void onMapChanged(@MapView.MapChange int change) { if (change == MapView.REGION_IS_CHANGING || change == MapView.REGION_DID_CHANGE) { if (!mapboxMap.getMarkerViewManager().getMarkerViewAdapters().isEmpty()) { - TextView viewCountView = (TextView) findViewById(R.id.countView); - viewCountView.setText("ViewCache size " + (mapView.getChildCount() - 5)); + viewCountView.setText(String.format(Locale.getDefault(), "ViewCache size %d", + mapboxMap.getMarkerViewManager().getMarkerViewContainer().getChildCount())); } } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/DynamicMarkerChangeActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/DynamicMarkerChangeActivity.java index 8446329e43..f7ffc61a7d 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/DynamicMarkerChangeActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/DynamicMarkerChangeActivity.java @@ -4,13 +4,10 @@ import android.os.Bundle; import android.support.annotation.NonNull; import android.support.design.widget.FloatingActionButton; import android.support.v4.content.ContextCompat; -import android.support.v7.app.ActionBar; +import android.support.v4.content.res.ResourcesCompat; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.MenuItem; import android.view.View; -import com.mapbox.mapboxsdk.annotations.IconFactory; import com.mapbox.mapboxsdk.annotations.Marker; import com.mapbox.mapboxsdk.annotations.MarkerOptions; import com.mapbox.mapboxsdk.geometry.LatLng; @@ -18,7 +15,11 @@ 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.IconUtils; +/** + * Test activity showcasing updating a Marker position, title, icon and snippet. + */ public class DynamicMarkerChangeActivity extends AppCompatActivity { private static final LatLng LAT_LNG_CHELSEA = new LatLng(51.481670, -0.190849); @@ -26,7 +27,6 @@ public class DynamicMarkerChangeActivity extends AppCompatActivity { private MapView mapView; private MapboxMap mapboxMap; - private IconFactory iconFactory; private Marker marker; @Override @@ -34,17 +34,6 @@ public class DynamicMarkerChangeActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_dynamic_marker); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - - iconFactory = IconFactory.getInstance(this); - mapView = (MapView) findViewById(R.id.mapView); mapView.setTag(false); mapView.onCreate(savedInstanceState); @@ -55,7 +44,8 @@ public class DynamicMarkerChangeActivity extends AppCompatActivity { // Create marker MarkerOptions markerOptions = new MarkerOptions() .position(LAT_LNG_CHELSEA) - .icon(iconFactory.fromResource(R.drawable.ic_chelsea)) + .icon(IconUtils.drawableToIcon(DynamicMarkerChangeActivity.this, R.drawable.ic_stars, + ResourcesCompat.getColor(getResources(), R.color.blueAccent, getTheme()))) .title(getString(R.string.dynamic_marker_chelsea_title)) .snippet(getString(R.string.dynamic_marker_chelsea_snippet)); marker = mapboxMap.addMarker(markerOptions); @@ -81,7 +71,11 @@ public class DynamicMarkerChangeActivity extends AppCompatActivity { // update marker marker.setPosition(first ? LAT_LNG_CHELSEA : LAT_LNG_ARSENAL); - marker.setIcon(iconFactory.fromResource(first ? R.drawable.ic_chelsea : R.drawable.ic_arsenal)); + marker.setIcon(IconUtils.drawableToIcon(this, R.drawable.ic_stars, first + ? ResourcesCompat.getColor(getResources(), R.color.blueAccent, getTheme()) : + ResourcesCompat.getColor(getResources(), R.color.redAccent, getTheme()) + )); + marker.setTitle(first ? getString(R.string.dynamic_marker_chelsea_title) : getString(R.string.dynamic_marker_arsenal_title)); marker.setSnippet(first @@ -129,15 +123,4 @@ public class DynamicMarkerChangeActivity extends AppCompatActivity { super.onLowMemory(); mapView.onLowMemory(); } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java index f1dc7f8c0d..f2f82865d1 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java @@ -3,17 +3,16 @@ package com.mapbox.mapboxsdk.testapp.activity.annotation; import android.animation.Animator; import android.animation.AnimatorInflater; import android.animation.AnimatorListenerAdapter; +import android.animation.FloatEvaluator; import android.animation.ObjectAnimator; +import android.animation.ValueAnimator; import android.content.Context; import android.os.Bundle; import android.os.Handler; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; import android.view.LayoutInflater; -import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; @@ -39,6 +38,13 @@ import com.mapbox.mapboxsdk.testapp.model.annotations.TextMarkerViewOptions; import java.util.Random; +/** + * Test activity showcasing multiple MarkerViews above Washington D.C. + * <p> + * Shows a couple of open InfoWindows out of current Viewport. + * Updates the rotation and location of a couple of MarkerViews. + * </p> + */ public class MarkerViewActivity extends AppCompatActivity { private static final LatLng[] LAT_LNGS = new LatLng[] { @@ -47,7 +53,7 @@ public class MarkerViewActivity extends AppCompatActivity { new LatLng(38.907227, -77.036530), new LatLng(38.905607, -77.031916), new LatLng(38.889441, -77.050134), - new LatLng(38.888000, -77.050000) //Slight overlap to show re-ordering on selection + new LatLng(38.888000, -77.050000) // Slight overlap to show re-ordering on selection }; private MapboxMap mapboxMap; @@ -71,15 +77,6 @@ public class MarkerViewActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_marker_view); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - final ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - final TextView viewCountView = (TextView) findViewById(R.id.countView); mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); @@ -110,7 +107,12 @@ public class MarkerViewActivity extends AppCompatActivity { options.title("Hello"); options.position(new LatLng(38.899774, -77.023237)); options.flat(true); - mapboxMap.addMarker(options); + MarkerView markerView = mapboxMap.addMarker(options); + + // Use object animator to rotate MarkerView + ValueAnimator markerAnimator = ObjectAnimator.ofObject(markerView, "rotation", new FloatEvaluator(), -90, 90); + markerAnimator.setDuration(5000); + markerAnimator.start(); MarkerViewActivity.this.mapboxMap.addMarker(new MarkerOptions() .title("United States") @@ -168,13 +170,13 @@ public class MarkerViewActivity extends AppCompatActivity { movingMarkerOne = MarkerViewActivity.this.mapboxMap.addMarker(new MarkerViewOptions() .position(CarLocation.CAR_0_LNGS[0]) .icon(IconFactory.getInstance(mapView.getContext()) - .fromResource(R.drawable.ic_chelsea)) + .fromResource(R.drawable.ic_android)) ); movingMarkerTwo = mapboxMap.addMarker(new MarkerViewOptions() .position(CarLocation.CAR_1_LNGS[0]) .icon(IconFactory.getInstance(mapView.getContext()) - .fromResource(R.drawable.ic_arsenal)) + .fromResource(R.drawable.ic_android_2)) ); // allow more open infowindows at the same time @@ -458,17 +460,6 @@ public class MarkerViewActivity extends AppCompatActivity { mapView.onLowMemory(); } - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - private static class CarLocation { static LatLng[] CAR_0_LNGS = new LatLng[] { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewScaleActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewScaleActivity.java deleted file mode 100644 index 53e352c2e6..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewScaleActivity.java +++ /dev/null @@ -1,179 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.activity.annotation; - -import android.os.Bundle; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.MenuItem; -import android.view.View; -import android.widget.SeekBar; -import android.widget.TextView; -import android.widget.Toast; - -import com.mapbox.mapboxsdk.annotations.Icon; -import com.mapbox.mapboxsdk.annotations.IconFactory; -import com.mapbox.mapboxsdk.annotations.MarkerView; -import com.mapbox.mapboxsdk.annotations.MarkerViewManager; -import com.mapbox.mapboxsdk.annotations.MarkerViewOptions; -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 java.util.Locale; - -public class MarkerViewScaleActivity extends AppCompatActivity implements OnMapReadyCallback { - - private MapboxMap mapboxMap; - private MapView mapView; - - private MarkerView markerView; - private MarkerViewManager markerViewManager; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_marker_view_scale); - - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - final ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - - mapView = (MapView) findViewById(R.id.mapView); - mapView.onCreate(savedInstanceState); - mapView.getMapAsync(this); - } - - @Override - public void onMapReady(MapboxMap map) { - mapboxMap = map; - markerViewManager = map.getMarkerViewManager(); - - final SeekBar xBar = (SeekBar) findViewById(R.id.seekbar_factor); - final TextView textView = (TextView) findViewById(R.id.textview_factor); - - // We need to listen to a render event to be sure - // the View of the Marker has been added to the map - mapView.addOnMapChangedListener(new MapView.OnMapChangedListener() { - @Override - public void onMapChanged(@MapView.MapChange int change) { - if (isMarkerRendered()) { - Toast.makeText(MarkerViewScaleActivity.this, "MarkerView is ready", Toast.LENGTH_SHORT).show(); - View view = markerViewManager.getView(markerView); - xBar.setOnSeekBarChangeListener(new FactorChangeListener(view, textView)); - xBar.setClickable(true); - mapView.removeOnMapChangedListener(this); - } - } - - private boolean isMarkerRendered() { - return markerView != null && markerViewManager.getView(markerView) != null; - } - }); - - Icon icon = IconFactory.getInstance(MarkerViewScaleActivity.this) - .fromResource(R.drawable.ic_circle); - - markerView = mapboxMap.addMarker(new MarkerViewOptions() - .position(new LatLng(38.907192, -77.036871)) - .icon(icon) - .flat(true)); - } - - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - - @Override - public void onResume() { - super.onResume(); - mapView.onResume(); - } - - @Override - public void onStart() { - super.onResume(); - mapView.onStart(); - } - - @Override - public void onStop() { - super.onStop(); - mapView.onStop(); - } - - @Override - public void onPause() { - super.onPause(); - mapView.onPause(); - } - - @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(); - } - - private static class FactorChangeListener implements SeekBar.OnSeekBarChangeListener { - - private TextView textView; - private View view; - - FactorChangeListener(View view, TextView textView) { - this.view = view; - this.textView = textView; - } - - @Override - public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { - float newScale = getScale(progress); - textView.setText(String.format(Locale.US, "Scale: %.1f", newScale)); - if (view != null) { - view.setScaleX(newScale); - view.setScaleY(newScale); - } - } - - @Override - public void onStartTrackingTouch(SeekBar seekBar) { - // Not used - } - - @Override - public void onStopTrackingTouch(SeekBar seekBar) { - // Not used - } - - private float getScale(int progress) { - float scale = 1.0f * progress / 25; - return scale < 1.0 ? 1.0f : scale; - } - } - -}
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewsInRectangleActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewsInRectangleActivity.java index 99a0465092..266db3fdd1 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewsInRectangleActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewsInRectangleActivity.java @@ -2,10 +2,7 @@ package com.mapbox.mapboxsdk.testapp.activity.annotation; import android.graphics.RectF; import android.os.Bundle; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.MenuItem; import android.view.View; import android.widget.Toast; @@ -33,11 +30,10 @@ public class MarkerViewsInRectangleActivity extends AppCompatActivity implements protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_marker_view_in_rect); - setupActionBar(); selectionBox = findViewById(R.id.selection_box); - //Initialize map as normal + // Initialize map as normal mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(this); @@ -53,14 +49,14 @@ public class MarkerViewsInRectangleActivity extends AppCompatActivity implements @Override public void onClick(View view) { - //Query + // Query int top = selectionBox.getTop() - mapView.getTop(); int left = selectionBox.getLeft() - mapView.getLeft(); RectF box = new RectF(left, top, left + selectionBox.getWidth(), top + selectionBox.getHeight()); Timber.i(String.format("Querying box %s", box)); List<MarkerView> markers = mapboxMap.getMarkerViewsInRect(box); - //Show count + // Show count Toast.makeText( MarkerViewsInRectangleActivity.this, String.format("%s markers inside box", markers.size()), @@ -108,26 +104,4 @@ public class MarkerViewsInRectangleActivity extends AppCompatActivity implements super.onLowMemory(); mapView.onLowMemory(); } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - - private void setupActionBar() { - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - final ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolygonActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolygonActivity.java index 16efa9f190..a2245a28e0 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolygonActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolygonActivity.java @@ -5,7 +5,6 @@ import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.Menu; import android.view.MenuItem; -import android.view.ViewGroup; import com.mapbox.mapboxsdk.annotations.Polygon; import com.mapbox.mapboxsdk.annotations.PolygonOptions; @@ -17,7 +16,6 @@ import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.MapboxMapOptions; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.testapp.utils.ToolbarComposer; import java.util.ArrayList; import java.util.List; @@ -31,9 +29,9 @@ import static com.mapbox.mapboxsdk.testapp.activity.annotation.PolygonActivity.C import static com.mapbox.mapboxsdk.testapp.activity.annotation.PolygonActivity.Config.STAR_SHAPE_POINTS; /** - * Activity to test the Polygon annotation API & programmatically creating a MapView. + * Test activity to showcase the Polygon annotation API & programmatically creating a MapView. * <p> - * Showcases changing Polygon features as visibility, alpha, color and points. + * Shows how to change Polygon features as visibility, alpha, color and points. * </p> */ public class PolygonActivity extends AppCompatActivity implements OnMapReadyCallback { @@ -50,8 +48,6 @@ public class PolygonActivity extends AppCompatActivity implements OnMapReadyCall @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_polygon); - ToolbarComposer.initDefaultUpToolbar(this, R.id.toolbar); // configure inital map state MapboxMapOptions options = new MapboxMapOptions() @@ -72,11 +68,7 @@ public class PolygonActivity extends AppCompatActivity implements OnMapReadyCall mapView.onCreate(savedInstanceState); mapView.getMapAsync(this); - // add to layout - ViewGroup container = (ViewGroup) findViewById(R.id.container); - if (container != null) { - container.addView(mapView); - } + setContentView(mapView); } @Override @@ -132,25 +124,18 @@ public class PolygonActivity extends AppCompatActivity implements OnMapReadyCall @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - case R.id.action_id_alpha: fullAlpha = !fullAlpha; polygon.setAlpha(fullAlpha ? FULL_ALPHA : PARTIAL_ALPHA); return true; - case R.id.action_id_visible: visible = !visible; polygon.setAlpha(visible ? (fullAlpha ? FULL_ALPHA : PARTIAL_ALPHA) : NO_ALPHA); return true; - case R.id.action_id_points: allPoints = !allPoints; polygon.setPoints(allPoints ? STAR_SHAPE_POINTS : BROKEN_SHAPE_POINTS); return true; - case R.id.action_id_color: color = !color; polygon.setFillColor(color ? BLUE_COLOR : RED_COLOR); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolylineActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolylineActivity.java index 44f11ca674..0aaa6127f4 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolylineActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PolylineActivity.java @@ -3,12 +3,11 @@ package com.mapbox.mapboxsdk.testapp.activity.annotation; import android.graphics.Color; 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.Toast; import com.mapbox.mapboxsdk.annotations.Polyline; import com.mapbox.mapboxsdk.annotations.PolylineOptions; @@ -22,6 +21,12 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +/** + * Test activity showcasing the Polyline annotations API. + * <p> + * Shows how to add and remove polylines. + * </p> + */ public class PolylineActivity extends AppCompatActivity { private static final String STATE_POLYLINE_OPTIONS = "polylineOptions"; @@ -52,15 +57,6 @@ public class PolylineActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_polyline); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - if (savedInstanceState != null) { polylineOptions = savedInstanceState.getParcelableArrayList(STATE_POLYLINE_OPTIONS); } else { @@ -182,11 +178,16 @@ public class PolylineActivity extends AppCompatActivity { @Override public boolean onOptionsItemSelected(MenuItem item) { + if (polylines.size() <= 0) { + Toast.makeText(PolylineActivity.this, "No polylines on map", Toast.LENGTH_LONG).show(); + return super.onOptionsItemSelected(item); + } switch (item.getItemId()) { case R.id.action_id_remove: // test to remove all annotations polylineOptions.clear(); mapboxMap.clear(); + polylines.clear(); return true; case R.id.action_id_alpha: @@ -216,11 +217,6 @@ public class PolylineActivity extends AppCompatActivity { p.setAlpha(visible ? (fullAlpha ? FULL_ALPHA : PARTIAL_ALPHA) : NO_ALPHA); } return true; - - case android.R.id.home: - onBackPressed(); - return true; - default: return super.onOptionsItemSelected(item); } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PressForMarkerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PressForMarkerActivity.java index 4b23060eec..7cfe35f160 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PressForMarkerActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/PressForMarkerActivity.java @@ -4,9 +4,7 @@ import android.graphics.PointF; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -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; @@ -20,6 +18,12 @@ import com.mapbox.mapboxsdk.testapp.R; import java.text.DecimalFormat; import java.util.ArrayList; +/** + * Test activity showcasing to add a Marker on click. + * <p> + * Shows how to use a OnMapClickListener and a OnMapLongClickListener + * </p> + */ public class PressForMarkerActivity extends AppCompatActivity { private MapView mapView; @@ -35,15 +39,6 @@ public class PressForMarkerActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_press_for_marker); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @@ -55,19 +50,14 @@ public class PressForMarkerActivity extends AppCompatActivity { mapboxMap.setOnMapLongClickListener(new MapboxMap.OnMapLongClickListener() { @Override public void onMapLongClick(@NonNull LatLng point) { - final PointF pixel = mapboxMap.getProjection().toScreenLocation(point); - - String title = LAT_LON_FORMATTER.format(point.getLatitude()) + ", " - + LAT_LON_FORMATTER.format(point.getLongitude()); - String snippet = "X = " + (int) pixel.x + ", Y = " + (int) pixel.y; - - MarkerOptions marker = new MarkerOptions() - .position(point) - .title(title) - .snippet(snippet); + addMarker(point); + } + }); - markerList.add(marker); - mapboxMap.addMarker(marker); + mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() { + @Override + public void onMapClick(@NonNull LatLng point) { + addMarker(point); } }); @@ -79,6 +69,22 @@ public class PressForMarkerActivity extends AppCompatActivity { }); } + private void addMarker(LatLng point) { + final PointF pixel = mapboxMap.getProjection().toScreenLocation(point); + + String title = LAT_LON_FORMATTER.format(point.getLatitude()) + ", " + + LAT_LON_FORMATTER.format(point.getLongitude()); + String snippet = "X = " + (int) pixel.x + ", Y = " + (int) pixel.y; + + MarkerOptions marker = new MarkerOptions() + .position(point) + .title(title) + .snippet(snippet); + + markerList.add(marker); + mapboxMap.addMarker(marker); + } + private void resetMap() { if (mapboxMap == null) { return; @@ -139,9 +145,6 @@ public class PressForMarkerActivity extends AppCompatActivity { @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; case R.id.menuItemReset: resetMap(); return true; diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraAnimationTypeActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraAnimationTypeActivity.java index 3d771613d4..030785565e 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraAnimationTypeActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraAnimationTypeActivity.java @@ -1,10 +1,7 @@ package com.mapbox.mapboxsdk.testapp.activity.camera; import android.os.Bundle; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.MenuItem; import android.view.View; import android.widget.Toast; @@ -18,6 +15,12 @@ import com.mapbox.mapboxsdk.testapp.R; import timber.log.Timber; +/** + * Test activity showcasing the Camera API and listen to camera updates by animating the camera above London. + * <p> + * Shows how to use animate, ease and move camera update factory methods. + * </p> + */ public class CameraAnimationTypeActivity extends AppCompatActivity implements OnMapReadyCallback { private static final LatLng LAT_LNG_LONDON_EYE = new LatLng(51.50325, -0.11968); @@ -32,15 +35,6 @@ public class CameraAnimationTypeActivity extends AppCompatActivity implements On super.onCreate(savedInstanceState); setContentView(R.layout.activity_camera_animation_types); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - mapView = (MapView) findViewById(R.id.mapView); if (mapView != null) { mapView.onCreate(savedInstanceState); @@ -199,15 +193,4 @@ public class CameraAnimationTypeActivity extends AppCompatActivity implements On super.onLowMemory(); mapView.onLowMemory(); } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java index 193b59a9db..08399f3b3e 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java @@ -7,15 +7,9 @@ import android.support.annotation.IdRes; import android.support.annotation.NonNull; import android.support.design.widget.FloatingActionButton; import android.support.v4.content.ContextCompat; -import android.support.v7.app.ActionBar; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; - -import timber.log.Timber; - import android.view.LayoutInflater; -import android.view.MenuItem; import android.view.View; import android.widget.SeekBar; import android.widget.TextView; @@ -28,6 +22,8 @@ import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.testapp.R; +import timber.log.Timber; + public class CameraPositionActivity extends AppCompatActivity implements OnMapReadyCallback { private MapView mapView; @@ -38,15 +34,6 @@ public class CameraPositionActivity extends AppCompatActivity implements OnMapRe super.onCreate(savedInstanceState); setContentView(R.layout.activity_camera_position); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(this); @@ -154,17 +141,6 @@ public class CameraPositionActivity extends AppCompatActivity implements OnMapRe mapView.onSaveInstanceState(outState); } - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - private View onInflateDialogContent(View view) { linkTextView(view, R.id.value_lat, R.id.seekbar_lat, new LatLngChangeListener(), 180 + 38); linkTextView(view, R.id.value_lon, R.id.seekbar_lon, new LatLngChangeListener(), 180 - 77); @@ -214,4 +190,4 @@ public class CameraPositionActivity extends AppCompatActivity implements OnMapRe super.onProgressChanged(seekBar, progress - 180, fromUser); } } -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java index 3dd6a6344d..5c33f3f168 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/LatLngBoundsActivity.java @@ -1,13 +1,7 @@ package com.mapbox.mapboxsdk.testapp.activity.camera; import android.os.Bundle; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; - -import timber.log.Timber; - -import android.view.MenuItem; import com.mapbox.mapboxsdk.annotations.MarkerOptions; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; @@ -23,6 +17,15 @@ import com.mapbox.mapboxsdk.testapp.R; import java.util.ArrayList; import java.util.List; +import timber.log.Timber; + +/** + * Test activity showcasing using the LatLngBounds camera API. + * <p> + * This activity opens the map at zoom level 0 and animates into a bounds set by Los Angeles and New York + * with some additional padding and an animation duration of 1500 ms. + * </p> + */ public class LatLngBoundsActivity extends AppCompatActivity implements OnMapReadyCallback { private static final LatLng LOS_ANGELES = new LatLng(34.053940, -118.242622); @@ -36,15 +39,6 @@ public class LatLngBoundsActivity extends AppCompatActivity implements OnMapRead super.onCreate(savedInstanceState); setContentView(R.layout.activity_visible_bounds); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - mapView = (MapView) findViewById(R.id.mapView); mapView.setStyleUrl(Style.DARK); mapView.onCreate(savedInstanceState); @@ -82,7 +76,7 @@ public class LatLngBoundsActivity extends AppCompatActivity implements OnMapRead // Move camera to the bounds with added padding int padding = (int) getResources().getDimension(R.dimen.coordinatebounds_margin); - mapboxMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, padding)); + mapboxMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, padding), 1500); // Log data Timber.e("Move to bounds: " + bounds.toString()); @@ -130,15 +124,4 @@ public class LatLngBoundsActivity extends AppCompatActivity implements OnMapRead super.onLowMemory(); mapView.onLowMemory(); } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ManualZoomActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ManualZoomActivity.java index 4bc30157f8..b999572436 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ManualZoomActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ManualZoomActivity.java @@ -3,9 +3,7 @@ package com.mapbox.mapboxsdk.testapp.activity.camera; import android.graphics.Point; 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; @@ -18,6 +16,12 @@ import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.maps.UiSettings; import com.mapbox.mapboxsdk.testapp.R; +/** + * Test activity showcasing the zoom Camera API. + * <p> + * This includes zoomIn, zoomOut, zoomTo, zoomBy (center and custom focal point). + * </p> + */ public class ManualZoomActivity extends AppCompatActivity { private MapboxMap mapboxMap; @@ -28,15 +32,6 @@ public class ManualZoomActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_manual_zoom); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - mapView = (MapView) findViewById(R.id.mapView); mapView.setStyleUrl(Style.SATELLITE); mapView.onCreate(savedInstanceState); @@ -61,10 +56,6 @@ public class ManualZoomActivity extends AppCompatActivity { public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - case R.id.action_zoom_in: mapboxMap.animateCamera(CameraUpdateFactory.zoomIn()); return true; diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/MaxMinZoomActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/MaxMinZoomActivity.java index 71e8cc0a08..86d5b47275 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/MaxMinZoomActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/MaxMinZoomActivity.java @@ -1,10 +1,7 @@ package com.mapbox.mapboxsdk.testapp.activity.camera; import android.os.Bundle; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.MenuItem; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; @@ -22,15 +19,6 @@ public class MaxMinZoomActivity extends AppCompatActivity implements OnMapReadyC super.onCreate(savedInstanceState); setContentView(R.layout.activity_maxmin_zoom); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(this); @@ -44,16 +32,6 @@ public class MaxMinZoomActivity extends AppCompatActivity implements OnMapReadyC } @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - } - return false; - } - - @Override protected void onStart() { super.onStart(); mapView.onStart(); @@ -94,5 +72,4 @@ public class MaxMinZoomActivity extends AppCompatActivity implements OnMapReadyC super.onLowMemory(); mapView.onLowMemory(); } - -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ScrollByActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ScrollByActivity.java index 2f16e862ee..2e889f6e11 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ScrollByActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/ScrollByActivity.java @@ -20,6 +20,9 @@ import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.maps.UiSettings; import com.mapbox.mapboxsdk.testapp.R; +/** + * Test activity showcasing using the scrollBy Camera API by moving x,y pixels above Grenada, Spain. + */ public class ScrollByActivity extends AppCompatActivity implements OnMapReadyCallback { public static final int MULTIPLIER_PER_PIXEL = 50; @@ -157,4 +160,4 @@ public class ScrollByActivity extends AppCompatActivity implements OnMapReadyCal } } -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java index 8e4b58366f..dde22db2db 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java @@ -3,12 +3,7 @@ package com.mapbox.mapboxsdk.testapp.activity.customlayer; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.v4.content.ContextCompat; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; - -import timber.log.Timber; - import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -19,10 +14,15 @@ import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.style.layers.CustomLayer; -import com.mapbox.mapboxsdk.style.layers.NoSuchLayerException; import com.mapbox.mapboxsdk.testapp.R; import com.mapbox.mapboxsdk.testapp.model.customlayer.ExampleCustomLayer; +/** + * Test activity showcasing the Custom Layer API + * <p> + * Note: experimental API, do not use. + * </p> + */ public class CustomLayerActivity extends AppCompatActivity { private MapboxMap mapboxMap; @@ -36,8 +36,6 @@ public class CustomLayerActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_custom_layer); - setupActionBar(); - mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @@ -63,21 +61,17 @@ public class CustomLayerActivity extends AppCompatActivity { private void swapCustomLayer() { if (customLayer != null) { - try { - mapboxMap.removeLayer(customLayer.getId()); - customLayer = null; - } catch (NoSuchLayerException noSuchLayerException) { - Timber.e("No custom layer to remove"); - } - fab.setImageResource(R.drawable.ic_layers_24dp); + mapboxMap.removeLayer(customLayer); + customLayer = null; + fab.setImageResource(R.drawable.ic_layers); } else { customLayer = new CustomLayer("custom", ExampleCustomLayer.createContext(), ExampleCustomLayer.InitializeFunction, ExampleCustomLayer.RenderFunction, ExampleCustomLayer.DeinitializeFunction); - mapboxMap.addLayer(customLayer, "building"); - fab.setImageResource(R.drawable.ic_layers_clear_24dp); + mapboxMap.addLayerBelow(customLayer, "building"); + fab.setImageResource(R.drawable.ic_layers_clear); } } @@ -138,9 +132,6 @@ public class CustomLayerActivity extends AppCompatActivity { @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; case R.id.action_update_layer: updateLayer(); return true; @@ -157,15 +148,4 @@ public class CustomLayerActivity extends AppCompatActivity { return super.onOptionsItemSelected(item); } } - - private void setupActionBar() { - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - final ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/directions/DirectionsActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/directions/DirectionsActivity.java deleted file mode 100644 index 13e384a8b5..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/directions/DirectionsActivity.java +++ /dev/null @@ -1,213 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.activity.directions; - -import android.graphics.Color; -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 timber.log.Timber; - -import android.view.MenuItem; - -import com.mapbox.mapboxsdk.annotations.MarkerOptions; -import com.mapbox.mapboxsdk.annotations.PolylineOptions; -import com.mapbox.mapboxsdk.camera.CameraPosition; -import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; -import com.mapbox.mapboxsdk.geometry.LatLng; -import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.mapboxsdk.maps.MapView; -import com.mapbox.services.Constants; -import com.mapbox.services.api.ServicesException; -import com.mapbox.services.commons.geojson.LineString; -import com.mapbox.services.commons.models.Position; -import com.mapbox.services.api.directions.v5.DirectionsCriteria; -import com.mapbox.services.api.directions.v5.MapboxDirections; -import com.mapbox.services.api.directions.v5.models.DirectionsResponse; -import com.mapbox.services.api.directions.v5.models.DirectionsRoute; - -import java.util.ArrayList; -import java.util.List; - -import retrofit2.Call; -import retrofit2.Callback; -import retrofit2.Response; - -public class DirectionsActivity extends AppCompatActivity { - - private MapView mapView; - private MapboxMap mapboxMap; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_directions); - - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - - mapView = (MapView) findViewById(R.id.mapView); - mapView.onCreate(savedInstanceState); - mapView.getMapAsync(new OnMapReadyCallback() { - @Override - public void onMapReady(@NonNull MapboxMap mapboxMap) { - DirectionsActivity.this.mapboxMap = mapboxMap; - loadRoute(); - } - }); - } - - private void loadRoute() { - // Dupont Circle (Washington, DC) - Position origin = Position.fromCoordinates(-77.04341, 38.90962); - - // The White House (Washington, DC) - Position destination = Position.fromCoordinates(-77.0365, 38.8977); - - // Set map at centroid - LatLng centroid = new LatLng( - (origin.getLatitude() + destination.getLatitude()) / 2, - (origin.getLongitude() + destination.getLongitude()) / 2); - - mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition.Builder() - .target(centroid) - .zoom(14) - .build())); - - // Add origin and destination to the map - mapboxMap.addMarker(new MarkerOptions() - .position(new LatLng(origin.getLatitude(), origin.getLongitude())) - .title("Origin") - .snippet("Dupont Circle")); - mapboxMap.addMarker(new MarkerOptions() - .position(new LatLng(destination.getLatitude(), destination.getLongitude())) - .title("Destination") - .snippet("The White House")); - - // Get route from API - getRoute(origin, destination); - } - - private void getRoute(Position origin, Position destination) { - try { - MapboxDirections md = new MapboxDirections.Builder() - .setAccessToken(getString(R.string.mapbox_access_token)) - .setOrigin(origin) - .setOverview(DirectionsCriteria.OVERVIEW_FULL) - .setDestination(destination) - .setProfile(DirectionsCriteria.PROFILE_WALKING) - .build(); - - md.enqueueCall(new Callback<DirectionsResponse>() { - - @Override - public void onFailure(Call<DirectionsResponse> call, Throwable throwable) { - Timber.e("Error: " + throwable.getMessage()); - } - - @Override - public void onResponse(Call<DirectionsResponse> call, Response<DirectionsResponse> response) { - // You can get generic HTTP info about the response - Timber.d("Response code: " + response.code()); - - // Print some info about the route - DirectionsRoute currentRoute = response.body().getRoutes().get(0); - Timber.d("Distance: " + currentRoute.getDistance()); - - // Draw the route on the map - drawRoute(currentRoute); - } - - }); - } catch (ServicesException servicesException) { - Timber.e("Error displaying route: " + servicesException.toString()); - servicesException.printStackTrace(); - } - } - - private void drawRoute(DirectionsRoute route) { - - PolylineOptions builder = new PolylineOptions(); - builder.color(Color.parseColor("#3887be")); - builder.alpha(0.5f); - builder.width(5); - builder.width(5); - - LineString lineString = LineString.fromPolyline(route.getGeometry(), Constants.OSRM_PRECISION_V5); - List<Position> coordinates = lineString.getCoordinates(); - List<LatLng> points = new ArrayList<>(); - for (int i = 0; i < coordinates.size(); i++) { - points.add(new LatLng( - coordinates.get(i).getLatitude(), - coordinates.get(i).getLongitude())); - } - - builder.addAll(points); - - // Draw Points on MapView - mapboxMap.addPolyline(builder); - } - - @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(); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/EspressoTestActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/EspressoTestActivity.java index 677e09e719..ee9f20dceb 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/EspressoTestActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/espresso/EspressoTestActivity.java @@ -9,7 +9,7 @@ import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.testapp.R; /** - * Base activity for instrumentation testing + * Base activity for instrumentation testing. */ public class EspressoTestActivity extends AppCompatActivity implements OnMapReadyCallback { @@ -21,7 +21,7 @@ public class EspressoTestActivity extends AppCompatActivity implements OnMapRead super.onCreate(savedInstanceState); setContentView(R.layout.activity_camera_test); - //Initialize map as normal + // Initialize map as normal mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(this); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxCountActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxCountActivity.java index 00cc8dfac7..9c031ad32a 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxCountActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxCountActivity.java @@ -2,10 +2,7 @@ package com.mapbox.mapboxsdk.testapp.activity.feature; import android.graphics.RectF; import android.os.Bundle; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.MenuItem; import android.view.View; import android.widget.Toast; @@ -22,7 +19,7 @@ import java.util.Map; import timber.log.Timber; /** - * Demo's query rendered features + * Test activity showcasing using the query rendered features API to count features in a rectangle. */ public class QueryRenderedFeaturesBoxCountActivity extends AppCompatActivity { @@ -33,11 +30,10 @@ public class QueryRenderedFeaturesBoxCountActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_query_features_box); - setupActionBar(); final View selectionBox = findViewById(R.id.selection_box); - //Initialize map as normal + // Initialize map as normal mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @@ -48,20 +44,20 @@ public class QueryRenderedFeaturesBoxCountActivity extends AppCompatActivity { selectionBox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - //Query + // Query int top = selectionBox.getTop() - mapView.getTop(); int left = selectionBox.getLeft() - mapView.getLeft(); RectF box = new RectF(left, top, left + selectionBox.getWidth(), top + selectionBox.getHeight()); Timber.i(String.format("Querying box %s", box)); List<Feature> features = mapboxMap.queryRenderedFeatures(box); - //Show count + // Show count Toast.makeText( QueryRenderedFeaturesBoxCountActivity.this, String.format("%s features in box", features.size()), Toast.LENGTH_SHORT).show(); - //Debug output + // Debug output debugOutput(features); } }); @@ -135,27 +131,4 @@ public class QueryRenderedFeaturesBoxCountActivity extends AppCompatActivity { super.onLowMemory(); mapView.onLowMemory(); } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - - private void setupActionBar() { - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - final ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - } - } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxHighlightActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxHighlightActivity.java index 8c4a499f9b..ca4fe4e4fd 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxHighlightActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxHighlightActivity.java @@ -3,10 +3,7 @@ package com.mapbox.mapboxsdk.testapp.activity.feature; import android.graphics.Color; import android.graphics.RectF; import android.os.Bundle; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.MenuItem; import android.view.View; import android.widget.Toast; @@ -37,11 +34,10 @@ public class QueryRenderedFeaturesBoxHighlightActivity extends AppCompatActivity protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_query_features_box); - setupActionBar(); final View selectionBox = findViewById(R.id.selection_box); - //Initialize map as normal + // Initialize map as normal mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @@ -52,28 +48,24 @@ public class QueryRenderedFeaturesBoxHighlightActivity extends AppCompatActivity selectionBox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - //Query + // Query int top = selectionBox.getTop() - mapView.getTop(); int left = selectionBox.getLeft() - mapView.getLeft(); RectF box = new RectF(left, top, left + selectionBox.getWidth(), top + selectionBox.getHeight()); Timber.i(String.format("Querying box %s for buildings", box)); List<Feature> features = mapboxMap.queryRenderedFeatures(box, "building"); - //Show count + // Show count Toast.makeText( QueryRenderedFeaturesBoxHighlightActivity.this, String.format("%s features in box", features.size()), Toast.LENGTH_SHORT).show(); - //remove layer / source if already added - try { - mapboxMap.removeSource("highlighted-shapes-source"); - mapboxMap.removeLayer("highlighted-shapes-layer"); - } catch (Exception exception) { - //that's ok - } + // remove layer / source if already added + mapboxMap.removeSource("highlighted-shapes-source"); + mapboxMap.removeLayer("highlighted-shapes-layer"); - //Add layer / source + // Add layer / source mapboxMap.addSource( new GeoJsonSource("highlighted-shapes-source", FeatureCollection.fromFeatures(features)) @@ -84,7 +76,6 @@ public class QueryRenderedFeaturesBoxHighlightActivity extends AppCompatActivity }); } }); - } public MapboxMap getMapboxMap() { @@ -132,27 +123,4 @@ public class QueryRenderedFeaturesBoxHighlightActivity extends AppCompatActivity super.onLowMemory(); mapView.onLowMemory(); } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - - private void setupActionBar() { - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - final ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - } - } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxSymbolCountActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxSymbolCountActivity.java index 4b7bbb9614..8c2f3a8fb5 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxSymbolCountActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxSymbolCountActivity.java @@ -4,10 +4,7 @@ import android.graphics.BitmapFactory; import android.graphics.RectF; import android.os.Bundle; import android.support.annotation.RawRes; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.MenuItem; import android.view.View; import android.widget.Toast; @@ -33,7 +30,7 @@ import timber.log.Timber; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage; /** - * Demo's query rendered features on Symbols + * Test activity showcasing using the query rendered features API to count Symbols in a rectangle. */ public class QueryRenderedFeaturesBoxSymbolCountActivity extends AppCompatActivity { @@ -46,11 +43,10 @@ public class QueryRenderedFeaturesBoxSymbolCountActivity extends AppCompatActivi protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_query_features_box); - setupActionBar(); final View selectionBox = findViewById(R.id.selection_box); - //Initialize map as normal + // Initialize map as normal mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @@ -59,7 +55,7 @@ public class QueryRenderedFeaturesBoxSymbolCountActivity extends AppCompatActivi public void onMapReady(final MapboxMap mapboxMap) { QueryRenderedFeaturesBoxSymbolCountActivity.this.mapboxMap = mapboxMap; - //Add a symbol layer (also works with annotations) + // Add a symbol layer (also works with annotations) try { mapboxMap.addSource(new GeoJsonSource("symbols-source", readRawResource(R.raw.test_points_utrecht))); } catch (IOException ioException) { @@ -76,14 +72,14 @@ public class QueryRenderedFeaturesBoxSymbolCountActivity extends AppCompatActivi selectionBox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - //Query + // Query int top = selectionBox.getTop() - mapView.getTop(); int left = selectionBox.getLeft() - mapView.getLeft(); RectF box = new RectF(left, top, left + selectionBox.getWidth(), top + selectionBox.getHeight()); Timber.i(String.format("Querying box %s", box)); List<Feature> features = mapboxMap.queryRenderedFeatures(box, "symbols-layer"); - //Show count + // Show count if (toast != null) { toast.cancel(); } @@ -160,27 +156,4 @@ public class QueryRenderedFeaturesBoxSymbolCountActivity extends AppCompatActivi super.onLowMemory(); mapView.onLowMemory(); } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - - private void setupActionBar() { - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - final ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - } - } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesPropertiesActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesPropertiesActivity.java index 17dfbc18b4..8b83db3069 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesPropertiesActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesPropertiesActivity.java @@ -6,13 +6,7 @@ import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.support.annotation.NonNull; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; - -import timber.log.Timber; - -import android.view.MenuItem; import android.view.View; import android.widget.LinearLayout; import android.widget.TextView; @@ -30,8 +24,10 @@ import com.mapbox.services.commons.geojson.Feature; import java.util.List; import java.util.Map; +import timber.log.Timber; + /** - * Demo's query rendered features + * Test activity showcasing using the query rendered features API to query feature properties on Map click. */ public class QueryRenderedFeaturesPropertiesActivity extends AppCompatActivity { @@ -43,11 +39,10 @@ public class QueryRenderedFeaturesPropertiesActivity extends AppCompatActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_query_features_point); - setupActionBar(); final float density = getResources().getDisplayMetrics().density; - //Initialize map as normal + // Initialize map as normal mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @@ -55,14 +50,14 @@ public class QueryRenderedFeaturesPropertiesActivity extends AppCompatActivity { public void onMapReady(final MapboxMap mapboxMap) { QueryRenderedFeaturesPropertiesActivity.this.mapboxMap = mapboxMap; - //Add custom window adapter + // Add custom window adapter addCustomInfoWindowAdapter(mapboxMap); - //Add a click listener + // Add a click listener mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() { @Override public void onMapClick(@NonNull LatLng point) { - //Query + // Query final PointF pixel = mapboxMap.getProjection().toScreenLocation(point); Timber.i(String.format( "Requesting features for %sx%s (%sx%s adjusted for density)", @@ -70,15 +65,15 @@ public class QueryRenderedFeaturesPropertiesActivity extends AppCompatActivity { ); List<Feature> features = mapboxMap.queryRenderedFeatures(pixel); - //Debug output + // Debug output debugOutput(features); - //Remove any previous markers + // Remove any previous markers if (marker != null) { mapboxMap.removeMarker(marker); } - //Add a marker on the clicked point + // Add a marker on the clicked point marker = mapboxMap.addMarker(new CustomMarkerOptions().position(point).features(features)); mapboxMap.selectMarker(marker); } @@ -186,28 +181,6 @@ public class QueryRenderedFeaturesPropertiesActivity extends AppCompatActivity { mapView.onLowMemory(); } - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - - private void setupActionBar() { - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - final ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - } - private static class CustomMarker extends Marker { private final List<Feature> features; @@ -232,7 +205,7 @@ public class QueryRenderedFeaturesPropertiesActivity extends AppCompatActivity { } private CustomMarkerOptions(Parcel in) { - //Should implement this + // Should implement this } @Override @@ -245,8 +218,8 @@ public class QueryRenderedFeaturesPropertiesActivity extends AppCompatActivity { return new CustomMarker(this, features); } - public static final Parcelable.Creator<CustomMarkerOptions> CREATOR - = new Parcelable.Creator<CustomMarkerOptions>() { + public static final Parcelable.Creator<CustomMarkerOptions> CREATOR = + new Parcelable.Creator<CustomMarkerOptions>() { public CustomMarkerOptions createFromParcel(Parcel in) { return new CustomMarkerOptions(in); } @@ -263,7 +236,7 @@ public class QueryRenderedFeaturesPropertiesActivity extends AppCompatActivity { @Override public void writeToParcel(Parcel out, int flags) { - //Should implement this + // Should implement this } } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MapFragmentActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MapFragmentActivity.java index 1c259b1304..930626078d 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MapFragmentActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MapFragmentActivity.java @@ -2,10 +2,7 @@ package com.mapbox.mapboxsdk.testapp.activity.fragment; import android.app.FragmentTransaction; import android.os.Bundle; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.MenuItem; import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; @@ -17,6 +14,12 @@ import com.mapbox.mapboxsdk.maps.MapboxMapOptions; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.testapp.R; +/** + * Test activity showcasing using the MapFragment API using SDK Fragments. + * <p> + * Uses MapboxMapOptions to initialise the Fragment. + * </p> + */ public class MapFragmentActivity extends AppCompatActivity implements OnMapReadyCallback { private MapboxMap mapboxMap; @@ -26,15 +29,6 @@ public class MapFragmentActivity extends AppCompatActivity implements OnMapReady super.onCreate(savedInstanceState); setContentView(R.layout.activity_map_fragment); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - MapFragment mapFragment; if (savedInstanceState == null) { final FragmentTransaction transaction = getFragmentManager().beginTransaction(); @@ -75,15 +69,4 @@ public class MapFragmentActivity extends AppCompatActivity implements OnMapReady mapboxMap.animateCamera( CameraUpdateFactory.newCameraPosition(new CameraPosition.Builder().tilt(45.0).build()), 10000); } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MultiMapActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MultiMapActivity.java index d5d51887dd..eec440afb0 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MultiMapActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/MultiMapActivity.java @@ -5,6 +5,9 @@ import android.os.Bundle; import com.mapbox.mapboxsdk.testapp.R; +/** + * Test Activity showcasing using multiple static map fragments in one layout. + */ public class MultiMapActivity extends AppCompatActivity { @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/SupportMapFragmentActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/SupportMapFragmentActivity.java index 7dcca89a04..ee16b251c5 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/SupportMapFragmentActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/SupportMapFragmentActivity.java @@ -2,10 +2,7 @@ package com.mapbox.mapboxsdk.testapp.activity.fragment; import android.os.Bundle; import android.support.v4.app.FragmentTransaction; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.MenuItem; import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; @@ -17,6 +14,12 @@ import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.maps.SupportMapFragment; import com.mapbox.mapboxsdk.testapp.R; +/** + * Test activity showcasing using the MapFragment API using Support Library Fragments. + * <p> + * Uses MapboxMapOptions to initialise the Fragment. + * </p> + */ public class SupportMapFragmentActivity extends AppCompatActivity implements OnMapReadyCallback { private MapboxMap mapboxMap; @@ -26,15 +29,6 @@ public class SupportMapFragmentActivity extends AppCompatActivity implements OnM super.onCreate(savedInstanceState); setContentView(R.layout.activity_map_fragment); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - SupportMapFragment mapFragment; if (savedInstanceState == null) { final FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); @@ -73,15 +67,4 @@ public class SupportMapFragmentActivity extends AppCompatActivity implements OnM mapboxMap.animateCamera( CameraUpdateFactory.newCameraPosition(new CameraPosition.Builder().tilt(45.0).build()), 10000); } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.java index e6953bd3d2..8025832429 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/fragment/ViewPagerActivity.java @@ -5,10 +5,7 @@ import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.MenuItem; import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.constants.Style; @@ -17,6 +14,9 @@ import com.mapbox.mapboxsdk.maps.MapboxMapOptions; import com.mapbox.mapboxsdk.maps.SupportMapFragment; import com.mapbox.mapboxsdk.testapp.R; +/** + * Test activity showcasing using the Android SDK ViewPager API to show MapFragments. + */ public class ViewPagerActivity extends AppCompatActivity { @Override @@ -24,15 +24,6 @@ public class ViewPagerActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_viewpager); - final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager); if (viewPager != null) { MapFragmentAdapter adapter = new MapFragmentAdapter(getSupportFragmentManager()); @@ -78,22 +69,10 @@ public class ViewPagerActivity extends AppCompatActivity { return fragment; } - @Override public CharSequence getPageTitle(int position) { return "Page " + position; } } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/geocoding/GeocoderActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/geocoding/GeocoderActivity.java deleted file mode 100644 index 39d52f7876..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/geocoding/GeocoderActivity.java +++ /dev/null @@ -1,205 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.activity.geocoding; - -import android.graphics.PointF; -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 timber.log.Timber; - -import android.view.Gravity; -import android.view.MenuItem; -import android.view.ViewGroup; -import android.widget.FrameLayout; -import android.widget.ImageView; -import android.widget.TextView; - -import com.mapbox.mapboxsdk.annotations.MarkerOptions; -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.OnMapReadyCallback; -import com.mapbox.mapboxsdk.maps.Projection; -import com.mapbox.mapboxsdk.testapp.R; -import com.mapbox.services.api.ServicesException; -import com.mapbox.services.commons.models.Position; -import com.mapbox.services.api.geocoding.v5.GeocodingCriteria; -import com.mapbox.services.api.geocoding.v5.MapboxGeocoding; -import com.mapbox.services.api.geocoding.v5.models.CarmenFeature; -import com.mapbox.services.api.geocoding.v5.models.GeocodingResponse; - -import java.util.List; - -import retrofit2.Call; -import retrofit2.Callback; -import retrofit2.Response; - -public class GeocoderActivity extends AppCompatActivity implements OnMapReadyCallback { - - private MapboxMap mapboxMap; - private MapView mapView; - private ImageView dropPinView; - private TextView textView; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_geocoder); - - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - - textView = (TextView) findViewById(R.id.message); - setMessage(getString(R.string.geocoder_instructions)); - - mapView = (MapView) findViewById(R.id.mapView); - mapView.setStyleUrl(Style.MAPBOX_STREETS); - mapView.onCreate(savedInstanceState); - - dropPinView = new ImageView(this); - dropPinView.setImageResource(R.drawable.ic_droppin_24dp); - FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( - ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER); - dropPinView.setLayoutParams(params); - mapView.addView(dropPinView); - mapView.getMapAsync(this); - } - - @Override - public void onMapReady(MapboxMap map) { - mapboxMap = map; - final Projection projection = mapboxMap.getProjection(); - final int width = mapView.getMeasuredWidth(); - final int height = mapView.getMeasuredHeight(); - - // Click listener - mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() { - @Override - public void onMapClick(@NonNull LatLng point) { - PointF centerPoint = new PointF(width / 2, (height + dropPinView.getHeight()) / 2); - LatLng centerLatLng = new LatLng(projection.fromScreenLocation(centerPoint)); - - setMessage("Geocoding..."); - - mapboxMap.removeAnnotations(); - mapboxMap.addMarker(new MarkerOptions().position(centerLatLng)); - - geocode(centerLatLng); - } - }); - } - - @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 onDestroy() { - super.onDestroy(); - mapView.onDestroy(); - } - - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - mapView.onSaveInstanceState(outState); - } - - /* - * Forward geocoding - */ - - private void geocode(final LatLng point) { - - try { - MapboxGeocoding client = new MapboxGeocoding.Builder() - .setAccessToken(getString(R.string.mapbox_access_token)) - .setCoordinates(Position.fromCoordinates(point.getLongitude(), point.getLatitude())) - .setGeocodingType(GeocodingCriteria.TYPE_POI) - .build(); - - client.enqueueCall(new Callback<GeocodingResponse>() { - @Override - public void onResponse(Call<GeocodingResponse> call, Response<GeocodingResponse> response) { - - List<CarmenFeature> results = response.body().getFeatures(); - if (results.size() > 0) { - String placeName = results.get(0).getPlaceName(); - setSuccess(placeName); - } else { - setMessage("No results."); - } - - } - - @Override - public void onFailure(Call<GeocodingResponse> call, Throwable throwable) { - setError(throwable.getMessage()); - } - }); - } catch (ServicesException servicesException) { - Timber.e("Error geocoding: " + servicesException.toString()); - servicesException.printStackTrace(); - setError(servicesException.getMessage()); - } - } - - /* - * Update text view - */ - - private void setMessage(String message) { - Timber.d("Message: " + message); - textView.setText(message); - } - - private void setSuccess(String placeName) { - Timber.d("Place name: " + placeName); - textView.setText(placeName); - } - - private void setError(String message) { - Timber.e("Error: " + message); - textView.setText("Error: " + message); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/PrintActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/PrintActivity.java index 7f3c16d7b8..18d80586c9 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/PrintActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/PrintActivity.java @@ -4,10 +4,7 @@ import android.graphics.Bitmap; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.print.PrintHelper; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.MenuItem; import android.view.View; import com.mapbox.mapboxsdk.maps.MapView; @@ -15,6 +12,9 @@ import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.testapp.R; +/** + * Test activity showcasing using the Snaphot API to print a Map. + */ public class PrintActivity extends AppCompatActivity implements MapboxMap.SnapshotReadyCallback { private MapView mapView; @@ -25,15 +25,6 @@ public class PrintActivity extends AppCompatActivity implements MapboxMap.Snapsh super.onCreate(savedInstanceState); setContentView(R.layout.activity_print); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - final ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @@ -104,16 +95,4 @@ public class PrintActivity extends AppCompatActivity implements MapboxMap.Snapsh super.onLowMemory(); mapView.onLowMemory(); } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.java index 3912dfa918..2be47b4e25 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/imagegenerator/SnapshotActivity.java @@ -4,10 +4,7 @@ import android.graphics.Bitmap; import android.os.Bundle; import android.support.design.widget.FloatingActionButton; import android.support.v4.content.ContextCompat; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.MenuItem; import android.view.View; import android.widget.ImageView; import android.widget.Toast; @@ -18,6 +15,9 @@ import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.testapp.R; +/** + * Test activity showcasing the Snapshot API to create and display a bitmap of the current shown Map. + */ public class SnapshotActivity extends AppCompatActivity implements OnMapReadyCallback, View.OnClickListener { private MapView mapView; @@ -28,15 +28,6 @@ public class SnapshotActivity extends AppCompatActivity implements OnMapReadyCal super.onCreate(savedInstanceState); setContentView(R.layout.activity_snapshot); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(this); @@ -112,15 +103,4 @@ public class SnapshotActivity extends AppCompatActivity implements OnMapReadyCal super.onDestroy(); mapView.onDestroy(); } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java index c70e263be5..18db2ba8a8 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/DynamicInfoWindowAdapterActivity.java @@ -1,20 +1,14 @@ package com.mapbox.mapboxsdk.testapp.activity.infowindow; import android.graphics.Color; -import android.graphics.PorterDuff; -import android.graphics.drawable.Drawable; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import android.support.v4.content.ContextCompat; -import android.support.v7.app.ActionBar; +import android.support.v4.content.res.ResourcesCompat; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.MenuItem; import android.view.View; import android.widget.TextView; -import com.mapbox.mapboxsdk.annotations.IconFactory; import com.mapbox.mapboxsdk.annotations.InfoWindow; import com.mapbox.mapboxsdk.annotations.Marker; import com.mapbox.mapboxsdk.annotations.MarkerView; @@ -25,9 +19,10 @@ 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.IconUtils; /** - * Shows how to dynamically update InfoWindow when Using an MapboxMap.InfoWindowAdapter + * Test activity showcasing how to dynamically update InfoWindow when Using an MapboxMap.InfoWindowAdapter. */ public class DynamicInfoWindowAdapterActivity extends AppCompatActivity implements OnMapReadyCallback { @@ -41,8 +36,6 @@ public class DynamicInfoWindowAdapterActivity extends AppCompatActivity implemen super.onCreate(savedInstanceState); setContentView(R.layout.activity_infowindow_adapter); - setupActionBar(); - mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(this); @@ -53,54 +46,48 @@ public class DynamicInfoWindowAdapterActivity extends AppCompatActivity implemen mapboxMap = map; - //Add info window adapter + // Add info window adapter addCustomInfoWindowAdapter(mapboxMap); - //Keep info windows open on click + // Keep info windows open on click mapboxMap.getUiSettings().setDeselectMarkersOnTap(false); - //Add a marker + // Add a marker final MarkerView marker = addMarker(mapboxMap); mapboxMap.selectMarker(marker); - //On map click, change the info window contents + // On map click, change the info window contents mapboxMap.setOnMapClickListener(new MapboxMap.OnMapClickListener() { @Override public void onMapClick(@NonNull LatLng point) { - //Distance from click to marker + // Distance from click to marker double distanceKm = marker.getPosition().distanceTo(point) / 1000; - //Get the info window + // Get the info window InfoWindow infoWindow = marker.getInfoWindow(); - //Get the view from the info window + // Get the view from the info window if (infoWindow != null && infoWindow.getView() != null) { - //Set the new text on the text view in the info window + // Set the new text on the text view in the info window ((TextView) infoWindow.getView()).setText(String.format("%.2fkm", distanceKm)); - //Update the info window position (as the text length changes) + // Update the info window position (as the text length changes) infoWindow.update(); } } }); - //Focus on Paris + // Focus on Paris mapboxMap.animateCamera(CameraUpdateFactory.newLatLng(paris)); } private MarkerView addMarker(MapboxMap mapboxMap) { - IconFactory iconFactory = IconFactory.getInstance(this); - Drawable iconDrawable = ContextCompat.getDrawable(this, R.drawable.ic_location_city_24dp); - iconDrawable.setColorFilter( - ContextCompat.getColor(DynamicInfoWindowAdapterActivity.this, R.color.mapbox_blue), - PorterDuff.Mode.SRC_IN - ); - return mapboxMap.addMarker( new MarkerViewOptions() .position(paris) - .icon(iconFactory.fromDrawable(iconDrawable)) - ); + .icon(IconUtils.drawableToIcon(this, R.drawable.ic_location_city, + ResourcesCompat.getColor(getResources(), R.color.mapbox_blue, getTheme())) + )); } private void addCustomInfoWindowAdapter(final MapboxMap mapboxMap) { @@ -162,26 +149,4 @@ public class DynamicInfoWindowAdapterActivity extends AppCompatActivity implemen super.onLowMemory(); mapView.onLowMemory(); } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - - private void setupActionBar() { - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowActivity.java index 0c2af9b7e3..b8083dfa74 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowActivity.java @@ -2,23 +2,27 @@ package com.mapbox.mapboxsdk.testapp.activity.infowindow; 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.widget.Toast; -import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.annotations.Marker; import com.mapbox.mapboxsdk.annotations.MarkerOptions; 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.maps.MapView; import java.text.DecimalFormat; +/** + * Test activity showcasing using the InfoWindow API above Washington D.C. + * <p> + * Allows to test mulitple concurrently open InfoWindows. + * </p> + */ public class InfoWindowActivity extends AppCompatActivity implements OnMapReadyCallback, MapboxMap.OnInfoWindowCloseListener, MapboxMap.OnMapLongClickListener, MapboxMap.OnInfoWindowClickListener, MapboxMap.OnInfoWindowLongClickListener { @@ -32,15 +36,6 @@ public class InfoWindowActivity extends AppCompatActivity super.onCreate(savedInstanceState); setContentView(R.layout.activity_infowindow); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(this); @@ -188,9 +183,6 @@ public class InfoWindowActivity extends AppCompatActivity toggleDeselectMarkersOnTap(!item.isChecked()); item.setChecked(!item.isChecked()); return true; - case android.R.id.home: - onBackPressed(); - return true; default: return super.onOptionsItemSelected(item); } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowAdapterActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowAdapterActivity.java index 08f64abcba..7026a797d5 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowAdapterActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/infowindow/InfoWindowAdapterActivity.java @@ -1,20 +1,13 @@ package com.mapbox.mapboxsdk.testapp.activity.infowindow; import android.graphics.Color; -import android.graphics.PorterDuff; -import android.graphics.drawable.Drawable; import android.os.Bundle; import android.support.annotation.NonNull; -import android.support.v4.content.ContextCompat; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.MenuItem; import android.view.View; import android.widget.TextView; import com.mapbox.mapboxsdk.annotations.Icon; -import com.mapbox.mapboxsdk.annotations.IconFactory; import com.mapbox.mapboxsdk.annotations.Marker; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.maps.MapView; @@ -23,31 +16,18 @@ import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.testapp.R; import com.mapbox.mapboxsdk.testapp.model.annotations.CityStateMarker; import com.mapbox.mapboxsdk.testapp.model.annotations.CityStateMarkerOptions; +import com.mapbox.mapboxsdk.testapp.utils.IconUtils; public class InfoWindowAdapterActivity extends AppCompatActivity { private MapView mapView; private MapboxMap mapboxMap; - private IconFactory iconFactory; - private Drawable iconDrawable; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_infowindow_adapter); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - - iconFactory = IconFactory.getInstance(this); - iconDrawable = ContextCompat.getDrawable(this, R.drawable.ic_location_city_24dp); - mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @@ -75,8 +55,7 @@ public class InfoWindowAdapterActivity extends AppCompatActivity { marker.position(new LatLng(lat, lng)); marker.infoWindowBackground(color); - iconDrawable.setColorFilter(Color.parseColor(color), PorterDuff.Mode.SRC_IN); - Icon icon = iconFactory.fromDrawable(iconDrawable); + Icon icon = IconUtils.drawableToIcon(this, R.drawable.ic_location_city, Color.parseColor(color)); marker.icon(icon); return marker; } @@ -144,15 +123,4 @@ public class InfoWindowAdapterActivity extends AppCompatActivity { super.onLowMemory(); mapView.onLowMemory(); } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java index 5c9d927e9b..6ec0ccc11f 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java @@ -3,13 +3,7 @@ package com.mapbox.mapboxsdk.testapp.activity.maplayout; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.design.widget.FloatingActionButton; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; - -import timber.log.Timber; - -import android.view.MenuItem; import android.view.View; import com.mapbox.mapboxsdk.constants.Style; @@ -18,6 +12,11 @@ import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.testapp.R; +import timber.log.Timber; + +/** + * Test Activity showcasing the different debug modes and allows to cycle between the default map styles. + */ public class DebugModeActivity extends AppCompatActivity { private MapView mapView; @@ -39,15 +38,6 @@ public class DebugModeActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_debug_mode); - final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - mapView = (MapView) findViewById(R.id.mapView); mapView.setTag(true); mapView.setStyleUrl(STYLES[currentStyleIndex]); @@ -127,16 +117,4 @@ public class DebugModeActivity extends AppCompatActivity { super.onLowMemory(); mapView.onLowMemory(); } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - - default: - return super.onOptionsItemSelected(item); - } - } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java index 6c43e28237..7ec9cb9242 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DoubleMapActivity.java @@ -6,11 +6,8 @@ import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentTransaction; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; import android.view.LayoutInflater; -import android.view.MenuItem; import android.view.SurfaceView; import android.view.View; import android.view.ViewGroup; @@ -38,15 +35,6 @@ public class DoubleMapActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_map_fragment); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - if (savedInstanceState == null) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.add(R.id.fragment_container, new DoubleMapFragment(), TAG_FRAGMENT); @@ -189,15 +177,4 @@ public class DoubleMapActivity extends AppCompatActivity { mapViewMini.onSaveInstanceState(outState); } } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapInDialogActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapInDialogActivity.java index ed3f315e06..495360a168 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapInDialogActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapInDialogActivity.java @@ -4,11 +4,8 @@ import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentManager; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; import android.view.LayoutInflater; -import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.Button; @@ -16,6 +13,12 @@ import android.widget.Button; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.testapp.R; +/** + * Test activity showcasing showing a Map inside of a DialogFragment. + * <p> + * Uses the deprecated TextureView API to workaround the issue of seeing a grey background before the gl surface. + * </p> + */ public class MapInDialogActivity extends AppCompatActivity { @Override @@ -23,15 +26,6 @@ public class MapInDialogActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_map_in_dialog); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - Button button = (Button) findViewById(R.id.button_open_dialog); button.setOnClickListener(new View.OnClickListener() { @Override @@ -43,17 +37,6 @@ public class MapInDialogActivity extends AppCompatActivity { }); } - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - public static class MapDialogFragment extends DialogFragment { private MapView mapView; @@ -124,4 +107,4 @@ public class MapInDialogActivity extends AppCompatActivity { mapView.onSaveInstanceState(outState); } } -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java index 90b91057ed..0cf0191cea 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/MapPaddingActivity.java @@ -2,23 +2,27 @@ package com.mapbox.mapboxsdk.testapp.activity.maplayout; 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 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.camera.CameraUpdateFactory; 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.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 { private MapView mapView; @@ -29,15 +33,6 @@ public class MapPaddingActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_map_padding); - final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - mapView = (MapView) findViewById(R.id.mapView); mapView.setTag(true); mapView.onCreate(savedInstanceState); @@ -50,7 +45,8 @@ public class MapPaddingActivity extends AppCompatActivity { int paddingLeft = (int) getResources().getDimension(R.dimen.map_padding_left); int paddingBottom = (int) getResources().getDimension(R.dimen.map_padding_bottom); int paddingRight = (int) getResources().getDimension(R.dimen.map_padding_right); - mapboxMap.setPadding(paddingLeft, toolbar.getHeight(), paddingRight, paddingBottom); + int paddingTop = (int) getResources().getDimension(R.dimen.map_padding_top); + mapboxMap.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); moveToBangalore(); } @@ -138,10 +134,6 @@ public class MapPaddingActivity extends AppCompatActivity { @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - case R.id.action_user_tracking: if (mapboxMap != null) { toggleGps(true); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/NavigationDrawerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/NavigationDrawerActivity.java index 7f59dd3bdb..888482b219 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/NavigationDrawerActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/NavigationDrawerActivity.java @@ -148,8 +148,8 @@ public class NavigationDrawerActivity extends AppCompatActivity { android.R.layout.simple_list_item_activated_1, android.R.id.text1, new String[] { - getString(R.string.title_section1), - getString(R.string.title_section2) + "Different style", + "Show snackbar" })); drawerListView.setItemChecked(currentSelectedPosition, true); return drawerListView; diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SimpleMapActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SimpleMapActivity.java index 7e04b95e20..8f8a5af3cc 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SimpleMapActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/SimpleMapActivity.java @@ -1,14 +1,14 @@ package com.mapbox.mapboxsdk.testapp.activity.maplayout; import android.os.Bundle; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.MenuItem; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.testapp.R; +/** + * Test activity showcasing a simple MapView without any MapboxMap interaction. + */ public class SimpleMapActivity extends AppCompatActivity { private MapView mapView; @@ -18,15 +18,6 @@ public class SimpleMapActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_map_simple); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - final ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); } @@ -72,15 +63,4 @@ public class SimpleMapActivity extends AppCompatActivity { super.onSaveInstanceState(outState); mapView.onSaveInstanceState(outState); } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/navigation/CarDrivingActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/navigation/CarDrivingActivity.java deleted file mode 100644 index 4bb6bc5f39..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/navigation/CarDrivingActivity.java +++ /dev/null @@ -1,201 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.activity.navigation; - -import android.Manifest; -import android.content.pm.PackageManager; -import android.graphics.Color; -import android.graphics.drawable.Drawable; -import android.location.Location; -import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.annotation.UiThread; -import android.support.v4.app.ActivityCompat; -import android.support.v4.content.ContextCompat; -import android.support.v4.content.res.ResourcesCompat; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.MenuItem; - - -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.MapView; -import com.mapbox.mapboxsdk.maps.MapboxMap; -import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; -import com.mapbox.mapboxsdk.maps.TrackingSettings; -import com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings; -import com.mapbox.mapboxsdk.testapp.R; - -public class CarDrivingActivity extends AppCompatActivity implements MapboxMap.OnMyLocationChangeListener { - - private static final int PERMISSIONS_LOCATION = 0; - - private MapView mapView; - private MapboxMap mapboxMap; - private Location location; - - @Override - protected void onCreate(final Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_car_driving); - - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - final ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - - mapView = (MapView) findViewById(R.id.mapView); - mapView.onCreate(savedInstanceState); - mapView.getMapAsync(new OnMapReadyCallback() { - @Override - public void onMapReady(@NonNull MapboxMap mapboxMap) { - CarDrivingActivity.this.mapboxMap = mapboxMap; - - // view settings - MyLocationViewSettings settings = mapboxMap.getMyLocationViewSettings(); - settings.setPadding(0, getWindow().getDecorView().getMeasuredHeight() / 3, 0, 0); - - // get car - Drawable car = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_taxi_top_small, getTheme()); - settings.setForegroundTintColor(Color.TRANSPARENT); - settings.setForegroundDrawable(car, car); - - // remove accuracy circle - settings.setAccuracyAlpha(0); - - // disable dismissal when a gesture occurs - TrackingSettings trackingSettings = mapboxMap.getTrackingSettings(); - trackingSettings.setDismissLocationTrackingOnGesture(false); - trackingSettings.setDismissBearingTrackingOnGesture(false); - - mapboxMap.setOnMyLocationChangeListener(CarDrivingActivity.this); - - if (savedInstanceState == null) { - toggleGps(true); - } - } - }); - } - - @UiThread - public void toggleGps(boolean enableGps) { - if (enableGps) { - if ((ContextCompat.checkSelfPermission(this, - Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) - || (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) - != PackageManager.PERMISSION_GRANTED)) { - ActivityCompat.requestPermissions(this, new String[] { - Manifest.permission.ACCESS_COARSE_LOCATION, - Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_LOCATION); - } else { - enableLocation(true); - } - } else { - enableLocation(false); - } - } - - private void enableLocation(boolean enabled) { - if (enabled) { - mapboxMap.setMyLocationEnabled(true); - Location location = mapboxMap.getMyLocation(); - if (location != null) { - setInitialPosition(new LatLng(location)); - } - } else { - mapboxMap.setMyLocationEnabled(false); - } - } - - @Override - public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { - if (requestCode == PERMISSIONS_LOCATION) { - if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - enableLocation(true); - } - } - } - - private void setInitialPosition(LatLng latLng) { - mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition( - new CameraPosition.Builder().target(latLng).zoom(15).tilt(20f).build())); - mapboxMap.setMyLocationEnabled(true); - - TrackingSettings trackingSettings = mapboxMap.getTrackingSettings(); - trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW); - trackingSettings.setMyBearingTrackingMode(MyBearingTracking.GPS); - } - - @Override - public void onMyLocationChange(@Nullable Location location) { - if (location != null) { - if (this.location == null) { - // initial location to reposition map - setInitialPosition(new LatLng(location)); - } - this.location = location; - } - } - - @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(); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/navigation/LocationPickerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/navigation/LocationPickerActivity.java deleted file mode 100644 index 8fb53645a1..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/navigation/LocationPickerActivity.java +++ /dev/null @@ -1,477 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.activity.navigation; - -import android.Manifest; -import android.app.ProgressDialog; -import android.content.Context; -import android.content.pm.PackageManager; -import android.graphics.PointF; -import android.location.Location; -import android.os.Build; -import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.ActivityCompat; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; - -import timber.log.Timber; - -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; -import android.view.animation.Animation; -import android.view.animation.AnimationUtils; -import android.widget.Button; -import android.widget.FrameLayout; -import android.widget.ImageButton; -import android.widget.ImageView; -import android.widget.Toast; - -import com.mapbox.mapboxsdk.annotations.IconFactory; -import com.mapbox.mapboxsdk.annotations.Marker; -import com.mapbox.mapboxsdk.annotations.MarkerView; -import com.mapbox.mapboxsdk.annotations.MarkerViewOptions; -import com.mapbox.mapboxsdk.camera.CameraPosition; -import com.mapbox.mapboxsdk.geometry.LatLng; -import com.mapbox.mapboxsdk.location.LocationListener; -import com.mapbox.mapboxsdk.location.LocationServices; -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.model.annotations.PulseMarkerView; -import com.mapbox.mapboxsdk.testapp.model.annotations.PulseMarkerViewOptions; -import com.mapbox.services.api.ServicesException; -import com.mapbox.services.commons.models.Position; -import com.mapbox.services.api.geocoding.v5.GeocodingCriteria; -import com.mapbox.services.api.geocoding.v5.MapboxGeocoding; -import com.mapbox.services.api.geocoding.v5.models.CarmenFeature; -import com.mapbox.services.api.geocoding.v5.models.GeocodingResponse; - -import java.util.List; - -import retrofit2.Call; -import retrofit2.Callback; -import retrofit2.Response; - -/** - * Sample Activity to show a typical location picker use case - */ -public class LocationPickerActivity extends AppCompatActivity { - private static final int REQUEST_PERMISSIONS = 101; - - private MapView mapView; - private MapboxMap mapboxMap; - - private ImageView dropPinView; - private Marker addressPin; - private ImageButton clearDisplayViewButton; - private MarkerView userMarker; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_location_picker); - - setupActionBar(); - - //Initialize map as normal - mapView = (MapView) findViewById(R.id.mapView); - mapView.onCreate(savedInstanceState); - - //Create ui elements - createDropPin(); - createSelectLocationButton(); - createClearSelectionButton(); - - mapView.getMapAsync(new OnMapReadyCallback() { - @Override - public void onMapReady(MapboxMap map) { - //Store for later - mapboxMap = map; - - //Add user marker - mapboxMap.getMarkerViewManager().addMarkerViewAdapter( - new PulseMarkerViewAdapter(LocationPickerActivity.this)); - userMarker = createCustomUserMarker(new LatLng(0, 0)); - - //Fix the focal point to the center of the map - PointF focalPoint = new PointF( - (mapView.getX() + mapView.getWidth() / 2), (mapView.getY() + mapView.getHeight() / 2)); - mapboxMap.getUiSettings().setFocalPoint(focalPoint); - - //Track camera updates to animate the user location views - trackUserLocationView(userMarker); - } - }); - } - - private void zoomInOn(Location location) { - //Move the camera to the user - if (location != null) { - mapboxMap.setCameraPosition(new CameraPosition.Builder() - .target(new LatLng(location)) - .zoom(16) - .bearing(0) - .tilt(0) - .build()); - } - } - - - /** - * Tracks the camera to animate the marker when overlapping with the picker. - * Makes sure the marker actually points to the user's position by tracking it. - */ - private void trackUserLocationView(final MarkerView markerView) { - final float circleDiameterSize = getResources().getDimension(R.dimen.circle_size); - - //Track camera changes to check for overlap - mapboxMap.setOnCameraChangeListener(new MapboxMap.OnCameraChangeListener() { - - private Animation pulseAnimation; - - @Override - public void onCameraChange(CameraPosition position) { - if (markerView == null) { - return; - } - - //Make drop pin visible, if it wasn't already - showDropPin(); - - //Get the distance from the tip of the location picker to the MarkerView - double distance = getLocationPickerLocation().distanceTo(markerView.getPosition()); - - //If closeby, animate, otherwise, stop animation - View view = mapboxMap.getMarkerViewManager().getView(markerView); - if (view != null) { - View backgroundView = view.findViewById(R.id.background_imageview); - if (pulseAnimation == null && distance < 0.5f * circleDiameterSize) { - pulseAnimation = AnimationUtils.loadAnimation(LocationPickerActivity.this, R.anim.pulse); - pulseAnimation.setRepeatCount(Animation.INFINITE); - pulseAnimation.setRepeatMode(Animation.RESTART); - backgroundView.startAnimation(pulseAnimation); - } else if (pulseAnimation != null && distance >= 0.5f * circleDiameterSize) { - backgroundView.clearAnimation(); - pulseAnimation = null; - } - } - } - }); - - //Track location updates to move the user marker - LocationServices.getLocationServices(getApplicationContext()).addLocationListener(new LocationListener() { - @Override - public void onLocationChanged(Location location) { - if (location != null && markerView != null) { - markerView.setPosition(new LatLng(location)); - } - } - }); - } - - private MarkerView createCustomUserMarker(LatLng markerPosition) { - return mapboxMap.addMarker(new PulseMarkerViewOptions() - .icon(IconFactory.getInstance(getApplicationContext()).fromResource(R.drawable.ic_my_location_24dp)) - .position(markerPosition) - ); - } - - private void createClearSelectionButton() { - clearDisplayViewButton = (ImageButton) findViewById(R.id.clearDisplayViewButton); - clearDisplayViewButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - removeAddressPin(); - hide(clearDisplayViewButton); - showDropPin(); - } - }); - } - - private void createSelectLocationButton() { - Button selectLocationButton = (Button) findViewById(R.id.selectLocationButton); - //noinspection ConstantConditions - selectLocationButton.setOnClickListener( - new View.OnClickListener() { - @Override - public void onClick(View view) { - Timber.i("Location Selected!"); - if (mapboxMap != null) { - //Control button's state - clearDisplayViewButton.setVisibility(View.VISIBLE); - dropPinView.setVisibility(View.INVISIBLE); - - //Get position for the drop pin - LatLng position = getLocationPickerLocation(); - - //Show the address pin (result) - showAddressPin(position); - - //Get the address for that location and update the marker - geocode(position, new GeocodeCallbacks() { - @Override - public void onResult(String result) { - updateAddressPin(result); - } - - @Override - public void onFailure(Throwable failure) { - showFeedbackMessage("Could not retrieve address: " + failure.getMessage()); - } - }); - } - } - } - ); - } - - private void createDropPin() { - float density = getResources().getDisplayMetrics().density; - - dropPinView = new ImageView(this); - dropPinView.setImageResource(R.drawable.ic_droppin_24dp); - FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( - ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER); - params.bottomMargin = (int) (12 * density); - dropPinView.setLayoutParams(params); - - mapView.addView(dropPinView); - } - - private void showDropPin() { - if (dropPinView != null && dropPinView.getVisibility() != View.VISIBLE) { - dropPinView.setVisibility(View.VISIBLE); - } - } - - private void hide(View view) { - if (view != null) { - view.setVisibility(View.INVISIBLE); - } - } - - private void setupActionBar() { - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - } - - /** - * Get address for the given location - */ - private void geocode(LatLng point, final GeocodeCallbacks callbacks) { - try { - //Create Geocoding client - MapboxGeocoding client = new MapboxGeocoding.Builder() - .setAccessToken(getString(R.string.mapbox_access_token)) - .setCoordinates(Position.fromCoordinates(point.getLongitude(), point.getLatitude())) - .setGeocodingType(GeocodingCriteria.TYPE_ADDRESS) - .build(); - - //Place the request - client.enqueueCall(new Callback<GeocodingResponse>() { - @Override - public void onResponse(Call<GeocodingResponse> call, Response<GeocodingResponse> response) { - - List<CarmenFeature> results = response.body().getFeatures(); - String address = null; - if (results.size() > 0) { - CarmenFeature feature = results.get(0); - address = feature.getAddress() + " " + feature.getText(); - Timber.i("address " + address); - } else { - showFeedbackMessage("No results for search."); - } - - callbacks.onResult(address); - } - - @Override - public void onFailure(Call<GeocodingResponse> call, Throwable throwable) { - Timber.e("Geocoding Failure: " + throwable.getMessage()); - callbacks.onFailure(throwable); - } - }); - } catch (ServicesException servicesException) { - Timber.e("Error geocoding: " + servicesException.toString()); - callbacks.onFailure(servicesException); - } - } - - private LatLng getLocationPickerLocation() { - return mapboxMap.getProjection().fromScreenLocation( - new PointF(dropPinView.getLeft() + (dropPinView.getWidth() / 2), dropPinView.getBottom()) - ); - } - - private Marker showAddressPin(LatLng position) { - if (addressPin != null) { - //Remove previous pin - removeAddressPin(); - } - - //Create new one - addressPin = mapboxMap.addMarker(new MarkerViewOptions().title("Loading address...").position(position)); - mapboxMap.selectMarker(addressPin); - return addressPin; - } - - private void removeAddressPin() { - if (mapboxMap != null && addressPin != null) { - mapboxMap.removeMarker(addressPin); - } - } - - private void updateAddressPin(@Nullable String address) { - if (addressPin != null) { - addressPin.setTitle(address == null ? "No address found" : address); - } - } - - private void showFeedbackMessage(String message) { - Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show(); - } - - private boolean arePermissionsGranted() { - if (Build.VERSION.SDK_INT >= 23 - && checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED - && checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { - Timber.i("Requesting permissions"); - ActivityCompat.requestPermissions(this, new String[] { - Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_PERMISSIONS); - return false; - } - Timber.i("Permissions already granted"); - return true; - } - - @Override - protected void onStart() { - super.onStart(); - mapView.onStart(); - - //Check permissions - if (arePermissionsGranted()) { - mapView.getMapAsync(new OnMapReadyCallback() { - - @Override - public void onMapReady(final MapboxMap mapboxMap) { - //Get the user's location - final LocationServices locationServices = LocationServices.getLocationServices(getApplicationContext()); - - Location location = locationServices.getLastLocation(); - if (location != null) { - zoomInOn(location); - userMarker.setPosition(new LatLng(location)); - } else { - final ProgressDialog loadingDialog = ProgressDialog.show( - LocationPickerActivity.this, "Loading", "Getting user location", false); - locationServices.addLocationListener(new LocationListener() { - @Override - public void onLocationChanged(@Nullable Location location) { - //Move the camera to the user - if (location != null) { - zoomInOn(location); - userMarker.setPosition(new LatLng(location)); - locationServices.removeLocationListener(this); - loadingDialog.hide(); - } - } - }); - } - - locationServices.toggleGPS(true); - } - }); - } - } - - @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(); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - - /** - * Custom MarkerViewAdapter for the pulsing marker - */ - private static class PulseMarkerViewAdapter extends MapboxMap.MarkerViewAdapter<PulseMarkerView> { - - private LayoutInflater inflater; - - public PulseMarkerViewAdapter(@NonNull Context context) { - super(context); - this.inflater = LayoutInflater.from(context); - } - - @Nullable - @Override - public View getView(@NonNull PulseMarkerView marker, @Nullable View convertView, @NonNull ViewGroup parent) { - ViewHolder viewHolder; - if (convertView == null) { - viewHolder = new ViewHolder(); - convertView = inflater.inflate(R.layout.view_pulse_marker, parent, false); - viewHolder.foregroundImageView = (ImageView) convertView.findViewById(R.id.foreground_imageView); - viewHolder.backgroundImageView = (ImageView) convertView.findViewById(R.id.background_imageview); - convertView.setTag(viewHolder); - } - return convertView; - } - - private static class ViewHolder { - ImageView foregroundImageView; - ImageView backgroundImageView; - } - } - - private interface GeocodeCallbacks { - void onResult(String result); - - void onFailure(Throwable failure); - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/DeleteRegionActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/DeleteRegionActivity.java new file mode 100644 index 0000000000..220f46f4e8 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/DeleteRegionActivity.java @@ -0,0 +1,168 @@ +package com.mapbox.mapboxsdk.testapp.activity.offline; + +import android.content.Context; +import android.content.DialogInterface; +import android.os.Bundle; +import android.support.v7.app.AlertDialog; +import android.support.v7.app.AppCompatActivity; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.BaseAdapter; +import android.widget.ListView; +import android.widget.TextView; +import android.widget.Toast; + +import com.mapbox.mapboxsdk.offline.OfflineManager; +import com.mapbox.mapboxsdk.offline.OfflineRegion; +import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.mapboxsdk.testapp.utils.OfflineUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * Test activity showing integration of deleting an OfflineRegion. + */ +public class DeleteRegionActivity extends AppCompatActivity implements AdapterView.OnItemClickListener { + + private OfflineRegionAdapter adapter; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_offline_region_delete); + + ListView listView = (ListView) findViewById(R.id.listView); + listView.setAdapter(adapter = new OfflineRegionAdapter(this)); + listView.setEmptyView(findViewById(android.R.id.empty)); + listView.setOnItemClickListener(this); + } + + @Override + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { + final OfflineRegion region = adapter.getItem(position); + String metadata = OfflineUtils.convertRegionName(region.getMetadata()); + + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle("Delete region"); + + final TextView input = new TextView(this); + input.setText(metadata); + builder.setView(input); + + builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + delete(region); + } + }); + builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dialog.cancel(); + } + }); + + builder.show(); + } + + private void delete(OfflineRegion region) { + region.delete(new OfflineRegion.OfflineRegionDeleteCallback() { + @Override + public void onDelete() { + Toast.makeText( + DeleteRegionActivity.this, + "Region deleted", + Toast.LENGTH_SHORT + ).show(); + loadOfflineRegions(); + } + + @Override + public void onError(String error) { + Toast.makeText( + DeleteRegionActivity.this, + "Region deletion failed with " + error, + Toast.LENGTH_LONG + ).show(); + } + }); + } + + @Override + protected void onStart() { + super.onStart(); + loadOfflineRegions(); + } + + private void loadOfflineRegions() { + OfflineManager.getInstance(this).listOfflineRegions(new OfflineManager.ListOfflineRegionsCallback() { + @Override + public void onList(OfflineRegion[] offlineRegions) { + if (offlineRegions != null && offlineRegions.length > 0) { + adapter.setOfflineRegions(Arrays.asList(offlineRegions)); + } + } + + @Override + public void onError(String error) { + Toast.makeText(DeleteRegionActivity.this, "Error loading regions " + error, Toast.LENGTH_LONG).show(); + } + }); + } + + private static class OfflineRegionAdapter extends BaseAdapter { + + private Context context; + private List<OfflineRegion> offlineRegions; + + OfflineRegionAdapter(Context ctx) { + context = ctx; + offlineRegions = new ArrayList<>(); + } + + void setOfflineRegions(List<OfflineRegion> offlineRegions) { + this.offlineRegions = offlineRegions; + notifyDataSetChanged(); + } + + @Override + public int getCount() { + return offlineRegions.size(); + } + + @Override + public OfflineRegion getItem(int position) { + return offlineRegions.get(position); + } + + @Override + public long getItemId(int position) { + return position; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + ViewHolder holder; + + if (convertView == null) { + holder = new ViewHolder(); + convertView = LayoutInflater.from(context).inflate(android.R.layout.simple_list_item_1, parent, false); + holder.text = (TextView) convertView.findViewById(android.R.id.text1); + convertView.setTag(holder); + } else { + holder = (ViewHolder) convertView.getTag(); + } + + holder.text.setText(OfflineUtils.convertRegionName(getItem(position).getMetadata())); + return convertView; + } + + static class ViewHolder { + TextView text; + } + } +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/OfflineActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/OfflineActivity.java index e2eda0e6b1..be5d809457 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/OfflineActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/OfflineActivity.java @@ -2,11 +2,8 @@ package com.mapbox.mapboxsdk.testapp.activity.offline; 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.text.TextUtils; -import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.ProgressBar; @@ -36,6 +33,12 @@ import java.util.ArrayList; import timber.log.Timber; +/** + * Test activity showcasing the Offline API. + * <p> + * Shows a map of Manhattan and allows the user to download and name a region. + * </p> + */ public class OfflineActivity extends AppCompatActivity implements OfflineDownloadRegionDialog.DownloadRegionDialogListener { @@ -68,18 +71,9 @@ public class OfflineActivity extends AppCompatActivity super.onCreate(savedInstanceState); setContentView(R.layout.activity_offline); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - // You can use Mapbox.setConnected(Boolean) to manually set the connectivity // state of your app. This will override any checks performed via the ConnectivityManager. - //Mapbox.getInstance().setConnected(false); + // Mapbox.getInstance().setConnected(false); Boolean connected = Mapbox.isConnected(); Timber.d(String.format(MapboxConstants.MAPBOX_LOCALE, "Mapbox is connected: %b", connected)); @@ -171,17 +165,6 @@ public class OfflineActivity extends AppCompatActivity mapView.onLowMemory(); } - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - /* * Buttons logic */ @@ -283,6 +266,7 @@ public class OfflineActivity extends AppCompatActivity if (status.isComplete()) { // Download complete endProgress("Region downloaded successfully."); + offlineRegion.setObserver(null); return; } else if (status.isRequiredResourceCountPrecise()) { // Switch to determinate state @@ -300,6 +284,7 @@ public class OfflineActivity extends AppCompatActivity public void onError(OfflineRegionError error) { Timber.e("onError reason: " + error.getReason()); Timber.e("onError message: " + error.getMessage()); + offlineRegion.setObserver(null); } @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/UpdateMetadataActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/UpdateMetadataActivity.java index a83cabba12..285e896766 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/UpdateMetadataActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/offline/UpdateMetadataActivity.java @@ -3,13 +3,10 @@ package com.mapbox.mapboxsdk.testapp.activity.offline; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; -import android.support.v7.app.ActionBar; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; import android.text.InputType; import android.view.LayoutInflater; -import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; @@ -40,15 +37,6 @@ public class UpdateMetadataActivity extends AppCompatActivity implements Adapter super.onCreate(savedInstanceState); setContentView(R.layout.activity_metadata_update); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - ListView listView = (ListView) findViewById(R.id.listView); listView.setAdapter(adapter = new OfflineRegionMetadataAdapter(this)); listView.setEmptyView(findViewById(android.R.id.empty)); @@ -125,17 +113,6 @@ public class UpdateMetadataActivity extends AppCompatActivity implements Adapter }); } - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - private static class OfflineRegionMetadataAdapter extends BaseAdapter { private Context context; diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CircleLayerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CircleLayerActivity.java index 0b102057b7..7628d6391e 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CircleLayerActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CircleLayerActivity.java @@ -5,13 +5,7 @@ import android.os.Bundle; import android.support.annotation.NonNull; import android.support.design.widget.FloatingActionButton; import android.support.v4.content.ContextCompat; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; - -import timber.log.Timber; - -import android.view.MenuItem; import android.view.View; import com.mapbox.mapboxsdk.camera.CameraPosition; @@ -28,10 +22,18 @@ import com.mapbox.mapboxsdk.testapp.R; import java.net.MalformedURLException; import java.net.URL; +import timber.log.Timber; + import static com.mapbox.mapboxsdk.style.layers.Filter.in; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius; +/** + * Test activity showcasing adding a Circle Layer to the Map + * <p> + * Uses bus stop data from Singapore as a source and allows to filter into 1 specific route with a line layer. + * </p> + */ public class CircleLayerActivity extends AppCompatActivity { private static final String[] STOPS_FOR_ROUTE = new String[] {"99009", "99131", "99049", "99039", "99029", "99019", @@ -50,15 +52,6 @@ public class CircleLayerActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_circle_layer); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @@ -87,7 +80,7 @@ public class CircleLayerActivity extends AppCompatActivity { public void onClick(View view) { // filter out stops for our route - layer.setFilter(in("number", STOPS_FOR_ROUTE)); + layer.setFilter(in("number", (Object[]) STOPS_FOR_ROUTE)); // add route as a line try { @@ -98,7 +91,7 @@ public class CircleLayerActivity extends AppCompatActivity { Timber.e("That's not an url... ", malformedUrlException); } LineLayer lineLayer = new LineLayer("route_layer", "bus_route"); - mapboxMap.addLayer(lineLayer, "stops_layer"); + mapboxMap.addLayerBelow(lineLayer, "stops_layer"); // move camera to start route mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition( @@ -156,15 +149,4 @@ public class CircleLayerActivity extends AppCompatActivity { super.onDestroy(); mapView.onDestroy(); } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CustomSpriteActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CustomSpriteActivity.java index d68872a5ba..3763b45e7a 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CustomSpriteActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CustomSpriteActivity.java @@ -5,13 +5,7 @@ import android.os.Bundle; import android.support.annotation.NonNull; import android.support.design.widget.FloatingActionButton; import android.support.v4.content.ContextCompat; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; - -import timber.log.Timber; - -import android.view.MenuItem; import android.view.View; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; @@ -28,10 +22,12 @@ import com.mapbox.services.commons.geojson.FeatureCollection; import com.mapbox.services.commons.geojson.Point; import com.mapbox.services.commons.models.Position; +import timber.log.Timber; + import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage; /** - * Example to add a sprite image and use it in a Symbol Layer + * Test activity showcasing adding a sprite image and use it in a Symbol Layer */ public class CustomSpriteActivity extends AppCompatActivity { private static final String CUSTOM_ICON = "custom-icon"; @@ -47,15 +43,6 @@ public class CustomSpriteActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_add_sprite); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @@ -74,7 +61,7 @@ public class CustomSpriteActivity extends AppCompatActivity { // Add an icon to reference later mapboxMap.addImage(CUSTOM_ICON, BitmapFactory.decodeResource(getResources(), R.drawable.ic_car_top)); - //Add a source with a geojson point + // Add a source with a geojson point point = Point.fromCoordinates(Position.fromCoordinates(13.400972d, 52.519003d)); source = new GeoJsonSource( "point", @@ -82,26 +69,26 @@ public class CustomSpriteActivity extends AppCompatActivity { ); mapboxMap.addSource(source); - //Add a symbol layer that references that point source + // Add a symbol layer that references that point source layer = new SymbolLayer("layer", "point"); layer.setProperties( - //Set the id of the sprite to use + // Set the id of the sprite to use iconImage(CUSTOM_ICON) ); // lets add a circle below labels! - mapboxMap.addLayer(layer, "waterway-label"); + mapboxMap.addLayerBelow(layer, "waterway-label"); - fab.setImageResource(R.drawable.ic_directions_car_black_24dp); + fab.setImageResource(R.drawable.ic_directions_car_black); } else { - //Update point + // Update point point = Point.fromCoordinates( Position.fromCoordinates(point.getCoordinates().getLongitude() + 0.001, point.getCoordinates().getLatitude() + 0.001) ); source.setGeoJson(FeatureCollection.fromFeatures(new Feature[] {Feature.fromGeometry(point)})); - //Move the camera as well + // Move the camera as well mapboxMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng( point.getCoordinates().getLatitude(), point.getCoordinates().getLongitude()))); } @@ -152,15 +139,4 @@ public class CustomSpriteActivity extends AppCompatActivity { super.onDestroy(); mapView.onDestroy(); } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DataDrivenStyleActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DataDrivenStyleActivity.java new file mode 100644 index 0000000000..3a5b30f71f --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DataDrivenStyleActivity.java @@ -0,0 +1,395 @@ +package com.mapbox.mapboxsdk.testapp.activity.style; + +import android.graphics.Color; +import android.os.Bundle; +import android.support.annotation.RawRes; +import android.support.v7.app.AppCompatActivity; +import android.view.Menu; +import android.view.MenuItem; +import android.widget.Toast; + +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.style.functions.stops.Stops; +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 java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.StringWriter; +import java.io.Writer; + +import timber.log.Timber; + +import static com.mapbox.mapboxsdk.style.functions.Function.composite; +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.exponential; +import static com.mapbox.mapboxsdk.style.functions.stops.Stops.interval; +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; +import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOutlineColor; + +/** + * Test activity showcasing the data driven runtime style API. + */ +public class DataDrivenStyleActivity extends AppCompatActivity { + + public static final String AMSTERDAM_PARKS_LAYER = "amsterdam-parks-layer"; + private MapView mapView; + private MapboxMap mapboxMap; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_data_driven_style); + + // Initialize map as normal + mapView = (MapView) findViewById(R.id.mapView); + mapView.onCreate(savedInstanceState); + + + mapView.getMapAsync(new OnMapReadyCallback() { + @Override + public void onMapReady(MapboxMap map) { + // Store for later + mapboxMap = map; + + // Add a parks layer + addParksLayer(); + + // Center and Zoom (Amsterdam, zoomed to streets) + mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(52.379189, 4.899431), 14)); + } + }); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.menu_data_driven_style, menu); + return true; + } + + @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(); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.action_add_exponential_zoom_function: + addExponentialZoomFunction(); + return true; + case R.id.action_add_interval_zoom_function: + addIntervalZoomFunction(); + return true; + case R.id.action_add_categorical_source_function: + addCategoricalSourceFunction(); + return true; + case R.id.action_add_exponential_source_function: + addExponentialSourceFunction(); + return true; + case R.id.action_add_identity_source_function: + addIdentitySourceFunction(); + return true; + case R.id.action_add_interval_source_function: + addIntervalSourceFunction(); + return true; + case R.id.action_add_composite_categorical_function: + addCompositeCategoricalFunction(); + return true; + case R.id.action_add_composite_exponential_function: + addCompositeExponentialFunction(); + return true; + case R.id.action_add_composite_interval_function: + addCompositeIntervalFunction(); + return true; + default: + return super.onOptionsItemSelected(item); + } + } + + + private void addExponentialZoomFunction() { + Timber.i("Add exponential zoom function"); + FillLayer layer = mapboxMap.getLayerAs("water"); + assert layer != null; + layer.setProperties( + fillColor( + zoom( + exponential( + stop(1, fillColor(Color.RED)), + stop(5, fillColor(Color.BLUE)), + stop(10, fillColor(Color.GREEN)) + ).withBase(0.5f) + ) + ) + ); + + Timber.i("Fill color: %s", layer.getFillColor()); + } + + private void addIntervalZoomFunction() { + Timber.i("Add interval zoom function"); + FillLayer layer = mapboxMap.getLayerAs("water"); + assert layer != null; + layer.setProperties( + fillColor( + zoom( + interval( + stop(1, fillColor(Color.RED)), + stop(5, fillColor(Color.BLUE)), + stop(10, fillColor(Color.GREEN)) + ) + ) + ) + ); + + Timber.i("Fill color: %s", layer.getFillColor()); + } + + private void addExponentialSourceFunction() { + Timber.i("Add exponential source function"); + FillLayer layer = mapboxMap.getLayerAs(AMSTERDAM_PARKS_LAYER); + assert layer != null; + layer.setProperties( + fillColor( + property( + "stroke-width", + exponential( + stop(1f, fillColor(Color.RED)), + stop(5f, fillColor(Color.BLUE)), + stop(10f, fillColor(Color.GREEN)) + ).withBase(0.5f) + ) + ) + ); + + Timber.i("Fill color: %s", layer.getFillColor()); + } + + private void addCategoricalSourceFunction() { + Timber.i("Add categorical source function"); + FillLayer layer = mapboxMap.getLayerAs(AMSTERDAM_PARKS_LAYER); + assert layer != null; + layer.setProperties( + fillColor( + property( + "name", + categorical( + stop("Westerpark", fillColor(Color.RED)), + stop("Jordaan", fillColor(Color.BLUE)), + stop("Prinseneiland", fillColor(Color.GREEN)) + )) + ) + ); + + Timber.i("Fill color: %s", layer.getFillColor()); + } + + private void addIdentitySourceFunction() { + Timber.i("Add identity source function"); + FillLayer layer = mapboxMap.getLayerAs(AMSTERDAM_PARKS_LAYER); + assert layer != null; + layer.setProperties( + fillOpacity( + property( + "fill-opacity", + Stops.<Float>identity()) + ) + ); + + Timber.i("Fill opacity: %s", layer.getFillOpacity()); + } + + private void addIntervalSourceFunction() { + Timber.i("Add interval source function"); + FillLayer layer = mapboxMap.getLayerAs(AMSTERDAM_PARKS_LAYER); + assert layer != null; + layer.setProperties( + fillColor( + property( + "stroke-width", + interval( + stop(1f, fillColor(Color.RED)), + stop(5f, fillColor(Color.BLUE)), + stop(10f, fillColor(Color.GREEN)) + )) + ) + ); + + Timber.i("Fill color: %s", layer.getFillColor()); + } + + private void addCompositeExponentialFunction() { + Timber.i("Add composite exponential function"); + FillLayer layer = mapboxMap.getLayerAs(AMSTERDAM_PARKS_LAYER); + assert layer != null; + layer.setProperties( + fillColor( + composite( + "stroke-width", + exponential( + stop(1, 1, fillColor(Color.RED)), + stop(10, 2, fillColor(Color.BLUE)), + stop(22, 3, fillColor(Color.GREEN)), + stop(1, 1, fillColor(Color.CYAN)), + stop(10, 2, fillColor(Color.GRAY)), + stop(22, 3, fillColor(Color.YELLOW)) + ).withBase(1f) + ) + ) + ); + + Timber.i("Fill color: %s", layer.getFillColor()); + } + + private void addCompositeIntervalFunction() { + Timber.i("Add composite exponential function"); + FillLayer layer = mapboxMap.getLayerAs(AMSTERDAM_PARKS_LAYER); + assert layer != null; + layer.setProperties( + fillColor( + composite( + "stroke-width", + interval( + stop(1, 1, fillColor(Color.RED)), + stop(10, 2, fillColor(Color.BLUE)), + stop(22, 3, fillColor(Color.GREEN)), + stop(1, 1, fillColor(Color.CYAN)), + stop(10, 2, fillColor(Color.GRAY)), + stop(22, 3, fillColor(Color.YELLOW)) + )) + ) + ); + + Timber.i("Fill color: %s", layer.getFillColor()); + } + + private void addCompositeCategoricalFunction() { + Timber.i("Add composite categorical function"); + FillLayer layer = mapboxMap.getLayerAs(AMSTERDAM_PARKS_LAYER); + assert layer != null; + layer.setProperties( + fillColor( + composite( + "name", + categorical( + stop(7f, "Westerpark", fillColor(Color.RED)), + stop(8f, "Westerpark", fillColor(Color.BLUE)), + stop(9f, "Westerpark", fillColor(Color.RED)), + stop(10f, "Westerpark", fillColor(Color.BLUE)), + stop(11f, "Westerpark", fillColor(Color.RED)), + stop(12f, "Westerpark", fillColor(Color.BLUE)), + stop(13f, "Westerpark", fillColor(Color.RED)), + stop(14f, "Westerpark", fillColor(Color.BLUE)), + stop(15f, "Westerpark", fillColor(Color.RED)), + stop(16f, "Westerpark", fillColor(Color.BLUE)), + stop(17f, "Westerpark", fillColor(Color.RED)), + stop(18f, "Westerpark", fillColor(Color.BLUE)), + stop(19f, "Westerpark", fillColor(Color.RED)), + stop(20f, "Westerpark", fillColor(Color.BLUE)), + stop(21f, "Westerpark", fillColor(Color.RED)), + stop(22f, "Westerpark", fillColor(Color.BLUE)), + stop(14f, "Jordaan", fillColor(Color.GREEN)), + stop(18f, "Jordaan", fillColor(Color.CYAN)), + stop(14f, "Prinseneiland", fillColor(Color.WHITE)), + stop(18f, "Prinseneiland", fillColor(Color.BLACK)) + )) + ) + ); + + Timber.i("Fill color: %s", layer.getFillColor()); + } + + private void addParksLayer() { + // Add a source + Source source; + try { + source = new GeoJsonSource("amsterdam-parks-source", readRawResource(R.raw.amsterdam)); + mapboxMap.addSource(source); + } catch (IOException ioException) { + Toast.makeText( + DataDrivenStyleActivity.this, + "Couldn't add source: " + ioException.getMessage(), + Toast.LENGTH_SHORT).show(); + return; + } + + + // Add a fill layer + mapboxMap.addLayer(new FillLayer(AMSTERDAM_PARKS_LAYER, source.getId()) + .withProperties( + fillColor(Color.BLACK), + fillOutlineColor(Color.BLUE), + fillAntialias(true) + ) + ); + } + + private String readRawResource(@RawRes int rawResource) throws IOException { + InputStream is = getResources().openRawResource(rawResource); + Writer writer = new StringWriter(); + char[] buffer = new char[1024]; + try { + 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(); + } + + return writer.toString(); + } +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GeoJsonClusteringActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GeoJsonClusteringActivity.java index 33fc7f60a6..80dfe777cb 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GeoJsonClusteringActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GeoJsonClusteringActivity.java @@ -3,12 +3,7 @@ package com.mapbox.mapboxsdk.testapp.activity.style; import android.graphics.Color; import android.os.Bundle; import android.support.v4.content.res.ResourcesCompat; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; - -import timber.log.Timber; - import android.view.MenuItem; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; @@ -25,6 +20,8 @@ import com.mapbox.mapboxsdk.testapp.R; import java.net.MalformedURLException; 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; @@ -36,7 +33,7 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textField; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textSize; /** - * Sample Activity to show off geojson source clustering and filter usage + * Test activity showcasing using a geojson source and visualise that source as a cluster by using filters. */ public class GeoJsonClusteringActivity extends AppCompatActivity { @@ -48,11 +45,9 @@ public class GeoJsonClusteringActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_geojson_clustering); - setupActionBar(); - - //Initialize map as normal + // Initialize map as normal mapView = (MapView) findViewById(R.id.mapView); - //noinspection ConstantConditions + // noinspection ConstantConditions mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @@ -61,7 +56,7 @@ public class GeoJsonClusteringActivity extends AppCompatActivity { mapboxMap = map; mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(37.7749, 122.4194), 0)); - //Add a clustered source with some layers + // Add a clustered source with some layers addClusteredGeoJsonSource(); } }); @@ -121,7 +116,7 @@ public class GeoJsonClusteringActivity extends AppCompatActivity { } private void addClusteredGeoJsonSource() { - //Add a clustered source + // Add a clustered source try { mapboxMap.addSource( new GeoJsonSource("earthquakes", @@ -136,11 +131,11 @@ public class GeoJsonClusteringActivity extends AppCompatActivity { Timber.e("That's not an url... " + malformedUrlException.getMessage()); } - //Add unclustered layer + // Add unclustered layer int[][] layers = new int[][] { - new int[] {150, ResourcesCompat.getColor(getResources(), R.color.red_accent, getTheme())}, - new int[] {20, ResourcesCompat.getColor(getResources(), R.color.green_accent, getTheme())}, - new int[] {0, ResourcesCompat.getColor(getResources(), R.color.blue_accent, getTheme())} + new int[] {150, ResourcesCompat.getColor(getResources(), R.color.redAccent, getTheme())}, + new int[] {20, ResourcesCompat.getColor(getResources(), R.color.greenAccent, getTheme())}, + new int[] {0, ResourcesCompat.getColor(getResources(), R.color.blueAccent, getTheme())} }; SymbolLayer unclustered = new SymbolLayer("unclustered-points", "earthquakes"); @@ -148,7 +143,7 @@ public class GeoJsonClusteringActivity extends AppCompatActivity { mapboxMap.addLayer(unclustered); for (int i = 0; i < layers.length; i++) { - //Add some nice circles + // Add some nice circles CircleLayer circles = new CircleLayer("cluster-" + i, "earthquakes"); circles.setProperties( circleColor(layers[i][1]), @@ -162,7 +157,7 @@ public class GeoJsonClusteringActivity extends AppCompatActivity { mapboxMap.addLayer(circles); } - //Add the count labels + // Add the count labels SymbolLayer count = new SymbolLayer("count", "earthquakes"); count.setProperties( textField("{point_count}"), @@ -172,18 +167,7 @@ public class GeoJsonClusteringActivity extends AppCompatActivity { mapboxMap.addLayer(count); - //Zoom out to start + // Zoom out to start mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(1)); } - - private void setupActionBar() { - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RealTimeGeoJsonActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RealTimeGeoJsonActivity.java index fad4f9714d..b9f7ebce35 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RealTimeGeoJsonActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RealTimeGeoJsonActivity.java @@ -3,13 +3,7 @@ package com.mapbox.mapboxsdk.testapp.activity.style; import android.os.Bundle; import android.os.Handler; import android.support.annotation.NonNull; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; - -import timber.log.Timber; - -import android.view.MenuItem; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; @@ -21,10 +15,12 @@ import com.mapbox.mapboxsdk.testapp.R; import java.net.MalformedURLException; import java.net.URL; +import timber.log.Timber; + import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage; /** - * Use realtime GeoJSON data streams to move a symbol on your map + * Test activity showcasing using realtime GeoJSON to move a symbol on your map * <p> * GL-native equivalent of https://www.mapbox.com/mapbox-gl-js/example/live-geojson/ * </p> @@ -46,15 +42,6 @@ public class RealTimeGeoJsonActivity extends AppCompatActivity implements OnMapR super.onCreate(savedInstanceState); setContentView(R.layout.activity_default); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(this); @@ -119,17 +106,6 @@ public class RealTimeGeoJsonActivity extends AppCompatActivity implements OnMapR mapView.onSaveInstanceState(outState); } - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - private static class RefreshGeoJsonRunnable implements Runnable { private MapboxMap mapboxMap; diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleActivity.java index 983f82c53a..af42b7a0fe 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleActivity.java @@ -4,9 +4,7 @@ import android.graphics.Color; import android.os.Bundle; import android.os.Handler; import android.support.annotation.RawRes; -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.widget.Toast; @@ -16,11 +14,12 @@ 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.style.functions.Function; +import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops; +import com.mapbox.mapboxsdk.style.functions.stops.Stop; import com.mapbox.mapboxsdk.style.layers.FillLayer; -import com.mapbox.mapboxsdk.style.layers.Function; import com.mapbox.mapboxsdk.style.layers.Layer; import com.mapbox.mapboxsdk.style.layers.LineLayer; -import com.mapbox.mapboxsdk.style.layers.NoSuchLayerException; import com.mapbox.mapboxsdk.style.layers.Property; import com.mapbox.mapboxsdk.style.layers.PropertyValue; import com.mapbox.mapboxsdk.style.layers.RasterLayer; @@ -45,13 +44,13 @@ import java.util.List; import timber.log.Timber; +import static com.mapbox.mapboxsdk.style.functions.Function.zoom; +import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop; +import static com.mapbox.mapboxsdk.style.functions.stops.Stops.exponential; import static com.mapbox.mapboxsdk.style.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.Function.Stop; -import static com.mapbox.mapboxsdk.style.layers.Function.stop; -import static com.mapbox.mapboxsdk.style.layers.Function.zoom; 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; @@ -71,7 +70,7 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.symbolPlacement; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility; /** - * Sample Activity to show off the runtime style api + * Test activity showcasing the runtime style API. */ public class RuntimeStyleActivity extends AppCompatActivity { @@ -83,9 +82,7 @@ public class RuntimeStyleActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_runtime_style); - setupActionBar(); - - //Initialize map as normal + // Initialize map as normal mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); @@ -93,10 +90,10 @@ public class RuntimeStyleActivity extends AppCompatActivity { mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(MapboxMap map) { - //Store for later + // Store for later mapboxMap = map; - //Center and Zoom (Amsterdam, zoomed to streets) + // Center and Zoom (Amsterdam, zoomed to streets) mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(52.379189, 4.899431), 14)); } }); @@ -153,8 +150,11 @@ public class RuntimeStyleActivity extends AppCompatActivity { @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); + case R.id.action_list_layers: + listLayers(); + return true; + case R.id.action_list_sources: + listSources(); return true; case R.id.action_water_color: setWaterColor(); @@ -203,6 +203,26 @@ public class RuntimeStyleActivity extends AppCompatActivity { } } + private void listLayers() { + List<Layer> layers = mapboxMap.getLayers(); + StringBuilder builder = new StringBuilder("Layers:"); + for (Layer layer : layers) { + builder.append("\n"); + builder.append(layer.getId()); + } + Toast.makeText(this, builder.toString(), Toast.LENGTH_LONG).show(); + } + + private void listSources() { + List<Source> sources = mapboxMap.getSources(); + StringBuilder builder = new StringBuilder("Sources:"); + for (Source source : sources) { + builder.append("\n"); + builder.append(source.getId()); + } + Toast.makeText(this, builder.toString(), Toast.LENGTH_LONG).show(); + } + private void setLayerInvisible() { String[] roadLayers = new String[] {"water"}; for (String roadLayer : roadLayers) { @@ -214,7 +234,7 @@ public class RuntimeStyleActivity extends AppCompatActivity { } private void setRoadSymbolPlacement() { - //Zoom so that the labels are visible first + // Zoom so that the labels are visible first mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(14), new DefaultCallback() { @Override public void onFinish() { @@ -251,16 +271,12 @@ public class RuntimeStyleActivity extends AppCompatActivity { } private void removeBuildings() { - //Zoom to see buildings first - try { - mapboxMap.removeLayer("building"); - } catch (NoSuchLayerException noSuchLayerException) { - Toast.makeText(RuntimeStyleActivity.this, noSuchLayerException.getMessage(), Toast.LENGTH_SHORT).show(); - } + // Zoom to see buildings first + mapboxMap.removeLayer("building"); } private void addParksLayer() { - //Add a source + // Add a source Source source; try { source = new GeoJsonSource("amsterdam-spots", readRawResource(R.raw.amsterdam)); @@ -282,18 +298,18 @@ public class RuntimeStyleActivity extends AppCompatActivity { fillAntialias(true) ); - //Only show me parks (except westerpark with stroke-width == 3) + // Only show me parks (except westerpark with stroke-width == 3) layer.setFilter(all(eq("type", "park"), eq("stroke-width", 2))); - mapboxMap.addLayer(layer, "building"); - //layer.setPaintProperty(fillColor(Color.RED)); //XXX But not after the object is attached + mapboxMap.addLayerBelow(layer, "building"); + // layer.setPaintProperty(fillColor(Color.RED)); // XXX But not after the object is attached - //Or get the object later and set it. It's all good. + // Or get the object later and set it. It's all good. mapboxMap.getLayer("parksLayer").setProperties(fillColor(Color.RED)); - //You can get a typed layer, if you're sure it's of that type. Use with care + // You can get a typed layer, if you're sure it's of that type. Use with care layer = mapboxMap.getLayerAs("parksLayer"); - //And get some properties + // And get some properties PropertyValue<Boolean> fillAntialias = layer.getFillAntialias(); Timber.d("Fill anti alias: " + fillAntialias.getValue()); layer.setProperties(fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP)); @@ -302,12 +318,12 @@ public class RuntimeStyleActivity extends AppCompatActivity { PropertyValue<String> visibility = layer.getVisibility(); Timber.d("Visibility: " + visibility.getValue()); - //Get a good look at it all + // Get a good look at it all mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(12)); } private void addDynamicParksLayer() { - //Load some data + // Load some data FeatureCollection parks; try { String json = readRawResource(R.raw.amsterdam); @@ -321,7 +337,7 @@ public class RuntimeStyleActivity extends AppCompatActivity { return; } - //Add an empty source + // Add an empty source mapboxMap.addSource(new GeoJsonSource("dynamic-park-source")); FillLayer layer = new FillLayer("dynamic-parks-layer", "dynamic-park-source"); @@ -332,15 +348,15 @@ public class RuntimeStyleActivity extends AppCompatActivity { fillAntialias(true) ); - //Only show me parks + // Only show me parks layer.setFilter(all(eq("type", "park"))); mapboxMap.addLayer(layer); - //Get a good look at it all + // Get a good look at it all mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(12)); - //Animate the parks source + // Animate the parks source animateParksSource(parks, 0); } @@ -354,7 +370,7 @@ public class RuntimeStyleActivity extends AppCompatActivity { } Timber.d("Updating parks source"); - //change the source + // change the source int park = counter < parks.getFeatures().size() - 1 ? counter : 0; GeoJsonSource source = mapboxMap.getSourceAs("dynamic-park-source"); @@ -369,14 +385,14 @@ public class RuntimeStyleActivity extends AppCompatActivity { features.add(parks.getFeatures().get(park)); source.setGeoJson(FeatureCollection.fromFeatures(features)); - //Re-post + // Re-post animateParksSource(parks, park + 1); } }, counter == 0 ? 100 : 1000); } private void addTerrainLayer() { - //Add a source + // Add a source Source source = new VectorSource("my-terrain-source", "mapbox://mapbox.mapbox-terrain-v2"); mapboxMap.addSource(source); @@ -391,10 +407,10 @@ public class RuntimeStyleActivity extends AppCompatActivity { mapboxMap.addLayer(layer); - //Need to get a fresh handle + // Need to get a fresh handle layer = mapboxMap.getLayerAs("terrainLayer"); - //Make sure it's also applied after the fact + // Make sure it's also applied after the fact layer.setMinZoom(10); layer.setMaxZoom(15); @@ -404,11 +420,11 @@ public class RuntimeStyleActivity extends AppCompatActivity { } private void addSatelliteLayer() { - //Add a source + // Add a source Source source = new RasterSource("my-raster-source", "mapbox://mapbox.satellite", 512); mapboxMap.addSource(source); - //Add a layer + // Add a layer mapboxMap.addLayer(new RasterLayer("satellite-layer", "my-raster-source")); } @@ -418,24 +434,29 @@ public class RuntimeStyleActivity extends AppCompatActivity { return; } - //Set a zoom function to update the color of the water - layer.setProperties(fillColor(zoom(0.8f, - stop(1, fillColor(Color.GREEN)), - stop(4, fillColor(Color.BLUE)), - stop(12, fillColor(Color.RED)), - stop(20, fillColor(Color.BLACK)) - ))); - - //do some animations to show it off properly + // Set a zoom function to update the color of the water + layer.setProperties(fillColor( + zoom( + exponential( + stop(1, fillColor(Color.GREEN)), + stop(4, fillColor(Color.BLUE)), + stop(12, fillColor(Color.RED)), + stop(20, fillColor(Color.BLACK)) + ).withBase(0.8f) + ) + )); + + // do some animations to show it off properly mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(1), 1500); PropertyValue<String> fillColor = layer.getFillColor(); - Function<String> function = fillColor.getFunction(); + Function<Float, String> function = (Function<Float, String>) fillColor.getFunction(); if (function != null) { - Timber.d("Fill color base: " + function.getBase()); - Timber.d("Fill color #stops: " + function.getStops().length); + ExponentialStops<Float, String> stops = (ExponentialStops) function.getStops(); + Timber.d("Fill color base: " + stops.getBase()); + Timber.d("Fill color #stops: " + stops.size()); if (function.getStops() != null) { - for (Stop stop : function.getStops()) { + for (Stop<Float, String> stop : stops) { Timber.d("Fill color #stops: " + stop); } } @@ -459,23 +480,12 @@ public class RuntimeStyleActivity extends AppCompatActivity { return writer.toString(); } - private void setupActionBar() { - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - } - private void addCustomTileSource() { - //Add a source + // Add a source Source source = new VectorSource("custom-tile-source", new TileSet("2.1.0", "https://vector.mapzen.com/osm/all/{z}/{x}/{y}.mvt?api_key=vector-tiles-LM25tq4")); mapboxMap.addSource(source); - //Add a layer + // Add a layer mapboxMap.addLayer( new FillLayer("custom-tile-layers", "custom-tile-source") .withSourceLayer("water") @@ -577,12 +587,12 @@ public class RuntimeStyleActivity extends AppCompatActivity { @Override public void onCancel() { - //noop + // noop } @Override public void onFinish() { - //noop + // noop } } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTestActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTestActivity.java index 1d242359bc..910233accf 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTestActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTestActivity.java @@ -9,7 +9,7 @@ import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.testapp.R; /** - * Test activity for unit test execution + * Test activity used for instrumentation test execution. */ public class RuntimeStyleTestActivity extends AppCompatActivity { @@ -21,7 +21,7 @@ public class RuntimeStyleTestActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_runtime_style); - //Initialize map as normal + // Initialize map as normal mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTimingTestActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTimingTestActivity.java index c57bc0069a..5057578731 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTimingTestActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTimingTestActivity.java @@ -29,7 +29,7 @@ public class RuntimeStyleTimingTestActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_runtime_style); - //Initialize map as normal + // Initialize map as normal mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/StyleFileActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/StyleFileActivity.java index 73e6bc985a..6906e90f6e 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/StyleFileActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/StyleFileActivity.java @@ -6,10 +6,7 @@ import android.support.annotation.NonNull; import android.support.annotation.RawRes; import android.support.design.widget.FloatingActionButton; import android.support.v4.content.ContextCompat; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.MenuItem; import android.view.View; import android.widget.Toast; @@ -32,7 +29,7 @@ import java.io.Writer; import timber.log.Timber; /** - * Example on how to use a file:// resource for the style.json + * Test activity showcasing how to use a file:// resource for the style.json */ public class StyleFileActivity extends AppCompatActivity { @@ -44,15 +41,6 @@ public class StyleFileActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_style_file); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @@ -93,7 +81,7 @@ public class StyleFileActivity extends AppCompatActivity { } protected void onPostExecute(Long result) { - //Actual file:// usage + // Actual file:// usage mapboxMap.setStyleUrl("file://" + cacheStyleFile.getAbsolutePath()); } @@ -168,15 +156,4 @@ public class StyleFileActivity extends AppCompatActivity { super.onDestroy(); mapView.onDestroy(); } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java index be71e58eba..82da905413 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java @@ -5,9 +5,7 @@ import android.graphics.Color; import android.graphics.PointF; 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; @@ -37,7 +35,7 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textFont; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textSize; /** - * Example to test runtime manipulation of symbol layers + * Test activity showcasing runtime manipulation of symbol layers. */ public class SymbolLayerActivity extends AppCompatActivity implements MapboxMap.OnMapClickListener { @@ -51,15 +49,6 @@ public class SymbolLayerActivity extends AppCompatActivity implements MapboxMap. super.onCreate(savedInstanceState); setContentView(R.layout.activity_symbollayer); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @@ -67,21 +56,21 @@ public class SymbolLayerActivity extends AppCompatActivity implements MapboxMap. public void onMapReady(@NonNull final MapboxMap map) { mapboxMap = map; - //Add a image for the makers + // Add a image for the makers mapboxMap.addImage( "my-marker-image", BitmapFactory.decodeResource(SymbolLayerActivity.this.getResources(), R.drawable.mapbox_marker_icon_default) ); - //Add a source + // Add a source FeatureCollection markers = FeatureCollection.fromFeatures(new Feature[] { Feature.fromGeometry(Point.fromCoordinates(new double[] {4.91638, 52.35673}), featureProperties("Marker 1")), Feature.fromGeometry(Point.fromCoordinates(new double[] {4.91638, 52.34673}), featureProperties("Marker 2")) }); mapboxMap.addSource(new GeoJsonSource(MARKER_SOURCE, markers)); - //Add the symbol-layer + // Add the symbol-layer mapboxMap.addLayer( new SymbolLayer(MARKER_LAYER, MARKER_SOURCE) .withProperties( @@ -93,10 +82,10 @@ public class SymbolLayerActivity extends AppCompatActivity implements MapboxMap. ) ); - //Show + // Show mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(52.35273, 4.91638), 14)); - //Set a click-listener so we can manipulate the map + // Set a click-listener so we can manipulate the map mapboxMap.setOnMapClickListener(SymbolLayerActivity.this); } }); @@ -104,13 +93,13 @@ public class SymbolLayerActivity extends AppCompatActivity implements MapboxMap. @Override public void onMapClick(@NonNull LatLng point) { - //Query which features are clicked + // Query which features are clicked PointF screenLoc = mapboxMap.getProjection().toScreenLocation(point); List<Feature> features = mapboxMap.queryRenderedFeatures(screenLoc, MARKER_LAYER); SymbolLayer layer = mapboxMap.getLayerAs(MARKER_LAYER); if (features.size() == 0) { - //Reset + // Reset layer.setProperties(iconSize(1f)); } else { layer.setProperties(iconSize(3f)); @@ -195,9 +184,6 @@ public class SymbolLayerActivity extends AppCompatActivity implements MapboxMap. @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; case R.id.action_toggle_text_size: toggleTextSize(); return true; @@ -211,5 +197,4 @@ public class SymbolLayerActivity extends AppCompatActivity implements MapboxMap. return super.onOptionsItemSelected(item); } } - -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java index e20455b1ce..d31bd1fa51 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationDrawableActivity.java @@ -9,25 +9,25 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.MenuItem; 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.location.LocationListener; -import com.mapbox.mapboxsdk.location.LocationServices; +import com.mapbox.mapboxsdk.location.LocationSource; import com.mapbox.mapboxsdk.maps.MapView; import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.MapboxMapOptions; import com.mapbox.mapboxsdk.maps.OnMapReadyCallback; import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.services.android.telemetry.location.LocationEngineListener; -public class MyLocationDrawableActivity extends AppCompatActivity implements LocationListener { +/** + * Test activity showcasing how to change the MyLocationView drawable. + */ +public class MyLocationDrawableActivity extends AppCompatActivity implements LocationEngineListener { private static final int PERMISSIONS_LOCATION = 0; @@ -38,14 +38,6 @@ public class MyLocationDrawableActivity extends AppCompatActivity implements Loc protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my_location_customization); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - final ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } findViewById(R.id.progress).setVisibility(View.GONE); @@ -53,8 +45,8 @@ public class MyLocationDrawableActivity extends AppCompatActivity implements Loc mapboxMapOptions.styleUrl(Style.MAPBOX_STREETS); // configure MyLocationView drawables - mapboxMapOptions.myLocationForegroundDrawable(ContextCompat.getDrawable(this, R.drawable.ic_chelsea)); - mapboxMapOptions.myLocationBackgroundDrawable(ContextCompat.getDrawable(this, R.drawable.ic_arsenal)); + 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, @@ -103,7 +95,7 @@ public class MyLocationDrawableActivity extends AppCompatActivity implements Loc if (location != null) { onLocationChanged(location); } else { - LocationServices.getLocationServices(this).addLocationListener(this); + LocationSource.getLocationEngine(this).addLocationEngineListener(this); } } else { mapboxMap.setMyLocationEnabled(false); @@ -120,6 +112,11 @@ public class MyLocationDrawableActivity extends AppCompatActivity implements Loc } @Override + public void onConnected() { + // Nothing + } + + @Override public void onLocationChanged(Location location) { if (mapboxMap != null) { mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 14)); @@ -167,16 +164,4 @@ public class MyLocationDrawableActivity extends AppCompatActivity implements Loc super.onLowMemory(); mapView.onLowMemory(); } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java index 2da3bedcbf..0417b1829f 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTintActivity.java @@ -12,25 +12,25 @@ import android.support.annotation.Nullable; import android.support.annotation.UiThread; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.MenuItem; 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.location.LocationListener; -import com.mapbox.mapboxsdk.location.LocationServices; +import com.mapbox.mapboxsdk.location.LocationSource; 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.widgets.MyLocationViewSettings; import com.mapbox.mapboxsdk.testapp.R; +import com.mapbox.services.android.telemetry.location.LocationEngineListener; -public class MyLocationTintActivity extends AppCompatActivity implements LocationListener { +/** + * Test activity showcasing how to tint the MyLocationView. + */ +public class MyLocationTintActivity extends AppCompatActivity implements LocationEngineListener { private MapView mapView; private MapboxMap mapboxMap; @@ -43,15 +43,6 @@ public class MyLocationTintActivity extends AppCompatActivity implements Locatio super.onCreate(savedInstanceState); setContentView(R.layout.activity_my_location_dot_color); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @@ -94,9 +85,9 @@ public class MyLocationTintActivity extends AppCompatActivity implements Locatio @Override public void onClick(View view) { myLocationViewSettings.setAccuracyTintColor( - ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapbox_green)); + ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapboxGreen)); myLocationViewSettings.setForegroundTintColor( - ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapbox_green)); + ContextCompat.getColor(MyLocationTintActivity.this, R.color.mapboxGreen)); myLocationViewSettings.setBackgroundTintColor(Color.WHITE); } }); @@ -133,6 +124,11 @@ public class MyLocationTintActivity extends AppCompatActivity implements Locatio } @Override + public void onConnected() { + // Nothing + } + + @Override public void onLocationChanged(Location location) { if (mapboxMap != null && firstRun) { mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 15)); @@ -144,7 +140,7 @@ public class MyLocationTintActivity extends AppCompatActivity implements Locatio protected void onStart() { super.onStart(); mapView.onStart(); - LocationServices.getLocationServices(this).addLocationListener(this); + LocationSource.getLocationEngine(this).addLocationEngineListener(this); } @Override @@ -162,7 +158,7 @@ public class MyLocationTintActivity extends AppCompatActivity implements Locatio @Override protected void onStop() { super.onStop(); - LocationServices.getLocationServices(this).removeLocationListener(this); + LocationSource.getLocationEngine(this).removeLocationEngineListener(this); mapView.onStop(); } @@ -184,17 +180,6 @@ public class MyLocationTintActivity extends AppCompatActivity implements Locatio mapView.onSaveInstanceState(outState); } - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - @UiThread public void toggleGps(boolean enableGps) { if (enableGps) { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationToggleActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationToggleActivity.java index e522840038..9e98d8c6b9 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationToggleActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationToggleActivity.java @@ -5,23 +5,22 @@ import android.content.pm.PackageManager; import android.location.Location; import android.os.Bundle; import android.support.annotation.NonNull; -import android.support.annotation.Nullable; import android.support.annotation.UiThread; import android.support.design.widget.FloatingActionButton; import android.support.v4.app.ActivityCompat; -import android.support.v4.content.ContextCompat; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.MenuItem; import android.view.View; -import com.mapbox.mapboxsdk.camera.CameraPosition; +import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.geometry.LatLng; +import com.mapbox.mapboxsdk.location.LocationSource; 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.services.android.telemetry.location.LocationEngine; +import com.mapbox.services.android.telemetry.location.LocationEngineListener; +import com.mapbox.services.android.telemetry.permissions.PermissionsManager; public class MyLocationToggleActivity extends AppCompatActivity { @@ -29,6 +28,9 @@ public class MyLocationToggleActivity extends AppCompatActivity { private MapboxMap mapboxMap; private FloatingActionButton locationToggleFab; + private LocationEngine locationServices; + private LocationEngineListener locationListener; + private static final int PERMISSIONS_LOCATION = 0; @Override @@ -36,15 +38,7 @@ public class MyLocationToggleActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my_location_toggle); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - final ActionBar actionBar = getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayShowTitleEnabled(true); - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } + locationServices = LocationSource.getLocationEngine(this); mapView = (MapView) findViewById(R.id.mapView); mapView.onCreate(savedInstanceState); @@ -100,6 +94,11 @@ public class MyLocationToggleActivity extends AppCompatActivity { protected void onDestroy() { super.onDestroy(); mapView.onDestroy(); + // Ensure no memory leak occurs if we register the location listener but the call hasn't + // been made yet. + if (locationListener != null) { + locationServices.removeLocationEngineListener(locationListener); + } } @Override @@ -108,27 +107,11 @@ public class MyLocationToggleActivity extends AppCompatActivity { mapView.onLowMemory(); } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - return true; - default: - return false; - } - } - @UiThread public void toggleGps(boolean enableGps) { if (enableGps) { - if ((ContextCompat.checkSelfPermission(this, - Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) - || (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) - != PackageManager.PERMISSION_GRANTED)) { - ActivityCompat.requestPermissions(this, new String[] { - Manifest.permission.ACCESS_COARSE_LOCATION, + if (!PermissionsManager.areLocationPermissionsGranted(this)) { + ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_LOCATION); } else { enableLocation(true); @@ -140,25 +123,37 @@ public class MyLocationToggleActivity extends AppCompatActivity { private void enableLocation(boolean enabled) { if (enabled) { - mapboxMap.setOnMyLocationChangeListener(new MapboxMap.OnMyLocationChangeListener() { - @Override - public void onMyLocationChange(@Nullable Location location) { - if (location != null) { - mapboxMap.setCameraPosition(new CameraPosition.Builder() - .target(new LatLng(location)) - .zoom(16) - .bearing(0) - .tilt(0) - .build()); - mapboxMap.setOnMyLocationChangeListener(null); - } + // To move the camera instantly, we attempt to get the last known location and either + // ease or animate the camera to that position depending on the zoom level. + Location lastLocation = LocationSource.getLocationEngine(this).getLastLocation(); + + if (lastLocation != null) { + if (mapboxMap.getCameraPosition().zoom > 15.99) { + mapboxMap.easeCamera(CameraUpdateFactory.newLatLng(new LatLng(lastLocation)), 1000); + } else { + mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lastLocation), 16), 1000); } - }); - locationToggleFab.setImageResource(R.drawable.ic_location_disabled_24dp); + } else { + locationListener = new LocationEngineListener() { + @Override + public void onConnected() { + // Nothing + } + + @Override + public void onLocationChanged(Location location) { + if (location != null) { + mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location), 16)); + locationServices.removeLocationEngineListener(this); + } + } + }; + locationServices.addLocationEngineListener(locationListener); + } + locationToggleFab.setImageResource(R.drawable.ic_location_disabled); } else { - locationToggleFab.setImageResource(R.drawable.ic_my_location_24dp); + locationToggleFab.setImageResource(R.drawable.ic_my_location); } - mapboxMap.setMyLocationEnabled(enabled); } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java index 3d08399abf..3a3301b87f 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/userlocation/MyLocationTrackingModeActivity.java @@ -1,15 +1,7 @@ package com.mapbox.mapboxsdk.testapp.activity.userlocation; -import android.Manifest; -import android.content.pm.PackageManager; -import android.location.Location; 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.v4.app.ActivityCompat; -import android.support.v4.content.ContextCompat; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; @@ -21,11 +13,8 @@ import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.Toast; -import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; -import com.mapbox.mapboxsdk.constants.MapboxConstants; 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; @@ -33,20 +22,26 @@ import com.mapbox.mapboxsdk.maps.TrackingSettings; import com.mapbox.mapboxsdk.maps.UiSettings; import com.mapbox.mapboxsdk.testapp.R; -public class MyLocationTrackingModeActivity extends AppCompatActivity - implements MapboxMap.OnMyLocationChangeListener, AdapterView.OnItemSelectedListener { +/** + * 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 { 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 Location location; - private static final int PERMISSIONS_LOCATION = 0; + private MenuItem dismissLocationTrackingOnGestureItem; private MenuItem dismissBearingTrackingOnGestureItem; private MenuItem enableRotateGesturesItem; @@ -91,8 +86,6 @@ public class MyLocationTrackingModeActivity extends AppCompatActivity bearingSpinner.setOnItemSelectedListener(MyLocationTrackingModeActivity.this); setCheckBoxes(); - mapboxMap.setOnMyLocationChangeListener(MyLocationTrackingModeActivity.this); - mapboxMap.setOnMyLocationTrackingModeChangeListener(new MapboxMap.OnMyLocationTrackingModeChangeListener() { @Override public void onMyLocationTrackingModeChange(@MyLocationTracking.Mode int myLocationTrackingMode) { @@ -131,91 +124,12 @@ public class MyLocationTrackingModeActivity extends AppCompatActivity }); if (savedInstanceState == null) { - toggleGps(true); + mapboxMap.setMyLocationEnabled(true); } } }); } - @UiThread - public void toggleGps(boolean enableGps) { - if (enableGps) { - if ((ContextCompat.checkSelfPermission(this, - Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) - || (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) - != PackageManager.PERMISSION_GRANTED)) { - ActivityCompat.requestPermissions(this, new String[] { - Manifest.permission.ACCESS_COARSE_LOCATION, - Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_LOCATION); - } else { - enableLocation(true); - } - } else { - enableLocation(false); - } - } - - private void enableLocation(boolean enabled) { - if (enabled) { - mapboxMap.setMyLocationEnabled(true); - Location location = mapboxMap.getMyLocation(); - if (location != null) { - setInitialPosition(new LatLng(location)); - } - } else { - mapboxMap.setMyLocationEnabled(false); - } - } - - @Override - public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { - if (requestCode == PERMISSIONS_LOCATION) { - if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { - enableLocation(true); - } - } - } - - private void setInitialPosition(LatLng latLng) { - mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 14)); - mapboxMap.setMyLocationEnabled(true); - locationSpinner.setEnabled(true); - bearingSpinner.setEnabled(true); - } - - @Override - public void onMyLocationChange(@Nullable Location location) { - if (location != null) { - if (this.location == null) { - // initial location to reposition map - setInitialPosition(new LatLng(location)); - } - this.location = location; - showSnackBar(); - } - } - - private void showSnackBar() { - String desc = "Loc Chg: "; - boolean noInfo = true; - if (location.hasSpeed()) { - desc += String.format(MapboxConstants.MAPBOX_LOCALE, "Spd = %.1f km/h ", location.getSpeed() * 3.6f); - noInfo = false; - } - if (location.hasAltitude()) { - desc += String.format(MapboxConstants.MAPBOX_LOCALE, "Alt = %.0f m ", location.getAltitude()); - noInfo = false; - } - if (location.hasAccuracy()) { - desc += String.format(MapboxConstants.MAPBOX_LOCALE, "Acc = %.0f m", location.getAccuracy()); - } - - if (noInfo) { - desc += "No extra info"; - } - Snackbar.make(findViewById(android.R.id.content), desc, Snackbar.LENGTH_SHORT).show(); - } - @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) throws SecurityException { TrackingSettings trackingSettings = mapboxMap.getTrackingSettings(); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureAdapter.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureAdapter.java index a935c2134f..7ac3401a0d 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureAdapter.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureAdapter.java @@ -13,6 +13,12 @@ import com.mapbox.mapboxsdk.testapp.utils.FontCache; import java.util.List; +/** + * Adapter used for FeatureOverviewActivity. + * <p> + * Adapts a Feature to a visual representation to be shown in a RecyclerView. + * </p> + */ public class FeatureAdapter extends RecyclerView.Adapter<FeatureAdapter.ViewHolder> { private List<Feature> features; @@ -52,4 +58,4 @@ public class FeatureAdapter extends RecyclerView.Adapter<FeatureAdapter.ViewHold public int getItemCount() { return features.size(); } -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureSectionAdapter.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureSectionAdapter.java index 012bbed4ca..1d89f89f08 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureSectionAdapter.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/adapter/FeatureSectionAdapter.java @@ -91,7 +91,8 @@ public class FeatureSectionAdapter extends RecyclerView.Adapter<RecyclerView.Vie @Override public void onBindViewHolder(RecyclerView.ViewHolder sectionViewHolder, int position) { if (isSectionHeaderPosition(position)) { - ((SectionViewHolder) sectionViewHolder).title.setText(sections.get(position).title); + String cleanTitle = sections.get(position).title.toString().replace("_", " "); + ((SectionViewHolder) sectionViewHolder).title.setText(cleanTitle); } else { adapter.onBindViewHolder(sectionViewHolder, getConvertedPosition(position)); } @@ -176,4 +177,4 @@ public class FeatureSectionAdapter extends RecyclerView.Adapter<RecyclerView.Vie return (valid ? adapter.getItemCount() + sections.size() : 0); } -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CityStateMarker.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CityStateMarker.java index 3b9f67aa1e..15b2f0b127 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CityStateMarker.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CityStateMarker.java @@ -15,4 +15,4 @@ public class CityStateMarker extends Marker { return infoWindowBackgroundColor; } -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarker.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarker.java index af97c9df69..6b172ef83f 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarker.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarker.java @@ -21,4 +21,4 @@ public class CountryMarker extends Marker { public int getFlagRes() { return flagRes; } -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerViewOptions.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerViewOptions.java index 4dc9195ffd..6602054f47 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerViewOptions.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/CountryMarkerViewOptions.java @@ -96,4 +96,4 @@ public class CountryMarkerViewOptions extends BaseMarkerViewOptions<CountryMarke return new CountryMarkerViewOptions[size]; } }; -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerView.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerView.java index 971c3359b2..b01c9907e0 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerView.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerView.java @@ -8,4 +8,4 @@ public class PulseMarkerView extends MarkerView { public PulseMarkerView(BaseMarkerViewOptions baseMarkerViewOptions) { super(baseMarkerViewOptions); } -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerViewOptions.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerViewOptions.java index 20c479fc9b..d9c6357774 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerViewOptions.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerViewOptions.java @@ -76,4 +76,4 @@ public class PulseMarkerViewOptions extends BaseMarkerViewOptions<PulseMarkerVie return new CountryMarkerViewOptions[size]; } }; -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/TextMarkerView.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/TextMarkerView.java index f507c5f1ab..dcee5c2409 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/TextMarkerView.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/TextMarkerView.java @@ -15,4 +15,4 @@ public class TextMarkerView extends MarkerView { public String getText() { return text; } -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/other/OfflineDownloadRegionDialog.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/other/OfflineDownloadRegionDialog.java index b70144123f..c4aa934139 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/other/OfflineDownloadRegionDialog.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/other/OfflineDownloadRegionDialog.java @@ -37,7 +37,7 @@ public class OfflineDownloadRegionDialog extends DialogFragment { final EditText regionNameEdit = new EditText(getActivity()); builder.setTitle("Choose a name for the region") - .setIcon(R.drawable.ic_airplanemode_active_black_24dp) + .setIcon(R.drawable.ic_airplanemode_active_black) .setView(regionNameEdit) .setPositiveButton("Start", new DialogInterface.OnClickListener() { @Override diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/other/OfflineListRegionsDialog.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/other/OfflineListRegionsDialog.java index 65c4102a8c..f717daeada 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/other/OfflineListRegionsDialog.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/other/OfflineListRegionsDialog.java @@ -28,7 +28,7 @@ public class OfflineListRegionsDialog extends DialogFragment { CharSequence[] items = offlineRegionsNames.toArray(new CharSequence[offlineRegionsNames.size()]); builder.setTitle("List of offline regions") - .setIcon(R.drawable.ic_airplanemode_active_black_24dp) + .setIcon(R.drawable.ic_airplanemode_active_black) .setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/FontCache.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/FontCache.java index e2271bd5ff..10ecf43bd3 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/FontCache.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/FontCache.java @@ -23,4 +23,4 @@ public class FontCache { } return tf; } -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/IconUtils.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/IconUtils.java new file mode 100644 index 0000000000..b6768a91a3 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/IconUtils.java @@ -0,0 +1,31 @@ +package com.mapbox.mapboxsdk.testapp.utils; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.drawable.Drawable; +import android.support.annotation.ColorInt; +import android.support.annotation.DrawableRes; +import android.support.annotation.NonNull; +import android.support.v4.content.res.ResourcesCompat; +import android.support.v4.graphics.drawable.DrawableCompat; + +import com.mapbox.mapboxsdk.annotations.Icon; +import com.mapbox.mapboxsdk.annotations.IconFactory; + +public class IconUtils { + + /** + * Demonstrates converting any Drawable to an Icon, for use as a marker icon. + */ + public static Icon drawableToIcon(@NonNull Context context, @DrawableRes int id, @ColorInt int colorRes) { + Drawable vectorDrawable = ResourcesCompat.getDrawable(context.getResources(), id, context.getTheme()); + Bitmap bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(), + vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(bitmap); + vectorDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); + DrawableCompat.setTint(vectorDrawable, colorRes); + vectorDrawable.draw(canvas); + return IconFactory.getInstance(context).fromBitmap(bitmap); + } +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/ItemClickSupport.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/ItemClickSupport.java index 414a781544..0939181ef4 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/ItemClickSupport.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/ItemClickSupport.java @@ -92,4 +92,4 @@ public class ItemClickSupport { boolean onItemLongClicked(RecyclerView recyclerView, int position, View view); } -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/TimingLogger.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/TimingLogger.java index e096aa202d..6f20d6fb0f 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/TimingLogger.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/TimingLogger.java @@ -106,7 +106,7 @@ public class TimingLogger { * dumpToLog call will do nothing. */ public void reset() { - disabled = false; //!Log.isLoggable(tag, Log.VERBOSE); + disabled = false; // !Log.isLoggable(tag, Log.VERBOSE); if (disabled) { return; } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/ToolbarComposer.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/ToolbarComposer.java deleted file mode 100644 index 3fa3bcd26f..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/utils/ToolbarComposer.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.mapbox.mapboxsdk.testapp.utils; - -import android.support.annotation.IdRes; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; - -import com.mapbox.mapboxsdk.testapp.R; - -/** - * Helper class to compose a Toolbar in an AppCompatActivity - */ -public class ToolbarComposer { - - - /** - * Initialises an up navigation toolbar with id R.id.toolbar on an AppCompatActivity. - * - * @param activity The activity hosting the Toolbar with id R.id.toolbar - */ - @Nullable - public static Toolbar initDefaultUpToolbar(@NonNull AppCompatActivity activity) { - return initDefaultUpToolbar(activity, R.id.toolbar); - } - - /** - * Initialises an up navigation toolbar given a view id on an AppCompatActivity. - * - * @param activity The activity hosting the Toolbar - * @param toolbarRes The view id resource used to look up the Toolbar - */ - @Nullable - public static Toolbar initDefaultUpToolbar(@NonNull AppCompatActivity activity, @IdRes int toolbarRes) { - Toolbar toolbar = (Toolbar) activity.findViewById(toolbarRes); - if (toolbar != null) { - activity.setSupportActionBar(toolbar); - - ActionBar actionBar = activity.getSupportActionBar(); - if (actionBar != null) { - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setDisplayShowHomeEnabled(true); - } - } - return toolbar; - } - -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/anim/pulse.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/anim/pulse.xml deleted file mode 100644 index 40bc57ab68..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/anim/pulse.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<set xmlns:android="http://schemas.android.com/apk/res/android" - android:interpolator="@android:anim/decelerate_interpolator"> - - <scale - android:duration="1000" - android:fromXScale="1" - android:fromYScale="1" - android:pivotX="50%" - android:pivotY="50%" - android:repeatCount="infinite" - android:repeatMode="restart" - android:toXScale="1.8" - android:toYScale="1.8"/> - - <set android:startOffset="200"> - <alpha - android:duration="800" - android:fromAlpha="1.0" - android:repeatCount="infinite" - android:repeatMode="restart" - android:toAlpha="0.0"/> - </set> -</set>
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/animator/rotate_360.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/animator/rotate_360.xml deleted file mode 100644 index e3569966d2..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/animator/rotate_360.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<set xmlns:android="http://schemas.android.com/apk/res/android"> - <objectAnimator - android:propertyName="rotation" - android:valueFrom="0" - android:valueTo="360" - android:valueType="floatType"/> -</set>
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/animator/scale_down.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/animator/scale_down.xml index d1067b09c2..f450edb1fb 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/animator/scale_down.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/animator/scale_down.xml @@ -8,4 +8,4 @@ android:propertyName="scaleY" android:duration="300" android:valueTo="1"/> -</set>
\ No newline at end of file +</set> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/animator/scale_up.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/animator/scale_up.xml index b43ed05513..f8da05f35e 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/animator/scale_up.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/animator/scale_up.xml @@ -8,4 +8,4 @@ android:propertyName="scaleY" android:duration="300" android:valueTo="2"/> -</set>
\ No newline at end of file +</set> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/ic_android.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/ic_android.png Binary files differnew file mode 100644 index 0000000000..a20277dc1b --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/ic_android.png diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/ic_android_2.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/ic_android_2.png Binary files differnew file mode 100644 index 0000000000..d1c802c265 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/ic_android_2.png diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/ic_drawer.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/ic_drawer.png Binary files differdeleted file mode 100644 index c59f601ca3..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-hdpi/ic_drawer.png +++ /dev/null diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/ic_android.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/ic_android.png Binary files differnew file mode 100644 index 0000000000..114bb25199 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/ic_android.png diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/ic_android_2.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/ic_android_2.png Binary files differnew file mode 100644 index 0000000000..62867cdca4 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/ic_android_2.png diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/ic_drawer.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/ic_drawer.png Binary files differdeleted file mode 100644 index 1ed2c56ee4..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-mdpi/ic_drawer.png +++ /dev/null diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/ic_android.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/ic_android.png Binary files differnew file mode 100644 index 0000000000..e80400c4dd --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/ic_android.png diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/ic_android_2.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/ic_android_2.png Binary files differnew file mode 100644 index 0000000000..1b34d09842 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/ic_android_2.png diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/ic_drawer.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/ic_drawer.png Binary files differdeleted file mode 100644 index a5fa74def4..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xhdpi/ic_drawer.png +++ /dev/null diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_android.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_android.png Binary files differnew file mode 100644 index 0000000000..19be40bf88 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_android.png diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_android_2.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_android_2.png Binary files differnew file mode 100644 index 0000000000..b44cec791f --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_android_2.png diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_arsenal.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_arsenal.png Binary files differdeleted file mode 100644 index 6fdac4ef09..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_arsenal.png +++ /dev/null diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_chelsea.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_chelsea.png Binary files differdeleted file mode 100644 index 6cd376b281..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_chelsea.png +++ /dev/null diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_drawer.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_drawer.png Binary files differdeleted file mode 100644 index 9c4685d6e0..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxhdpi/ic_drawer.png +++ /dev/null diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/ic_android.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/ic_android.png Binary files differnew file mode 100644 index 0000000000..c2c4373973 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/ic_android.png diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/ic_android_2.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/ic_android_2.png Binary files differnew file mode 100644 index 0000000000..b735fda69f --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/ic_android_2.png diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/ic_taxi_top_small.png b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/ic_taxi_top_small.png Binary files differdeleted file mode 100644 index e04c199160..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable-xxxhdpi/ic_taxi_top_small.png +++ /dev/null diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_add_24dp.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_add.xml index 6cdfce3074..6cdfce3074 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_add_24dp.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_add.xml diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_add_a_photo_black_24dp.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_add_a_photo_black.xml index 3d2ba42f3e..3d2ba42f3e 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_add_a_photo_black_24dp.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_add_a_photo_black.xml diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_airplanemode_active_black_24dp.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_airplanemode_active_black.xml index 55a8d22a54..55a8d22a54 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_airplanemode_active_black_24dp.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_airplanemode_active_black.xml diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_circle.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_circle.xml index 006b2ce5a8..3217661b64 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_circle.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_circle.xml @@ -9,4 +9,4 @@ <size android:width="@dimen/circle_size" android:height="@dimen/circle_size"/> -</shape>
\ No newline at end of file +</shape> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_clear_24dp.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_clear_24dp.xml deleted file mode 100644 index 1e2d044bee..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_clear_24dp.xml +++ /dev/null @@ -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="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/> -</vector> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_delete_24dp.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_delete.xml index f0e8643c35..f0e8643c35 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_delete_24dp.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_delete.xml diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_directions_bus_black_24dp.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_directions_bus_black.xml index e16e259792..e16e259792 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_directions_bus_black_24dp.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_directions_bus_black.xml diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_directions_car_black_24dp.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_directions_car_black.xml index 6d6337c3ab..6d6337c3ab 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_directions_car_black_24dp.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_directions_car_black.xml diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_directions_run_black_24dp.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_directions_run_black.xml index dfa43f020e..dfa43f020e 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_directions_run_black_24dp.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_directions_run_black.xml diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_droppin_24dp.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_droppin.xml index a25e7884cd..a25e7884cd 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_droppin_24dp.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_droppin.xml diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_input_24dp.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_input.xml index fea69dfb79..fea69dfb79 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_input_24dp.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_input.xml diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_layers_24dp.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_layers.xml index 944b526c5c..944b526c5c 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_layers_24dp.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_layers.xml diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_layers_clear_24dp.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_layers_clear.xml index 249f57fc65..249f57fc65 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_layers_clear_24dp.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_layers_clear.xml diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_location_city_24dp.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_location_city.xml index e9bea94b41..e9bea94b41 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_location_city_24dp.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_location_city.xml diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_location_disabled_24dp.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_location_disabled.xml index 4fedff778b..4fedff778b 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_location_disabled_24dp.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_location_disabled.xml diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_my_location_24dp.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_my_location.xml index eb979016bf..eb979016bf 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_my_location_24dp.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_my_location.xml diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_print_24dp.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_print.xml index 7a9bc00287..7a9bc00287 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_print_24dp.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_print.xml diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_refresh_24dp.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_refresh.xml index 20cd9a07d8..20cd9a07d8 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_refresh_24dp.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_refresh.xml diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_stars.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_stars.xml new file mode 100644 index 0000000000..61c5d7ace2 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_stars.xml @@ -0,0 +1,9 @@ +<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="#FF000000" + android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM16.23,18L12,15.45 7.77,18l1.12,-4.81 -3.73,-3.23 4.92,-0.42L12,5l1.92,4.53 4.92,0.42 -3.73,3.23L16.23,18z"/> +</vector> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/line_divider.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/line_divider.xml index 2dc6b4a008..c301b9b6f4 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/line_divider.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/line_divider.xml @@ -1,11 +1,12 @@ <?xml version="1.0" encoding="utf-8"?> -<shape xmlns:android="http://schemas.android.com/apk/res/android" +<shape + xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <size android:width="1dp" - android:height="1dp" /> + android:height="1dp"/> - <solid android:color="@android:color/darker_gray" /> + <solid android:color="@android:color/darker_gray"/> -</shape>
\ No newline at end of file +</shape> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/marker.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/marker.xml new file mode 100644 index 0000000000..71992ebd7f --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/marker.xml @@ -0,0 +1,4 @@ +<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> + <size android:width="10px" android:height="10px"/> + <solid android:color="@color/redAccent"/> +</shape>
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_add_remove_marker.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_add_remove_marker.xml index 596f52aab1..6da5a61ecb 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_add_remove_marker.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_add_remove_marker.xml @@ -1,19 +1,13 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" 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" /> - <com.mapbox.mapboxsdk.maps.MapView android:id="@+id/mapView" android:layout_width="match_parent" - android:layout_height="match_parent" /> + android:layout_height="match_parent"/> -</LinearLayout>
\ No newline at end of file +</LinearLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_add_sprite.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_add_sprite.xml index e0e2cbfdab..00dc67ebed 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_add_sprite.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_add_sprite.xml @@ -1,26 +1,19 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" +<RelativeLayout + 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" /> - <com.mapbox.mapboxsdk.maps.MapView android:id="@id/mapView" - android:layout_below="@id/toolbar" android:layout_width="match_parent" + android:layout_height="match_parent" app:mapbox_cameraTargetLat="52.519003" app:mapbox_cameraTargetLng="13.400972" - app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets" app:mapbox_cameraZoom="16" - android:layout_height="match_parent"/> + app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"/> <android.support.design.widget.FloatingActionButton android:id="@id/fab" @@ -30,7 +23,7 @@ android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:layout_margin="@dimen/fab_margin" - android:src="@drawable/ic_add_24dp" - app:backgroundTint="@android:color/white" /> + android:src="@drawable/ic_add" + app:backgroundTint="@android:color/white"/> </RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_animated_marker.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_animated_marker.xml index 6534c23c72..0566757d58 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_animated_marker.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_animated_marker.xml @@ -1,25 +1,18 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" +<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" /> - <com.mapbox.mapboxsdk.maps.MapView android:id="@id/mapView" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_below="@id/toolbar" app:mapbox_cameraTargetLat="51.502615" app:mapbox_cameraTargetLng="4.972326" - app:mapbox_styleUrl="@string/mapbox_style_light" - app:mapbox_cameraZoom="6" /> + app:mapbox_cameraZoom="6" + app:mapbox_styleUrl="@string/mapbox_style_light"/> -</RelativeLayout> +</LinearLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_camera_animation_types.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_camera_animation_types.xml index 8a139083f8..b70bb6d7b2 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_camera_animation_types.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_camera_animation_types.xml @@ -1,25 +1,18 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" +<RelativeLayout + 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" /> - <com.mapbox.mapboxsdk.maps.MapView android:id="@id/mapView" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_below="@+id/toolbar" app:mapbox_cameraTargetLat="51.50325" app:mapbox_cameraTargetLng="-0.11968" - app:mapbox_cameraZoom="15" /> + app:mapbox_cameraZoom="15"/> <LinearLayout android:layout_width="match_parent" @@ -33,21 +26,21 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" - android:text="@string/button_camera_move" /> + android:text="@string/button_camera_move"/> <Button android:id="@+id/cameraEaseButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" - android:text="@string/button_camera_ease" /> + android:text="@string/button_camera_ease"/> <Button android:id="@+id/cameraAnimateButton" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" - android:text="@string/button_camera_animate" /> + android:text="@string/button_camera_animate"/> </LinearLayout> </RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_camera_position.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_camera_position.xml index a1d7a8351d..341218c406 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_camera_position.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_camera_position.xml @@ -1,36 +1,24 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" +<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"> + android:layout_height="match_parent"> - <android.support.v7.widget.Toolbar - android:id="@+id/toolbar" + <com.mapbox.mapboxsdk.maps.MapView + android:id="@id/mapView" android:layout_width="match_parent" - android:layout_height="?attr/actionBarSize" - android:background="@color/primary" - android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> + android:layout_height="match_parent" + app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"/> - <android.support.design.widget.CoordinatorLayout - 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_styleUrl="@string/mapbox_style_mapbox_streets" /> - - <android.support.design.widget.FloatingActionButton - android:id="@+id/fab" - 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_input_24dp" - app:backgroundTint="@android:color/white" /> + <android.support.design.widget.FloatingActionButton + android:id="@+id/fab" + 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_input" + app:backgroundTint="@android:color/white"/> - </android.support.design.widget.CoordinatorLayout> -</LinearLayout> +</android.support.design.widget.CoordinatorLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_camera_test.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_camera_test.xml index 4f86120097..05affaf081 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_camera_test.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_camera_test.xml @@ -1,22 +1,16 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" +<RelativeLayout + 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.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" /> - <!-- TODO remove zoom #6747--> <com.mapbox.mapboxsdk.maps.MapView android:id="@id/mapView" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@id/toolbar" - app:mapbox_cameraZoom="1" /> + app:mapbox_cameraZoom="1"/> </RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_car_driving.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_car_driving.xml deleted file mode 100644 index f52d5e70c2..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_car_driving.xml +++ /dev/null @@ -1,24 +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"/> - - <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="15" /> - -</LinearLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_circle_layer.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_circle_layer.xml index 4aecf36c71..8a21bef8a8 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_circle_layer.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_circle_layer.xml @@ -30,7 +30,7 @@ android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:layout_margin="@dimen/fab_margin" - android:src="@drawable/ic_directions_bus_black_24dp" + android:src="@drawable/ic_directions_bus_black" app:backgroundTint="@android:color/white" /> </RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_circlelayer.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_circlelayer.xml deleted file mode 100644 index e0e2cbfdab..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_circlelayer.xml +++ /dev/null @@ -1,36 +0,0 @@ -<?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" - 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" /> - - <com.mapbox.mapboxsdk.maps.MapView - android:id="@id/mapView" - android:layout_below="@id/toolbar" - android:layout_width="match_parent" - app:mapbox_cameraTargetLat="52.519003" - app:mapbox_cameraTargetLng="13.400972" - app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets" - app:mapbox_cameraZoom="16" - android:layout_height="match_parent"/> - - <android.support.design.widget.FloatingActionButton - android:id="@id/fab" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentBottom="true" - android:layout_alignParentEnd="true" - android:layout_alignParentRight="true" - android:layout_margin="@dimen/fab_margin" - android:src="@drawable/ic_add_24dp" - app:backgroundTint="@android:color/white" /> - -</RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_custom_layer.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_custom_layer.xml index 247d10bf86..800926f894 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_custom_layer.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_custom_layer.xml @@ -1,45 +1,25 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" +<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"> - <android.support.v7.widget.Toolbar - android:id="@+id/toolbar" + <com.mapbox.mapboxsdk.maps.MapView + android:id="@id/mapView" android:layout_width="match_parent" - android:layout_height="?attr/actionBarSize" - android:background="@color/primary" - android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> + android:layout_height="match_parent"/> - </android.support.v7.widget.Toolbar> + <android.support.design.widget.FloatingActionButton + android:id="@+id/fab" + 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_layers" + app:backgroundTint="@android:color/white"/> - <FrameLayout - android:id="@+id/content_frame" - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <android.support.design.widget.CoordinatorLayout - 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/fab" - 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_layers_24dp" - app:backgroundTint="@android:color/white" /> - - </android.support.design.widget.CoordinatorLayout> - - </FrameLayout> +</android.support.design.widget.CoordinatorLayout> -</LinearLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_data_driven_style.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_data_driven_style.xml new file mode 100644 index 0000000000..7454ce5860 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_data_driven_style.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <com.mapbox.mapboxsdk.maps.MapView + android:id="@id/mapView" + android:layout_width="match_parent" + android:layout_height="match_parent"/> + +</RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_debug_mode.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_debug_mode.xml index 36adfbc6e9..ffbf2e30a1 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_debug_mode.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_debug_mode.xml @@ -1,57 +1,35 @@ <?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"> - - </android.support.v7.widget.Toolbar> - - <FrameLayout - android:id="@+id/content_frame" +<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"> + + <com.mapbox.mapboxsdk.maps.MapView + android:id="@+id/mapView" android:layout_width="match_parent" - android:layout_height="match_parent" - > - - <android.support.design.widget.CoordinatorLayout - 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/fabDebug" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="end|bottom" - android:layout_marginBottom="82dp" - android:layout_marginRight="@dimen/fab_margin" - android:src="@drawable/ic_refresh_24dp" - app:backgroundTint="@color/accent" - app:layout_anchorGravity="top" /> - - <android.support.design.widget.FloatingActionButton - android:id="@+id/fabStyles" - 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_layers_24dp" - app:backgroundTint="@color/primary" /> - - </android.support.design.widget.CoordinatorLayout> - - </FrameLayout> - -</LinearLayout> + android:layout_height="match_parent"/> + + <android.support.design.widget.FloatingActionButton + android:id="@+id/fabDebug" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="end|bottom" + android:layout_marginBottom="82dp" + android:layout_marginRight="@dimen/fab_margin" + android:src="@drawable/ic_refresh" + app:backgroundTint="@color/accent" + app:layout_anchorGravity="top"/> + + <android.support.design.widget.FloatingActionButton + android:id="@+id/fabStyles" + 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_layers" + app:backgroundTint="@color/primary"/> + +</android.support.design.widget.CoordinatorLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_default.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_default.xml index 742f6612bd..f292c80267 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_default.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_default.xml @@ -1,19 +1,12 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" +<RelativeLayout + xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> - <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" /> - <com.mapbox.mapboxsdk.maps.MapView android:id="@+id/mapView" android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_below="@id/toolbar" /> + android:layout_height="match_parent"/> </RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_directions.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_directions.xml deleted file mode 100644 index bc100b6059..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_directions.xml +++ /dev/null @@ -1,21 +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" /> - - <com.mapbox.mapboxsdk.maps.MapView - android:id="@+id/mapView" - android:layout_width="match_parent" - android:layout_height="match_parent" - app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets" /> - -</LinearLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_dynamic_marker.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_dynamic_marker.xml index 2625e65bbf..e119d3cf7c 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_dynamic_marker.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_dynamic_marker.xml @@ -1,51 +1,29 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" +<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.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" /> - - <FrameLayout - android:id="@+id/content_frame" + <com.mapbox.mapboxsdk.maps.MapView + android:id="@id/mapView" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_below="@+id/toolbar"> - - <android.support.design.widget.CoordinatorLayout - 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="51.506675" - app:mapbox_cameraTargetLng="-0.128699" - app:mapbox_uiCompassFadeFacingNorth="false" - app:mapbox_cameraBearing="90" - app:mapbox_cameraTilt="40" - app:mapbox_cameraZoom="10" /> - - <android.support.design.widget.FloatingActionButton - android:id="@+id/fab" - 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_animate_coordinates" - app:backgroundTint="@color/white" /> - - </android.support.design.widget.CoordinatorLayout> - - </FrameLayout> - -</RelativeLayout> - - + app:mapbox_cameraBearing="90" + app:mapbox_cameraTargetLat="51.506675" + app:mapbox_cameraTargetLng="-0.128699" + app:mapbox_cameraTilt="40" + app:mapbox_cameraZoom="10" + app:mapbox_uiCompassFadeFacingNorth="false"/> + + <android.support.design.widget.FloatingActionButton + android:id="@+id/fab" + 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_animate_coordinates" + app:backgroundTint="@color/white"/> + +</android.support.design.widget.CoordinatorLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_feature_overview.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_feature_overview.xml new file mode 100644 index 0000000000..28b23b633d --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_feature_overview.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <android.support.v7.widget.RecyclerView + android:id="@+id/recyclerView" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:scrollbars="vertical"/> + +</LinearLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_geocoder.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_geocoder.xml deleted file mode 100644 index d13d16a73e..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_geocoder.xml +++ /dev/null @@ -1,31 +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" /> - - <com.mapbox.mapboxsdk.maps.MapView - android:id="@id/mapView" - android:layout_width="match_parent" - android:layout_height="0dp" - android:layout_weight="5" - app:mapbox_cameraTargetLat="38.90962" - app:mapbox_cameraTargetLng="-77.04341" - app:mapbox_cameraZoom="15" /> - - <TextView - android:id="@+id/message" - android:layout_width="match_parent" - android:layout_height="0dp" - android:layout_weight="1" - android:gravity="center" /> - -</LinearLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_geojson_clustering.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_geojson_clustering.xml index 4c0d067c14..f292c80267 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_geojson_clustering.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_geojson_clustering.xml @@ -1,19 +1,12 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <android.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"/> +<RelativeLayout + xmlns:android="http://schemas.android.com/apk/res/android" + 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:layout_below="@id/toolbar"/> + android:layout_height="match_parent"/> </RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow.xml index 1c8e33fb33..3339341f6e 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow.xml @@ -1,24 +1,18 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" +<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" /> - <com.mapbox.mapboxsdk.maps.MapView android:id="@id/mapView" android:layout_width="match_parent" android:layout_height="match_parent" app:mapbox_cameraTargetLat="38.897705003219784" app:mapbox_cameraTargetLng="-77.03655168667463" - app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets" - app:mapbox_cameraZoom="15" /> + app:mapbox_cameraZoom="15" + app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"/> </LinearLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow_adapter.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow_adapter.xml index 134c3f331e..abb41c05c4 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow_adapter.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow_adapter.xml @@ -1,24 +1,18 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" +<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" /> - <com.mapbox.mapboxsdk.maps.MapView android:id="@id/mapView" android:layout_width="match_parent" android:layout_height="match_parent" app:mapbox_cameraTargetLat="47.798202" app:mapbox_cameraTargetLng="7.573781" - app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets" - app:mapbox_cameraZoom="4" /> + app:mapbox_cameraZoom="4" + app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"/> </LinearLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow_adapter_dynamic.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow_adapter_dynamic.xml deleted file mode 100644 index 134c3f331e..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_infowindow_adapter_dynamic.xml +++ /dev/null @@ -1,24 +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" /> - - <com.mapbox.mapboxsdk.maps.MapView - android:id="@id/mapView" - android:layout_width="match_parent" - android:layout_height="match_parent" - app:mapbox_cameraTargetLat="47.798202" - app:mapbox_cameraTargetLng="7.573781" - app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets" - app:mapbox_cameraZoom="4" /> - -</LinearLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_location_picker.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_location_picker.xml deleted file mode 100644 index f6a89c0149..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_location_picker.xml +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <android.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" /> - - <com.mapbox.mapboxsdk.maps.MapView - android:id="@id/mapView" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_below="@id/toolbar" /> - - <ImageButton - android:id="@+id/clearDisplayViewButton" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_above="@+id/selectLocationButton" - android:layout_alignParentLeft="true" - android:layout_alignParentStart="true" - android:layout_marginLeft="@dimen/full_button_margin" - android:background="@color/accent" - android:src="@drawable/ic_clear_24dp" - android:visibility="gone" /> - - <Button - android:id="@+id/selectLocationButton" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:layout_alignParentBottom="true" - android:layout_margin="@dimen/full_button_margin" - android:background="@color/primary" - android:text="@string/navigation_select_location_button_text" - android:textColor="@android:color/white" /> - -</RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_location_source.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_location_source.xml deleted file mode 100644 index a1d7a8351d..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_location_source.xml +++ /dev/null @@ -1,36 +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" /> - - <android.support.design.widget.CoordinatorLayout - 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_styleUrl="@string/mapbox_style_mapbox_streets" /> - - <android.support.design.widget.FloatingActionButton - android:id="@+id/fab" - 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_input_24dp" - app:backgroundTint="@android:color/white" /> - - </android.support.design.widget.CoordinatorLayout> -</LinearLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_main.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_main.xml deleted file mode 100644 index 41956385f9..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - 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" /> - - <android.support.v7.widget.RecyclerView - android:id="@+id/recyclerView" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:scrollbars="vertical" /> - -</LinearLayout>
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_manual_zoom.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_manual_zoom.xml index 3732326f39..d533762857 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_manual_zoom.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_manual_zoom.xml @@ -1,25 +1,18 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="match_parent" - android:layout_height="match_parent" +<RelativeLayout + xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" - 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" /> + android:layout_width="match_parent" + android:layout_height="match_parent"> <com.mapbox.mapboxsdk.maps.MapView android:id="@id/mapView" - app:mapbox_cameraTargetLat="50.871062" - app:mapbox_cameraTargetLng="1.583210" - app:mapbox_cameraBearing="220" - app:mapbox_cameraZoom="10" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_below="@id/toolbar" /> + android:layout_below="@id/toolbar" + app:mapbox_cameraBearing="220" + app:mapbox_cameraTargetLat="50.871062" + app:mapbox_cameraTargetLng="1.583210" + app:mapbox_cameraZoom="10"/> </RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_map_fragment.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_map_fragment.xml index a421f21ede..43fa8fb995 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_map_fragment.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_map_fragment.xml @@ -1,22 +1,16 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".activity.fragment.MapFragmentActivity"> - <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" /> - <FrameLayout android:id="@+id/fragment_container" android:layout_width="match_parent" - android:layout_height="match_parent" /> + android:layout_height="match_parent"/> </LinearLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_map_in_dialog.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_map_in_dialog.xml index 1edc456252..3fd66977e2 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_map_in_dialog.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_map_in_dialog.xml @@ -4,13 +4,6 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - <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" /> - <Button android:id="@+id/button_open_dialog" android:layout_width="wrap_content" @@ -18,4 +11,4 @@ android:layout_gravity="center" android:text="@string/button_open_dialog"/> -</FrameLayout>
\ No newline at end of file +</FrameLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_map_padding.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_map_padding.xml index cd61fef44b..a0de31ee48 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_map_padding.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_map_padding.xml @@ -12,7 +12,6 @@ <View android:layout_width="@dimen/map_padding_left" android:layout_height="match_parent" - android:layout_marginTop="?attr/actionBarSize" android:alpha="0.5" android:background="@color/mapbox_blue" /> @@ -27,19 +26,10 @@ android:alpha="0.5" android:background="@color/mapbox_blue" /> - <android.support.v7.widget.Toolbar - android:id="@+id/toolbar" - android:layout_width="match_parent" - android:layout_height="?attr/actionBarSize" - android:alpha="0.5" - android:background="@color/primary" - android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> - <View android:layout_width="@dimen/map_padding_right" android:layout_height="match_parent" android:layout_gravity="end" - android:layout_marginTop="?attr/actionBarSize" android:alpha="0.5" android:background="@color/mapbox_blue" /> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_map_simple.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_map_simple.xml index 4ad49e4a9f..96a3f5b046 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_map_simple.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_map_simple.xml @@ -1,19 +1,15 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" 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"/> + android:orientation="vertical" + tools:context=".activity.maplayout.SimpleMapActivity"> <com.mapbox.mapboxsdk.maps.MapView android:id="@id/mapView" android:layout_width="match_parent" - android:layout_height="match_parent" /> + android:layout_height="match_parent"/> </LinearLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_bulk.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_bulk.xml index 229d8e87c1..ff28d2edf0 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_bulk.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_bulk.xml @@ -1,32 +1,19 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" +<RelativeLayout + 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.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"> - - <Spinner - android:id="@+id/spinner" - android:layout_width="wrap_content" - android:layout_height="wrap_content" /> - - </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_cameraTargetLat="38.87031" android:layout_below="@id/toolbar" + app:mapbox_cameraTargetLat="38.87031" app:mapbox_cameraTargetLng="-77.00897" - app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets" - app:mapbox_cameraZoom="10" /> + app:mapbox_cameraZoom="10" + app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"/> <TextView android:id="@+id/countView" @@ -45,6 +32,6 @@ android:layout_alignParentRight="true" android:layout_gravity="end|bottom" android:layout_margin="@dimen/fab_margin" - android:src="@drawable/ic_animate_coordinates" /> + android:src="@drawable/ic_animate_coordinates"/> </RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_view.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_view.xml index f06975466b..cf4b51bbe0 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_view.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_view.xml @@ -1,16 +1,10 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" +<RelativeLayout + 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.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" /> - <com.mapbox.mapboxsdk.maps.MapView android:id="@id/mapView" android:layout_width="match_parent" @@ -25,7 +19,6 @@ android:id="@+id/countView" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_below="@id/toolbar" android:padding="16dp" android:textSize="20sp" /> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_view_in_rect.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_view_in_rect.xml index 36dd89c885..ecda2873ce 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_view_in_rect.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_view_in_rect.xml @@ -4,18 +4,10 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - <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"/> - <com.mapbox.mapboxsdk.maps.MapView android:id="@+id/mapView" android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_below="@id/toolbar"/> + android:layout_height="match_parent"/> <FrameLayout android:id="@+id/selection_box" @@ -23,6 +15,6 @@ android:layout_height="150dp" android:layout_centerInParent="true" android:alpha="0.3" - android:background="#1d72da"/> + android:background="@color/mapboxGreen"/> </RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_view_scale.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_view_scale.xml deleted file mode 100644 index 8f98b5bea2..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_marker_view_scale.xml +++ /dev/null @@ -1,61 +0,0 @@ -<?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" - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <android.support.v7.widget.Toolbar - android:id="@id/toolbar" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:background="@color/primary" - android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> - - <RelativeLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:paddingBottom="8dp"> - - <TextView - android:id="@+id/title" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="12dp" - android:paddingBottom="8dp" - android:textSize="20sp" - android:textColor="#FFFFFF" - android:text="Scaling in the View Marker API" /> - - <TextView - android:id="@+id/textview_factor" - android:layout_alignBottom="@+id/seekbar_factor" - android:layout_below="@id/title" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="Scale: 1" /> - - <SeekBar - android:id="@+id/seekbar_factor" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_below="@id/title" - android:clickable="false" - android:layout_marginLeft="56dp" - android:progress="0" /> - - </RelativeLayout> - - - </android.support.v7.widget.Toolbar> - - <com.mapbox.mapboxsdk.maps.MapView - android:id="@id/mapView" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_below="@id/toolbar" - app:mapbox_cameraTargetLat="38.907192" - app:mapbox_cameraTargetLng="-77.036871" - app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets" - app:mapbox_cameraZoom="12" /> - -</RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_maxmin_zoom.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_maxmin_zoom.xml index 20de7c00bf..4428100e41 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_maxmin_zoom.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_maxmin_zoom.xml @@ -1,25 +1,17 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" +<RelativeLayout + 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" /> + android:layout_height="match_parent"> <com.mapbox.mapboxsdk.maps.MapView android:id="@id/mapView" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_below="@id/toolbar" app:mapbox_cameraTargetLat="-1.063510" app:mapbox_cameraTargetLng=" 32.895425" - app:mapbox_styleUrl="@string/mapbox_style_satellite_streets" - app:mapbox_cameraZoom="4" /> + app:mapbox_cameraZoom="4" + app:mapbox_styleUrl="@string/mapbox_style_satellite_streets"/> </RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_metadata_update.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_metadata_update.xml index 067a52dae4..084675fb2c 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_metadata_update.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_metadata_update.xml @@ -1,20 +1,14 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" 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" /> - <ListView android:id="@+id/listView" android:layout_width="match_parent" - android:layout_height="match_parent" /> + android:layout_height="match_parent"/> <TextView android:id="@android:id/empty" @@ -22,6 +16,6 @@ android:layout_height="match_parent" android:gravity="center" android:text="No Results" - android:textSize="24sp" /> + android:textSize="24sp"/> -</LinearLayout>
\ No newline at end of file +</LinearLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_multi_map.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_multi_map.xml index f8046a8821..0b3fd9acdf 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_multi_map.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_multi_map.xml @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" xmlns:mapbox="http://schemas.android.com/tools" android:id="@+id/map_container" android:layout_width="match_parent" @@ -23,7 +24,7 @@ mapbox:center_latitude="38.913187" mapbox:center_longitude="-77.032546" mapbox:style_url="mapbox://styles/mapbox/streets-v9" - mapbox:zoom="12" /> + mapbox:zoom="12"/> <!-- SF --> <fragment @@ -35,7 +36,7 @@ mapbox:center_latitude="37.775732" mapbox:center_longitude="-122.413985" mapbox:style_url="mapbox://styles/mapbox/outdoors-v9" - mapbox:zoom="13" /> + mapbox:zoom="13"/> </LinearLayout> <LinearLayout @@ -55,7 +56,7 @@ mapbox:center_latitude="12.97913" mapbox:center_longitude="77.59188" mapbox:style_url="mapbox://styles/mapbox/light-v9" - mapbox:zoom="14" /> + mapbox:zoom="14"/> <!-- Ayacucho --> <fragment @@ -67,6 +68,6 @@ mapbox:center_latitude="-13.155980" mapbox:center_longitude="-74.217134" mapbox:style_url="mapbox://styles/mapbox/dark-v9" - mapbox:zoom="15" /> + mapbox:zoom="15"/> </LinearLayout> -</LinearLayout>
\ No newline at end of file +</LinearLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_customization.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_customization.xml index 262128703f..d65d5796f1 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_customization.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_customization.xml @@ -1,17 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" android:id="@id/container" 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" /> - <FrameLayout android:id="@id/progress" android:layout_width="match_parent" @@ -21,7 +15,7 @@ style="?android:attr/progressBarStyleLarge" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_gravity="center" /> + android:layout_gravity="center"/> </FrameLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_dot_color.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_dot_color.xml index d41cc79326..de18e265de 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_dot_color.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_dot_color.xml @@ -1,23 +1,14 @@ <?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:mapbox="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"> - <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"/> - <com.mapbox.mapboxsdk.maps.MapView android:id="@id/mapView" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_below="@+id/toolbar" mapbox:mapbox_uiAttribution="false" mapbox:mapbox_uiLogo="false"/> @@ -68,4 +59,4 @@ </LinearLayout> -</RelativeLayout>
\ No newline at end of file +</RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_toggle.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_toggle.xml index 8ca01ef411..2ec35faf04 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_toggle.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_my_location_toggle.xml @@ -1,36 +1,23 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" +<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" - android:orientation="vertical"> + android:layout_height="match_parent"> - <android.support.v7.widget.Toolbar - android:id="@id/toolbar" + <com.mapbox.mapboxsdk.maps.MapView + android:id="@id/mapView" android:layout_width="match_parent" - android:layout_height="?attr/actionBarSize" - android:background="@color/primary" - android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> + android:layout_height="match_parent"/> - <android.support.design.widget.CoordinatorLayout - 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_24dp" - tools:backgroundTint="@color/primary" /> - - </android.support.design.widget.CoordinatorLayout> + <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"/> -</LinearLayout> +</android.support.design.widget.CoordinatorLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_navigation_drawer.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_navigation_drawer.xml index 2bf08fbdc1..26a71bc568 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_navigation_drawer.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_navigation_drawer.xml @@ -30,4 +30,4 @@ android:layout_gravity="start" android:fitsSystemWindows="true" /> -</android.support.v4.widget.DrawerLayout>
\ No newline at end of file +</android.support.v4.widget.DrawerLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_offline.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_offline.xml index 434cb59115..d4b64b1ea2 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_offline.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_offline.xml @@ -1,52 +1,44 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" +<RelativeLayout + xmlns:android="http://schemas.android.com/apk/res/android" 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" /> + android:layout_height="match_parent"> <ProgressBar android:id="@+id/progress_bar" style="?android:attr/progressBarStyleHorizontal" android:layout_width="match_parent" android:layout_height="25dp" - android:layout_below="@+id/toolbar" android:indeterminate="true" - android:visibility="gone" /> + android:visibility="gone"/> <com.mapbox.mapboxsdk.maps.MapView android:id="@id/mapView" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_below="@+id/progress_bar" /> + android:layout_below="@+id/progress_bar"/> <Button + android:id="@+id/button_download_region" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:padding="10dp" - android:text="@string/button_download_region" - android:id="@+id/button_download_region" - android:layout_margin="@dimen/fab_margin" + android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" - android:layout_alignParentBottom="true" - android:background="@color/white"/> + android:layout_margin="@dimen/fab_margin" + android:background="@color/white" + android:padding="10dp" + android:text="@string/button_download_region"/> <Button + android:id="@+id/button_list_regions" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:padding="10dp" - android:text="@string/button_list_regions" - android:id="@+id/button_list_regions" android:layout_alignBottom="@+id/button_download_region" android:layout_alignParentRight="true" android:layout_marginRight="@dimen/fab_margin" - android:background="@color/white"/> + android:background="@color/white" + android:padding="10dp" + android:text="@string/button_list_regions"/> </RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_offline_region_delete.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_offline_region_delete.xml new file mode 100644 index 0000000000..084675fb2c --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_offline_region_delete.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <ListView + android:id="@+id/listView" + android:layout_width="match_parent" + android:layout_height="match_parent"/> + + <TextView + android:id="@android:id/empty" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="center" + android:text="No Results" + android:textSize="24sp"/> + +</LinearLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_polygon.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_polygon.xml deleted file mode 100644 index 1c60deb328..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_polygon.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/container" - 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> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_polyline.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_polyline.xml index d856676260..3f8c384b3f 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_polyline.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_polyline.xml @@ -1,22 +1,14 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" +<RelativeLayout + 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" /> + 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:layout_below="@+id/toolbar" app:mapbox_uiAttributionTintColor="@android:color/holo_green_dark" app:mapbox_cameraTargetLat="47.798202" app:mapbox_cameraTargetLng="7.573781" @@ -32,7 +24,7 @@ android:layout_alignParentRight="true" android:layout_gravity="end|bottom" android:layout_margin="@dimen/fab_margin" - android:src="@drawable/ic_add_24dp" + android:src="@drawable/ic_add" app:backgroundTint="@android:color/white" /> </RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_press_for_marker.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_press_for_marker.xml index f5a9a17917..9932803907 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_press_for_marker.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_press_for_marker.xml @@ -1,28 +1,21 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" +<RelativeLayout + 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" /> + android:layout_height="match_parent"> <com.mapbox.mapboxsdk.maps.MapView android:id="@id/mapView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/toolbar" - app:mapbox_uiAttributionGravity="top|end" app:mapbox_cameraTargetLat="45.1855569" app:mapbox_cameraTargetLng="5.7215506" - app:mapbox_uiLogoGravity="top|end" - app:mapbox_uiLogoMarginRight="10dp" + app:mapbox_cameraZoom="11" app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets" - app:mapbox_cameraZoom="11" /> + app:mapbox_uiAttributionGravity="top|end" + app:mapbox_uiLogoGravity="top|end" + app:mapbox_uiLogoMarginRight="10dp"/> </RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_print.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_print.xml index 76451f5918..3ff8caea70 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_print.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_print.xml @@ -1,45 +1,23 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" +<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"> + android:layout_height="match_parent"> - <android.support.v7.widget.Toolbar - android:id="@+id/toolbar" + <com.mapbox.mapboxsdk.maps.MapView + android:id="@id/mapView" android:layout_width="match_parent" - android:layout_height="?attr/actionBarSize" - android:background="@color/primary" - android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> - - </android.support.v7.widget.Toolbar> - - <FrameLayout - android:id="@+id/content_frame" - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <android.support.design.widget.CoordinatorLayout - 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/fab" - 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_print_24dp" - app:backgroundTint="@color/accent" /> - - </android.support.design.widget.CoordinatorLayout> - - </FrameLayout> - -</LinearLayout> + android:layout_height="match_parent"/> + + <android.support.design.widget.FloatingActionButton + android:id="@+id/fab" + 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_print" + app:backgroundTint="@color/accent"/> + +</android.support.design.widget.CoordinatorLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_query_features_box.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_query_features_box.xml index dfd067cec7..3ddd7d64b4 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_query_features_box.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_query_features_box.xml @@ -1,16 +1,10 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" +<RelativeLayout + 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.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" /> - <com.mapbox.mapboxsdk.maps.MapView android:id="@+id/mapView" android:layout_width="match_parent" @@ -18,7 +12,7 @@ android:layout_below="@id/toolbar" app:mapbox_cameraTargetLat="52.0907" app:mapbox_cameraTargetLng="5.1214" - app:mapbox_cameraZoom="16" /> + app:mapbox_cameraZoom="16"/> <FrameLayout android:id="@+id/selection_box" @@ -26,6 +20,6 @@ android:layout_height="150dp" android:layout_centerInParent="true" android:alpha="0.3" - android:background="#1d72da" /> + android:background="@color/mapboxGreen"/> </RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_query_features_point.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_query_features_point.xml index 6889a5fac1..66750dc47e 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_query_features_point.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_query_features_point.xml @@ -1,23 +1,16 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" +<RelativeLayout + 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.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" /> - <com.mapbox.mapboxsdk.maps.MapView android:id="@+id/mapView" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_below="@id/toolbar" app:mapbox_cameraTargetLat="52.0907" app:mapbox_cameraTargetLng="5.1214" - app:mapbox_cameraZoom="16" /> + app:mapbox_cameraZoom="16"/> </RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_runtime_style.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_runtime_style.xml index 34823b0da1..7454ce5860 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_runtime_style.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_runtime_style.xml @@ -1,19 +1,12 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" +<RelativeLayout + xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> - <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" /> - <com.mapbox.mapboxsdk.maps.MapView android:id="@id/mapView" android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_below="@id/toolbar" /> + android:layout_height="match_parent"/> </RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_scroll_by.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_scroll_by.xml index 46734ed82d..bc24533960 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_scroll_by.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_scroll_by.xml @@ -91,7 +91,7 @@ android:layout_height="wrap_content" android:layout_gravity="end|bottom" android:layout_margin="@dimen/fab_margin" - android:src="@drawable/ic_input_24dp" + android:src="@drawable/ic_input" app:backgroundTint="@color/white" /> </android.support.design.widget.CoordinatorLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_snapshot.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_snapshot.xml index ac69780592..6b99711e84 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_snapshot.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_snapshot.xml @@ -1,21 +1,14 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" +<RelativeLayout + 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="match_parent" - android:layout_below="@+id/toolbar" android:orientation="vertical"> <ImageView @@ -23,7 +16,7 @@ android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" - android:background="@color/primary" /> + android:background="@color/primary"/> <com.mapbox.mapboxsdk.maps.MapView android:id="@id/mapView" @@ -41,7 +34,7 @@ android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:layout_margin="@dimen/fab_margin" - android:src="@drawable/ic_add_a_photo_black_24dp" - app:backgroundTint="@android:color/white" /> + android:src="@drawable/ic_add_a_photo_black" + app:backgroundTint="@android:color/white"/> </RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_style_file.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_style_file.xml index e0e2cbfdab..b133f3d9a5 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_style_file.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_style_file.xml @@ -1,26 +1,18 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" +<RelativeLayout + 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" /> + android:layout_height="match_parent"> <com.mapbox.mapboxsdk.maps.MapView android:id="@id/mapView" - android:layout_below="@id/toolbar" android:layout_width="match_parent" + android:layout_height="match_parent" app:mapbox_cameraTargetLat="52.519003" app:mapbox_cameraTargetLng="13.400972" - app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets" app:mapbox_cameraZoom="16" - android:layout_height="match_parent"/> + app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"/> <android.support.design.widget.FloatingActionButton android:id="@id/fab" @@ -30,7 +22,7 @@ android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:layout_margin="@dimen/fab_margin" - android:src="@drawable/ic_add_24dp" - app:backgroundTint="@android:color/white" /> + android:src="@drawable/ic_add" + app:backgroundTint="@android:color/white"/> </RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_surfaceview_mediacontrols.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_surfaceview_mediacontrols.xml deleted file mode 100644 index 364e86adda..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_surfaceview_mediacontrols.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?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" - 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" /> - - <com.mapbox.mapboxsdk.maps.MapView - android:id="@id/mapView" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_below="@id/toolbar" - app:mapbox_styleUrl="@string/mapbox_style_light" /> - - <FrameLayout - android:id="@+id/container" - android:layout_width="match_parent" - android:layout_height="128dp" - android:layout_alignParentBottom="true" - android:paddingBottom="48dp" - android:paddingLeft="16dp" - android:paddingRight="16dp" /> - -</RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_symbollayer.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_symbollayer.xml index 67892abbd1..9b88994f1c 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_symbollayer.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_symbollayer.xml @@ -1,22 +1,15 @@ <?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" - 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"/> +<RelativeLayout + 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"> <com.mapbox.mapboxsdk.maps.MapView android:id="@id/mapView" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_below="@id/toolbar" app:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"/> </RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_video_view.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_video_view.xml deleted file mode 100644 index b640f9f878..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_video_view.xml +++ /dev/null @@ -1,37 +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/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools" - android:layout_width="match_parent" - android:layout_height="match_parent" - tools:context=".activity.maplayout.VideoViewActivity"> - - <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" /> - - <VideoView - android:id="@+id/video_view" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_alignParentBottom="true" - android:layout_alignParentLeft="true" - android:layout_alignParentStart="true" - android:layout_margin="16dp" /> - - <com.mapbox.mapboxsdk.maps.MapView - android:id="@id/mapView" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_below="@id/toolbar" - mapbox:mapbox_uiAttributionGravity="top" - mapbox:mapbox_cameraTargetLat="34.4021" - mapbox:mapbox_cameraTargetLng="-119.7081" - mapbox:mapbox_uiLogoGravity="top" - mapbox:mapbox_styleUrl="mapbox://styles/mapbox/streets-v9" - mapbox:mapbox_cameraZoom="13" /> - -</RelativeLayout>
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_viewpager.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_viewpager.xml index 9bb5560bb2..d931cb3643 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_viewpager.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_viewpager.xml @@ -1,21 +1,13 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" +<RelativeLayout + xmlns:android="http://schemas.android.com/apk/res/android" 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" /> + android:layout_height="match_parent"> <android.support.v4.view.ViewPager android:id="@+id/viewpager" android:layout_width="match_parent" - android:layout_height="match_parent" - android:layout_below="@id/toolbar"> + android:layout_height="match_parent"> <android.support.v4.view.PagerTabStrip android:id="@+id/viewpager_header" @@ -23,8 +15,8 @@ android:layout_height="wrap_content" android:layout_gravity="top" android:paddingBottom="4dp" - android:paddingTop="4dp" /> + android:paddingTop="4dp"/> </android.support.v4.view.ViewPager> -</RelativeLayout>
\ No newline at end of file +</RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_visible_bounds.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_visible_bounds.xml index 17a5c27942..89a28a7799 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_visible_bounds.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_visible_bounds.xml @@ -1,19 +1,13 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" 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" /> - <com.mapbox.mapboxsdk.maps.MapView android:id="@id/mapView" android:layout_width="match_parent" - android:layout_height="match_parent" /> + android:layout_height="match_parent"/> </LinearLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/dialog_camera_position.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/dialog_camera_position.xml index c1ffa7d203..1c9fbbd482 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/dialog_camera_position.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/dialog_camera_position.xml @@ -199,4 +199,4 @@ </RelativeLayout> -</LinearLayout>
\ No newline at end of file +</LinearLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/fragment_dialog_map.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/fragment_dialog_map.xml index b40ad1273d..8241d0264f 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/fragment_dialog_map.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/fragment_dialog_map.xml @@ -15,4 +15,4 @@ mapbox:mapbox_renderTextureMode="true" mapbox:mapbox_styleUrl="mapbox://styles/mapbox/streets-v9" /> -</LinearLayout>
\ No newline at end of file +</LinearLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/item_main_feature.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/item_main_feature.xml index 93af094e3f..b290d013f0 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/item_main_feature.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/item_main_feature.xml @@ -1,10 +1,13 @@ <?xml version="1.0" encoding="utf-8"?> -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="72dp" android:background="?android:attr/selectableItemBackground" android:orientation="vertical" + android:paddingEnd="16dp" android:paddingLeft="16dp" + android:paddingRight="16dp" android:paddingStart="16dp" android:paddingTop="16dp"> @@ -12,24 +15,22 @@ android:id="@+id/nameView" android:layout_width="match_parent" android:layout_height="wrap_content" - android:gravity="center_vertical" - android:text="Dummy headline" - android:layout_marginRight="16dp" android:layout_marginEnd="16dp" - android:singleLine="true" + android:layout_marginRight="16dp" + android:gravity="center_vertical" + android:maxLines="1" android:textColor="@android:color/black" - android:textSize="16sp" /> + android:textSize="16sp"/> <TextView android:id="@+id/descriptionView" android:layout_width="match_parent" android:layout_height="wrap_content" - android:alpha="0.56" - android:layout_marginRight="16dp" android:layout_marginEnd="16dp" - android:singleLine="true" - android:text="Description is dummy dummy" + android:layout_marginRight="16dp" + android:alpha="0.56" + android:maxLines="1" android:textColor="@android:color/black" - android:textSize="14sp" /> + android:textSize="14sp"/> -</LinearLayout>
\ No newline at end of file +</LinearLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/section_main_layout.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/section_main_layout.xml index 8978d4e3eb..75f6ac9588 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/section_main_layout.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/section_main_layout.xml @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" +<RelativeLayout + xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="48dp"> @@ -7,21 +8,21 @@ android:layout_width="match_parent" android:layout_height="0.25dp" android:alpha="0.56" - android:background="@drawable/line_divider" /> + android:background="@drawable/line_divider"/> <TextView android:id="@+id/section_text" android:layout_width="match_parent" android:layout_height="48dp" + android:layout_marginEnd="16dp" android:layout_marginLeft="16dp" + android:layout_marginRight="16dp" android:layout_marginStart="16dp" android:layout_marginTop="16dp" - android:layout_marginRight="16dp" - android:layout_marginEnd="16dp" android:alpha="0.54" android:background="@android:color/transparent" - android:singleLine="true" + android:maxLines="1" android:textColor="@android:color/black" - android:textSize="14sp" /> + android:textSize="14sp"/> -</RelativeLayout>
\ No newline at end of file +</RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/view_custom_marker.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/view_custom_marker.xml index 98050c061f..c2bbdae775 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/view_custom_marker.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/view_custom_marker.xml @@ -18,4 +18,4 @@ android:layout_centerHorizontal="true" android:padding="2dp"/> -</RelativeLayout>
\ No newline at end of file +</RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/view_pulse_marker.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/view_pulse_marker.xml deleted file mode 100644 index e1ac50b440..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/view_pulse_marker.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="48dp" - android:layout_height="48dp"> - - <ImageView - android:id="@+id/foreground_imageView" - android:layout_width="@dimen/circle_size" - android:layout_height="@dimen/circle_size" - android:layout_gravity="center" - android:src="@drawable/ic_circle"/> - - <ImageView - android:id="@+id/background_imageview" - android:layout_width="@dimen/circle_size" - android:layout_height="@dimen/circle_size" - android:layout_gravity="center" - android:alpha="0.5" - android:src="@drawable/ic_circle"/> - -</FrameLayout>
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/view_text_marker.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/view_text_marker.xml index 8a3508691a..299865be9e 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/view_text_marker.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/view_text_marker.xml @@ -2,7 +2,7 @@ <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:background="@color/mapbox_green"> + android:background="@color/mapboxGreen"> <TextView android:id="@id/textView" @@ -13,4 +13,4 @@ android:padding="4dp" android:layout_centerInParent="true" /> -</RelativeLayout>
\ No newline at end of file +</RelativeLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_bulk_marker.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_bulk_marker.xml new file mode 100644 index 0000000000..8b7245c5ca --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_bulk_marker.xml @@ -0,0 +1,9 @@ +<?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"> + <item + android:id="@+id/spinner" + android:title="Amount of markers" + app:actionViewClass="android.widget.Spinner" + app:showAsAction="always"/> +</menu> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_custom_layer.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_custom_layer.xml index ec1f756333..4639dd65ba 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_custom_layer.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_custom_layer.xml @@ -14,4 +14,4 @@ <item android:id="@+id/action_set_color_blue" android:title="Blue" /> -</menu>
\ No newline at end of file +</menu> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_data_driven_style.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_data_driven_style.xml new file mode 100644 index 0000000000..3eae56a273 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_data_driven_style.xml @@ -0,0 +1,50 @@ +<?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_add_exponential_zoom_function" + android:title="Add an exponential zoom function" + mapbox:showAsAction="never"/> + + <item + android:id="@+id/action_add_interval_zoom_function" + android:title="Add an interval zoom function" + mapbox:showAsAction="never"/> + + <item + android:id="@+id/action_add_categorical_source_function" + android:title="Add a categorical source function" + mapbox:showAsAction="never"/> + + <item + android:id="@+id/action_add_exponential_source_function" + android:title="Add an exponential source function" + mapbox:showAsAction="never"/> + + <item + android:id="@+id/action_add_identity_source_function" + android:title="Add an identity source function" + mapbox:showAsAction="never"/> + + <item + android:id="@+id/action_add_interval_source_function" + android:title="Add an interval source function" + mapbox:showAsAction="never"/> + + <item + android:id="@+id/action_add_composite_exponential_function" + android:title="Add a composite, exponential function" + mapbox:showAsAction="never"/> + + <item + android:id="@+id/action_add_composite_categorical_function" + android:title="Add a composite, categorical function" + mapbox:showAsAction="never"/> + + <item + android:id="@+id/action_add_composite_interval_function" + android:title="Add a composite, interval function" + mapbox:showAsAction="never"/> + +</menu> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_infowindow.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_infowindow.xml index adca8d2e00..3dc705dbb9 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_infowindow.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_infowindow.xml @@ -16,4 +16,4 @@ android:checked="true"/> </group> -</menu>
\ No newline at end of file +</menu> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_main.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_main.xml deleted file mode 100644 index 2c5178af08..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_main.xml +++ /dev/null @@ -1,3 +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"></menu> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_padding.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_padding.xml index 0db887c4e7..e0052d4a8c 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_padding.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_padding.xml @@ -9,4 +9,4 @@ android:id="@+id/action_bangalore" android:title="Bangalore" mapbox:showAsAction="never" /> -</menu>
\ No newline at end of file +</menu> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_polygon.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_polygon.xml index 62d4c83594..a7fdf56be5 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_polygon.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_polygon.xml @@ -17,4 +17,4 @@ android:id="@+id/action_id_color" android:title="@string/action_color_polygon" mapbox:showAsAction="never" /> -</menu>
\ No newline at end of file +</menu> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_polyline.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_polyline.xml index 7c324fc9dc..8549d66042 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_polyline.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_polyline.xml @@ -3,7 +3,7 @@ xmlns:mapbox="http://schemas.android.com/apk/res-auto"> <item android:id="@+id/action_id_remove" - android:icon="@drawable/ic_delete_24dp" + android:icon="@drawable/ic_delete" android:title="@string/action_remove_polylines" mapbox:showAsAction="ifRoom" /> <item @@ -22,4 +22,4 @@ android:id="@+id/action_id_visible" android:title="@string/action_visibility_polygon" mapbox:showAsAction="never" /> -</menu>
\ No newline at end of file +</menu> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_runtime_style.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_runtime_style.xml index 18f09db82a..86f0b4faee 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_runtime_style.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_runtime_style.xml @@ -3,6 +3,14 @@ xmlns:mapbox="http://schemas.android.com/apk/res-auto"> <item + android:id="@+id/action_list_layers" + android:title="List all layers in the style" + mapbox:showAsAction="never" /> + <item + android:id="@+id/action_list_sources" + android:title="List all sources in the style" + mapbox:showAsAction="never" /> + <item android:id="@+id/action_water_color" android:title="Color the water" mapbox:showAsAction="never" /> @@ -58,4 +66,4 @@ android:id="@+id/action_numeric_filter" android:title="Apply numeric fill filter" mapbox:showAsAction="never" /> -</menu>
\ No newline at end of file +</menu> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_symbol_layer.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_symbol_layer.xml index e6fd1fce45..77468b4861 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_symbol_layer.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_symbol_layer.xml @@ -13,4 +13,4 @@ android:id="@+id/action_toggle_text_font" android:title="Toggle text font"/> -</menu>
\ No newline at end of file +</menu> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_tracking.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_tracking.xml index 91424d3f5b..940dd9c461 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_tracking.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_tracking.xml @@ -29,4 +29,4 @@ app:showAsAction="never" /> </group> -</menu>
\ No newline at end of file +</menu> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_zoom.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_zoom.xml index 5cec70afb6..0cea519a24 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_zoom.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_zoom.xml @@ -22,4 +22,4 @@ android:title="Zoom to 4" mapbox:showAsAction="never" /> -</menu>
\ No newline at end of file +</menu> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/raw/amsterdam.geojson b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/raw/amsterdam.geojson index c5585533a0..e433a509eb 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/raw/amsterdam.geojson +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/raw/amsterdam.geojson @@ -256,7 +256,7 @@ "stroke-width": 2, "stroke-opacity": 1, "fill": "#555555", - "fill-opacity": 0.5, + "fill-opacity": 1.0, "name": "Sarphatipark", "type": "park", "description": "Sarphatipark is a small park in the popular De Pijp neighbourhood. It was openend in late 19th century, and named after Samuel Sarphati." @@ -482,7 +482,7 @@ "stroke-width": 2, "stroke-opacity": 1, "fill": "#555555", - "fill-opacity": 0.5, + "fill-opacity": 0.1, "name": "Sloterdijk", "type": "area", "description": "To protect the area around Sloten from the as-yet undrained IJ the Spaarndammerdijk was laid along the south bank of this inlet. In this vicinity at the same time, a dam on the Slochter (or Slooter) river was built, the Slooterdam. Trade grew in the vicinity, and in the 15th century a weigh house and a church were built. The area is nowadays best known as a large intersection of train lines and a business and industrial centre north-west of Amsterdam." @@ -574,7 +574,7 @@ "stroke-width": 2, "stroke-opacity": 1, "fill": "#555555", - "fill-opacity": 0.5, + "fill-opacity": 0.7, "name": "Artis", "type": "poi", "description": "Artis, short for Natura Artis Magistra (Latin for \"Nature is the teacher of art and science\"), is a zoo in the centre of Amsterdam. It is the oldest zoo in the Netherlands and one of the oldest zoos of mainland Europe. Artis Royal Zoo is not just a zoo, it also contains an aquarium and a planetarium. Artis also has an arboretum and a fairly large art collection. A part of the art collection is on display in the Aquarium building of the zoo. Artis contains 27 monumental buildings, most of which are used as enclosures for the animals, making Artis a unique cultural heritage of the 19th century." diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/raw/sea_waves.mp4 b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/raw/sea_waves.mp4 Binary files differdeleted file mode 100644 index ac2bcae016..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/raw/sea_waves.mp4 +++ /dev/null diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values-v21/attrs.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values-v21/attrs.xml index 2eb503b057..944f563f2f 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values-v21/attrs.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values-v21/attrs.xml @@ -3,4 +3,4 @@ <declare-styleable name="ScrimInsetsView"> <attr name="appInsetForeground" format="reference|color" /> </declare-styleable> -</resources>
\ No newline at end of file +</resources> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values-v21/dimens.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values-v21/dimens.xml deleted file mode 100644 index 035b9f3564..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values-v21/dimens.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<resources> - <dimen name="toolbar_padding_top">25dp</dimen> -</resources>
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values-v21/styles.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values-v21/styles.xml index 3d61b9a36d..ab690c664c 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values-v21/styles.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values-v21/styles.xml @@ -3,17 +3,17 @@ <style name="AppTheme" parent="AppBaseTheme"> - </style>r + </style> - <style name="AppTheme.ActionBar.Transparent" parent="AppTheme"> + <style name="AppTheme.ActionBar.Transparent" parent="NoActionBar"> <item name="colorPrimary">@android:color/transparent</item> <item name="android:windowDrawsSystemBarBackgrounds">true</item> <item name="android:windowTranslucentStatus">true</item> </style> <style name="AppTheme.ActionBar" parent="AppTheme"> - <item name="colorPrimaryDark">@color/primary_dark</item> + <item name="colorPrimaryDark">@color/primaryDark</item> <item name="colorPrimary">@color/primary</item> </style> -</resources>
\ No newline at end of file +</resources> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values-w820dp/dimens.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values-w820dp/dimens.xml deleted file mode 100644 index 63fc816444..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values-w820dp/dimens.xml +++ /dev/null @@ -1,6 +0,0 @@ -<resources> - <!-- Example customization of dimensions originally defined in res/values/dimens.xml - (such as screen margins) for screens with more than 820dp of available width. This - would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --> - <dimen name="activity_horizontal_margin">64dp</dimen> -</resources> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/arrays.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/arrays.xml new file mode 100644 index 0000000000..94763342d2 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/arrays.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string-array name="bulk_marker_list"> + <item>10</item> + <item>100</item> + <item>500</item> + <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>
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/colors.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/colors.xml index 78fc76af1c..88524d44ea 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/colors.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/colors.xml @@ -1,12 +1,13 @@ <?xml version="1.0" encoding="utf-8"?> <resources> - <color name="primary">#1E8CAB</color> - <color name="primary_dark">#166B83</color> + <color name="primary">#52A1D8</color> + <color name="primaryDark">#3887BE</color> <color name="accent">#E55E5E</color> <color name="white">#F9F9F9</color> - <color name="mapbox_green">#56B881</color> + <color name="mapboxGreen">#56B881</color> + + <color name="redAccent">#D50000</color> + <color name="blueAccent">#2962FF</color> + <color name="greenAccent">#1B5E20</color> - <color name="red_accent">#D50000</color> - <color name="blue_accent">#2962FF</color> - <color name="green_accent">#1B5E20</color> </resources> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/dimens.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/dimens.xml index b77a25b681..402d42d485 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/dimens.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/dimens.xml @@ -2,18 +2,12 @@ <resources> <dimen name="circle_size">24dp</dimen> <dimen name="fab_margin">16dp</dimen> - <dimen name="full_button_margin">8dp</dimen> <dimen name="attr_margin">10dp</dimen> <dimen name="coordinatebounds_margin">32dp</dimen> <dimen name="map_padding_left">96dp</dimen> <dimen name="map_padding_bottom">256dp</dimen> <dimen name="map_padding_right">32dp</dimen> - <dimen name="toolbar_shadow">4dp</dimen> + <dimen name="map_padding_top">0dp</dimen> <dimen name="locationview_background_drawable_padding">2dp</dimen> - <dimen name="locationview_padding_top">350dp</dimen> - <!-- Default screen margins, per the Android Design guidelines. --> - <dimen name="activity_horizontal_margin">16dp</dimen> - <dimen name="activity_vertical_margin">16dp</dimen> <dimen name="navigation_drawer_width">240dp</dimen> - <dimen name="toolbar_padding_top">0dp</dimen> </resources> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/ids.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/ids.xml index 120bf49fca..6701032d97 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/ids.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/ids.xml @@ -8,4 +8,4 @@ <item name="toolbar" type="id" /> <item name="container" type="id" /> <item name="item_click_support" type="id" /> -</resources>
\ No newline at end of file +</resources> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml index 53688cdf35..61d251f861 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml @@ -1,50 +1,28 @@ <?xml version="1.0" encoding="utf-8"?> <resources> - <string name="app_name">Mapbox Android SDK TestApp</string> - <!-- Test Activities --> - <string name="activity_mapboxmap">MapboxMap Activity</string> - - <!-- Fragment --> + <!--Activity--> <string name="activity_map_fragment_suport">Support Map Fragment</string> <string name="activity_map_fragment">Map Fragment</string> <string name="activity_multimap">Multiple Maps on Screen</string> - - <!-- Annotations --> <string name="activity_add_bulk_markers">Add Markers In Bulk</string> - <string name="activity_animated_marker">Animated Marker (experimental)</string> + <string name="activity_animated_marker">Animated Markers</string> <string name="activity_dynamic_marker">Dynamic Marker</string> <string name="activity_polyline">Polyline</string> <string name="activity_polygon">Polygon</string> <string name="activity_press_for_marker">Press Map For Marker</string> <string name="activity_view_marker">View Marker API</string> - <string name="activity_view_marker_scale">Scaling in the View Marker API</string> <string name="activity_add_remove_markers">Add/Remove marker</string> - - <!-- InfoWindow--> <string name="activity_info_window">Standard InfoWindow</string> <string name="activity_infowindow_adapter">Custom InfoWindow</string> <string name="activity_dynamic_infowindow_adapter">Custom Dynamic InfoWindow</string> - - <!-- Camera --> <string name="activity_camera_animation_types">Animation Types</string> <string name="activity_camera_zoom">Zoom Methods</string> <string name="activity_visible_coordinate_bounds">LatLngBounds Method</string> <string name="activity_camera_position">CameraPosition Method</string> <string name="activity_scroll_by">Scroll By Method</string> - - <!-- API --> - <string name="activity_directions">Directions</string> - <string name="activity_geocoder">Geocoder</string> - - <!-- Navigation --> - <string name="activity_location_picker">Location Picker</string> - <string name="activity_car_driving">Driving animation</string> - - <!-- Other --> <string name="activity_double_map">Double Map Activity</string> - <string name="activity_back_to_map">Back to 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> @@ -55,9 +33,11 @@ <string name="activity_debug_mode">Debug Mode</string> <string name="activity_offline">Offline Map</string> <string name="activity_update_metadata">Update metadata Map</string> + <string name="activity_offline_region_delete">Delete region</string> <string name="activity_minmax_zoom">Min/Max Zoom</string> <string name="activity_viewpager">ViewPager</string> <string name="activity_runtime_style">Runtime Style</string> + <string name="activity_data_driven_style">Data Driven Style</string> <string name="activity_circle_layer">Circle layer</string> <string name="activity_style_file">Local Style file</string> <string name="activity_geojson_clustering">GeoJson Clustering</string> @@ -74,7 +54,7 @@ <string name="activity_map_in_dialog">Dialog with map</string> <string name="activity_marker_view_rectangle">Marker views in rectangle</string> - <!-- Description --> + <!--Description--> <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> @@ -89,7 +69,6 @@ <string name="description_camera_zoom">Different types of zoom methods</string> <string name="description_minmax_zoom">Configure a max and min zoomlevel</string> <string name="description_info_window">Learn how to handle the InfoWindow</string> - <string name="description_info_window_concurrent">InfoWindow example with multiple open</string> <string name="description_add_bulk_markers">Add Markers In Bulk to a Map</string> <string name="description_camera_animation_types">Showcase the different animation types</string> <string name="description_visible_bounds">Center the camera around a bounds</string> @@ -98,21 +77,18 @@ <string name="description_debug_mode">Debug Mode</string> <string name="description_offline">Offline Map example</string> <string name="description_update_metadata">Update metadata example</string> - <string name="description_animated_marker">Animate the position change of a Marker</string> + <string name="description_offline_region_delete">Delete region example</string> + <string name="description_animated_marker">Animate the position change of a marker</string> <string name="description_polyline">Add a polyline to a map</string> <string name="description_polygon">Add a polygon to a map</string> - <string name="description_directions">Example with Directions API</string> - <string name="description_geocoder">Example with Geocoder API</string> <string name="description_scroll_by">Scroll with pixels in x,y direction</string> <string name="description_snapshot">Example to make a snapshot of the map</string> <string name="description_doublemap">2 maps in a view hierarchy</string> - <string name="description_back_to_map">Restart map view after temporarily leaving to another activity</string> <string name="description_view_marker">Use an Android SDK View as marker</string> - <string name="description_view_marker_scale">Scale a View Marker</string> <string name="description_dynamic_info_window_adapter">Learn how to create a dynamic custom InfoWindow</string> - <string name="description_location_picker">Use a fixed Marker to select your location</string> <string name="description_viewpager">Use SupportMapFragments in a ViewPager</string> <string name="description_runtime_style">Adopt the map style on the fly</string> + <string name="description_data_driven_style">Use functions to change the map appearance</string> <string name="description_symbol_layer">Manipulate symbols at runtime</string> <string name="description_custom_sprite">Use a custom sprite in a Symbol Layer</string> <string name="description_geojson_clustering">Use GeoJson sources and dynamic layers to cluster information</string> @@ -123,7 +99,6 @@ <string name="description_query_rendered_features_box_count">Count all rendered features in box</string> <string name="description_query_rendered_features_box_symbol_count">Count all rendered symbols in box</string> <string name="description_query_rendered_features_box_highlight">Hightligh buildings in box</string> - <string name="description_car_driving">MyLocationView follow map update example</string> <string name="description_simple_map">Shows a simple map</string> <string name="description_add_remove_markers">Based on zoom level</string> <string name="description_style_file">Use a local file as the style</string> @@ -131,109 +106,58 @@ <string name="description_marker_view_rectangle">Marker Views within a rectangle</string> <string name="description_circle_layer">Show bus stops and route in Singapore</string> - <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> - + <!--Categories--> <string name="category">category</string> + <string name="category_basic">_Basic</string> <string name="category_annotation">Annotation</string> <string name="category_camera">Camera</string> <string name="category_custom_layer">Custom Layer</string> - <string name="category_directions">Directions</string> <string name="category_fragment">Fragment</string> - <string name="category_geocoding">Geocoding</string> <string name="category_imagegenerator">Image Generator</string> - <string name="category_infowindow">InfoWindow</string> + <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_navigation">Navigation</string> <string name="category_style">Styling</string> <string name="category_features">Features</string> - <string name="action_visible_bounds_explanation">Center map around 2 markers</string> + <!--Actions--> <string name="action_remove_polylines">Remove polylines</string> - <string name="action_visibility_polygon">Change visibility</string> <string name="action_alpha_polygon">Change alpha</string> <string name="action_points_polygon">Change points</string> <string name="action_color_polygon">Change color</string> <string name="action_width_polyline">Change width</string> + <!--Menu--> + <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> + + <!--Button--> <string name="button_camera_move">Move</string> <string name="button_camera_ease">Ease</string> <string name="button_camera_animate">Animate</string> - <string name="button_make_snapshot">Snapshot</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="label_fps">FPS:</string> - - <string name="styleMapboxStreets">Mapbox Streets</string> - <string name="styleEmerald">Emerald</string> - <string name="styleLight">Light</string> - <string name="styleDark">Dark</string> - <string name="styleSatellite">Satellite</string> - <string name="styleSatelliteStreets">Satellite Streets</string> - - <string-array name="outdoors_class_list"> - <item>Day</item> - <item>Night</item> - </string-array> - - <string-array name="bulk_marker_list"> - <item>10</item> - <item>100</item> - <item>500</item> - <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> - - <string name="zoom_botton">Zoom</string> - - <string name="scrollby_x_value">X: %1$d</string> - <string name="scrollby_y_value">Y: %1$d</string> <string name="button_download_region">Download region</string> <string name="button_list_regions">List regions</string> + <!--Other--> + <string name="navigation_drawer_open">Open navigation drawer</string> + <string name="navigation_drawer_close">Close navigation drawer</string> + <string name="scrollby_x_value">X: %1$d</string> + <string name="scrollby_y_value">Y: %1$d</string> <string name="dialog_camera_position">Animate to new position</string> - - <string name="geocoder_instructions">Tap Map To Geocode Where Black Marker Is Currently Located</string> - <string name="dynamic_marker_chelsea_title">Chelsea</string> <string name="dynamic_marker_chelsea_snippet">Stamford Bridge</string> <string name="dynamic_marker_arsenal_title">Arsenal</string> <string name="dynamic_marker_arsenal_snippet">Emirates Stadium</string> - - <string name="navigation_select_location_button_text">Select Location!</string> - - <string name="title_section1">Different style</string> - <string name="title_section2">Show Snackbar</string> - - <string name="navigation_drawer_open">Open navigation drawer</string> - <string name="navigation_drawer_close">Close navigation drawer</string> - - <string name="action_example">Example action</string> - - <string name="action_settings">Settings</string> - <string name="menuitem_title_rotate_gesture_enabled">Enable rotate gestures</string> - <string name="menuitem_title_scroll_gesture_enabled">Enable scroll gestures</string> - -</resources>
\ No newline at end of file +</resources> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/styles.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/styles.xml index e358fcd5a0..777d8a5f56 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/styles.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/styles.xml @@ -1,14 +1,23 @@ <?xml version="1.0" encoding="utf-8"?> <resources> - <style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light.NoActionBar"> + <style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="colorPrimary">@color/primary</item> - <item name="colorPrimaryDark">@color/primary_dark</item> + <item name="colorPrimaryDark">@color/primaryDark</item> <item name="colorAccent">@color/accent</item> <item name="android:windowBackground">@color/white</item> + <item name="android:spinnerItemStyle">@style/MySpinnerStyle</item> + <item name="android:spinnerDropDownItemStyle">@style/SpinnerItem.DropDownItem</item> </style> - <style name="AppTheme.ActionBar.Transparent" parent="AppTheme"> + <style name="NoActionBar" parent="Theme.AppCompat.NoActionBar"> + <item name="colorPrimary">@color/primary</item> + <item name="colorPrimaryDark">@color/primaryDark</item> + <item name="colorAccent">@color/accent</item> + <item name="android:windowBackground">@color/white</item> + </style> + + <style name="AppTheme.ActionBar.Transparent" parent="NoActionBar"> <item name="android:windowContentOverlay">@null</item> <item name="windowActionBarOverlay">true</item> <item name="colorPrimary">@android:color/transparent</item> @@ -18,6 +27,15 @@ <item name="windowActionBarOverlay">false</item> </style> + <style name="MySpinnerStyle"> + <item name="android:popupBackground">@android:color/background_light</item> + <item name="android:textColor">@android:color/background_light</item> + </style> + + <style name="SpinnerItem.DropDownItem" parent="@android:style/Widget.DropDownItem.Spinner"> + <item name="android:textColor">@android:color/background_light</item> + </style> + <style name="AppTheme" parent="AppBaseTheme" /> </resources> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/AnnotationTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/AnnotationTest.java index 611e4f978c..605e159b84 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/AnnotationTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/AnnotationTest.java @@ -88,4 +88,4 @@ public class AnnotationTest { assertSame("hashcode should match", annotation.hashCode(), id); } -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java index 3c52c16422..ebd30f5422 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java @@ -17,9 +17,6 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; public class MarkerViewTest { @@ -144,70 +141,6 @@ public class MarkerViewTest { } @Test - public void testRotationUpdatePositive() { - float startRotation = 45; - float endRotation = 180; - - // allow calls to our mock - when(mapboxMap.getMarkerViewManager()).thenReturn(markerViewManager); - - MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng()).rotation(startRotation); - MarkerView marker = markerOptions.getMarker(); - marker.setMapboxMap(mapboxMap); - - marker.setRotation(endRotation); - verify(markerViewManager, times(1)).animateRotationBy(marker, endRotation); - } - - @Test - public void testRotationUpdateNegative() { - float startRotation = 10; - float endRotation = 270; - - // allow calls to our mock - when(mapboxMap.getMarkerViewManager()).thenReturn(markerViewManager); - - MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng()).rotation(startRotation); - MarkerView marker = markerOptions.getMarker(); - marker.setMapboxMap(mapboxMap); - - marker.setRotation(endRotation); - verify(markerViewManager, times(1)).animateRotationBy(marker, endRotation); - } - - @Test - public void testRotationUpdateMax() { - float startRotation = 359; - float endRotation = 0; - - // allow calls to our mock - when(mapboxMap.getMarkerViewManager()).thenReturn(markerViewManager); - - MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng()).rotation(startRotation); - MarkerView marker = markerOptions.getMarker(); - marker.setMapboxMap(mapboxMap); - - marker.setRotation(endRotation); - verify(markerViewManager, times(1)).animateRotationBy(marker, 0); - } - - @Test - public void testRotationUpdateMin() { - float startRotation = 0; - float endRotation = 359; - - // allow calls to our mock - when(mapboxMap.getMarkerViewManager()).thenReturn(markerViewManager); - - MarkerViewOptions markerOptions = new MarkerViewOptions().position(new LatLng()).rotation(startRotation); - MarkerView marker = markerOptions.getMarker(); - marker.setMapboxMap(mapboxMap); - - marker.setRotation(endRotation); - verify(markerViewManager, times(1)).animateRotationBy(marker, endRotation); - } - - @Test public void testVisible() { boolean visible = false; MarkerViewOptions markerOptions = new MarkerViewOptions().visible(visible).position(new LatLng()); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/camera/CameraPositionTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/camera/CameraPositionTest.java index a8aad8d639..b3eace7856 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/camera/CameraPositionTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/camera/CameraPositionTest.java @@ -123,4 +123,4 @@ public class CameraPositionTest { Parcelable parcelable = MockParcel.obtain(object); assertEquals("Parcel should match original object", parcelable, object); } -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/constants/StyleVersionTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/constants/StyleVersionTest.java deleted file mode 100644 index 5623afeb58..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/constants/StyleVersionTest.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.mapbox.mapboxsdk.constants; - - -import com.mapbox.mapboxsdk.testapp.model.constants.AppConstant; - -import org.junit.Test; - -import static junit.framework.Assert.assertEquals; - -public class StyleVersionTest { - - private static final double DELTA = 1e-15; - - @Test - public void testSanity() { - assertEquals("Style version should match, when upgrading, verify that integers.xml is updated", - AppConstant.STYLE_VERSION, - 9, - DELTA); - } -} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java index a42ca96cf5..60573f4b74 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngBoundsTest.java @@ -202,4 +202,4 @@ public class LatLngBoundsTest { Parcelable parcel = MockParcel.obtain(latLngBounds); assertEquals("Parcel should match original object", parcel, latLngBounds); } -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngTest.java index 5cbf1fa63c..06fe1c91b9 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/geometry/LatLngTest.java @@ -10,7 +10,6 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNotSame; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -181,17 +180,13 @@ public class LatLngTest { @Test public void testWrapped() { - LatLng latLng = new LatLng(45.0, -185.0); - LatLng wrapped = latLng.wrap(); - assertNotSame(latLng, wrapped); - assertEquals("longitude wrapped value", wrapped.getLongitude(), 175.0, DELTA); + LatLng latLng = new LatLng(45.0, -185.0).wrap(); + assertEquals("longitude wrapped value", latLng.getLongitude(), 175.0, DELTA); } @Test public void testUnnecessaryWrapped() { - LatLng latLng = new LatLng(45.0, 50.0); - LatLng wrapped = latLng.wrap(); - assertNotSame(latLng, wrapped); - assertEquals("longitude wrapped value", wrapped.getLongitude(), 50.0, DELTA); + LatLng latLng = new LatLng(45.0, 50.0).wrap(); + assertEquals("longitude wrapped value", latLng.getLongitude(), 50.0, DELTA); } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/TrackingSettingsTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/TrackingSettingsTest.java index 150f638e1c..de5f364a5b 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/TrackingSettingsTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/TrackingSettingsTest.java @@ -3,6 +3,7 @@ package com.mapbox.mapboxsdk.maps; import android.Manifest; import android.content.Context; import android.content.pm.PackageManager; +import android.graphics.PointF; import com.mapbox.mapboxsdk.constants.MyLocationTracking; import com.mapbox.mapboxsdk.maps.widgets.MyLocationView; @@ -16,7 +17,9 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; public class TrackingSettingsTest { @@ -30,11 +33,14 @@ public class TrackingSettingsTest { @InjectMocks FocalPointChangeListener focalPointChangeListener = mock(FocalPointChangeListener.class); + @InjectMocks + TrackingSettings.CameraZoomInvalidator zoomInvalidator = mock(TrackingSettings.CameraZoomInvalidator.class); + private TrackingSettings trackingSettings; @Before public void beforeTest() { - trackingSettings = new TrackingSettings(myLocationView, uiSettings, focalPointChangeListener); + trackingSettings = new TrackingSettings(myLocationView, uiSettings, focalPointChangeListener, zoomInvalidator); } @Test @@ -67,4 +73,27 @@ public class TrackingSettingsTest { trackingSettings.setMyLocationEnabled(true); assertTrue("Location should be enabled", trackingSettings.isMyLocationEnabled()); } + + @Test + public void testCameraZoomTo2forTracking() { + trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW); + verify(zoomInvalidator, atLeast(1)).zoomTo(2.0); + } + + @Test + public void testFocalPointChangeForTracking() { + final float centerX = 32.3f; + final float centerY = 46.3f; + final PointF pointF = new PointF(centerX, centerY); + when(myLocationView.getCenter()).thenReturn(pointF); + + trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW); + verify(focalPointChangeListener, atLeast(1)).onFocalPointChanged(pointF); + } + + @Test + public void testFocalPointChangeForNonTracking() { + trackingSettings.setMyLocationTrackingMode(MyLocationTracking.TRACKING_NONE); + verify(focalPointChangeListener, atLeast(1)).onFocalPointChanged(null); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java index 1f532255d7..fbe00b4dce 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java @@ -286,6 +286,41 @@ public class UiSettingsTest { } @Test + public void testDoubleTapGesturesEnabled() { + uiSettings.setDoubleTapGesturesEnabled(true); + assertEquals("DoubleTap gesture should be enabled", true, uiSettings.isDoubleTapGesturesEnabled()); + } + + @Test + public void testDoubleTapGesturesDisabled() { + uiSettings.setDoubleTapGesturesEnabled(false); + assertEquals("DoubleTap gesture should be disabled", false, uiSettings.isDoubleTapGesturesEnabled()); + } + + @Test + public void testDoubleTapGestureChange() { + assertEquals("Default state should be true", true, uiSettings.isDoubleTapGestureChangeAllowed()); + uiSettings.setDoubleTapGestureChangeAllowed(false); + assertEquals("State should have been changed", false, uiSettings.isDoubleTapGestureChangeAllowed()); + } + + @Test + public void testDoubleTapGestureChangeAllowed() { + uiSettings.setDoubleTapGesturesEnabled(false); + assertEquals("DoubleTap gesture should be false", false, uiSettings.isDoubleTapGesturesEnabled()); + uiSettings.setDoubleTapGesturesEnabled(true); + assertEquals("DoubleTap gesture should be true", true, uiSettings.isDoubleTapGesturesEnabled()); + } + + @Test + public void testDoubleTapGestureChangeDisallowed() { + assertEquals("DoubleTap gesture should be true", true, uiSettings.isDoubleTapGesturesEnabled()); + uiSettings.setDoubleTapGestureChangeAllowed(false); + uiSettings.setDoubleTapGesturesEnabled(false); + assertEquals("DoubleTap gesture change should be ignored", true, uiSettings.isDoubleTapGesturesEnabled()); + } + + @Test public void testScrollGesturesEnabled() { uiSettings.setScrollGesturesEnabled(true); assertEquals("Scroll gesture should be enabled", true, uiSettings.isScrollGesturesEnabled()); @@ -337,4 +372,4 @@ public class UiSettingsTest { assertEquals("Zoom gesture should be disabled", false, uiSettings.isZoomGesturesEnabled()); assertEquals("Scroll gesture should be disabled", false, uiSettings.isScrollGesturesEnabled()); } -}
\ No newline at end of file +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/style/layers/FunctionTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/style/layers/FunctionTest.java index 4e82ca2318..bac1154d62 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/style/layers/FunctionTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/style/layers/FunctionTest.java @@ -1,9 +1,12 @@ package com.mapbox.mapboxsdk.style.layers; +import com.mapbox.mapboxsdk.style.functions.Function; + import org.junit.Test; -import static com.mapbox.mapboxsdk.style.layers.Function.stop; -import static com.mapbox.mapboxsdk.style.layers.Function.zoom; +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.interval; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineBlur; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertNotNull; @@ -15,9 +18,10 @@ public class FunctionTest { @Test public void testZoomFunction() { - Function zoomF = zoom( + Function<Float, Float> zoomF = zoom(interval( stop(1f, lineBlur(1f)), stop(10f, lineBlur(20f)) + ) ); assertNotNull(zoomF.toValueObject()); diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/telemetry/ExponentialBackOffTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/telemetry/ExponentialBackOffTest.java deleted file mode 100644 index 50ce19c050..0000000000 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/telemetry/ExponentialBackOffTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.mapbox.mapboxsdk.telemetry; - -import org.junit.Test; - -import static junit.framework.Assert.assertEquals; - -public class ExponentialBackOffTest { - - @Test - public void testExponentialBackOff() { - MapboxEventManager.ExponentialBackoffCounter counter = new MapboxEventManager.ExponentialBackoffCounter(); - assertEquals(30000, counter.getNextCount()); - assertEquals(60000, counter.getNextCount()); - assertEquals(90000, counter.getNextCount()); - assertEquals(120000, counter.getNextCount()); - assertEquals(150000, counter.getNextCount()); - assertEquals(180000, counter.getNextCount()); - } -}
\ No newline at end of file |