Skip to content

Commit

Permalink
Update Plugins for MapLibre Native Android v11 (#50)
Browse files Browse the repository at this point in the history
* Updated package names

Package names changed from com.mapboxsdk to org.maplibre.android.

* Update dependencies

Switch to Kotlin 1.9.0

* Updated template files for plugin-annotation / Restored Kotlin version to 1.8.10

Updated templates and files regenerated based on these templates.
Restored Kotlin version to 1.8.10.

* Updated for latest release of Maplibre.

* Update other plugins

* Update checkout action

* Updated Instrumentation Tests for plugin-annotation

* Replace MapboxMap

* Replace some mapboxMap

---------

Co-authored-by: Christophe Brasseur <[email protected]>
Co-authored-by: Bart Louwers <[email protected]>
  • Loading branch information
3 people authored May 14, 2024
1 parent 28c82a8 commit 36a02c0
Show file tree
Hide file tree
Showing 98 changed files with 1,085 additions and 1,080 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
BUILDTYPE: Release
IS_LOCAL_DEVELOPMENT: false
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.plugins.annotation.MapboxMapAction;
import com.mapbox.mapboxsdk.plugins.annotation.WaitAction;
import com.mapbox.mapboxsdk.plugins.utils.OnMapReadyIdlingResource;
Expand All @@ -16,6 +15,7 @@
import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TestName;
import org.maplibre.android.maps.MapLibreMap;

import androidx.test.espresso.Espresso;
import androidx.test.espresso.IdlingRegistry;
Expand All @@ -38,7 +38,7 @@ public abstract class BaseActivityTest {
@Rule
public TestName testName = new TestName();

protected MapboxMap mapboxMap;
protected MapLibreMap maplibreMap;
protected OnMapReadyIdlingResource idlingResource;

@Before
Expand All @@ -47,7 +47,7 @@ public void beforeTest() {
Timber.e("@Before %s: register idle resource", testName.getMethodName());
IdlingRegistry.getInstance().register(idlingResource = new OnMapReadyIdlingResource(rule.getActivity()));
Espresso.onIdle();
mapboxMap = idlingResource.getMapboxMap();
maplibreMap = idlingResource.getMapLibreMap();
} catch (IdlingResourceTimeoutException idlingResourceTimeoutException) {
throw new RuntimeException(String.format("Could not start %s test for %s.\n Either the ViewHierarchy doesn't "
+ "contain a view with resource id = R.id.mapView or \n the hosting Activity wasn't in an idle state.",
Expand All @@ -60,11 +60,11 @@ public void beforeTest() {
protected void validateTestSetup() {
Assert.assertTrue("Device is not connected to the Internet.", isConnected(rule.getActivity()));
checkViewIsDisplayed(android.R.id.content);
Assert.assertNotNull(mapboxMap);
Assert.assertNotNull(maplibreMap);
}

protected MapboxMap getMapboxMap() {
return mapboxMap;
protected MapLibreMap getMapboxMap() {
return maplibreMap;
}

protected abstract Class getActivityClass();
Expand Down Expand Up @@ -93,7 +93,7 @@ protected ViewInteraction onMapView() {
}

protected MapboxMapAction getMapboxMapAction(MapboxMapAction.OnInvokeActionListener onInvokeActionListener) {
return new MapboxMapAction(onInvokeActionListener, mapboxMap);
return new MapboxMapAction(onInvokeActionListener, maplibreMap);
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import androidx.test.ext.junit.runners.AndroidJUnit4;

import com.mapbox.mapboxsdk.geometry.LatLng;
import org.maplibre.android.geometry.LatLng;
import com.mapbox.mapboxsdk.plugins.testapp.activity.TestActivity;
import com.mapbox.mapboxsdk.plugins.BaseActivityTest;

Expand All @@ -17,7 +17,7 @@

import static com.mapbox.mapboxsdk.plugins.annotation.MapboxMapAction.invoke;
import static org.junit.Assert.*;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static org.maplibre.android.style.layers.Property.*;

/**
* Basic smoke tests for CircleManager
Expand All @@ -34,8 +34,8 @@ protected Class getActivityClass() {

private void setupCircleManager() {
Timber.i("Retrieving layer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
circleManager = new CircleManager(idlingResource.getMapView(), mapboxMap, Objects.requireNonNull(mapboxMap.getStyle()));
invoke(maplibreMap, (uiController, maplibreMap) -> {
circleManager = new CircleManager(idlingResource.getMapView(), maplibreMap, Objects.requireNonNull(maplibreMap.getStyle()));
});
}

Expand All @@ -44,7 +44,7 @@ public void testCircleTranslateAsConstant() {
validateTestSetup();
setupCircleManager();
Timber.i("circle-translate");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, maplibreMap) -> {
assertNotNull(circleManager);

circleManager.setCircleTranslate(new Float[]{0f, 0f});
Expand All @@ -57,7 +57,7 @@ public void testCircleTranslateAnchorAsConstant() {
validateTestSetup();
setupCircleManager();
Timber.i("circle-translate-anchor");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, maplibreMap) -> {
assertNotNull(circleManager);

circleManager.setCircleTranslateAnchor(CIRCLE_TRANSLATE_ANCHOR_MAP);
Expand All @@ -70,7 +70,7 @@ public void testCirclePitchScaleAsConstant() {
validateTestSetup();
setupCircleManager();
Timber.i("circle-pitch-scale");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, maplibreMap) -> {
assertNotNull(circleManager);

circleManager.setCirclePitchScale(CIRCLE_PITCH_SCALE_MAP);
Expand All @@ -83,7 +83,7 @@ public void testCirclePitchAlignmentAsConstant() {
validateTestSetup();
setupCircleManager();
Timber.i("circle-pitch-alignment");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, maplibreMap) -> {
assertNotNull(circleManager);

circleManager.setCirclePitchAlignment(CIRCLE_PITCH_ALIGNMENT_MAP);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

// This file is generated.

package com.mapbox.mapboxsdk.plugins.annotation;
Expand All @@ -6,10 +7,10 @@

import androidx.test.ext.junit.runners.AndroidJUnit4;

import com.mapbox.mapboxsdk.geometry.LatLng;
import org.maplibre.android.geometry.LatLng;
import com.mapbox.mapboxsdk.plugins.BaseActivityTest;
import com.mapbox.mapboxsdk.plugins.testapp.activity.TestActivity;
import com.mapbox.mapboxsdk.utils.ColorUtils;
import org.maplibre.android.utils.ColorUtils;

import timber.log.Timber;

Expand All @@ -20,7 +21,7 @@

import static com.mapbox.mapboxsdk.plugins.annotation.MapboxMapAction.invoke;
import static org.junit.Assert.*;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static org.maplibre.android.style.layers.Property.*;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -40,8 +41,8 @@ protected Class getActivityClass() {

private void setupAnnotation() {
Timber.i("Retrieving layer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
CircleManager circleManager = new CircleManager(idlingResource.getMapView(), mapboxMap, Objects.requireNonNull(mapboxMap.getStyle()));
invoke(maplibreMap, (uiController, maplibreMap) -> {
CircleManager circleManager = new CircleManager(idlingResource.getMapView(), maplibreMap, Objects.requireNonNull(maplibreMap.getStyle()));
circle = circleManager.create(new CircleOptions().withLatLng(new LatLng()));
});
}
Expand All @@ -51,7 +52,7 @@ public void testCircleRadius() {
validateTestSetup();
setupAnnotation();
Timber.i("circle-radius");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, maplibreMap) -> {
assertNotNull(circle);

circle.setCircleRadius(2.0f);
Expand All @@ -64,7 +65,7 @@ public void testCircleColor() {
validateTestSetup();
setupAnnotation();
Timber.i("circle-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, maplibreMap) -> {
assertNotNull(circle);

circle.setCircleColor("rgba(0, 0, 0, 1)");
Expand All @@ -77,7 +78,7 @@ public void testCircleColorAsInt() {
validateTestSetup();
setupAnnotation();
Timber.i("circle-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, maplibreMap) -> {
assertNotNull(circle);
circle.setCircleColor(ColorUtils.rgbaToColor("rgba(0, 0, 0, 1)"));
assertEquals(circle.getCircleColorAsInt(), ColorUtils.rgbaToColor("rgba(0, 0, 0, 1)"));
Expand All @@ -90,7 +91,7 @@ public void testCircleBlur() {
validateTestSetup();
setupAnnotation();
Timber.i("circle-blur");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, maplibreMap) -> {
assertNotNull(circle);

circle.setCircleBlur(2.0f);
Expand All @@ -103,7 +104,7 @@ public void testCircleOpacity() {
validateTestSetup();
setupAnnotation();
Timber.i("circle-opacity");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, maplibreMap) -> {
assertNotNull(circle);

circle.setCircleOpacity(2.0f);
Expand All @@ -116,7 +117,7 @@ public void testCircleStrokeWidth() {
validateTestSetup();
setupAnnotation();
Timber.i("circle-stroke-width");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, maplibreMap) -> {
assertNotNull(circle);

circle.setCircleStrokeWidth(2.0f);
Expand All @@ -129,7 +130,7 @@ public void testCircleStrokeColor() {
validateTestSetup();
setupAnnotation();
Timber.i("circle-stroke-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, maplibreMap) -> {
assertNotNull(circle);

circle.setCircleStrokeColor("rgba(0, 0, 0, 1)");
Expand All @@ -142,7 +143,7 @@ public void testCircleStrokeColorAsInt() {
validateTestSetup();
setupAnnotation();
Timber.i("circle-stroke-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, maplibreMap) -> {
assertNotNull(circle);
circle.setCircleStrokeColor(ColorUtils.rgbaToColor("rgba(0, 0, 0, 1)"));
assertEquals(circle.getCircleStrokeColorAsInt(), ColorUtils.rgbaToColor("rgba(0, 0, 0, 1)"));
Expand All @@ -155,7 +156,7 @@ public void testCircleStrokeOpacity() {
validateTestSetup();
setupAnnotation();
Timber.i("circle-stroke-opacity");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, maplibreMap) -> {
assertNotNull(circle);

circle.setCircleStrokeOpacity(2.0f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import androidx.test.ext.junit.runners.AndroidJUnit4;

import com.mapbox.mapboxsdk.geometry.LatLng;
import org.maplibre.android.geometry.LatLng;
import com.mapbox.mapboxsdk.plugins.testapp.activity.TestActivity;
import com.mapbox.mapboxsdk.plugins.BaseActivityTest;

Expand All @@ -17,7 +17,7 @@

import static com.mapbox.mapboxsdk.plugins.annotation.MapboxMapAction.invoke;
import static org.junit.Assert.*;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static org.maplibre.android.style.layers.Property.*;

/**
* Basic smoke tests for FillManager
Expand All @@ -34,8 +34,8 @@ protected Class getActivityClass() {

private void setupFillManager() {
Timber.i("Retrieving layer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
fillManager = new FillManager(idlingResource.getMapView(), mapboxMap, Objects.requireNonNull(mapboxMap.getStyle()));
invoke(maplibreMap, (uiController, maplibreMap) -> {
fillManager = new FillManager(idlingResource.getMapView(), maplibreMap, Objects.requireNonNull(maplibreMap.getStyle()));
});
}

Expand All @@ -44,7 +44,7 @@ public void testFillAntialiasAsConstant() {
validateTestSetup();
setupFillManager();
Timber.i("fill-antialias");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, maplibreMap) -> {
assertNotNull(fillManager);

fillManager.setFillAntialias(true);
Expand All @@ -57,7 +57,7 @@ public void testFillTranslateAsConstant() {
validateTestSetup();
setupFillManager();
Timber.i("fill-translate");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, maplibreMap) -> {
assertNotNull(fillManager);

fillManager.setFillTranslate(new Float[]{0f, 0f});
Expand All @@ -70,7 +70,7 @@ public void testFillTranslateAnchorAsConstant() {
validateTestSetup();
setupFillManager();
Timber.i("fill-translate-anchor");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, maplibreMap) -> {
assertNotNull(fillManager);

fillManager.setFillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

// This file is generated.

package com.mapbox.mapboxsdk.plugins.annotation;
Expand All @@ -6,10 +7,10 @@

import androidx.test.ext.junit.runners.AndroidJUnit4;

import com.mapbox.mapboxsdk.geometry.LatLng;
import org.maplibre.android.geometry.LatLng;
import com.mapbox.mapboxsdk.plugins.BaseActivityTest;
import com.mapbox.mapboxsdk.plugins.testapp.activity.TestActivity;
import com.mapbox.mapboxsdk.utils.ColorUtils;
import org.maplibre.android.utils.ColorUtils;

import timber.log.Timber;

Expand All @@ -20,7 +21,7 @@

import static com.mapbox.mapboxsdk.plugins.annotation.MapboxMapAction.invoke;
import static org.junit.Assert.*;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static org.maplibre.android.style.layers.Property.*;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -40,8 +41,8 @@ protected Class getActivityClass() {

private void setupAnnotation() {
Timber.i("Retrieving layer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
FillManager fillManager = new FillManager(idlingResource.getMapView(), mapboxMap, Objects.requireNonNull(mapboxMap.getStyle()));
invoke(maplibreMap, (uiController, maplibreMap) -> {
FillManager fillManager = new FillManager(idlingResource.getMapView(), maplibreMap, Objects.requireNonNull(maplibreMap.getStyle()));
List<LatLng> innerLatLngs = new ArrayList<>();
innerLatLngs.add(new LatLng());
innerLatLngs.add(new LatLng(1, 1));
Expand All @@ -57,7 +58,7 @@ public void testFillOpacity() {
validateTestSetup();
setupAnnotation();
Timber.i("fill-opacity");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, maplibreMap) -> {
assertNotNull(fill);

fill.setFillOpacity(2.0f);
Expand All @@ -70,7 +71,7 @@ public void testFillColor() {
validateTestSetup();
setupAnnotation();
Timber.i("fill-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, maplibreMap) -> {
assertNotNull(fill);

fill.setFillColor("rgba(0, 0, 0, 1)");
Expand All @@ -83,7 +84,7 @@ public void testFillColorAsInt() {
validateTestSetup();
setupAnnotation();
Timber.i("fill-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, maplibreMap) -> {
assertNotNull(fill);
fill.setFillColor(ColorUtils.rgbaToColor("rgba(0, 0, 0, 1)"));
assertEquals(fill.getFillColorAsInt(), ColorUtils.rgbaToColor("rgba(0, 0, 0, 1)"));
Expand All @@ -96,7 +97,7 @@ public void testFillOutlineColor() {
validateTestSetup();
setupAnnotation();
Timber.i("fill-outline-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, maplibreMap) -> {
assertNotNull(fill);

fill.setFillOutlineColor("rgba(0, 0, 0, 1)");
Expand All @@ -109,7 +110,7 @@ public void testFillOutlineColorAsInt() {
validateTestSetup();
setupAnnotation();
Timber.i("fill-outline-color");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, maplibreMap) -> {
assertNotNull(fill);
fill.setFillOutlineColor(ColorUtils.rgbaToColor("rgba(0, 0, 0, 1)"));
assertEquals(fill.getFillOutlineColorAsInt(), ColorUtils.rgbaToColor("rgba(0, 0, 0, 1)"));
Expand All @@ -122,7 +123,7 @@ public void testFillPattern() {
validateTestSetup();
setupAnnotation();
Timber.i("fill-pattern");
invoke(mapboxMap, (uiController, mapboxMap) -> {
invoke(maplibreMap, (uiController, maplibreMap) -> {
assertNotNull(fill);

fill.setFillPattern("pedestrian-polygon");
Expand Down
Loading

0 comments on commit 36a02c0

Please sign in to comment.