Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] Add OfflineManager.setAutopack(bool) API
Browse files Browse the repository at this point in the history
  • Loading branch information
pozdnyakov committed Nov 25, 2019
1 parent 6749a03 commit 753a640
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,23 @@ private boolean isValidOfflineRegionDefinition(OfflineRegionDefinition definitio
@Keep
public native void setOfflineMapboxTileCountLimit(long limit);

/**
* Sets the automatic database file packing.
* By default, the automatic database file packing is enabled.
* <p>
* If the automatic database file packing is enabled, the database file is packed
* automatically after {@link OfflineManager#clearAmbientCache} or {@link OfflineRegion#delete}
* calls.
*
* If the automatic database file packing is disabled, database file packing is only invoked on
* explicit {@link OfflineManager#packDatabase} calls.
* </p>
*
* @param autopack flag setting the automatic database file packing.
*/
@Keep
public native void setAutopack(boolean autopack);

@Keep
private native void initialize(FileSource fileSource);

Expand Down
5 changes: 5 additions & 0 deletions platform/android/src/offline/offline_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ void OfflineManager::setMaximumAmbientCacheSize(jni::JNIEnv& env_, const jni::jl
std::exception_ptr exception) mutable { handleException(exception, *callback); });
}

void OfflineManager::setAutopack(jni::JNIEnv&, jboolean autopack) {
fileSource->setAutopack(autopack);
}

// FileSource::FileSourceCallback //

void OfflineManager::FileSourceCallback::onSuccess(jni::JNIEnv& env,
Expand Down Expand Up @@ -211,6 +215,7 @@ void OfflineManager::registerNative(jni::JNIEnv& env) {
METHOD(&OfflineManager::invalidateAmbientCache, "nativeInvalidateAmbientCache"),
METHOD(&OfflineManager::clearAmbientCache, "nativeClearAmbientCache"),
METHOD(&OfflineManager::setMaximumAmbientCacheSize, "nativeSetMaximumAmbientCacheSize"),
METHOD(&OfflineManager::setAutopack, "setAutopack"),
METHOD(&OfflineManager::putResourceWithUrl, "putResourceWithUrl"));
}

Expand Down
2 changes: 2 additions & 0 deletions platform/android/src/offline/offline_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ class OfflineManager {

void setMaximumAmbientCacheSize(jni::JNIEnv&, const jni::jlong size, const jni::Object<FileSourceCallback>& callback_);

void setAutopack(jni::JNIEnv&, jboolean autopack);

private:
std::shared_ptr<mbgl::DefaultFileSource> fileSource;
};
Expand Down

0 comments on commit 753a640

Please sign in to comment.