From 66b2a525917fa52d4e258ed039fd41fe5449bf63 Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 4 Mar 2020 16:54:09 +0800 Subject: [PATCH] [android] Add sort key jni binding for fill_layer and line_layer --- CHANGELOG.md | 6 ++++++ platform/android/src/style/layers/fill_layer.cpp | 10 +++++++++- platform/android/src/style/layers/fill_layer.hpp | 2 ++ platform/android/src/style/layers/layer.cpp.ejs | 4 +++- platform/android/src/style/layers/line_layer.cpp | 10 +++++++++- platform/android/src/style/layers/line_layer.hpp | 2 ++ 6 files changed, 31 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f829790d71..daa27e960c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,12 @@ But `within` expression need to accept an Object and then convert to GeoJSON object, now `toGeoJSON` method can convert both string and Object to GeoJSON. +### ✨ New features + +- [android] Add jni binding for line-sort-key and fill-sort-key ([#16256](https://github.com/mapbox/mapbox-gl-native/pull/16256)) + + With this change, android sdk will be able to get sort key for LineLayer and FillLayer. + ## maps-v1.3.0 (2020.02-relvanillashake) ### 🐞 Bug fixes diff --git a/platform/android/src/style/layers/fill_layer.cpp b/platform/android/src/style/layers/fill_layer.cpp index c54f4cd39d9..3679688efc7 100644 --- a/platform/android/src/style/layers/fill_layer.cpp +++ b/platform/android/src/style/layers/fill_layer.cpp @@ -41,6 +41,11 @@ namespace android { // Property getters + jni::Local> FillLayer::getFillSortKey(jni::JNIEnv& env) { + using namespace mbgl::android::conversion; + return std::move(*convert>>(env, toFillLayer(layer).getFillSortKey())); + } + jni::Local> FillLayer::getFillAntialias(jni::JNIEnv& env) { using namespace mbgl::android::conversion; return std::move(*convert>>(env, toFillLayer(layer).getFillAntialias())); @@ -172,10 +177,13 @@ namespace android { // Register the peer jni::RegisterNativePeer( - env, javaClass, "nativePtr", + env, + javaClass, + "nativePtr", jni::MakePeer, "initialize", "finalize", + METHOD(&FillLayer::getFillSortKey, "nativeGetFillSortKey"), METHOD(&FillLayer::getFillAntialias, "nativeGetFillAntialias"), METHOD(&FillLayer::getFillOpacityTransition, "nativeGetFillOpacityTransition"), METHOD(&FillLayer::setFillOpacityTransition, "nativeSetFillOpacityTransition"), diff --git a/platform/android/src/style/layers/fill_layer.hpp b/platform/android/src/style/layers/fill_layer.hpp index b021ddca143..e6471643cae 100644 --- a/platform/android/src/style/layers/fill_layer.hpp +++ b/platform/android/src/style/layers/fill_layer.hpp @@ -26,6 +26,8 @@ class FillLayer : public Layer { // Properties + jni::Local> getFillSortKey(jni::JNIEnv&); + jni::Local> getFillAntialias(jni::JNIEnv&); jni::Local> getFillOpacity(jni::JNIEnv&); diff --git a/platform/android/src/style/layers/layer.cpp.ejs b/platform/android/src/style/layers/layer.cpp.ejs index c81fc5ab39b..e98ee49ff66 100644 --- a/platform/android/src/style/layers/layer.cpp.ejs +++ b/platform/android/src/style/layers/layer.cpp.ejs @@ -118,7 +118,9 @@ namespace android { // Register the peer jni::RegisterNativePeer<<%- camelize(type) %>Layer>( - env, javaClass, "nativePtr", + env, + javaClass, + "nativePtr", <% if (type === 'background') { -%> jni::MakePeer<<%- camelize(type) %>Layer, jni::String&>, <% } else { -%> diff --git a/platform/android/src/style/layers/line_layer.cpp b/platform/android/src/style/layers/line_layer.cpp index 73fcd5f9915..1719c9ae59c 100644 --- a/platform/android/src/style/layers/line_layer.cpp +++ b/platform/android/src/style/layers/line_layer.cpp @@ -61,6 +61,11 @@ namespace android { return std::move(*convert>>(env, toLineLayer(layer).getLineRoundLimit())); } + jni::Local> LineLayer::getLineSortKey(jni::JNIEnv& env) { + using namespace mbgl::android::conversion; + return std::move(*convert>>(env, toLineLayer(layer).getLineSortKey())); + } + jni::Local> LineLayer::getLineOpacity(jni::JNIEnv& env) { using namespace mbgl::android::conversion; return std::move(*convert>>(env, toLineLayer(layer).getLineOpacity())); @@ -264,7 +269,9 @@ namespace android { // Register the peer jni::RegisterNativePeer( - env, javaClass, "nativePtr", + env, + javaClass, + "nativePtr", jni::MakePeer, "initialize", "finalize", @@ -272,6 +279,7 @@ namespace android { METHOD(&LineLayer::getLineJoin, "nativeGetLineJoin"), METHOD(&LineLayer::getLineMiterLimit, "nativeGetLineMiterLimit"), METHOD(&LineLayer::getLineRoundLimit, "nativeGetLineRoundLimit"), + METHOD(&LineLayer::getLineSortKey, "nativeGetLineSortKey"), METHOD(&LineLayer::getLineOpacityTransition, "nativeGetLineOpacityTransition"), METHOD(&LineLayer::setLineOpacityTransition, "nativeSetLineOpacityTransition"), METHOD(&LineLayer::getLineOpacity, "nativeGetLineOpacity"), diff --git a/platform/android/src/style/layers/line_layer.hpp b/platform/android/src/style/layers/line_layer.hpp index 75a367ab70d..72a69f218ea 100644 --- a/platform/android/src/style/layers/line_layer.hpp +++ b/platform/android/src/style/layers/line_layer.hpp @@ -34,6 +34,8 @@ class LineLayer : public Layer { jni::Local> getLineRoundLimit(jni::JNIEnv&); + jni::Local> getLineSortKey(jni::JNIEnv&); + jni::Local> getLineOpacity(jni::JNIEnv&); void setLineOpacityTransition(jni::JNIEnv&, jlong duration, jlong delay); jni::Local> getLineOpacityTransition(jni::JNIEnv&);