diff --git a/CHANGELOG.md b/CHANGELOG.md index 26c14cfba..db9bf997d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ Mapbox welcomes participation and contributions from everyone. Please read [`Contributing Guide`](https://github.com/mapbox/mapbox-gl-native/blob/master/CONTRIBUTING.md) to get started. +## 9.5.0-alpha.1 - September 3, 2020 +[Changes](https://github.com/mapbox/mapbox-gl-native-android/compare/android-v9.4.0...android-v9.5.0-alpha.1) since [Mapbox Maps SDK for Android v9.4.0](https://github.com/mapbox/mapbox-gl-native-android/releases/tag/android-v9.4.0) +### Changes made to match core library v4.0.0 updates + - Remove `LocalGlyphRasterizer`, now it's a part of core as pure C++ implementation. ([#548](https://github.com/mapbox/mapbox-gl-native-android/pull/548)) + - `LocationIndicatorLayer`: deprecate getImageTiltDisplacement method, introduce it's replacement - getImagePitchDisplacement. ([#548](https://github.com/mapbox/mapbox-gl-native-android/pull/548)) + - `LocationPropertyFactory`: `imageTiltDisplacement` methods are deprecated, `imagePitchDisplacement` are introduced for replacement. ([#548](https://github.com/mapbox/mapbox-gl-native-android/pull/548)) +### Dependencies + - Update core library to 4.0.0 + ## 9.4.0 - August 26, 2020 [Changes](https://github.com/mapbox/mapbox-gl-native-android/compare/android-v9.3.0...android-v9.4.0) since [Mapbox Maps SDK for Android v9.3.0](https://github.com/mapbox/mapbox-gl-native-android/releases/tag/android-v9.3.0) ### Features diff --git a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationIndicatorLayer.java b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationIndicatorLayer.java index 9399c8fa3..72375df41 100644 --- a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationIndicatorLayer.java +++ b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationIndicatorLayer.java @@ -111,15 +111,30 @@ public PropertyValue getPerspectiveCompensation() { } /** + * @deprecated Use {@link LocationIndicatorLayer#getImagePitchDisplacement} instead. + * * Get the ImageTiltDisplacement property * * @return property wrapper value around Float */ @NonNull @SuppressWarnings("unchecked") + @Deprecated public PropertyValue getImageTiltDisplacement() { checkThread(); - return (PropertyValue) new PropertyValue("image-tilt-displacement", nativeGetImageTiltDisplacement()); + return (PropertyValue) new PropertyValue("image-pitch-displacement", nativeGetImageTiltDisplacement()); + } + + /** + * Get the ImagePitchDisplacement property + * + * @return property wrapper value around Float + */ + @NonNull + @SuppressWarnings("unchecked") + public PropertyValue getImagePitchDisplacement() { + checkThread(); + return (PropertyValue) new PropertyValue("image-pitch-displacement", nativeGetImagePitchDisplacement()); } /** @@ -419,6 +434,10 @@ public void setAccuracyRadiusBorderColorTransition(@NonNull TransitionOptions op @Keep private native Object nativeGetImageTiltDisplacement(); + @NonNull + @Keep + private native Object nativeGetImagePitchDisplacement(); + @NonNull @Keep private native Object nativeGetBearing(); diff --git a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationPropertyFactory.java b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationPropertyFactory.java index 367c47091..9fb6ed6d0 100644 --- a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationPropertyFactory.java +++ b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationPropertyFactory.java @@ -50,25 +50,50 @@ public static PropertyValue perspectiveCompensation(Expression expre } /** + * @deprecated Use {@link LocationPropertyFactory#imagePitchDisplacement} instead. + * * The displacement off the center of the top image and the shadow image when the pitch of the map is greater than 0. This helps producing a three-dimensional appearence. * * @param value a Float value * @return property wrapper around Float */ public static PropertyValue imageTiltDisplacement(Float value) { - return new PaintPropertyValue<>("image-tilt-displacement", value); + return new PaintPropertyValue<>("image-pitch-displacement", value); } /** + * @deprecated Use {@link LocationPropertyFactory#imagePitchDisplacement} instead. + * * The displacement off the center of the top image and the shadow image when the pitch of the map is greater than 0. This helps producing a three-dimensional appearence. * * @param expression an expression statement * @return property wrapper around an expression statement */ public static PropertyValue imageTiltDisplacement(Expression expression) { - return new PaintPropertyValue<>("image-tilt-displacement", expression); + return new PaintPropertyValue<>("image-pitch-displacement", expression); + } + + /** + * The displacement off the center of the top image and the shadow image when the pitch of the map is greater than 0. This helps producing a three-dimensional appearence. + * + * @param value a Float value + * @return property wrapper around Float + */ + public static PropertyValue imagePitchDisplacement(Float value) { + return new PaintPropertyValue<>("image-pitch-displacement", value); } + /** + * The displacement off the center of the top image and the shadow image when the pitch of the map is greater than 0. This helps producing a three-dimensional appearence. + * + * @param expression an expression statement + * @return property wrapper around an expression statement + */ + public static PropertyValue imagePitchDisplacement(Expression expression) { + return new PaintPropertyValue<>("image-pitch-displacement", expression); + } + + /** * The bearing of the location indicator. * diff --git a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/text/LocalGlyphRasterizer.java b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/text/LocalGlyphRasterizer.java deleted file mode 100644 index de920ded2..000000000 --- a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/text/LocalGlyphRasterizer.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.mapbox.mapboxsdk.text; - -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Bitmap; -import android.graphics.Rect; -import android.graphics.Typeface; -import androidx.annotation.Keep; -import androidx.annotation.NonNull; -import androidx.annotation.WorkerThread; - -/** - * LocalGlyphRasterizer is the Android-specific platform implementation used - * by the portable local_glyph_rasterizer.hpp - */ -@Keep -class LocalGlyphRasterizer { - - @Keep - private class GlyphMetrics { - int width; - int height; - int top; - int left; - int ascender; - int descender; - int advance; - Bitmap glyphBitmap; - } - - @NonNull - private final GlyphMetrics glyphMetrics; - @NonNull - private final Rect bounds; - @NonNull - private final Paint paint; - @NonNull - private final Canvas canvas; - - LocalGlyphRasterizer() { - glyphMetrics = new GlyphMetrics(); - glyphMetrics.glyphBitmap = Bitmap.createBitmap(35, 35, Bitmap.Config.ARGB_8888); - - bounds = new Rect(); - - paint = new Paint(); - paint.setAntiAlias(true); - paint.setTextSize(24); - - canvas = new Canvas(); - canvas.setBitmap(glyphMetrics.glyphBitmap); - } - - /*** - * Uses Android-native drawing code to encapsulate the glyph metrics and a raterized - * square {@link Bitmap} to a single structure which can be returned to portable - * code for transformation into the native glyph data structure. - * - * @param fontFamily Font family string to pass to Typeface.create - * @param bold If true, use Typeface.BOLD option - * @param glyphID 16-bit Unicode BMP codepoint to draw - * - * @return Return GlyphMetrics that contains all the necessary information to display - * the character in the requested tile. - */ - @WorkerThread - protected GlyphMetrics getGlyphMetrics(String fontFamily, boolean bold, char glyphID) { - paint.setTypeface(Typeface.create(fontFamily, bold ? Typeface.BOLD : Typeface.NORMAL)); - - // Get font metrics - Paint.FontMetricsInt metrics = paint.getFontMetricsInt(); - glyphMetrics.ascender = Math.abs(metrics.top); - glyphMetrics.descender = Math.abs(metrics.bottom); - - String glyph = String.valueOf(glyphID); - paint.getTextBounds(glyph, 0, 1, bounds); - glyphMetrics.left = bounds.left; - glyphMetrics.width = bounds.right - bounds.left; - glyphMetrics.height = bounds.bottom - bounds.top; - glyphMetrics.top = Math.abs(bounds.top); - glyphMetrics.advance = Math.round(paint.measureText(glyph, 0, 1)); - - if (glyphMetrics.width == 0 && glyphMetrics.height == 0) { - return glyphMetrics; - } - // Draw glyph on the canvas with the 3 pixels' boarder padding from the left and top - float x = 3 - bounds.left; - float y = 3 - bounds.top; - canvas.drawColor(Color.WHITE); - canvas.drawText(glyph, x, y, paint); - - return glyphMetrics; - } -} \ No newline at end of file diff --git a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/text/package-info.java b/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/text/package-info.java deleted file mode 100644 index 52c7014bc..000000000 --- a/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/text/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Contains the Mapbox Maps Android Text API classes. - */ -package com.mapbox.mapboxsdk.text; diff --git a/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationIndicatorLayerTest.java b/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationIndicatorLayerTest.java index 3197af4a3..85eed235d 100644 --- a/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationIndicatorLayerTest.java +++ b/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationIndicatorLayerTest.java @@ -114,6 +114,19 @@ public void testImageTiltDisplacementAsConstant() { assertEquals(layer.getImageTiltDisplacement().getValue(), propertyValue); } + @Test + @UiThreadTest + public void testImagePitchDisplacementAsConstant() { + Timber.i("image-tilt-displacement"); + assertNotNull(layer); + assertNull(layer.getImagePitchDisplacement().getValue()); + + // Set and Get + Float propertyValue = 0.3f; + layer.setProperties(imageTiltDisplacement(propertyValue)); + assertEquals(layer.getImagePitchDisplacement().getValue(), propertyValue); + } + @Test @UiThreadTest public void testBearingAsConstant() { 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 73527a295..5c88fdabe 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 @@ -195,7 +195,7 @@ public void testHeatmapRadiusAsConstant() { assertNull(layer.getHeatmapRadius().getValue()); // Set and Get - Float propertyValue = 0.3f; + Float propertyValue = 1.0f; layer.setProperties(heatmapRadius(propertyValue)); assertEquals(layer.getHeatmapRadius().getValue(), propertyValue); } diff --git a/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java b/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java index e08ae2d06..0313f0ada 100644 --- a/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java +++ b/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java @@ -198,7 +198,7 @@ public void testSymbolSpacingAsConstant() { assertNull(layer.getSymbolSpacing().getValue()); // Set and Get - Float propertyValue = 0.3f; + Float propertyValue = 1.0f; layer.setProperties(symbolSpacing(propertyValue)); assertEquals(layer.getSymbolSpacing().getValue(), propertyValue); } diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 6cae8249f..27c38f6cc 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -40,7 +40,7 @@ ext { ktlint : '0.34.0', commonsIO : '2.6', mapboxSdkVersions: '1.1.0', - mapboxSdkCore : '3.1.0', + mapboxSdkCore : '4.0.0', mapboxSdkRegistryPlugin: '0.2.1' ]