diff --git a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/BackgroundLayer.java b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/BackgroundLayer.java index a3a537da9..3197b1a5b 100644 --- a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/BackgroundLayer.java +++ b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/BackgroundLayer.java @@ -10,6 +10,11 @@ import androidx.annotation.UiThread; import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.mapbox.mapboxsdk.style.expressions.Expression; +import com.mapbox.mapboxsdk.style.layers.TransitionOptions; + /** * The background color or pattern of the map. * diff --git a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/CircleLayer.java b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/CircleLayer.java index 9de4fa089..03f926ed5 100644 --- a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/CircleLayer.java +++ b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/CircleLayer.java @@ -10,8 +10,10 @@ import androidx.annotation.UiThread; import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor; +import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.mapbox.mapboxsdk.style.expressions.Expression; +import com.mapbox.mapboxsdk.style.layers.TransitionOptions; /** * A filled circle. diff --git a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillExtrusionLayer.java b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillExtrusionLayer.java index d36823df0..28d125565 100644 --- a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillExtrusionLayer.java +++ b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillExtrusionLayer.java @@ -10,8 +10,10 @@ import androidx.annotation.UiThread; import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor; +import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.mapbox.mapboxsdk.style.expressions.Expression; +import com.mapbox.mapboxsdk.style.layers.TransitionOptions; /** * An extruded (3D) polygon. diff --git a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillLayer.java b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillLayer.java index 8cc6330b7..98b5f8feb 100644 --- a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillLayer.java +++ b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillLayer.java @@ -10,8 +10,10 @@ import androidx.annotation.UiThread; import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor; +import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.mapbox.mapboxsdk.style.expressions.Expression; +import com.mapbox.mapboxsdk.style.layers.TransitionOptions; /** * A filled polygon with an optional stroked border. @@ -141,6 +143,18 @@ public class FillLayer extends Layer { // Property getters + /** + * Get the FillSortKey property + * + * @return property wrapper value around Float + */ + @NonNull + @SuppressWarnings("unchecked") + public PropertyValue getFillSortKey() { + checkThread(); + return (PropertyValue) new PropertyValue("fill-sort-key", nativeGetFillSortKey()); + } + /** * Get the FillAntialias property * @@ -364,6 +378,10 @@ public class FillLayer extends Layer { nativeSetFillPatternTransition(options.getDuration(), options.getDelay()); } + @NonNull + @Keep + private native Object nativeGetFillSortKey(); + @NonNull @Keep private native Object nativeGetFillAntialias(); diff --git a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/HeatmapLayer.java b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/HeatmapLayer.java index 3c652388f..5e5faed33 100644 --- a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/HeatmapLayer.java +++ b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/HeatmapLayer.java @@ -10,8 +10,10 @@ import androidx.annotation.UiThread; import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor; +import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.mapbox.mapboxsdk.style.expressions.Expression; +import com.mapbox.mapboxsdk.style.layers.TransitionOptions; /** * A heatmap. diff --git a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/HillshadeLayer.java b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/HillshadeLayer.java index 3efeffc1b..dae70ae36 100644 --- a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/HillshadeLayer.java +++ b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/HillshadeLayer.java @@ -10,6 +10,11 @@ import androidx.annotation.UiThread; import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.mapbox.mapboxsdk.style.expressions.Expression; +import com.mapbox.mapboxsdk.style.layers.TransitionOptions; + /** * Client-side hillshading visualization based on DEM data. Currently, the implementation only supports Mapbox Terrain RGB and Mapzen Terrarium tiles. * diff --git a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java index 0fdbaf7fe..cf1335269 100644 --- a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java +++ b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java @@ -10,8 +10,10 @@ import androidx.annotation.UiThread; import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor; +import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.mapbox.mapboxsdk.style.expressions.Expression; +import com.mapbox.mapboxsdk.style.layers.TransitionOptions; /** * A stroked line. @@ -189,6 +191,18 @@ public class LineLayer extends Layer { return (PropertyValue) new PropertyValue("line-round-limit", nativeGetLineRoundLimit()); } + /** + * Get the LineSortKey property + * + * @return property wrapper value around Float + */ + @NonNull + @SuppressWarnings("unchecked") + public PropertyValue getLineSortKey() { + checkThread(); + return (PropertyValue) new PropertyValue("line-sort-key", nativeGetLineSortKey()); + } + /** * Get the LineOpacity property * @@ -560,6 +574,10 @@ public class LineLayer extends Layer { @Keep private native Object nativeGetLineRoundLimit(); + @NonNull + @Keep + private native Object nativeGetLineSortKey(); + @NonNull @Keep private native Object nativeGetLineOpacity(); diff --git a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java index 79c8ea128..b7a90c656 100644 --- a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java +++ b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/PropertyFactory.java @@ -1645,6 +1645,26 @@ public class PropertyFactory { return new PaintPropertyValue<>("background-opacity", expression); } + /** + * Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key. + * + * @param value a Float value + * @return property wrapper around Float + */ + public static PropertyValue fillSortKey(Float value) { + return new LayoutPropertyValue<>("fill-sort-key", value); + } + + /** + * Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key. + * + * @param value a Float value + * @return property wrapper around Float + */ + public static PropertyValue fillSortKey(Expression value) { + return new LayoutPropertyValue<>("fill-sort-key", value); + } + /** * The display of line endings. * @@ -1725,6 +1745,26 @@ public class PropertyFactory { return new LayoutPropertyValue<>("line-round-limit", value); } + /** + * Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key. + * + * @param value a Float value + * @return property wrapper around Float + */ + public static PropertyValue lineSortKey(Float value) { + return new LayoutPropertyValue<>("line-sort-key", value); + } + + /** + * Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key. + * + * @param value a Float value + * @return property wrapper around Float + */ + public static PropertyValue lineSortKey(Expression value) { + return new LayoutPropertyValue<>("line-sort-key", value); + } + /** * Label placement relative to its geometry. * @@ -1766,7 +1806,7 @@ public class PropertyFactory { } /** - * If true, the symbols will not cross tile edges to avoid mutual collisions. Recommended in layers that don't have enough padding in the vector tile to prevent collisions, or if it is a point symbol layer placed after a line symbol layer. + * If true, the symbols will not cross tile edges to avoid mutual collisions. Recommended in layers that don't have enough padding in the vector tile to prevent collisions, or if it is a point symbol layer placed after a line symbol layer. When using a client that supports global collision detection, like Mapbox GL JS version 0.42.0 or greater, enabling this property is not needed to prevent clipped labels at tile boundaries. * * @param value a Boolean value * @return property wrapper around Boolean @@ -1776,7 +1816,7 @@ public class PropertyFactory { } /** - * If true, the symbols will not cross tile edges to avoid mutual collisions. Recommended in layers that don't have enough padding in the vector tile to prevent collisions, or if it is a point symbol layer placed after a line symbol layer. + * If true, the symbols will not cross tile edges to avoid mutual collisions. Recommended in layers that don't have enough padding in the vector tile to prevent collisions, or if it is a point symbol layer placed after a line symbol layer. When using a client that supports global collision detection, like Mapbox GL JS version 0.42.0 or greater, enabling this property is not needed to prevent clipped labels at tile boundaries. * * @param value a Boolean value * @return property wrapper around Boolean @@ -2316,7 +2356,7 @@ public class PropertyFactory { } /** - * To increase the chance of placing high-priority labels on the map, you can provide an array of {@link Property.TEXT_ANCHOR} locations: the render will attempt to place the label at each location, in order, before moving onto the next label. Use `text-justify: auto` to choose justification based on anchor position. To apply an offset, use the {@link PropertyFactory#textRadialOffset} or the two-dimensional {@link PropertyFactory#textOffset}. + * To increase the chance of placing high-priority labels on the map, you can provide an array of {@link Property.TEXT_ANCHOR} locations: the renderer will attempt to place the label at each location, in order, before moving onto the next label. Use `text-justify: auto` to choose justification based on anchor position. To apply an offset, use the {@link PropertyFactory#textRadialOffset} or the two-dimensional {@link PropertyFactory#textOffset}. * * @param value a String[] value * @return property wrapper around String[] @@ -2326,7 +2366,7 @@ public class PropertyFactory { } /** - * To increase the chance of placing high-priority labels on the map, you can provide an array of {@link Property.TEXT_ANCHOR} locations: the render will attempt to place the label at each location, in order, before moving onto the next label. Use `text-justify: auto` to choose justification based on anchor position. To apply an offset, use the {@link PropertyFactory#textRadialOffset} or the two-dimensional {@link PropertyFactory#textOffset}. + * To increase the chance of placing high-priority labels on the map, you can provide an array of {@link Property.TEXT_ANCHOR} locations: the renderer will attempt to place the label at each location, in order, before moving onto the next label. Use `text-justify: auto` to choose justification based on anchor position. To apply an offset, use the {@link PropertyFactory#textRadialOffset} or the two-dimensional {@link PropertyFactory#textOffset}. * * @param value a String[] value * @return property wrapper around String[] diff --git a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/RasterLayer.java b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/RasterLayer.java index 1f4b844cb..9c0c73327 100644 --- a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/RasterLayer.java +++ b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/RasterLayer.java @@ -8,6 +8,13 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.UiThread; +import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor; + +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.mapbox.mapboxsdk.style.expressions.Expression; +import com.mapbox.mapboxsdk.style.layers.TransitionOptions; + /** * Raster map textures such as satellite imagery. * diff --git a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java index 156e11126..06d488d6e 100644 --- a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java +++ b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java @@ -10,9 +10,12 @@ import androidx.annotation.UiThread; import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor; +import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.mapbox.mapboxsdk.style.expressions.Expression; +import com.mapbox.mapboxsdk.style.layers.TransitionOptions; import com.mapbox.mapboxsdk.style.types.Formatted; +import com.mapbox.mapboxsdk.style.types.FormattedSection; /** * An icon or a text label. diff --git a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs index e62c82e3b..3d2ccffba 100644 --- a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs +++ b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs @@ -7,11 +7,11 @@ package com.mapbox.mapboxsdk.style.layers; -import android.support.annotation.ColorInt; -import android.support.annotation.Keep; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.annotation.UiThread; +import androidx.annotation.ColorInt; +import androidx.annotation.Keep; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.UiThread; import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor; diff --git a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property.java.ejs b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property.java.ejs index aaab1fe9f..7d859893b 100644 --- a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property.java.ejs +++ b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property.java.ejs @@ -5,7 +5,7 @@ package com.mapbox.mapboxsdk.style.layers; -import android.support.annotation.StringDef; +import androidx.annotation.StringDef; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property_factory.java.ejs b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property_factory.java.ejs index f4b171489..0a8d5c3b2 100644 --- a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property_factory.java.ejs +++ b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property_factory.java.ejs @@ -6,7 +6,7 @@ package com.mapbox.mapboxsdk.style.layers; -import android.support.annotation.ColorInt; +import androidx.annotation.ColorInt; import com.mapbox.mapboxsdk.style.expressions.Expression; import com.mapbox.mapboxsdk.style.types.Formatted; diff --git a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/light.java.ejs b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/light.java.ejs index e5d50b948..30a021195 100644 --- a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/light.java.ejs +++ b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/light.java.ejs @@ -6,10 +6,10 @@ package com.mapbox.mapboxsdk.style.light; -import android.support.annotation.ColorInt; -import android.support.annotation.Keep; -import android.support.annotation.NonNull; -import android.support.annotation.UiThread; +import androidx.annotation.ColorInt; +import androidx.annotation.Keep; +import androidx.annotation.NonNull; +import androidx.annotation.UiThread; import com.mapbox.mapboxsdk.style.layers.Property; import com.mapbox.mapboxsdk.style.layers.TransitionOptions; diff --git a/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java b/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java index 8ec149874..c6fe2d62d 100644 --- a/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java +++ b/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java @@ -10,11 +10,13 @@ import com.mapbox.mapboxsdk.maps.BaseLayerTest; import org.junit.Before; import timber.log.Timber; +import com.mapbox.mapboxsdk.style.expressions.Expression; import com.mapbox.mapboxsdk.style.layers.BackgroundLayer; import org.junit.Test; import org.junit.runner.RunWith; +import static com.mapbox.mapboxsdk.style.expressions.Expression.*; import static org.junit.Assert.*; import static com.mapbox.mapboxsdk.style.layers.Property.*; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; diff --git a/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java b/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java index d886f58cc..ef75a5e64 100644 --- a/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java +++ b/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java @@ -99,6 +99,32 @@ public class FillLayerTest extends BaseLayerTest { + @Test + @UiThreadTest + public void testFillSortKeyAsConstant() { + Timber.i("fill-sort-key"); + assertNotNull(layer); + assertNull(layer.getFillSortKey().getValue()); + + // Set and Get + Float propertyValue = 0.3f; + layer.setProperties(fillSortKey(propertyValue)); + assertEquals(layer.getFillSortKey().getValue(), propertyValue); + } + + @Test + @UiThreadTest + public void testFillSortKeyAsExpression() { + Timber.i("fill-sort-key-expression"); + assertNotNull(layer); + assertNull(layer.getFillSortKey().getExpression()); + + // Set and Get + Expression expression = number(Expression.get("undefined")); + layer.setProperties(fillSortKey(expression)); + assertEquals(layer.getFillSortKey().getExpression(), expression); + } + @Test @UiThreadTest public void testFillAntialiasAsConstant() { diff --git a/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HeatmapLayerTest.java b/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HeatmapLayerTest.java index 566dd7a70..79c244c45 100644 --- a/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HeatmapLayerTest.java +++ b/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HeatmapLayerTest.java @@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.testapp.style; +import android.graphics.Color; import androidx.test.annotation.UiThreadTest; import androidx.test.ext.junit.runners.AndroidJUnit4; diff --git a/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HillshadeLayerTest.java b/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HillshadeLayerTest.java index 60e977429..68943d19a 100644 --- a/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HillshadeLayerTest.java +++ b/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HillshadeLayerTest.java @@ -10,11 +10,13 @@ import com.mapbox.mapboxsdk.maps.BaseLayerTest; import org.junit.Before; import timber.log.Timber; +import com.mapbox.mapboxsdk.style.expressions.Expression; import com.mapbox.mapboxsdk.style.layers.HillshadeLayer; import org.junit.Test; import org.junit.runner.RunWith; +import static com.mapbox.mapboxsdk.style.expressions.Expression.*; import static org.junit.Assert.*; import static com.mapbox.mapboxsdk.style.layers.Property.*; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; diff --git a/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java b/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java index 18bb31da0..daeb41c1c 100644 --- a/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java +++ b/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java @@ -164,6 +164,32 @@ public class LineLayerTest extends BaseLayerTest { assertEquals(layer.getLineRoundLimit().getValue(), propertyValue); } + @Test + @UiThreadTest + public void testLineSortKeyAsConstant() { + Timber.i("line-sort-key"); + assertNotNull(layer); + assertNull(layer.getLineSortKey().getValue()); + + // Set and Get + Float propertyValue = 0.3f; + layer.setProperties(lineSortKey(propertyValue)); + assertEquals(layer.getLineSortKey().getValue(), propertyValue); + } + + @Test + @UiThreadTest + public void testLineSortKeyAsExpression() { + Timber.i("line-sort-key-expression"); + assertNotNull(layer); + assertNull(layer.getLineSortKey().getExpression()); + + // Set and Get + Expression expression = number(Expression.get("undefined")); + layer.setProperties(lineSortKey(expression)); + assertEquals(layer.getLineSortKey().getExpression(), expression); + } + @Test @UiThreadTest public void testLineOpacityTransition() { diff --git a/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java b/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java index 55ffe97dd..56cf1e845 100644 --- a/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java +++ b/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java @@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.testapp.style; +import android.graphics.Color; import androidx.test.annotation.UiThreadTest; import androidx.test.ext.junit.runners.AndroidJUnit4; @@ -9,11 +10,13 @@ import com.mapbox.mapboxsdk.maps.BaseLayerTest; import org.junit.Before; import timber.log.Timber; +import com.mapbox.mapboxsdk.style.expressions.Expression; import com.mapbox.mapboxsdk.style.layers.RasterLayer; import org.junit.Test; import org.junit.runner.RunWith; +import static com.mapbox.mapboxsdk.style.expressions.Expression.*; import static org.junit.Assert.*; import static com.mapbox.mapboxsdk.style.layers.Property.*; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*; diff --git a/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs b/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs index c71ea0d37..dd18ad581 100644 --- a/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs +++ b/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs @@ -7,7 +7,7 @@ package com.mapbox.mapboxsdk.testapp.style; import android.graphics.Color; -import android.support.test.annotation.UiThreadTest; +import androidx.test.annotation.UiThreadTest; import androidx.test.ext.junit.runners.AndroidJUnit4; import com.mapbox.mapboxsdk.maps.BaseLayerTest; diff --git a/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs b/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs index e26ec2d6c..b98e788ce 100644 --- a/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs +++ b/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs @@ -4,8 +4,8 @@ package com.mapbox.mapboxsdk.testapp.style; import android.graphics.Color; -import android.support.test.espresso.UiController; -import android.support.test.espresso.ViewAction; +import androidx.test.espresso.UiController; +import androidx.test.espresso.ViewAction; import androidx.test.ext.junit.runners.AndroidJUnit4; import android.view.View; @@ -24,9 +24,9 @@ import org.hamcrest.Matcher; import org.junit.Test; import org.junit.runner.RunWith; -import static android.support.test.espresso.Espresso.onView; -import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed; -import static android.support.test.espresso.matcher.ViewMatchers.withId; +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.withId; import static com.mapbox.mapboxsdk.style.expressions.Expression.eq; import static com.mapbox.mapboxsdk.style.layers.Property.ANCHOR_MAP; import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionBase; diff --git a/package-lock.json b/package-lock.json index 27c044c32..fe0b7d470 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,9 +5,9 @@ "requires": true, "dependencies": { "ejs": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/ejs/-/ejs-2.7.1.tgz", - "integrity": "sha512-kS/gEPzZs3Y1rRsbGX4UOSjtP/CeJP0CxSNZHYxGfVM/VgLcv0ZqM7C45YyTj2DI2g7+P9Dd24C+IMIg6D0nYQ==", + "version": "2.7.4", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-2.7.4.tgz", + "integrity": "sha512-7vmuyh5+kuUyJKePhQfRQBhXV5Ce+RnaeeQArKu1EAMpL3WbgMt5WG6uQZpEVvYSSsxMXRKOewtDk9RaTKXRlA==", "dev": true }, "esm": { diff --git a/package.json b/package.json index 8d3f68473..e509e6530 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "license": "BSD-2-Clause", "dependencies": {}, "devDependencies": { - "ejs": "^2.5.7", + "ejs": "^2.7.4", "esm": "~3.1.0", "lodash": "^4.16.4", "pixelmatch": "^4.0.2" diff --git a/scripts/generate-style-code.js b/scripts/generate-style-code.js index fd9490445..bc3f67c9a 100755 --- a/scripts/generate-style-code.js +++ b/scripts/generate-style-code.js @@ -8,8 +8,8 @@ const _ = require('lodash'); // FIXME: https://github.com/mapbox/mapbox-gl-native/issues/15008 delete spec.layout_circle["circle-sort-key"] -delete spec.layout_line["line-sort-key"] -delete spec.layout_fill["fill-sort-key"] +//delete spec.layout_line["line-sort-key"] +//delete spec.layout_fill["fill-sort-key"] require('../vendor/mapbox-gl-native/scripts/style-code'); @@ -383,6 +383,17 @@ for (const layer of layers) { writeIfModified(`MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/${camelize(layer.type)}LayerTest.java`, layerJavaUnitTests(layer)); } +// Jni +const layerHpp = ejs.compile(fs.readFileSync('vendor/mapbox-gl-native/platform/android/src/style/layers/layer.hpp.ejs', 'utf8'), {strict: true}); +const layerCpp = ejs.compile(fs.readFileSync('vendor/mapbox-gl-native/platform/android/src/style/layers/layer.cpp.ejs', 'utf8'), {strict: true}); + +for (const layer of layers) { + const layerFileName = layer.type.replace('-', '_'); + + writeIfModified(`vendor/mapbox-gl-native/platform/android/src/style/layers/${layerFileName}_layer.hpp`, layerHpp(layer)); + writeIfModified(`vendor/mapbox-gl-native/platform/android/src/style/layers/${layerFileName}_layer.cpp`, layerCpp(layer)); +} + // Java PropertyFactory const propertiesTemplate = ejs.compile(fs.readFileSync('MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/property_factory.java.ejs', 'utf8'), {strict: true}); writeIfModified( diff --git a/vendor/mapbox-gl-native b/vendor/mapbox-gl-native index efc605bed..fb0c7c93a 160000 --- a/vendor/mapbox-gl-native +++ b/vendor/mapbox-gl-native @@ -1 +1 @@ -Subproject commit efc605bed6f2d8f54b7097af1b91416c3fa13e06 +Subproject commit fb0c7c93a0f82cae603edc29e7e9a56024ed2b39