mirror of
https://github.com/Dasemu/NavFrame.git
synced 2026-11-26 15:26:05 +00:00
feat: require precise GPS for imported routes and release 0.13.4
This commit is contained in:
1 parent
27bc1f6958
commit
4ffd4d874e
5 files changed
+53
-6
No files matched your search
@@ -387,14 +387,17 @@ open class MainActivity : Activity() {
|
||||
val current = service ?: return
|
||||
if (!current.preparedRouteIsImported()) { hint.text = "Vuelve a cargar la ruta GPX"; return }
|
||||
positionWait?.cancel()
|
||||
if (current.hasFreshGpsFix()) { perform(Action.ROUTE); return }
|
||||
if (current.hasGuidanceGpsFix()) { perform(Action.ROUTE); return }
|
||||
current.setPhoneVisible(true)
|
||||
hint.text = "Esperando GPS preciso para iniciar el GPX…"
|
||||
routeLoading?.visibility = View.VISIBLE
|
||||
startButton?.isEnabled = false
|
||||
positionWait = scope.launch {
|
||||
try {
|
||||
withTimeout(60_000) { current.gpsReady.first { it && current.hasFreshGpsFix() } }
|
||||
withTimeout(60_000) {
|
||||
// Map readiness stays true while accuracy improves from 100 m to 25 m.
|
||||
while (!current.hasGuidanceGpsFix()) delay(200)
|
||||
}
|
||||
ensureActive()
|
||||
if (current.preparedRouteIsImported()) perform(Action.ROUTE)
|
||||
} catch (_: TimeoutCancellationException) { hint.text = "Sin GPS preciso · activa ubicación y pulsa Iniciar navegación de nuevo" }
|
||||
|
||||
@@ -723,7 +723,7 @@ class TftService : Service() {
|
||||
fun isGpsSessionActive(): Boolean = gpsRequested
|
||||
fun hasFreshGpsFix(): Boolean = usableGpsFix(AndroidLocationProvider.MAP_ACCURACY_METERS)
|
||||
fun usesCompassHeading(): Boolean = (locationProvider ?: visibleGpsProvider)?.headingFromCompass == true
|
||||
private fun hasGuidanceGpsFix(): Boolean = usableGpsFix(AndroidLocationProvider.GUIDANCE_ACCURACY_METERS)
|
||||
fun hasGuidanceGpsFix(): Boolean = usableGpsFix(AndroidLocationProvider.GUIDANCE_ACCURACY_METERS)
|
||||
private fun usableGpsFix(maxAccuracy: Float): Boolean = lastGpsFix?.let { it.accuracyMeters.isFinite() && it.accuracyMeters in 0f..maxAccuracy && SystemClock.elapsedRealtime() - lastGpsElapsed in 0..15_000 && (locationProvider?.providerEnabled?.value == true || (phoneVisible && visibleGpsProvider?.providerEnabled?.value == true)) } == true
|
||||
private fun stopVisibleGps() {
|
||||
visibleGpsJob?.cancel(); visibleGpsJob = null
|
||||
|
||||
Reference in new issue
Block a user