Skip to content

Colota - Android GPS Location tracker

feat(dashboard): show the sync interval under the recording interval (#931)

Max Dietrichff9e6df9e661
diff --git a/apps/docs/docs/development/architecture.md b/apps/docs/docs/development/architecture.md
index 663ebfea..b1e4b4ac 100644
--- a/apps/docs/docs/development/architecture.md
+++ b/apps/docs/docs/development/architecture.md
@@ -304,7 +304,7 @@ For backups, two `internal` methods support the export/import flow without expos
| Screen | Purpose |
| --- | --- |
-| `DashboardScreen` | Full-bleed map with no header. One banner slot under the status inset for a missing permission, location services off or a critical battery, and a docked card over the bottom edge: the tracking state line, the interval row (fix cadence and sync cadence, from the active profile or from settings; a zero sync interval reads as instant) and the server row. The Start/Stop pill and the Route toggle float above the dock. Nothing polls: it reads on focus and takes the rest from events |
+| `DashboardScreen` | Full-bleed map with no header. One banner slot under the status inset for a missing permission, location services off or a critical battery, and a docked card over the bottom edge: the tracking state line, the interval row (fix cadence with the sync cadence under it, from the active profile or from settings; a zero sync interval reads as instant, offline mode replaces the sync cadence) and the server row. The Start/Stop pill and the Route toggle float above the dock. Nothing polls: it reads on focus and takes the rest from events |
| `SettingsScreen` | The hub, a tab of five grouped lists: Tracking (Connection, Tracking & sync, Tracking profiles), Display, Data, Help and About. Two rows carry live state through the derivation their target screen opens with (`serverState.describeServer`, `profileRow.profileStateLabel`); every other sub is a stored value, an on-disk fact or the nouns inside the screen, computed by `utils/settingsRow` |
| `ConnectionScreen` | The server hub: a sync state line from `utils/serverState`, offline mode, the endpoint (saved on blur), Test connection, and rows to Request format, Authentication and Client certificate |
| `TrackingSyncScreen` | GPS interval, distance filter, accuracy threshold and sync strategy preset |
@@ -397,7 +397,7 @@ Supporting utilities in `mapUtils.ts`:
| `geo` | Haversine distance, speed/distance/duration/time formatting with configurable unit system (metric/imperial) and time format (12h/24h), auto-detected from locale on first use |
| `exportConverters` | Export-format metadata (labels, icons, extensions, MIME types) for the export UI. Serialization itself is native - see `ExportConverters.kt` |
| `trips` | Trip segmentation via time-gap detection (15-min threshold), dropping segments whose bounding box spans under 100 m so stationary heartbeat runs do not become trips, plus distance computation, trip stats (avg speed, elevation gain/loss), and trip color assignment. Elevation is smoothed over a time window before accumulating, since raw altitude swings between fixes overstate the climb. Manual `trip_boundary_overrides` take priority over the gap threshold, and a segment abutting a forced split is exempt from the 100 m filter so an explicit edit is never silently dropped. `getDailyStats` in `DatabaseHelper.kt` mirrors all of this for the calendar and summary |
-| `dashboardState` | Pure functions behind the Dashboard: `pickBannerCondition` ranks the one banner slot (location grant, background grant while tracking, location services, battery), `describeState` turns tracking, pause and fix state into the dock's state line, `intervalText` and `formatLastFix` |
+| `dashboardState` | Pure functions behind the Dashboard: `pickBannerCondition` ranks the one banner slot (location grant, background grant while tracking, location services, battery), `describeState` turns tracking, pause and fix state into the dock's state line, `intervalLines` and `formatLastFix` |
| `settingsValidation` | URL validation and security checks for endpoint configuration |
### Hooks
diff --git a/apps/mobile/src/components/features/dashboard/DashboardDock.tsx b/apps/mobile/src/components/features/dashboard/DashboardDock.tsx
index 40524dc7..374e259f 100644
--- a/apps/mobile/src/components/features/dashboard/DashboardDock.tsx
+++ b/apps/mobile/src/components/features/dashboard/DashboardDock.tsx
@@ -8,16 +8,14 @@ import { ScrollView } from "react-native"
import { CircleAlert, CircleDashed, CircleDot, CirclePause, Timer, type LucideIcon } from "lucide-react-native"
import { useTheme } from "../../../hooks/useTheme"
import { Settings, ThemeColors } from "../../../types/global"
-import { describeState, type StateIcon, type StateTone } from "../../../utils/dashboardState"
+import { describeState, type IntervalLines, type StateIcon, type StateTone } from "../../../utils/dashboardState"
import { size } from "../../../constants"
import { MapDock } from "../../ui/MapDock"
import { Divider } from "../../ui/Divider"
import { SpinningLoader } from "../../ui/SpinningLoader"
-import { StatRow } from "../../ui/StatRow"
import { ConnectionStatus } from "./ConnectionStatus"
import { StateLine } from "../../ui/StateLine"
import { WelcomeCard } from "./WelcomeCard"
-import { useTranslation } from "../../../i18n/useTranslation"
type DashboardDockProps = {
tracking: boolean
@@ -29,7 +27,7 @@ type DashboardDockProps = {
coords: { accuracy: number; timestamp: number } | null
lastKnown: { timestamp: number } | null
stoppedByBattery: boolean
- intervalText: string
+ interval: IntervalLines
endpoint: string | null
isOfflineMode: boolean
navigation: any
@@ -61,7 +59,7 @@ export function DashboardDock({
coords,
lastKnown,
stoppedByBattery,
- intervalText,
+ interval,
endpoint,
isOfflineMode,
navigation,
@@ -76,7 +74,6 @@ export function DashboardDock({
onNavigateToRequestFormat
}: DashboardDockProps) {
const { colors } = useTheme()
- const { t } = useTranslation()
if (firstRun) {
return (
@@ -119,7 +116,13 @@ export function DashboardDock({
<MapDock maxHeight={maxHeight}>
<StateLine icon={icon} iconColor={iconColor} label={state.label} caption={state.caption} testID="dock-state" />
<Divider tight inset />
- <StatRow icon={Timer} label={t("dashboard.interval")} value={intervalText} testID="dock-interval" />
+ <StateLine
+ icon={Timer}
+ iconColor={colors.textSecondary}
+ label={interval.label}
+ caption={interval.caption}
+ testID="dock-interval"
+ />
{!isOfflineMode && (
<>
<Divider tight inset />
diff --git a/apps/mobile/src/components/features/dashboard/__tests__/DashboardDock.test.tsx b/apps/mobile/src/components/features/dashboard/__tests__/DashboardDock.test.tsx
index fe0fe72f..f1d9dbb1 100644
--- a/apps/mobile/src/components/features/dashboard/__tests__/DashboardDock.test.tsx
+++ b/apps/mobile/src/components/features/dashboard/__tests__/DashboardDock.test.tsx
@@ -57,7 +57,7 @@ const idleProps = {
coords: null,
lastKnown: null,
stoppedByBattery: false,
- intervalText: "Every 30 s · Balanced",
+ interval: { label: "Records every 30 s", caption: "Syncs every 5 min" },
endpoint: "https://tracks.example.org/api",
isOfflineMode: false,
navigation: { navigate: jest.fn() },
@@ -97,7 +97,7 @@ describe("DashboardDock", () => {
expect(divider.props.inset).toBe(true)
}
expect(idle.getByLabelText("Ready, No fixes yet")).toBeTruthy()
- expect(idle.getByLabelText("Interval, Every 30 s · Balanced")).toBeTruthy()
+ expect(idle.getByLabelText("Records every 30 s, Syncs every 5 min")).toBeTruthy()
idle.unmount()
const live = renderDock(trackingProps)
diff --git a/apps/mobile/src/i18n/locales/en.json b/apps/mobile/src/i18n/locales/en.json
index c271917e..b0364f8e 100644
--- a/apps/mobile/src/i18n/locales/en.json
+++ b/apps/mobile/src/i18n/locales/en.json
@@ -301,7 +301,6 @@
"connection.test.serverReturned": "Server returned {{status}}",
"connection.test.testing": "Testing",
"dashboard.checking": "Checking",
- "dashboard.interval": "Interval",
"dashboard.locationOff.cancel": "Start anyway",
"dashboard.locationOff.confirm": "Location settings",
"dashboard.locationOff.message": "Location Services are disabled. Tracking will not work until they are enabled in Settings.",
@@ -1044,9 +1043,9 @@
"template.reitti.description": "OwnTracks-compatible format for Reitti",
"template.traccar.description": "Traccar OsmAnd protocol (HTTP GET)",
"trackMap.fit": "Fit the day",
- "tracking.every": "Every {{duration}}",
- "tracking.interval.instantSync": "Instant sync",
- "tracking.interval.sync": "Sync {{duration}}",
+ "tracking.every": "Records every {{duration}}",
+ "tracking.interval.instantSync": "Syncs each fix",
+ "tracking.interval.sync": "Syncs every {{duration}}",
"tracking.phrase.after": "every {{duration}} after {{distance}}",
"tracking.phrase.anyMovement": "every {{duration}}, any movement",
"tracking.phrase.whileStill": "every {{duration}} while still",
diff --git a/apps/mobile/src/i18n/locales/es.json b/apps/mobile/src/i18n/locales/es.json
index 88328f2d..33583043 100644
--- a/apps/mobile/src/i18n/locales/es.json
+++ b/apps/mobile/src/i18n/locales/es.json
@@ -301,7 +301,6 @@
"connection.test.serverReturned": "El servidor devolvió {{status}}",
"connection.test.testing": "Probando",
"dashboard.checking": "Verificando",
- "dashboard.interval": "Intervalo",
"dashboard.locationOff.cancel": "Iniciar de todos modos",
"dashboard.locationOff.confirm": "Configuración de ubicación",
"dashboard.locationOff.message": "Los servicios de ubicación están desactivados. El seguimiento no funcionará hasta que los actives en Configuración.",
@@ -1044,9 +1043,9 @@
"template.reitti.description": "Formato compatible con OwnTracks para Reitti",
"template.traccar.description": "Protocolo OsmAnd de Traccar (HTTP GET)",
"trackMap.fit": "Ajustar el día",
- "tracking.every": "Cada {{duration}}",
- "tracking.interval.instantSync": "Sincronización inmediata",
- "tracking.interval.sync": "Sincronizar cada {{duration}}",
+ "tracking.every": "Registra cada {{duration}}",
+ "tracking.interval.instantSync": "Sincroniza cada posición",
+ "tracking.interval.sync": "Sincroniza cada {{duration}}",
"tracking.phrase.after": "cada {{duration}} tras {{distance}}",
"tracking.phrase.anyMovement": "cada {{duration}}, cualquier movimiento",
"tracking.phrase.whileStill": "cada {{duration}} en reposo",
diff --git a/apps/mobile/src/screens/DashboardScreen.tsx b/apps/mobile/src/screens/DashboardScreen.tsx
index 6b13363e..49cb1a09 100644
--- a/apps/mobile/src/screens/DashboardScreen.tsx
+++ b/apps/mobile/src/screens/DashboardScreen.tsx
@@ -17,7 +17,7 @@ import { showConfirm } from "../services/modalService"
import { Button, Container, DashboardBanner, DashboardDock, DashboardMap } from "../components"
import type { LastKnownLocation } from "../components/features/dashboard/DashboardMap"
import { TrackToggleButton } from "../components/features/map/TrackToggleButton"
-import { intervalText, pickBannerCondition } from "../utils/dashboardState"
+import { intervalLines, pickBannerCondition } from "../utils/dashboardState"
import { size, space } from "../constants"
import { Square, Play } from "lucide-react-native"
import { logger } from "../utils/logger"
@@ -226,8 +226,8 @@ export function DashboardScreen({ navigation }: ScreenProps) {
const hasFix = tracking && coords !== null && coords.latitude !== 0 && coords.longitude !== 0
const dockCoords = hasFix ? { accuracy: coords.accuracy ?? 0, timestamp: coords.timestamp ?? 0 } : null
const intervalRow = activeProfile
- ? intervalText(activeProfile.interval, activeProfile.syncInterval)
- : intervalText(settings.interval, settings.syncInterval)
+ ? intervalLines(activeProfile.interval, activeProfile.syncInterval, settings.isOfflineMode)
+ : intervalLines(settings.interval, settings.syncInterval, settings.isOfflineMode)
return (
<Container>
@@ -290,7 +290,7 @@ export function DashboardScreen({ navigation }: ScreenProps) {
coords={dockCoords}
lastKnown={lastKnown ?? null}
stoppedByBattery={stoppedByBattery}
- intervalText={intervalRow}
+ interval={intervalRow}
endpoint={settings.endpoint}
isOfflineMode={settings.isOfflineMode}
navigation={navigation}
diff --git a/apps/mobile/src/screens/__tests__/DashboardScreen.test.tsx b/apps/mobile/src/screens/__tests__/DashboardScreen.test.tsx
index f1d5441b..6b43e5e2 100644
--- a/apps/mobile/src/screens/__tests__/DashboardScreen.test.tsx
+++ b/apps/mobile/src/screens/__tests__/DashboardScreen.test.tsx
@@ -260,17 +260,32 @@ describe("DashboardScreen", () => {
expect(getByTestId("DashboardDock").props.endpoint).toBe(DEFAULT_SETTINGS.endpoint)
})
+ it("says offline mode in place of the sync cadence, because nothing is sent while it is on", async () => {
+ mockSettings = { ...DEFAULT_SETTINGS, isOfflineMode: true }
+
+ const { getByTestId } = renderScreen()
+ await settle()
+
+ expect(getByTestId("DashboardDock").props.interval.caption).toBe("Offline mode")
+ })
+
it("labels the interval row with the fix and sync cadence from settings while no profile is active", async () => {
mockSettings = { ...DEFAULT_SETTINGS, interval: 30, syncInterval: 300 }
const batched = renderScreen()
await settle()
- expect(batched.getByTestId("DashboardDock").props.intervalText).toBe("Every 30 s · Sync 5 min")
+ expect(batched.getByTestId("DashboardDock").props.interval).toEqual({
+ label: "Records every 30 s",
+ caption: "Syncs every 5 min"
+ })
batched.unmount()
mockSettings = { ...DEFAULT_SETTINGS, interval: 5, syncInterval: 0 }
const instant = renderScreen()
await settle()
- expect(instant.getByTestId("DashboardDock").props.intervalText).toBe("Every 5 s · Instant sync")
+ expect(instant.getByTestId("DashboardDock").props.interval).toEqual({
+ label: "Records every 5 s",
+ caption: "Syncs each fix"
+ })
expect(mockGetProfiles).not.toHaveBeenCalled()
})
@@ -285,7 +300,12 @@ describe("DashboardScreen", () => {
])
const { getByTestId } = renderScreen()
- await waitFor(() => expect(getByTestId("DashboardDock").props.intervalText).toBe("Every 5 min · Sync 15 min"))
+ await waitFor(() =>
+ expect(getByTestId("DashboardDock").props.interval).toEqual({
+ label: "Records every 5 min",
+ caption: "Syncs every 15 min"
+ })
+ )
})
it("falls back to the settings pair when the active profile id matches no saved profile", async () => {
@@ -297,7 +317,10 @@ describe("DashboardScreen", () => {
const { getByTestId } = renderScreen()
await waitFor(() => expect(mockGetProfiles).toHaveBeenCalled())
- expect(getByTestId("DashboardDock").props.intervalText).toBe("Every 30 s · Sync 5 min")
+ expect(getByTestId("DashboardDock").props.interval).toEqual({
+ label: "Records every 30 s",
+ caption: "Syncs every 5 min"
+ })
})
it("starts tracking directly when location services are enabled", async () => {
diff --git a/apps/mobile/src/utils/__tests__/dashboardState.test.ts b/apps/mobile/src/utils/__tests__/dashboardState.test.ts
index 045e3ec4..b40859ff 100644
--- a/apps/mobile/src/utils/__tests__/dashboardState.test.ts
+++ b/apps/mobile/src/utils/__tests__/dashboardState.test.ts
@@ -3,7 +3,7 @@ import {
formatDuration,
formatInterval,
formatLastFix,
- intervalText,
+ intervalLines,
pickBannerCondition,
recordingPhrase,
recordingSummary,
@@ -199,38 +199,42 @@ describe("describeState", () => {
describe("formatInterval", () => {
it("keeps sub-minute intervals in seconds", () => {
- expect(formatInterval(5)).toBe("Every 5 s")
- expect(formatInterval(30)).toBe("Every 30 s")
+ expect(formatInterval(5)).toBe("Records every 5 s")
+ expect(formatInterval(30)).toBe("Records every 30 s")
})
it("promotes whole minutes so 300 does not have to be divided in the head", () => {
- expect(formatInterval(60)).toBe("Every 1 min")
- expect(formatInterval(300)).toBe("Every 5 min")
+ expect(formatInterval(60)).toBe("Records every 1 min")
+ expect(formatInterval(300)).toBe("Records every 5 min")
})
it("promotes whole hours", () => {
- expect(formatInterval(3600)).toBe("Every 1 h")
- expect(formatInterval(7200)).toBe("Every 2 h")
+ expect(formatInterval(3600)).toBe("Records every 1 h")
+ expect(formatInterval(7200)).toBe("Records every 2 h")
})
it("falls back to seconds when neither unit divides evenly, so nothing is rounded away", () => {
- expect(formatInterval(90)).toBe("Every 90 s")
- expect(formatInterval(5400)).toBe("Every 90 min")
+ expect(formatInterval(90)).toBe("Records every 90 s")
+ expect(formatInterval(5400)).toBe("Records every 90 min")
})
})
-describe("intervalText", () => {
+describe("intervalLines", () => {
it.each([
- [5, 900, "Every 5 s · Sync 15 min"],
- [30, 300, "Every 30 s · Sync 5 min"],
- [5, 90, "Every 5 s · Sync 90 s"],
- [3600, 7200, "Every 1 h · Sync 2 h"]
- ])("pairs the fix cadence %i s with the sync cadence %i s in the same units", (interval, sync, expected) => {
- expect(intervalText(interval, sync)).toBe(expected)
+ [5, 900, "Records every 5 s", "Syncs every 15 min"],
+ [30, 300, "Records every 30 s", "Syncs every 5 min"],
+ [5, 90, "Records every 5 s", "Syncs every 90 s"],
+ [3600, 7200, "Records every 1 h", "Syncs every 2 h"]
+ ])("leads with the fix cadence %i s and puts the sync cadence %i s under it", (interval, sync, label, caption) => {
+ expect(intervalLines(interval, sync, false)).toEqual({ label, caption })
})
it("calls a zero sync interval instant, since every fix is sent as it lands", () => {
- expect(intervalText(5, 0)).toBe("Every 5 s · Instant sync")
+ expect(intervalLines(5, 0, false)).toEqual({ label: "Records every 5 s", caption: "Syncs each fix" })
+ })
+
+ it("says offline mode instead of a sync cadence, because nothing is sent while it is on", () => {
+ expect(intervalLines(30, 300, true)).toEqual({ label: "Records every 30 s", caption: "Offline mode" })
})
})
diff --git a/apps/mobile/src/utils/dashboardState.ts b/apps/mobile/src/utils/dashboardState.ts
index 8223be6c..64a5ae8d 100644
--- a/apps/mobile/src/utils/dashboardState.ts
+++ b/apps/mobile/src/utils/dashboardState.ts
@@ -152,12 +152,19 @@ export function trackingSummary(
return isOfflineMode ? recording : `${recording} · ${syncSummary(syncIntervalSeconds)}`
}
-export function intervalText(intervalSeconds: number, syncIntervalSeconds: number): string {
- const sync =
- syncIntervalSeconds === 0
+export type IntervalLines = { label: string; caption: string }
+
+export function intervalLines(
+ intervalSeconds: number,
+ syncIntervalSeconds: number,
+ isOfflineMode: boolean
+): IntervalLines {
+ const caption = isOfflineMode
+ ? t("dashboard.offlineMode")
+ : syncIntervalSeconds === 0
? t("tracking.interval.instantSync")
: t("tracking.interval.sync", { duration: formatDuration(syncIntervalSeconds) })
- return `${formatInterval(intervalSeconds)} · ${sync}`
+ return { label: formatInterval(intervalSeconds), caption }
}
export function formatLastFix(timestampSeconds: number | null, now: Date = new Date()): string {
diff --git a/fastlane/metadata/android/en-US/changelogs/52.txt b/fastlane/metadata/android/en-US/changelogs/52.txt
index f31a4e40..4536015a 100644
--- a/fastlane/metadata/android/en-US/changelogs/52.txt
+++ b/fastlane/metadata/android/en-US/changelogs/52.txt
@@ -1,2 +1,3 @@
- Colota is now available in Spanish
- Profiles no longer skip a pause zone's entry delay
+- The Dashboard no longer cuts off the sync interval and says Offline mode when that is on