summaryrefslogtreecommitdiff
path: root/platform/android/src/style
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/src/style')
-rw-r--r--platform/android/src/style/formatted.cpp43
-rw-r--r--platform/android/src/style/formatted.hpp23
-rw-r--r--platform/android/src/style/formatted_section.cpp11
-rw-r--r--platform/android/src/style/formatted_section.hpp18
-rw-r--r--platform/android/src/style/position.cpp2
5 files changed, 96 insertions, 1 deletions
diff --git a/platform/android/src/style/formatted.cpp b/platform/android/src/style/formatted.cpp
new file mode 100644
index 0000000000..ecbc7be1c8
--- /dev/null
+++ b/platform/android/src/style/formatted.cpp
@@ -0,0 +1,43 @@
+#include "formatted.hpp"
+#include "formatted_section.hpp"
+
+namespace mbgl {
+namespace android {
+
+void Formatted::registerNative(jni::JNIEnv& env) {
+ jni::Class<Formatted>::Singleton(env);
+}
+
+jni::Local<jni::Object<Formatted>> Formatted::New(jni::JNIEnv& env, const style::expression::Formatted& value) {
+ static auto& formatted = jni::Class<Formatted>::Singleton(env);
+ static auto formattedConstructor = formatted.GetConstructor<jni::Array<jni::Object<FormattedSection>>>(env);
+ static auto& formattedSection = jni::Class<FormattedSection>::Singleton(env);
+
+ auto sections = jni::Array<jni::Object<FormattedSection>>::New(env, value.sections.size());
+ for (std::size_t i = 0; i < value.sections.size(); i++) {
+ auto section = value.sections.at(i);
+ auto text = jni::Make<jni::String>(env, section.text);
+
+ double fontScale = 1.0;
+ if (section.fontScale) {
+ fontScale = section.fontScale.value();
+ }
+
+ if (section.fontStack) {
+ auto fontStack = jni::Array<jni::String>::New(env, section.fontStack.value().size());
+ for (std::size_t j = 0; j < section.fontStack.value().size(); j++) {
+ fontStack.Set(env, j, jni::Make<jni::String>(env, section.fontStack.value().at(j)));
+ }
+ static auto formattedSectionConstructor = formattedSection.GetConstructor<jni::String, double, jni::Array<jni::String>>(env);
+ sections.Set(env, i, formattedSection.New(env, formattedSectionConstructor, text, fontScale, fontStack));
+ } else {
+ static auto formattedSectionConstructor = formattedSection.GetConstructor<jni::String, double>(env);
+ sections.Set(env, i, formattedSection.New(env, formattedSectionConstructor, text, fontScale));
+ }
+ }
+
+ return formatted.New(env, formattedConstructor, sections);
+}
+
+} // namespace android
+} // namespace mbgl \ No newline at end of file
diff --git a/platform/android/src/style/formatted.hpp b/platform/android/src/style/formatted.hpp
new file mode 100644
index 0000000000..ca91f6562c
--- /dev/null
+++ b/platform/android/src/style/formatted.hpp
@@ -0,0 +1,23 @@
+#pragma once
+
+#include <mbgl/util/noncopyable.hpp>
+
+#include <jni/jni.hpp>
+#include <mbgl/style/expression/formatted.hpp>
+
+namespace mbgl {
+ namespace android {
+
+ using SuperTag = jni::ObjectTag;
+ class Formatted : private mbgl::util::noncopyable {
+ public:
+ static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/types/Formatted"; };
+
+ static jni::Local<jni::Object<Formatted>>
+ New(jni::JNIEnv&, const style::expression::Formatted &value);
+
+ static void registerNative(jni::JNIEnv &);
+ };
+
+ } // namespace android
+} // namespace mbgl \ No newline at end of file
diff --git a/platform/android/src/style/formatted_section.cpp b/platform/android/src/style/formatted_section.cpp
new file mode 100644
index 0000000000..ddcf76f816
--- /dev/null
+++ b/platform/android/src/style/formatted_section.cpp
@@ -0,0 +1,11 @@
+#include "formatted_section.hpp"
+
+namespace mbgl {
+namespace android {
+
+void FormattedSection::registerNative(jni::JNIEnv& env) {
+ jni::Class<FormattedSection>::Singleton(env);
+}
+
+} // namespace android
+} // namespace mbgl \ No newline at end of file
diff --git a/platform/android/src/style/formatted_section.hpp b/platform/android/src/style/formatted_section.hpp
new file mode 100644
index 0000000000..f759a94e8e
--- /dev/null
+++ b/platform/android/src/style/formatted_section.hpp
@@ -0,0 +1,18 @@
+#pragma once
+
+#include <mbgl/util/noncopyable.hpp>
+
+#include <jni/jni.hpp>
+
+namespace mbgl {
+namespace android {
+
+class FormattedSection : private mbgl::util::noncopyable {
+public:
+ static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/types/FormattedSection"; };
+
+ static void registerNative(jni::JNIEnv&);
+};
+
+} // namespace android
+} // namespace mbgl \ No newline at end of file
diff --git a/platform/android/src/style/position.cpp b/platform/android/src/style/position.cpp
index 20a0c47dff..326310be07 100644
--- a/platform/android/src/style/position.cpp
+++ b/platform/android/src/style/position.cpp
@@ -31,5 +31,5 @@ float Position::getPolarAngle(jni::JNIEnv& env, const jni::Object<Position>& pos
return position.Get(env, field);
}
-} // namespace andr[oid
+} // namespace android
} // namespace mbgl \ No newline at end of file