Colota - Android GPS Location tracker
chore: bump version to 1.9.0 (#408)
Max Dietrich72e802400ad3
diff --git a/apps/mobile/android/app/build.gradle b/apps/mobile/android/app/build.gradleindex 5fe2c38d..f3fb96e2 100644--- a/apps/mobile/android/app/build.gradle+++ b/apps/mobile/android/app/build.gradle@@ -94,8 +94,8 @@ android {applicationId "com.Colota"minSdkVersion rootProject.ext.minSdkVersiontargetSdkVersion rootProject.ext.targetSdkVersion- versionCode 37- versionName "1.8.0"+ versionCode 38+ versionName "1.9.0"// Strip Build IDs for reproducible builds (IzzyOnDroid/F-Droid)externalNativeBuild {diff --git a/apps/mobile/android/apps/mobile/android/app/src/test/java/com/colota/importer/CsvParserTest.kt b/apps/mobile/android/apps/mobile/android/app/src/test/java/com/colota/importer/CsvParserTest.ktdeleted file mode 100644index ceedc165..00000000--- a/apps/mobile/android/apps/mobile/android/app/src/test/java/com/colota/importer/CsvParserTest.kt+++ /dev/null@@ -1,150 +0,0 @@-/**- * Copyright (C) 2026 Max Dietrich- * Licensed under the GNU AGPLv3. See LICENSE in the project root for details.- */--package com.Colota.importer--import org.junit.Assert.assertEquals-import org.junit.Assert.assertTrue-import org.junit.Test-import org.junit.runner.RunWith-import org.robolectric.RobolectricTestRunner-import java.util.concurrent.atomic.AtomicBoolean--@RunWith(RobolectricTestRunner::class)-class CsvParserTest {-- private val cancelled = AtomicBoolean(false)- private val nowSec = 1_750_000_000L-- @Test- fun `parses Colota CSV export header order`() {- // Mirrors apps/mobile/android/app/src/main/java/com/colota/export/ExportConverters.kt- // CsvFormat header: id,timestamp,iso_time,latitude,longitude,accuracy,altitude,speed,battery- val csv = """- id,timestamp,iso_time,latitude,longitude,accuracy,altitude,speed,battery- 0,1704110400,2024-01-01T12:00:00.000Z,52.5,13.4,5,30,2,80- """.trimIndent()-- val result = CsvParser.parse(csv.byteInputStream(), cancelled, nowSec)- assertEquals(0, result.invalid)- assertEquals(1, result.rows.size)- val row = result.rows[0]- assertEquals(52.5, row.latitude, 1e-9)- assertEquals(13.4, row.longitude, 1e-9)- assertEquals(1_704_110_400L, row.timestamp)- assertEquals(5, row.accuracy)- assertEquals(30, row.altitude)- assertEquals(2, row.speed)- assertEquals(80, row.battery)- }-- @Test- fun `accepts foreign column order via header lookup`() {- // Foreign CSVs (Strava, custom spreadsheets) have the same fields in different- // orders. The parser maps by header name, not by position, so this should work.- val csv = """- time,lat,lon,acc- 2024-01-01T12:00:00Z,52.5,13.4,7- """.trimIndent()-- val result = CsvParser.parse(csv.byteInputStream(), cancelled, nowSec)- assertEquals(1, result.rows.size)- assertEquals(7, result.rows[0].accuracy)- }-- @Test- fun `falls back from numeric timestamp to ISO when numeric is blank`() {- // Tolerates a partially populated row: numeric ts blank, ISO column present.- val csv = """- timestamp,iso_time,latitude,longitude- ,2024-01-01T12:00:00Z,52.5,13.4- """.trimIndent()-- val result = CsvParser.parse(csv.byteInputStream(), cancelled, nowSec)- assertEquals(1, result.rows.size)- assertEquals(1_704_110_400L, result.rows[0].timestamp)- }-- @Test- fun `rejects header missing required columns`() {- // No lat/lon means we can't import anything; surface a clear error rather- // than silently producing zero rows.- val csv = """- id,name,description- 0,foo,bar- """.trimIndent()-- try {- CsvParser.parse(csv.byteInputStream(), cancelled, nowSec)- } catch (e: UnsupportedFormatException) {- assertTrue(e.message?.contains("latitude") == true)- return- }- throw AssertionError("expected UnsupportedFormatException for missing required columns")- }-- @Test- fun `drops malformed rows but continues parsing`() {- // A single bad row shouldn't abort the whole import.- val csv = """- timestamp,latitude,longitude- 1704110400,52.5,13.4- ,,- 1704110500,52.6,13.5- """.trimIndent()-- val result = CsvParser.parse(csv.byteInputStream(), cancelled, nowSec)- assertEquals(2, result.rows.size)- assertEquals(1, result.invalid)- }-- @Test- fun `skips blank lines without counting them as invalid`() {- // Blank lines are common in hand-edited CSVs (trailing newline, separator- // between sections). They're not data, not malformed data.- val csv = """- timestamp,latitude,longitude- 1704110400,52.5,13.4-- 1704110500,52.6,13.5- """.trimIndent()-- val result = CsvParser.parse(csv.byteInputStream(), cancelled, nowSec)- assertEquals(2, result.rows.size)- assertEquals(0, result.invalid)- }-- @Test- fun `splitCsvLine strips surrounding double quotes`() {- val parts = CsvParser.splitCsvLine("\"a\",b,\"c\"")- assertEquals(listOf("a", "b", "c"), parts)- }-- @Test- fun `parseHeader maps aliases to canonical indices`() {- // Common aliases (lat/lng/velocity etc.) should map correctly so we accept- // exports from other apps without forcing the user to rename columns.- val cols = CsvParser.parseHeader("ts,lat,lng,velocity,ele")- assertEquals(0, cols.tsNumeric)- assertEquals(1, cols.lat)- assertEquals(2, cols.lon)- assertEquals(3, cols.speed)- assertEquals(4, cols.altitude)- }-- @Test- fun `cancellation flag interrupts parse`() {- val csv = buildString {- append("timestamp,latitude,longitude\n")- for (i in 0 until 1000) append("1704110${400 + i},52.5,13.4\n")- }- try {- CsvParser.parse(csv.byteInputStream(), AtomicBoolean(true), nowSec)- } catch (_: InterruptedException) {- return- }- throw AssertionError("expected InterruptedException")- }-}diff --git a/apps/mobile/android/apps/mobile/android/app/src/test/java/com/colota/importer/GpxParserTest.kt b/apps/mobile/android/apps/mobile/android/app/src/test/java/com/colota/importer/GpxParserTest.ktdeleted file mode 100644index 3d85acc8..00000000--- a/apps/mobile/android/apps/mobile/android/app/src/test/java/com/colota/importer/GpxParserTest.kt+++ /dev/null@@ -1,141 +0,0 @@-/**- * Copyright (C) 2026 Max Dietrich- * Licensed under the GNU AGPLv3. See LICENSE in the project root for details.- */--package com.Colota.importer--import org.junit.Assert.assertEquals-import org.junit.Assert.assertTrue-import org.junit.Test-import org.junit.runner.RunWith-import org.robolectric.RobolectricTestRunner-import java.util.concurrent.atomic.AtomicBoolean--@RunWith(RobolectricTestRunner::class)-class GpxParserTest {-- private val cancelled = AtomicBoolean(false)- private val nowSec = 1_750_000_000L-- @Test- fun `parses Colota GPX export with track-points and extensions`() {- // Mirrors apps/mobile/android/app/src/main/java/com/colota/export/ExportConverters.kt- // GpxFormat output: trkpt with ele/time/extensions for accuracy/speed/battery.- val gpx = """- <?xml version="1.0" encoding="UTF-8"?>- <gpx version="1.1" creator="Colota">- <trk>- <name>Test</name>- <trkseg>- <trkpt lat="52.500000" lon="13.400000">- <ele>30</ele>- <time>2024-01-01T12:00:00.000Z</time>- <extensions>- <accuracy>5</accuracy>- <speed>2</speed>- <battery>80</battery>- </extensions>- </trkpt>- </trkseg>- </trk>- </gpx>- """.trimIndent()-- val result = GpxParser.parse(gpx.byteInputStream(), cancelled, nowSec)- assertEquals(0, result.invalid)- assertEquals(1, result.rows.size)- val row = result.rows[0]- assertEquals(52.5, row.latitude, 1e-9)- assertEquals(13.4, row.longitude, 1e-9)- assertEquals(1_704_110_400L, row.timestamp)- assertEquals(30, row.altitude)- assertEquals(5, row.accuracy)- assertEquals(2, row.speed)- assertEquals(80, row.battery)- }-- @Test- fun `parses GPX waypoints and track-points together`() {- // Real GPX files mix wpt (standalone), rte/rtept, trk/trkseg/trkpt. The semantic- // distinction (planned route vs recorded track) doesn't survive into the flat- // locations table - we collect them all.- val gpx = """- <?xml version="1.0" encoding="UTF-8"?>- <gpx version="1.1">- <wpt lat="52.5" lon="13.4">- <time>2024-01-01T12:00:00Z</time>- </wpt>- <trk>- <trkseg>- <trkpt lat="52.6" lon="13.5">- <time>2024-01-01T12:01:00Z</time>- </trkpt>- </trkseg>- </trk>- </gpx>- """.trimIndent()-- val result = GpxParser.parse(gpx.byteInputStream(), cancelled, nowSec)- assertEquals(2, result.rows.size)- assertEquals(52.5, result.rows[0].latitude, 1e-9)- assertEquals(52.6, result.rows[1].latitude, 1e-9)- }-- @Test- fun `parses Garmin TrackPointExtension nested namespaced extensions`() {- // Sport watches commonly use the GPX 1.1 TrackPointExtension wrapper - the- // parser must recurse into it to find leaf elements like <gpxtpx:speed>.- val gpx = """- <?xml version="1.0" encoding="UTF-8"?>- <gpx version="1.1" xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1">- <trk><trkseg>- <trkpt lat="52.5" lon="13.4">- <time>2024-01-01T12:00:00Z</time>- <extensions>- <gpxtpx:TrackPointExtension>- <gpxtpx:speed>3.5</gpxtpx:speed>- <gpxtpx:course>180.0</gpxtpx:course>- </gpxtpx:TrackPointExtension>- </extensions>- </trkpt>- </trkseg></trk>- </gpx>- """.trimIndent()-- val result = GpxParser.parse(gpx.byteInputStream(), cancelled, nowSec)- assertEquals(1, result.rows.size)- assertEquals(3, result.rows[0].speed)- assertEquals(180.0, result.rows[0].bearing!!, 1e-9)- }-- @Test- fun `drops trkpt without time as invalid`() {- // Time is required for the locations table; a trkpt missing it is unusable.- val gpx = """- <?xml version="1.0" encoding="UTF-8"?>- <gpx version="1.1">- <trk><trkseg>- <trkpt lat="52.5" lon="13.4"><ele>30</ele></trkpt>- </trkseg></trk>- </gpx>- """.trimIndent()-- val result = GpxParser.parse(gpx.byteInputStream(), cancelled, nowSec)- assertEquals(1, result.invalid)- assertTrue(result.rows.isEmpty())- }-- @Test- fun `cancellation flag interrupts parse`() {- val gpx = "<?xml version=\"1.0\"?><gpx><trk><trkseg>" +- "<trkpt lat=\"1\" lon=\"1\"><time>2024-01-01T00:00:00Z</time></trkpt>".repeat(1000) +- "</trkseg></trk></gpx>"- try {- GpxParser.parse(gpx.byteInputStream(), AtomicBoolean(true), nowSec)- } catch (_: InterruptedException) {- return- }- throw AssertionError("expected InterruptedException")- }-}diff --git a/apps/mobile/android/apps/mobile/android/app/src/test/java/com/colota/importer/KmlParserTest.kt b/apps/mobile/android/apps/mobile/android/app/src/test/java/com/colota/importer/KmlParserTest.ktdeleted file mode 100644index ce428185..00000000--- a/apps/mobile/android/apps/mobile/android/app/src/test/java/com/colota/importer/KmlParserTest.kt+++ /dev/null@@ -1,133 +0,0 @@-/**- * Copyright (C) 2026 Max Dietrich- * Licensed under the GNU AGPLv3. See LICENSE in the project root for details.- */--package com.Colota.importer--import org.junit.Assert.assertEquals-import org.junit.Assert.assertNotNull-import org.junit.Assert.assertTrue-import org.junit.Test-import org.junit.runner.RunWith-import org.robolectric.RobolectricTestRunner-import java.util.concurrent.atomic.AtomicBoolean--@RunWith(RobolectricTestRunner::class)-class KmlParserTest {-- private val cancelled = AtomicBoolean(false)- private val nowSec = 1_750_000_000L-- @Test- fun `parses Colota KML export Point Placemark with TimeStamp`() {- // Mirrors apps/mobile/android/app/src/main/java/com/colota/export/ExportConverters.kt- // KmlFormat output: each track sample is a Placemark with Point + TimeStamp/when.- val kml = """- <?xml version="1.0" encoding="UTF-8"?>- <kml xmlns="http://www.opengis.net/kml/2.2">- <Document>- <Placemark>- <TimeStamp><when>2024-01-01T12:00:00.000Z</when></TimeStamp>- <Point>- <coordinates>13.4,52.5,30</coordinates>- </Point>- </Placemark>- </Document>- </kml>- """.trimIndent()-- val result = KmlParser.parse(kml.byteInputStream(), cancelled, nowSec)- assertEquals(0, result.invalid)- assertEquals(1, result.rows.size)- val row = result.rows[0]- // KML coordinate order is lon,lat - the parser must flip it back.- assertEquals(52.5, row.latitude, 1e-9)- assertEquals(13.4, row.longitude, 1e-9)- assertEquals(30, row.altitude)- assertEquals(1_704_110_400L, row.timestamp)- }-- @Test- fun `skips style-only Placemarks without counting them as invalid`() {- // Colota's KML export includes a final LineString-only Placemark for the- // rendered track path. It has no per-point timestamp and no Point geometry;- // dropping it shouldn't pollute the invalid counter (which the UI shows).- val kml = """- <?xml version="1.0" encoding="UTF-8"?>- <kml xmlns="http://www.opengis.net/kml/2.2">- <Document>- <Style id="pathStyle"><LineStyle><color>ff0000ff</color></LineStyle></Style>- <Placemark>- <TimeStamp><when>2024-01-01T12:00:00Z</when></TimeStamp>- <Point><coordinates>13.4,52.5</coordinates></Point>- </Placemark>- <Placemark>- <name>Track Path</name>- <styleUrl>#pathStyle</styleUrl>- </Placemark>- </Document>- </kml>- """.trimIndent()-- val result = KmlParser.parse(kml.byteInputStream(), cancelled, nowSec)- assertEquals(1, result.rows.size)- assertEquals("metadata-only Placemark shouldn't count as invalid", 0, result.invalid)- }-- @Test- fun `drops LineString-only Placemark since vertices have no per-point time`() {- // KML LineStrings carry a whole-line TimeSpan at best; vertex-level timestamps- // aren't a thing in the schema. Importing the vertices would invent timestamps,- // so we drop them. They count as invalid so the user knows data was skipped.- val kml = """- <?xml version="1.0" encoding="UTF-8"?>- <kml xmlns="http://www.opengis.net/kml/2.2">- <Document>- <Placemark>- <LineString>- <coordinates>13.4,52.5 13.5,52.6 13.6,52.7</coordinates>- </LineString>- </Placemark>- </Document>- </kml>- """.trimIndent()-- val result = KmlParser.parse(kml.byteInputStream(), cancelled, nowSec)- assertTrue(result.rows.isEmpty())- assertEquals("three skipped vertices counted as invalid", 3, result.invalid)- }-- @Test- fun `parseCoordinatesText handles whitespace-separated tuples`() {- // KML LineString coords are whitespace-separated tuples; the spec allows- // newlines and tab indentation between them.- val text = """- 13.4,52.5,30- 13.5,52.6- 13.6,52.7,40- """.trimIndent()- val parsed = KmlParser.parseCoordinatesText(text)- assertEquals(3, parsed.size)- // tuples are (lat, lon, alt?) after the flip- assertEquals(52.5 to 13.4, parsed[0].first to parsed[0].second)- assertEquals(30, parsed[0].third)- // missing altitude -> null- assertEquals(52.6 to 13.5, parsed[1].first to parsed[1].second)- assertNotNull("alt 30 should round-trip", parsed[0].third)- }-- @Test- fun `cancellation flag interrupts parse`() {- val kml = """<?xml version="1.0"?><kml xmlns="http://www.opengis.net/kml/2.2"><Document>""" +- ("<Placemark><TimeStamp><when>2024-01-01T12:00:00Z</when></TimeStamp>" +- "<Point><coordinates>13.4,52.5</coordinates></Point></Placemark>").repeat(1000) +- "</Document></kml>"- try {- KmlParser.parse(kml.byteInputStream(), AtomicBoolean(true), nowSec)- } catch (_: InterruptedException) {- return- }- throw AssertionError("expected InterruptedException")- }-}