From 40d818715c87c38f3bba2efa626b196673e8d666 Mon Sep 17 00:00:00 2001 From: Sarah Date: Wed, 4 Oct 2023 16:10:22 +0200 Subject: [PATCH 1/2] feat: update maplibre native version --- android/rctmgl/build.gradle | 8 ++-- .../rctmgl/location/LocationManager.java | 4 +- .../rctmgl/modules/RCTMGLOfflineModule.java | 47 +++++++++---------- 3 files changed, 27 insertions(+), 32 deletions(-) diff --git a/android/rctmgl/build.gradle b/android/rctmgl/build.gradle index fb0efce5e..ee3a4ae17 100644 --- a/android/rctmgl/build.gradle +++ b/android/rctmgl/build.gradle @@ -33,7 +33,7 @@ dependencies { implementation("com.facebook.react:react-android") // MapLibre SDK - implementation "org.maplibre.gl:android-sdk:9.6.0" + implementation "org.maplibre.gl:android-sdk:10.2.0" implementation "org.maplibre.gl:android-sdk-turf:5.9.0" // Dependencies @@ -45,9 +45,9 @@ dependencies { // MapLibre plugins - implementation ("org.maplibre.gl:android-plugin-localization-v9:1.0.0") - implementation ("org.maplibre.gl:android-plugin-annotation-v9:1.0.0") - implementation ("org.maplibre.gl:android-plugin-markerview-v9:1.0.0") + implementation ("org.maplibre.gl:android-plugin-localization-v9:2.0.1") + implementation ("org.maplibre.gl:android-plugin-annotation-v9:2.0.1") + implementation ("org.maplibre.gl:android-plugin-markerview-v9:2.0.1") } allprojects { diff --git a/android/rctmgl/src/main/java/com/mapbox/rctmgl/location/LocationManager.java b/android/rctmgl/src/main/java/com/mapbox/rctmgl/location/LocationManager.java index 88db2137d..16dbb387f 100644 --- a/android/rctmgl/src/main/java/com/mapbox/rctmgl/location/LocationManager.java +++ b/android/rctmgl/src/main/java/com/mapbox/rctmgl/location/LocationManager.java @@ -13,7 +13,7 @@ import com.mapbox.android.core.location.LocationEnginePriority; */ -import com.mapbox.mapboxsdk.location.engine.LocationEngineProvider; +import com.mapbox.mapboxsdk.location.engine.LocationEngineDefault; import com.mapbox.mapboxsdk.location.engine.LocationEngineRequest; import com.mapbox.mapboxsdk.location.engine.LocationEngineResult; import com.mapbox.mapboxsdk.location.permissions.PermissionsManager; @@ -63,7 +63,7 @@ private LocationManager(Context context) { } private void buildEngineRequest() { - locationEngine = LocationEngineProvider.getBestLocationEngine(this.context.getApplicationContext()); + locationEngine = LocationEngineDefault.INSTANCE.getDefaultLocationEngine(this.context.getApplicationContext()); locationEngineRequest = new LocationEngineRequest.Builder(DEFAULT_INTERVAL_MILLIS) .setFastestInterval(DEFAULT_FASTEST_INTERVAL_MILLIS) .setPriority(LocationEngineRequest.PRIORITY_HIGH_ACCURACY) diff --git a/android/rctmgl/src/main/java/com/mapbox/rctmgl/modules/RCTMGLOfflineModule.java b/android/rctmgl/src/main/java/com/mapbox/rctmgl/modules/RCTMGLOfflineModule.java index bbb34bf15..80e714167 100644 --- a/android/rctmgl/src/main/java/com/mapbox/rctmgl/modules/RCTMGLOfflineModule.java +++ b/android/rctmgl/src/main/java/com/mapbox/rctmgl/modules/RCTMGLOfflineModule.java @@ -1,18 +1,11 @@ package com.mapbox.rctmgl.modules; +import android.content.Context; import android.os.Handler; import android.os.Looper; import android.util.Log; -import com.facebook.react.bridge.Arguments; -import com.facebook.react.bridge.Promise; -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.bridge.ReactContextBaseJavaModule; -import com.facebook.react.bridge.ReactMethod; -import com.facebook.react.bridge.ReadableMap; -import com.facebook.react.bridge.WritableArray; -import com.facebook.react.bridge.WritableMap; -import com.facebook.react.bridge.WritableNativeMap; +import com.facebook.react.bridge.*; import com.facebook.react.module.annotations.ReactModule; import com.facebook.react.modules.core.RCTNativeAppEventEmitter; import com.mapbox.geojson.FeatureCollection; @@ -58,12 +51,14 @@ public class RCTMGLOfflineModule extends ReactContextBaseJavaModule { public static final Double DEFAULT_MIN_ZOOM_LEVEL = 10.0; public static final Double DEFAULT_MAX_ZOOM_LEVEL = 20.0; - private ReactApplicationContext mReactContext; + private final Context mContext; + private final ReactContext mReactContext; private Double mProgressEventThrottle = 300.0; public RCTMGLOfflineModule(ReactApplicationContext reactApplicationContext) { super(reactApplicationContext); mReactContext = reactApplicationContext; + mContext = reactApplicationContext.getApplicationContext(); } @Override @@ -84,7 +79,7 @@ public void removeListeners(Integer count) { @ReactMethod public void createPack(ReadableMap options, final Promise promise) { final String name = ConvertUtils.getString("name", options, ""); - final OfflineManager offlineManager = OfflineManager.getInstance(mReactContext); + final OfflineManager offlineManager = OfflineManager.Companion.getInstance(mContext); LatLngBounds latLngBounds = getBoundsFromOptions(options); OfflineRegionDefinition definition = makeDefinition(latLngBounds, options); @@ -110,7 +105,7 @@ public void onError(String error) { public void getPacks(final Promise promise) { activateFileSource(); - final OfflineManager offlineManager = OfflineManager.getInstance(mReactContext); + final OfflineManager offlineManager = OfflineManager.Companion.getInstance(mContext); offlineManager.listOfflineRegions(new OfflineManager.ListOfflineRegionsCallback() { @Override @@ -134,7 +129,7 @@ public void onError(String error) { @ReactMethod public void invalidateAmbientCache(final Promise promise) { activateFileSource(); - final OfflineManager offlineManager = OfflineManager.getInstance(mReactContext); + final OfflineManager offlineManager = OfflineManager.Companion.getInstance(mContext); offlineManager.invalidateAmbientCache(new OfflineManager.FileSourceCallback() { @Override public void onSuccess() { @@ -152,7 +147,7 @@ public void onError(String error) { public void clearAmbientCache(final Promise promise) { activateFileSource(); - final OfflineManager offlineManager = OfflineManager.getInstance(mReactContext); + final OfflineManager offlineManager = OfflineManager.Companion.getInstance(mContext); offlineManager.clearAmbientCache(new OfflineManager.FileSourceCallback() { @Override @@ -171,7 +166,7 @@ public void onError(String error) { public void setMaximumAmbientCacheSize(int size, final Promise promise) { activateFileSource(); - final OfflineManager offlineManager = OfflineManager.getInstance(mReactContext); + final OfflineManager offlineManager = OfflineManager.Companion.getInstance(mContext); offlineManager.setMaximumAmbientCacheSize(size, new OfflineManager.FileSourceCallback() { @Override @@ -190,7 +185,7 @@ public void onError(String error) { @ReactMethod public void resetDatabase(final Promise promise) { activateFileSource(); - final OfflineManager offlineManager = OfflineManager.getInstance(mReactContext); + final OfflineManager offlineManager = OfflineManager.Companion.getInstance(mContext); offlineManager.resetDatabase(new OfflineManager.FileSourceCallback() { @Override public void onSuccess() { @@ -208,7 +203,7 @@ public void onError(String error) { public void getPackStatus(final String name, final Promise promise) { activateFileSource(); - final OfflineManager offlineManager = OfflineManager.getInstance(mReactContext); + final OfflineManager offlineManager = OfflineManager.Companion.getInstance(mContext); offlineManager.listOfflineRegions(new OfflineManager.ListOfflineRegionsCallback() { @Override @@ -245,7 +240,7 @@ public void onError(String error) { public void setPackObserver(final String name, final Promise promise) { activateFileSource(); - final OfflineManager offlineManager = OfflineManager.getInstance(mReactContext); + final OfflineManager offlineManager = OfflineManager.Companion.getInstance(mContext); offlineManager.listOfflineRegions(new OfflineManager.ListOfflineRegionsCallback() { @Override @@ -271,7 +266,7 @@ public void onError(String error) { public void invalidatePack(final String name, final Promise promise) { activateFileSource(); - final OfflineManager offlineManager = OfflineManager.getInstance(mReactContext); + final OfflineManager offlineManager = OfflineManager.Companion.getInstance(mContext); offlineManager.listOfflineRegions(new OfflineManager.ListOfflineRegionsCallback() { @Override @@ -308,7 +303,7 @@ public void onError(String error) { public void deletePack(final String name, final Promise promise) { activateFileSource(); - final OfflineManager offlineManager = OfflineManager.getInstance(mReactContext); + final OfflineManager offlineManager = OfflineManager.Companion.getInstance(mContext); offlineManager.listOfflineRegions(new OfflineManager.ListOfflineRegionsCallback() { @Override @@ -348,7 +343,7 @@ public void onError(String error) { public void pausePackDownload(final String name, final Promise promise) { activateFileSource(); - final OfflineManager offlineManager = OfflineManager.getInstance(mReactContext); + final OfflineManager offlineManager = OfflineManager.Companion.getInstance(mContext); offlineManager.listOfflineRegions(new OfflineManager.ListOfflineRegionsCallback() { @Override @@ -380,7 +375,7 @@ public void onError(String error) { public void resumePackDownload(final String name, final Promise promise) { activateFileSource(); - final OfflineManager offlineManager = OfflineManager.getInstance(mReactContext); + final OfflineManager offlineManager = OfflineManager.Companion.getInstance(mContext); offlineManager.listOfflineRegions(new OfflineManager.ListOfflineRegionsCallback() { @Override @@ -407,7 +402,7 @@ public void onError(String error) { public void mergeOfflineRegions(final String path, final Promise promise) { activateFileSource(); - final OfflineManager offlineManager = OfflineManager.getInstance(mReactContext); + final OfflineManager offlineManager = OfflineManager.Companion.getInstance(mContext); offlineManager.mergeOfflineRegions(path, new OfflineManager.MergeOfflineRegionsCallback() { @Override @@ -424,7 +419,7 @@ public void onError(String error) { @ReactMethod public void setTileCountLimit(int tileCountLimit) { - OfflineManager offlineManager = OfflineManager.getInstance(mReactContext); + OfflineManager offlineManager = OfflineManager.Companion.getInstance(mContext); offlineManager.setOfflineMapboxTileCountLimit(tileCountLimit); } @@ -439,7 +434,7 @@ private OfflineRegionDefinition makeDefinition(LatLngBounds latLngBounds, Readab latLngBounds, ConvertUtils.getDouble("minZoom", options, DEFAULT_MIN_ZOOM_LEVEL), ConvertUtils.getDouble("maxZoom", options, DEFAULT_MAX_ZOOM_LEVEL), - mReactContext.getResources().getDisplayMetrics().density); + mContext.getResources().getDisplayMetrics().density); } private byte[] getMetadataBytes(String metadata) { @@ -591,7 +586,7 @@ private OfflineRegion getRegionByName(String name, OfflineRegion[] offlineRegion } private void activateFileSource() { - FileSource fileSource = FileSource.getInstance(mReactContext); + FileSource fileSource = FileSource.getInstance(mContext); fileSource.activate(); } } From 53e7b01b94880d66631a29a757f874cd47d99db0 Mon Sep 17 00:00:00 2001 From: Sarah Date: Wed, 4 Oct 2023 16:17:48 +0200 Subject: [PATCH 2/2] chore: add changelog entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10149115f..2d8b51486 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ Please add unreleased changes in the following style: PR Title ([#123](link to my pr)) ``` +Update react-maplibre ([#34](https://github.com/maplibre/maplibre-react-native/issues/34)) + ## 9.1.0 Update react to 18.2.0 and react-native to 0.72.1. ([#49](https://github.com/maplibre/maplibre-react-native/pull/49))