Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: migrate maplibre-native for android to version 11.0.0 (take 2) #406

Merged
merged 4 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
iOS Devices with an Apple A7 GPU or later are supported onwards. See the
[maplibre-native changelog](https://github.com/maplibre/maplibre-native/blob/main/platform/ios/CHANGELOG.md#600)
for more information.
* Updated maplibre-native for android to v11.0.0. This version uses
OpenGL ES 3.0.

## 0.19.0

Expand Down
12 changes: 6 additions & 6 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
group 'com.mapbox.mapboxgl'
group 'org.maplibre.maplibregl'
version '1.0-SNAPSHOT'

buildscript {
Expand All @@ -24,7 +24,7 @@ apply plugin: 'org.jetbrains.kotlin.android'

android {
if (project.android.hasProperty("namespace")) {
namespace 'com.mapbox.mapboxgl'
namespace 'org.maplibre.maplibregl'
}

compileSdkVersion 34
Expand All @@ -46,10 +46,10 @@ android {
jvmTarget = JavaVersion.VERSION_1_8
}
dependencies {
implementation 'org.maplibre.gl:android-sdk:10.2.0'
implementation 'org.maplibre.gl:android-plugin-annotation-v9:2.0.0'
implementation 'org.maplibre.gl:android-plugin-offline-v9:2.0.0'
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
implementation 'org.maplibre.gl:android-sdk:11.0.0'
implementation 'org.maplibre.gl:android-plugin-annotation-v9:3.0.0'
implementation 'org.maplibre.gl:android-plugin-offline-v9:3.0.0'
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
}
}

Expand Down
2 changes: 1 addition & 1 deletion android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rootProject.name = 'mapbox_gl'
rootProject.name = 'maplibre_gl'
2 changes: 1 addition & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mapbox.mapboxgl">
package="org.maplibre.maplibregl">
</manifest>
12 changes: 0 additions & 12 deletions android/src/main/java/com/mapbox/mapboxgl/MapBoxUtils.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package com.mapbox.mapboxgl;
package org.maplibre.maplibregl;

import android.content.Context;
import android.graphics.Point;
import android.util.DisplayMetrics;
import com.mapbox.geojson.Polygon;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdate;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import org.maplibre.geojson.Polygon;
import org.maplibre.android.camera.CameraPosition;
import org.maplibre.android.camera.CameraUpdate;
import org.maplibre.android.camera.CameraUpdateFactory;
import org.maplibre.android.geometry.LatLng;
import org.maplibre.android.geometry.LatLngBounds;
import org.maplibre.android.maps.MapLibreMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/** Conversions between JSON-like values and MapboxMaps data types. */
/** Conversions between JSON-like values and MapLibreMaps data types. */
class Convert {

private static final String TAG = "Convert";
Expand All @@ -43,7 +43,7 @@ static boolean isScrollByCameraUpdate(Object o) {
return toString(toList(o).get(0)).equals("scrollBy");
}

static CameraUpdate toCameraUpdate(Object o, MapboxMap mapboxMap, float density) {
static CameraUpdate toCameraUpdate(Object o, MapLibreMap maplibreMap, float density) {
final List<?> data = toList(o);
switch (toString(data.get(0))) {
case "newCameraPosition":
Expand All @@ -60,7 +60,7 @@ static CameraUpdate toCameraUpdate(Object o, MapboxMap mapboxMap, float density)
case "newLatLngZoom":
return CameraUpdateFactory.newLatLngZoom(toLatLng(data.get(1)), toFloat(data.get(2)));
case "scrollBy":
mapboxMap.scrollBy(
maplibreMap.scrollBy(
toFractionalPixels(data.get(1), density), toFractionalPixels(data.get(2), density));
return null;
case "zoomBy":
Expand Down Expand Up @@ -164,12 +164,12 @@ private static List<List<LatLng>> toLatLngListList(Object o) {
}

static Polygon interpretListLatLng(List<List<LatLng>> geometry) {
List<List<com.mapbox.geojson.Point>> points = new ArrayList<>(geometry.size());
List<List<org.maplibre.geojson.Point>> points = new ArrayList<>(geometry.size());
for (List<LatLng> innerGeometry : geometry) {
List<com.mapbox.geojson.Point> innerPoints = new ArrayList<>(innerGeometry.size());
List<org.maplibre.geojson.Point> innerPoints = new ArrayList<>(innerGeometry.size());
for (LatLng latLng : innerGeometry) {
innerPoints.add(
com.mapbox.geojson.Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude()));
org.maplibre.geojson.Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude()));
}
points.add(innerPoints);
}
Expand Down Expand Up @@ -205,7 +205,7 @@ static String toString(Object o) {
return (String) o;
}

static void interpretMapboxMapOptions(Object o, MapboxMapOptionsSink sink, Context context) {
static void interpretMapLibreMapOptions(Object o, MapLibreMapOptionsSink sink, Context context) {
final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
final Map<?, ?> data = toMap(o);
final Object cameraTargetBounds = data.get("cameraTargetBounds");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.mapbox.mapboxgl;
package org.maplibre.maplibregl;

import android.content.Context;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.mapbox.mapboxsdk.net.ConnectivityReceiver;
import org.maplibre.android.net.ConnectivityReceiver;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodCall;
Expand Down Expand Up @@ -70,7 +70,7 @@ private static void copy(InputStream input, OutputStream output) throws IOExcept

@Override
public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) {
MapBoxUtils.getMapbox(context);
MapLibreUtils.getMapLibre(context);

switch (methodCall.method) {
case "installOfflineMapTiles":
Expand All @@ -92,7 +92,7 @@ public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) {
break;
case "setHttpHeaders":
Map<String, String> headers = (Map<String, String>) methodCall.argument("headers");
MapboxHttpRequestUtil.setHttpHeaders(headers, result);
MapLibreHttpRequestUtil.setHttpHeaders(headers, result);
break;
case "downloadOfflineRegion#setup":
String channelName = methodCall.argument("channelName");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// This file is generated by
// ./scripts/lib/generate.dart

package com.mapbox.mapboxgl;
package org.maplibre.maplibregl;

import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
import com.mapbox.mapboxsdk.style.layers.PropertyValue;
import org.maplibre.android.style.expressions.Expression;
import org.maplibre.android.style.layers.PropertyFactory;
import org.maplibre.android.style.layers.PropertyValue;

import java.util.LinkedList;
import java.util.List;
Expand All @@ -16,7 +16,7 @@
import com.google.gson.JsonPrimitive;


import static com.mapbox.mapboxgl.Convert.toMap;
import static org.maplibre.maplibregl.Convert.toMap;

class LayerPropertyConverter {
static PropertyValue[] interpretSymbolLayerProperties(Object o) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.mapbox.mapboxgl;
package org.maplibre.maplibregl;

import com.mapbox.mapboxsdk.module.http.HttpRequestUtil;
import org.maplibre.android.module.http.HttpRequestUtil;
import io.flutter.plugin.common.MethodChannel;
import java.util.Map;
import okhttp3.OkHttpClient;
import okhttp3.Request;

abstract class MapboxHttpRequestUtil {
abstract class MapLibreHttpRequestUtil {

public static void setHttpHeaders(Map<String, String> headers, MethodChannel.Result result) {
HttpRequestUtil.setOkHttpClient(getOkHttpClient(headers, result).build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package com.mapbox.mapboxgl;
package org.maplibre.maplibregl;

import android.content.Context;
import android.view.Gravity;
import androidx.annotation.NonNull;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
import org.maplibre.android.camera.CameraPosition;
import org.maplibre.android.geometry.LatLngBounds;
import org.maplibre.android.maps.MapLibreMapOptions;
import io.flutter.plugin.common.BinaryMessenger;

class MapboxMapBuilder implements MapboxMapOptionsSink {
class MapLibreMapBuilder implements MapLibreMapOptionsSink {
public final String TAG = getClass().getSimpleName();
private final MapboxMapOptions options =
new MapboxMapOptions().attributionEnabled(true).logoEnabled(false).textureMode(true);
private final MapLibreMapOptions options =
new MapLibreMapOptions().attributionEnabled(true).logoEnabled(false).textureMode(true);
private boolean trackCameraPosition = false;
private boolean myLocationEnabled = false;
private boolean dragEnabled = true;
Expand All @@ -24,14 +24,14 @@ class MapboxMapBuilder implements MapboxMapOptionsSink {
private String styleString = "";
private LatLngBounds bounds = null;

MapboxMapController build(
MapLibreMapController build(
int id,
Context context,
BinaryMessenger messenger,
MapboxMapsPlugin.LifecycleProvider lifecycleProvider) {
MapLibreMapsPlugin.LifecycleProvider lifecycleProvider) {

final MapboxMapController controller =
new MapboxMapController(
final MapLibreMapController controller =
new MapLibreMapController(
id, context, messenger, lifecycleProvider, options, styleString, dragEnabled);
controller.init();
controller.setMyLocationEnabled(myLocationEnabled);
Expand Down
Loading