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 #403

Closed
wants to merge 10 commits into from
Closed
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
8 changes: 1 addition & 7 deletions .github/workflows/flutter_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on: [push, pull_request, workflow_dispatch]

env:
FLUTTER_CHANNEL: 'stable'
FLUTTER_VERSION: '3.10.5'

jobs:
format:
Expand All @@ -15,7 +14,6 @@ jobs:
- uses: actions/checkout@v4
- uses: subosito/[email protected]
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: ${{ env.FLUTTER_CHANNEL }}
cache: true
- name: Lint analysis
Expand All @@ -29,7 +27,6 @@ jobs:
- uses: actions/checkout@v4
- uses: subosito/[email protected]
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: ${{ env.FLUTTER_CHANNEL }}
cache: true
- run: flutter pub get
Expand All @@ -51,12 +48,11 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- uses: subosito/[email protected]
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: ${{ env.FLUTTER_CHANNEL }}
cache: true
- run: flutter pub get
Expand All @@ -75,7 +71,6 @@ jobs:
- uses: actions/checkout@v4
- uses: subosito/[email protected]
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: ${{ env.FLUTTER_CHANNEL }}
cache: true
- uses: maxim-lobanov/setup-cocoapods@v1
Expand All @@ -101,7 +96,6 @@ jobs:
- uses: actions/checkout@v4
- uses: subosito/[email protected]
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: ${{ env.FLUTTER_CHANNEL }}
cache: true
- run: flutter pub get
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/formatter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ on: [workflow_dispatch]

env:
FLUTTER_CHANNEL: 'stable'
FLUTTER_VERSION: '3.10.5'

jobs:
format:
Expand All @@ -14,7 +13,6 @@ jobs:
- uses: actions/checkout@v4
- uses: subosito/[email protected]
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: ${{ env.FLUTTER_CHANNEL }}
cache: true
- name: format
Expand Down
19 changes: 8 additions & 11 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 @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
classpath 'com.android.tools.build:gradle:8.2.2'
}
}

Expand All @@ -24,8 +24,9 @@ apply plugin: 'org.jetbrains.kotlin.android'

android {

compileSdkVersion 31
ndkVersion "20.1.5948944"
compileSdkVersion 34
ndkVersion "25.1.8937393"
namespace "org.maplibre.maplibregl"

defaultConfig {
minSdkVersion 21
Expand All @@ -36,19 +37,15 @@ android {
disable 'InvalidPackage'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
dependencies {
implementation 'org.maplibre.gl:android-sdk:10.2.0'
implementation 'org.maplibre.gl:android-sdk:11.0.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'
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip
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'
3 changes: 1 addition & 2 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mapbox.mapboxgl">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</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