Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5a67efcf authored by Romain Hunault's avatar Romain Hunault 💻
Browse files

Merge branch 'ellenhp/murena_infra' into 'main'

Move to murena infra

See merge request e/os/cardinal!58
parents e537ab15 052fb0a9
Loading
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -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:
+1 −1
Original line number Diff line number Diff line
@@ -9,4 +9,4 @@
.externalNativeBuild
.cxx
local.properties
secrets.properties
+34 −0
Original line number Diff line number Diff line
@@ -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",
+25 −8
Original line number Diff line number Diff line
@@ -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
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -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")
Loading