Make Android snapshotter supports hiding the attribution (#3878)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -31,6 +31,7 @@ jni::Local<jni::Object<MapSnapshot>> MapSnapshot::New(JNIEnv& env,
|
||||
float pixelRatio,
|
||||
std::vector<std::string> attributions,
|
||||
bool showLogo,
|
||||
bool showAttribution,
|
||||
mbgl::MapSnapshotter::PointForFn pointForFn,
|
||||
mbgl::MapSnapshotter::LatLngForFn latLngForFn) {
|
||||
// Create the bitmap
|
||||
@@ -39,14 +40,17 @@ jni::Local<jni::Object<MapSnapshot>> MapSnapshot::New(JNIEnv& env,
|
||||
// Create the Mapsnapshot peers
|
||||
static auto& javaClass = jni::Class<MapSnapshot>::Singleton(env);
|
||||
static auto constructor =
|
||||
javaClass.GetConstructor<jni::jlong, jni::Object<Bitmap>, jni::Array<jni::String>, jni::jboolean>(env);
|
||||
javaClass
|
||||
.GetConstructor<jni::jlong, jni::Object<Bitmap>, jni::Array<jni::String>, jni::jboolean, jni::jboolean>(
|
||||
env);
|
||||
auto nativePeer = std::make_unique<MapSnapshot>(pixelRatio, pointForFn, latLngForFn);
|
||||
return javaClass.New(env,
|
||||
constructor,
|
||||
reinterpret_cast<jlong>(nativePeer.release()),
|
||||
bitmap,
|
||||
conversion::toArray(env, attributions),
|
||||
(jni::jboolean)showLogo);
|
||||
(jni::jboolean)showLogo,
|
||||
(jni::jboolean)showAttribution);
|
||||
}
|
||||
|
||||
void MapSnapshot::registerNative(jni::JNIEnv& env) {
|
||||
|
||||
@@ -27,6 +27,7 @@ public:
|
||||
float pixelRatio,
|
||||
std::vector<std::string> attributions,
|
||||
bool showLogo,
|
||||
bool showAttribution,
|
||||
PointForFn pointForFn,
|
||||
LatLngForFn latLngForFn);
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ MapSnapshotter::MapSnapshotter(jni::JNIEnv& _env,
|
||||
const jni::Object<LatLngBounds>& region,
|
||||
const jni::Object<CameraPosition>& position,
|
||||
jni::jboolean _showLogo,
|
||||
jni::jboolean _showAttribution,
|
||||
const jni::String& _localIdeographFontFamily)
|
||||
: javaPeer(_env, _obj),
|
||||
pixelRatio(_pixelRatio) {
|
||||
@@ -39,6 +40,7 @@ MapSnapshotter::MapSnapshotter(jni::JNIEnv& _env,
|
||||
auto size = mbgl::Size{static_cast<uint32_t>(width), static_cast<uint32_t>(height)};
|
||||
|
||||
showLogo = _showLogo;
|
||||
showAttribution = _showAttribution;
|
||||
|
||||
// Create the core snapshotter
|
||||
snapshotter = std::make_unique<mbgl::MapSnapshotter>(
|
||||
@@ -94,7 +96,7 @@ void MapSnapshotter::start(JNIEnv& env) {
|
||||
} else {
|
||||
// Create the wrapper
|
||||
auto mapSnapshot = android::MapSnapshot::New(
|
||||
*_env, std::move(image), pixelRatio, attributions, showLogo, pointForFn, latLngForFn);
|
||||
*_env, std::move(image), pixelRatio, attributions, showLogo, showAttribution, pointForFn, latLngForFn);
|
||||
|
||||
// invoke callback
|
||||
static auto onSnapshotReady = javaClass.GetMethod<void(jni::Object<MapSnapshot>)>(*_env, "onSnapshotReady");
|
||||
@@ -327,6 +329,7 @@ void MapSnapshotter::registerNative(jni::JNIEnv& env) {
|
||||
const jni::Object<LatLngBounds>&,
|
||||
const jni::Object<CameraPosition>&,
|
||||
jni::jboolean,
|
||||
jni::jboolean,
|
||||
const jni::String&>,
|
||||
"nativeInitialize",
|
||||
"finalize",
|
||||
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
const jni::Object<LatLngBounds>& region,
|
||||
const jni::Object<CameraPosition>& position,
|
||||
jni::jboolean showLogo,
|
||||
jni::jboolean _showAttribution,
|
||||
const jni::String& localIdeographFontFamily);
|
||||
|
||||
virtual ~MapSnapshotter() override;
|
||||
@@ -73,6 +74,7 @@ private:
|
||||
|
||||
float pixelRatio;
|
||||
bool showLogo;
|
||||
bool showAttribution;
|
||||
|
||||
FileSource* jFileSource;
|
||||
void activateFilesource(JNIEnv&);
|
||||
|
||||
Reference in New Issue
Block a user