diff options
author | Tobrun <tobrun.van.nuland@gmail.com> | 2017-10-27 15:57:35 -0700 |
---|---|---|
committer | Tobrun <tobrun@mapbox.com> | 2017-11-01 14:56:37 -0700 |
commit | cb7f6dfaec2f90a81d588c2458e01d2a191f9ba1 (patch) | |
tree | eeb4d9847940c571f5a03ae4e52f32fd776451be /platform/android/src | |
parent | e5243b7691831e194ccb1638d33b8d4dd94f4d9c (diff) | |
download | qtlocation-mapboxgl-cb7f6dfaec2f90a81d588c2458e01d2a191f9ba1.tar.gz |
[android] - make snapshot logo optional
Diffstat (limited to 'platform/android/src')
4 files changed, 11 insertions, 4 deletions
diff --git a/platform/android/src/snapshotter/map_snapshot.cpp b/platform/android/src/snapshotter/map_snapshot.cpp index 843a8a487a..f5092b3c56 100644 --- a/platform/android/src/snapshotter/map_snapshot.cpp +++ b/platform/android/src/snapshotter/map_snapshot.cpp @@ -27,14 +27,15 @@ jni::Object<MapSnapshot> MapSnapshot::New(JNIEnv& env, PremultipliedImage&& image, float pixelRatio, std::vector<std::string> attributions, + bool showLogo, mbgl::MapSnapshotter::PointForFn pointForFn) { // Create the bitmap auto bitmap = Bitmap::CreateBitmap(env, std::move(image)); // Create the Mapsnapshot peers - static auto constructor = javaClass.GetConstructor<jni::jlong, jni::Object<Bitmap>, jni::Array<jni::String>>(env); + static auto constructor = javaClass.GetConstructor<jni::jlong, jni::Object<Bitmap>, jni::Array<jni::String>, jni::jboolean>(env); auto nativePeer = std::make_unique<MapSnapshot>(pixelRatio, pointForFn); - return javaClass.New(env, constructor, reinterpret_cast<jlong>(nativePeer.release()), bitmap, jni::Make<jni::Array<jni::String>>(env, attributions)); + return javaClass.New(env, constructor, reinterpret_cast<jlong>(nativePeer.release()), bitmap, jni::Make<jni::Array<jni::String>>(env, attributions), (jni::jboolean) showLogo); } jni::Class<MapSnapshot> MapSnapshot::javaClass; diff --git a/platform/android/src/snapshotter/map_snapshot.hpp b/platform/android/src/snapshotter/map_snapshot.hpp index 64090bb48b..4673dcd16e 100644 --- a/platform/android/src/snapshotter/map_snapshot.hpp +++ b/platform/android/src/snapshotter/map_snapshot.hpp @@ -26,6 +26,7 @@ public: PremultipliedImage&& image, float pixelRatio, std::vector<std::string> attributions, + bool showLogo, PointForFn pointForFn); MapSnapshot(jni::JNIEnv&) {}; diff --git a/platform/android/src/snapshotter/map_snapshotter.cpp b/platform/android/src/snapshotter/map_snapshotter.cpp index 3c6623af40..637eb5c1fd 100644 --- a/platform/android/src/snapshotter/map_snapshotter.cpp +++ b/platform/android/src/snapshotter/map_snapshotter.cpp @@ -22,6 +22,7 @@ MapSnapshotter::MapSnapshotter(jni::JNIEnv& _env, jni::String styleURL, jni::Object<LatLngBounds> region, jni::Object<CameraPosition> position, + jni::jboolean _showLogo, jni::String _programCacheDir) : javaPeer(SeizeGenericWeakRef(_env, jni::Object<MapSnapshotter>(jni::NewWeakGlobalRef(_env, _obj.Get()).release()))) , pixelRatio(_pixelRatio) @@ -41,6 +42,8 @@ MapSnapshotter::MapSnapshotter(jni::JNIEnv& _env, bounds = LatLngBounds::getLatLngBounds(_env, region); } + showLogo = _showLogo; + // Create the core snapshotter snapshotter = std::make_unique<mbgl::MapSnapshotter>(fileSource, *threadPool, @@ -70,7 +73,7 @@ void MapSnapshotter::start(JNIEnv&) { javaPeer->Call(*_env, onSnapshotFailed, jni::Make<jni::String>(*_env, util::toString(err))); } else { // Create the wrapper - auto mapSnapshot = android::MapSnapshot::New(*_env, std::move(image), pixelRatio, attributions, pointForFn); + auto mapSnapshot = android::MapSnapshot::New(*_env, std::move(image), pixelRatio, attributions, showLogo, pointForFn); // invoke callback static auto onSnapshotReady = javaClass.GetMethod<void (jni::Object<MapSnapshot>)>(*_env, "onSnapshotReady"); @@ -117,7 +120,7 @@ void MapSnapshotter::registerNative(jni::JNIEnv& env) { // Register the peer jni::RegisterNativePeer<MapSnapshotter>(env, MapSnapshotter::javaClass, "nativePtr", - std::make_unique<MapSnapshotter, JNIEnv&, jni::Object<MapSnapshotter>, jni::Object<FileSource>, jni::jfloat, jni::jint, jni::jint, jni::String, jni::Object<LatLngBounds>, jni::Object<CameraPosition>, jni::String>, + std::make_unique<MapSnapshotter, JNIEnv&, jni::Object<MapSnapshotter>, jni::Object<FileSource>, jni::jfloat, jni::jint, jni::jint, jni::String, jni::Object<LatLngBounds>, jni::Object<CameraPosition>, jni::jboolean, jni::String>, "nativeInitialize", "finalize", METHOD(&MapSnapshotter::setStyleUrl, "setStyleUrl"), diff --git a/platform/android/src/snapshotter/map_snapshotter.hpp b/platform/android/src/snapshotter/map_snapshotter.hpp index fa8a2d7a5a..8cd85060bf 100644 --- a/platform/android/src/snapshotter/map_snapshotter.hpp +++ b/platform/android/src/snapshotter/map_snapshotter.hpp @@ -36,6 +36,7 @@ public: jni::String styleURL, jni::Object<LatLngBounds> region, jni::Object<CameraPosition> position, + jni::jboolean showLogo, jni::String programCacheDir); ~MapSnapshotter(); @@ -59,6 +60,7 @@ private: GenericUniqueWeakObject<MapSnapshotter> javaPeer; float pixelRatio; + bool showLogo; std::shared_ptr<mbgl::ThreadPool> threadPool; std::unique_ptr<Actor<mbgl::MapSnapshotter::Callback>> snapshotCallback; |