Selectable renderer implementation (#1247)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
mwilsnd
2023-06-26 15:49:48 -05:00
committed by Bart Louwers
parent fe165c8924
commit 1963697687
64 changed files with 1189 additions and 316 deletions

View File

@@ -58,6 +58,40 @@ android {
buildConfigField "String", "MAPBOX_VERSION_STRING", String.format("\"Mapbox/%s\"", project.VERSION_NAME)
buildConfigField "String", "MAPBOX_EVENTS_USER_AGENT", String.format("\"mapbox-maps-android/%s\"", project.VERSION_NAME)
consumerProguardFiles 'proguard-rules.pro'
externalNativeBuild {
cmake {
arguments "-DMLN_LEGACY_RENDERER=ON", "-DMLN_DRAWABLE_RENDERER=OFF", "-DMLN_RENDERER_SPLIT_VIEW=OFF"
}
}
}
flavorDimensions += "renderer"
productFlavors {
create("legacy") {
dimension = "renderer"
externalNativeBuild {
cmake {
arguments "-DMLN_LEGACY_RENDERER=ON", "-DMLN_DRAWABLE_RENDERER=OFF", "-DMLN_RENDERER_SPLIT_VIEW=OFF"
}
}
}
create("drawable") {
dimension = "renderer"
externalNativeBuild {
cmake {
arguments "-DMLN_LEGACY_RENDERER=OFF", "-DMLN_DRAWABLE_RENDERER=ON", "-DMLN_RENDERER_SPLIT_VIEW=OFF"
}
}
}
create("split") {
dimension = "renderer"
externalNativeBuild {
cmake {
arguments "-DMLN_LEGACY_RENDERER=ON", "-DMLN_DRAWABLE_RENDERER=ON", "-DMLN_RENDERER_SPLIT_VIEW=ON"
}
}
}
}
// build native libraries
@@ -93,6 +127,7 @@ android {
debug {
testCoverageEnabled false
jniDebuggable true
debuggable true
}
}
namespace 'org.maplibre.android'

View File

@@ -37,4 +37,13 @@
# while we don't include this dependency directly
# a large amount of users combine it with our SDK
# we aren't able to provide a proguard config in that project (jar vs aar)
-dontwarn com.sun.xml.internal.ws.spi.db.*
-dontwarn com.sun.xml.internal.ws.spi.db.*
# okhttp
-dontwarn org.bouncycastle.jsse.BCSSLSocket
-dontwarn org.bouncycastle.jsse.BCSSLParameters
-dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider
-dontwarn org.conscrypt.*
-dontwarn org.openjsse.javax.net.ssl.SSLParameters
-dontwarn org.openjsse.javax.net.ssl.SSLSocket
-dontwarn org.openjsse.net.ssl.OpenJSSE

View File

@@ -1,7 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-feature
android:glEsVersion="0x00020000"
android:glEsVersion="0x00030000"
android:required="true"/>
<uses-feature
android:name="android.hardware.wifi"

View File

@@ -392,6 +392,10 @@ public class MapLibreGLSurfaceView extends SurfaceView implements SurfaceHolder.
mEglContext = null;
} else {
mEglConfig = view.eglConfigChooser.chooseConfig(mEgl, mEglDisplay);
if (mEglConfig == null) {
Log.e(TAG, "failed to select an EGL configuration");
return;
}
/*
* Create an EGL context. We want to do this as rarely as we can, because an

View File

@@ -33,6 +33,8 @@ android {
buildTypes {
debug {
jniDebuggable true
debuggable true
testCoverageEnabled true
minifyEnabled false
shrinkResources false
@@ -46,6 +48,19 @@ android {
}
}
flavorDimensions += "renderer"
productFlavors {
create("legacy") {
dimension = "renderer"
}
create("drawable") {
dimension = "renderer"
}
create("split") {
dimension = "renderer"
}
}
buildFeatures {
viewBinding = true
}
@@ -78,7 +93,7 @@ dependencies {
implementation dependenciesList.okhttp3
implementation dependenciesList.leakCanary
debugImplementation dependenciesList.leakCanary
androidTestImplementation dependenciesList.supportAnnotations
androidTestImplementation dependenciesList.testRunner

View File

@@ -11,4 +11,13 @@
# GMS
-dontnote com.google.android.gms.**
-keep class org.maplibre.android.testapp.model.customlayer.ExampleCustomLayer { *; }
-keep class com.mapbox.mapboxsdk.testapp.model.customlayer.ExampleCustomLayer { *; }
# okhttp
-dontwarn org.bouncycastle.jsse.BCSSLSocket
-dontwarn org.bouncycastle.jsse.BCSSLParameters
-dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider
-dontwarn org.conscrypt.*
-dontwarn org.openjsse.javax.net.ssl.SSLParameters
-dontwarn org.openjsse.javax.net.ssl.SSLSocket
-dontwarn org.openjsse.net.ssl.OpenJSSE

View File

@@ -3,9 +3,10 @@ package org.maplibre.android.testapp.activity.maplayout
import android.os.Bundle
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import org.maplibre.android.maps.*
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.utils.NavUtils
import com.mapbox.mapboxsdk.maps.*
import com.mapbox.mapboxsdk.testapp.R
import com.mapbox.mapboxsdk.testapp.utils.ApiKeyUtils
import com.mapbox.mapboxsdk.testapp.utils.NavUtils
/**
* Test activity showcasing a simple MapView without any MapboxMap interaction.
@@ -18,11 +19,16 @@ class SimpleMapActivity : AppCompatActivity() {
mapView = findViewById(R.id.mapView)
mapView.onCreate(savedInstanceState)
mapView.getMapAsync(
OnMapReadyCallback { maplibreMap: MapLibreMap ->
val styles = Style.getPredefinedStyles()
if (styles != null && styles.size > 0) {
val styleUrl = styles[0].url
maplibreMap.setStyle(Style.Builder().fromUri(styleUrl))
OnMapReadyCallback { mapboxMap: MapboxMap ->
var key = ApiKeyUtils.getApiKey(applicationContext)
if (key == null || key == "YOUR_API_KEY_GOES_HERE") {
mapboxMap.setStyle(Style.Builder().fromUri("https://demotiles.maplibre.org/style.json"))
} else {
val styles = Style.getPredefinedStyles()
if (styles != null && styles.size > 0) {
val styleUrl = styles[0].url
mapboxMap.setStyle(Style.Builder().fromUri(styleUrl))
}
}
}
)

View File

@@ -44,7 +44,7 @@ afterEvaluate {
artifactId project.ext.mapLibreArtifactId
version this.version
from components.release
from components.legacyRelease
artifact androidSourcesJar
artifact androidJavadocsJar