diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 63398a08f88be9be32a4556ab7f30ba615bfa1a4..d3217d048a7e58b0b3f92a7c0a9b919259b5f35b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -175,9 +175,6 @@ build_release: stage: release # Use an image with Android SDK pre-installed image: cimg/android:2024.01.1-ndk - # Only run on version tags (v*) - rules: - - if: '$CI_COMMIT_TAG =~ /^v.*/' # Resource group for concurrency control resource_group: android-release-${CI_COMMIT_REF_SLUG} variables: diff --git a/cardinal-android/.gitignore b/cardinal-android/.gitignore index 79e5d67a9e2633f038b6792641fb28c3e5156d52..aeb393a6a45a1d31db17a48a498812137878a3b3 100644 --- a/cardinal-android/.gitignore +++ b/cardinal-android/.gitignore @@ -9,4 +9,4 @@ .externalNativeBuild .cxx local.properties - +secrets.properties diff --git a/cardinal-android/app/build.gradle.kts b/cardinal-android/app/build.gradle.kts index e1190a376ce393bdf6fa53666fd71b6d9545b285..5e9a4bedc6631f5c01de787e435749ceca004549 100644 --- a/cardinal-android/app/build.gradle.kts +++ b/cardinal-android/app/build.gradle.kts @@ -17,6 +17,9 @@ */ import com.android.build.api.dsl.ApkSigningConfig +import java.io.FileInputStream +import java.io.FileNotFoundException +import java.util.Properties plugins { alias(libs.plugins.android.application) @@ -29,6 +32,30 @@ plugins { kotlin("plugin.serialization") version "2.2.21" } +val stadiaKey = + Properties().apply { + try { + load(FileInputStream(File(rootProject.projectDir, "secrets.properties"))) + } catch (ex: FileNotFoundException) { + // No-op. + } + }.getProperty("stadiaKey", "").ifEmpty { + val keyFromEnv = System.getenv("STADIA_KEY") + if (keyFromEnv.isNullOrEmpty()) { keyFromEnv } else { null } + } + +val defaultPeliasEndpoint = if (stadiaKey != null) { + "https://api.stadiamaps.com/geocoding/v1" +} else { + "https://maps.earth/pelias/v1" +} + +val defaultValhallaEndpoint = if (stadiaKey != null) { + "https://api.stadiamaps.com/route/v1" +} else { + "https://maps.earth/valhalla/route" +} + android { namespace = "earth.maps.cardinal" compileSdk = 36 @@ -80,11 +107,17 @@ android { signingConfig = signingConfigs["release"] as ApkSigningConfig manifestPlaceholders["icon"] = "@mipmap/ic_launcher" manifestPlaceholders["round_icon"] = "@mipmap/ic_launcher_round" + resValue("string", "default_pelias_endpoint", defaultPeliasEndpoint) + resValue("string", "default_valhalla_endpoint", defaultValhallaEndpoint) + resValue("string", "default_api_key", stadiaKey.orEmpty()) } debug { applicationIdSuffix = ".debug" manifestPlaceholders["icon"] = "@mipmap/ic_launcher_debug" manifestPlaceholders["round_icon"] = "@mipmap/ic_launcher_round_debug" + resValue("string", "default_pelias_endpoint", defaultPeliasEndpoint) + resValue("string", "default_valhalla_endpoint", defaultValhallaEndpoint) + resValue("string", "default_api_key", stadiaKey.orEmpty()) } } @@ -121,6 +154,7 @@ android { commandLine = listOf( "cargo", "run", + "--locked", "--bin", "uniffi-bindgen", "-p", diff --git a/cardinal-android/app/src/main/java/earth/maps/cardinal/data/AppPreferences.kt b/cardinal-android/app/src/main/java/earth/maps/cardinal/data/AppPreferences.kt index 66fa70be2cf153e8ec5e38576ca898192704074c..0c8d07d1bda9b87e6007ee844577ac59571c69ab 100644 --- a/cardinal-android/app/src/main/java/earth/maps/cardinal/data/AppPreferences.kt +++ b/cardinal-android/app/src/main/java/earth/maps/cardinal/data/AppPreferences.kt @@ -22,6 +22,7 @@ import android.content.Context import android.content.SharedPreferences import android.text.format.DateFormat import androidx.core.content.edit +import earth.maps.cardinal.R import java.util.Locale /** @@ -55,8 +56,6 @@ class AppPreferences(private val context: Context) { private const val KEY_VALHALLA_API_KEY = "valhalla_api_key" // Default values - private const val DEFAULT_PELIAS_BASE_URL = "https://maps.earth/pelias/v1" - private const val DEFAULT_VALHALLA_BASE_URL = "https://maps.earth/valhalla/route" private const val DEFAULT_LAST_ROUTING_MODE = "auto" // Contrast level constants @@ -338,8 +337,12 @@ class AppPreferences(private val context: Context) { * Returns the default Pelias base URL if none is saved. */ fun loadPeliasBaseUrl(): String { - return prefs.getString(KEY_PELIAS_BASE_URL, DEFAULT_PELIAS_BASE_URL) - ?: DEFAULT_PELIAS_BASE_URL + val url = prefs.getString(KEY_PELIAS_BASE_URL, null) + return if (url.isNullOrBlank()) { + context.getString(R.string.default_pelias_endpoint) + } else { + url + } } /** @@ -360,7 +363,12 @@ class AppPreferences(private val context: Context) { * Returns null if no API key is saved. */ fun loadPeliasApiKey(): String? { - return prefs.getString(KEY_PELIAS_API_KEY, null) + val key = prefs.getString(KEY_PELIAS_API_KEY, null) + return if (key.isNullOrBlank() && loadPeliasBaseUrl() == context.getString(R.string.default_pelias_endpoint)) { + context.getString(R.string.default_api_key) + } else { + key + } } // Valhalla API configuration methods @@ -379,8 +387,12 @@ class AppPreferences(private val context: Context) { * Returns the default Valhalla base URL if none is saved. */ fun loadValhallaBaseUrl(): String { - return prefs.getString(KEY_VALHALLA_BASE_URL, DEFAULT_VALHALLA_BASE_URL) - ?: DEFAULT_VALHALLA_BASE_URL + val url = prefs.getString(KEY_VALHALLA_BASE_URL, null) + return if (url.isNullOrBlank()) { + context.getString(R.string.default_valhalla_endpoint) + } else { + url + } } /** @@ -401,6 +413,11 @@ class AppPreferences(private val context: Context) { * Returns null if no API key is saved. */ fun loadValhallaApiKey(): String? { - return prefs.getString(KEY_VALHALLA_API_KEY, null) + val key = prefs.getString(KEY_VALHALLA_API_KEY, null) + return if (key.isNullOrBlank() && loadValhallaBaseUrl() == context.getString(R.string.default_valhalla_endpoint)) { + context.getString(R.string.default_api_key) + } else { + key + } } } diff --git a/cardinal-android/app/src/main/java/earth/maps/cardinal/tileserver/TileDownloadManager.kt b/cardinal-android/app/src/main/java/earth/maps/cardinal/tileserver/TileDownloadManager.kt index 0e725f57e21e8c66473fa20622863e264da999d0..ef8eea08a5528a8153f7a40d895b4778493c3f6f 100644 --- a/cardinal-android/app/src/main/java/earth/maps/cardinal/tileserver/TileDownloadManager.kt +++ b/cardinal-android/app/src/main/java/earth/maps/cardinal/tileserver/TileDownloadManager.kt @@ -893,7 +893,7 @@ class TileDownloadManager( var fileOutputStream: FileOutputStream? = null try { val url = ValhallaTileUtils.getTileUrl( - "https://cardinaldata.airmail.rs/valhalla-250825", hierarchyLevel, tileIndex + "https://tiles.maps.murena.com/valhalla-250825", hierarchyLevel, tileIndex ) Log.v(TAG, "Downloading Valhalla tile $hierarchyLevel/$tileIndex from $url") diff --git a/cardinal-android/app/src/main/res/values/strings.xml b/cardinal-android/app/src/main/res/values/strings.xml index 0a4607dff558d483b9fc637e1c567cfdfc22bb50..12c8f68cabf56319e27e14faa1f4fac30766af50 100644 --- a/cardinal-android/app/src/main/res/values/strings.xml +++ b/cardinal-android/app/src/main/res/values/strings.xml @@ -118,7 +118,7 @@ Disabled - https://pmtiles.ellenhp.workers.dev/planet-250825.pmtiles/planet-250825/{z}/{x}/{y}.mvt + https://tiles.maps.murena.com/tiles/planet-260112/planet/{z}/{x}/{y}.mvt Offline Settings diff --git a/cardinal-android/gradle/libs.versions.toml b/cardinal-android/gradle/libs.versions.toml index 76c8a36c1de457eb6cc9cb6b9d6dabb1aa7c4e74..0693e64c759ffd98f4fbf244d91ac0df72607bd5 100644 --- a/cardinal-android/gradle/libs.versions.toml +++ b/cardinal-android/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -agp = "8.13.1" +agp = "8.13.2" androidaddressformatter = "8f279fe" assertjCore = "3.27.6" desugar_jdk_libs = "2.1.5" diff --git a/docs/BASEMAP_GENERATION.md b/docs/BASEMAP_GENERATION.md index 6d6fd3f31f70b8636879217affa060b538602847..e01af4e9c4ac2661d6f17b1b1d36d1778d2163da 100644 --- a/docs/BASEMAP_GENERATION.md +++ b/docs/BASEMAP_GENERATION.md @@ -73,7 +73,7 @@ You can refer to the [Planetiler documentation on full-planet builds](https://gi As of late 2025, the following command is recommended in the documentation for full-planet builds, and should work unmodified on sufficiently powerful hardware: ```bash -java -Xmx20g \ +java -Xmx40g \ -jar target/*with-deps.jar \ `# Use the planet.osm.pbf file downloaded earlier here.` \ --osm_path=$OSM_PATH --download \ @@ -96,7 +96,7 @@ PMTiles is a cloud-native format for collections of map tiles that allows a tile Latency between the tileserver instances and the Object Store should be minimized for good performance, and the Object Store must support HTTP range requests. -To perform the conversion, ensure a sufficiently modern version of **Go** is installed, and clone the PMTiles repository: https://github.com/protomaps/PMTiles +To perform the conversion, ensure a sufficiently modern version of **Go** is installed, and install the pmtiles utilities according to the [documentation](https://docs.protomaps.com/guide/getting-started) In the root of the PMTiles repo, run the following: `pmtiles convert $MBTILES_PATH planet.pmtiles`