diff --git a/README.md b/README.md index 6f43287..83fb4bc 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ NavFrame is an experimental Android navigation app that renders its own 480×240 The owner has confirmed static and synthetic NavFrame frames on a Xiaomi 11 Lite 5G NE running Android 14 and a 2026 Yamaha MT-07, and the bundled Asturias map working offline on the phone. On 2026-10-12, the owner reported that the latest version displayed the map on the TFT for about 20 minutes, then showed `Mapa no disponible` in La Corredoria (Oviedo) for the rest of the trip while the phone map continued working. An offline map was installed. The exact installed build, diagnostic code and background state were not recorded; the cause is under investigation. This establishes a successful map display followed by a persistent failure, not sustained TFT reliability. -The current checkout is version 0.14.6. The 0.13 series adds voice/routing language selection for Spanish, English, German, French, and Italian, plus a system-language option; unsupported system locales resolve to English. Speech still depends on the Android TextToSpeech engine and its installed voice data. The app includes offline map and place data for Asturias, plus installable regional packages. Worldwide regions can be discovered and built on demand through the [regional package workflow](docs/GLOBAL_OFFLINE.md); this is not complete worldwide coverage. Installed packages currently provide map and local place/camera data. Offline route calculation, global camera completeness, and complete worldwide font coverage are not provided. +The current checkout is version 0.14.7. The 0.13 series adds voice/routing language selection for Spanish, English, German, French, and Italian, plus a system-language option; unsupported system locales resolve to English. Speech still depends on the Android TextToSpeech engine and its installed voice data. The app includes offline map and place data for Asturias, plus installable regional packages. Worldwide regions can be discovered and built on demand through the [regional package workflow](docs/GLOBAL_OFFLINE.md); this is not complete worldwide coverage. Installed packages currently provide map and local place/camera data. Offline route calculation, global camera completeness, and complete worldwide font coverage are not provided. Route calculation and address search use configurable online services. Spoken output uses the selected language when Android provides voice data; voice availability and offline behavior depend on the device's TextToSpeech engine. Physical validation of route guidance, voice playback, camera alerts, sustained TFT map rendering, and a 30-minute screen-off session remains pending unless a newer test report says otherwise. diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 4de9793..5e26d3f 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -15,8 +15,8 @@ android { applicationId = "dev.navframe.app" minSdk = 26 targetSdk = 35 - versionName = "0.14.6" - versionCode = 23 + versionName = "0.14.7" + versionCode = 24 } if (hasReleaseSigning) { signingConfigs.create("production") { diff --git a/app/src/main/java/dev/navframe/app/MainActivity.kt b/app/src/main/java/dev/navframe/app/MainActivity.kt index b9b6d49..026083d 100644 --- a/app/src/main/java/dev/navframe/app/MainActivity.kt +++ b/app/src/main/java/dev/navframe/app/MainActivity.kt @@ -23,6 +23,7 @@ open class MainActivity : Activity() { private var searchJob: Job? = null private var positionWait: Job? = null private var importJob: Job? = null + private var lastImportedRoute: ImportedRoute? = null private var pendingImportUri: Uri? = null private var searchGeneration = 0L private var updatingDestination = false @@ -356,6 +357,7 @@ open class MainActivity : Activity() { val current = service ?: run { hint.text = "Servicio no disponible · vuelve a cargar el GPX"; return@launch } cancelSearch(); routeDialog?.dismiss() current.prepareImportedRoute(imported) + lastImportedRoute = imported destination = null; destinationName = "" hint.text = "Ruta GPX cargada" showImportedRouteSheet(imported.name) @@ -373,6 +375,11 @@ open class MainActivity : Activity() { val box = column().apply { setPadding(dp(20), dp(16), dp(20), dp(16)) } box.addView(label(name ?: "Ruta GPX", 20f)) box.addView(routeInfo) + lastImportedRoute?.takeIf { !it.isTrack && it.route.geometry.size in 2..50 }?.let { imported -> + box.addView(button("Calcular por carreteras · evitar autopistas") { + service?.calculateImportedStops(imported) + }) + } routeLoading = ProgressBar(this).apply { visibility = View.GONE } box.addView(routeLoading) retryRouteButton = null diff --git a/app/src/main/java/dev/navframe/app/TftService.kt b/app/src/main/java/dev/navframe/app/TftService.kt index cdd5eab..24de837 100644 --- a/app/src/main/java/dev/navframe/app/TftService.kt +++ b/app/src/main/java/dev/navframe/app/TftService.kt @@ -586,6 +586,47 @@ class TftService : Service() { mutableRouteInfo.value = "GPX · %.1f km · %d puntos\nSigue el trazado: sin instrucciones de giro, ETA ni recálculo automático. Revisa el recorrido antes de iniciar.".format(java.util.Locale.ROOT, imported.route.distanceMeters / 1000.0, imported.route.geometry.size) if (!hasActiveGuidance()) showPreparedPreview() } + /** Resolve GPX route stops against Valhalla; never alter a detailed imported track. */ + fun calculateImportedStops(imported: ImportedRoute) { + if (imported.isTrack || imported.route.geometry.size !in 2..50) { + mutableRouteInfo.value = "Solo se pueden calcular rutas GPX con entre 2 y 50 puntos de paso." + return + } + val stops = imported.route.geometry + val generation = preparedGeneration + val options = RouteOptions(profile = RouteProfile.AVOID_MOTORWAYS, avoidMotorways = true, avoidUnpaved = true) + mutableRouteInfo.value = "Calculando sobre carreteras · evitando autopistas y pistas sin asfaltar…" + routeJob?.cancel() + routeJob = scope.launch { + try { + val engine = routingEngineFactory(routingEndpoint()) + val geometry = mutableListOf() + var metres = 0L + for (i in 0 until stops.lastIndex) { + val part = engine.calculateRoute(stops[i], stops[i + 1], options) + ensureActive() + if (part.geometry.size < 2) throw java.io.IOException("Segmento sin geometría") + geometry.addAll(if (i == 0) part.geometry else part.geometry.drop(1)) + metres += part.distanceMeters + if (geometry.size > 10_000) throw IllegalArgumentException("La ruta supera 10000 puntos") + if (generation != preparedGeneration) return@launch + mutableRouteInfo.value = "Calculando carreteras · tramo ${i + 1}/${stops.lastIndex}" + } + ensureActive() + if (generation != preparedGeneration) return@launch + val result = RouteResult(geometry = geometry, maneuvers = emptyList(), + distanceMeters = metres.coerceAtMost(Int.MAX_VALUE.toLong()).toInt(), + durationSeconds = 0, destination = geometry.last(), imported = true) + prepareImportedRoute(ImportedRoute(imported.name, result, isTrack = true)) + mutableRouteInfo.value = "GPX ajustado a carreteras · %.1f km · %d puntos\nComprueba que no haya autovías ni tramos inadecuados antes de salir. No hay avisos de giro ni recálculo.".format(java.util.Locale.ROOT, metres / 1000.0, geometry.size) + } catch (cancelled: CancellationException) { + throw cancelled + } catch (error: Exception) { + if (generation == preparedGeneration) + mutableRouteInfo.value = "No se pudo calcular sobre carreteras. Se conserva el GPX original; comprueba conexión y endpoint Valhalla." + } + } + } fun preparedRouteIsImported() = hasPreparedRoute() && routePlan?.route?.imported == true fun hasPreparedRoute() = !preparedDestinationDirty && routePlan != null fun routeUsesGps() = !preparedDestinationDirty && routePlan?.demo == false diff --git a/core/src/main/kotlin/dev/navframe/core/GpxRouteImporter.kt b/core/src/main/kotlin/dev/navframe/core/GpxRouteImporter.kt index 5efe2f4..8803901 100644 --- a/core/src/main/kotlin/dev/navframe/core/GpxRouteImporter.kt +++ b/core/src/main/kotlin/dev/navframe/core/GpxRouteImporter.kt @@ -9,7 +9,7 @@ import org.xml.sax.SAXException import org.xml.sax.ext.DefaultHandler2 import kotlin.math.* -data class ImportedRoute(val name: String?, val route: RouteResult) +data class ImportedRoute(val name: String?, val route: RouteResult, val isTrack: Boolean = false) /** Imports geometry only: GPX points do not establish road turns, speeds or travel time. */ object GpxRouteImporter { @@ -52,7 +52,7 @@ object GpxRouteImporter { return ImportedRoute(handler.name?.trim()?.takeIf { it.isNotEmpty() }, RouteResult( geometry = points.toList(), maneuvers = emptyList(), distanceMeters = distance.roundToInt().coerceAtLeast(1), durationSeconds = 0, destination = points.last(), imported = true, - )) + ), handler.isTrack) } private class Handler : DefaultHandler2() { @@ -61,6 +61,7 @@ object GpxRouteImporter { private var routeName: String? = null private var trackName: String? = null val points: List get() = if (tracks > 0) trackPoints else routePoints + val isTrack: Boolean get() = tracks > 0 val name: String? get() = if (tracks > 0) trackName else routeName private val path = mutableListOf() private var rootNamespace = ""