Package-level declarations

Types

Link copied to clipboard

Listens for ACTION_LOCALE_CHANGED, which the platform also broadcasts when the user edits the Android 14+ regional preferences (Settings > System > Languages & input > Regional preferences) — the documented way to notice a temperature-unit change.

Link copied to clipboard
typealias CommonUri = Uri

Platform-agnostic URI representation backed by uri-kmp.

Link copied to clipboard
object Crc32

CRC-32 (IEEE 802.3 / zlib): reflected polynomial 0xEDB88320, initial value and final XOR 0xFFFFFFFF.

Link copied to clipboard
actual object DateFormatter

Platform-agnostic Date formatter utility.

expect object DateFormatter

Platform-agnostic Date formatter utility.

actual object DateFormatter

Platform-agnostic Date formatter utility.

Link copied to clipboard

Sometimes when starting services we face situations where messages come in that require computation but we can't do that computation yet because we are still waiting for some long running init to complete.

Link copied to clipboard

The desktop JVM has no locale-change notification: Locale.getDefault() is fixed for the life of the process unless the app itself changes it, so there is nothing to observe. Consumers still get their initial read.

Link copied to clipboard
data class DurationUnitLabels(val days: String, val hours: String, val minutes: String, val seconds: String)

The per-unit templates formatDuration fills with a count as %1$d. Screens use the translated set from core:resources; English is for text that is never translated, such as an exported report.

Link copied to clipboard
object Exceptions
Link copied to clipboard
object GPSFormat
Link copied to clipboard

This util class allows you to optimize the binary size of the transmitted text message strings. It replaces certain characters from national alphabets with the characters from the latin alphabet that have an identical appearance (homoglyphs), for example: cyrillic "А", "С", "у" -> latin "A", "C", "y", etc. According to statistics, such letters can make up about 20-25% of the total number of letters in the average text. Replacing them with Latin characters reduces the binary size of the transmitted message. The average transmitted message volume can then fit around ~140-145 characters instead of ~115-120

Link copied to clipboard

Signals that the OS locale or its regional preferences changed, so anything holding a formatted value can re-read it.

Link copied to clipboard

The display units, as values that change over time.

Link copied to clipboard
class LocaleUnitsProviderImpl(localeChangeNotifier: LocaleChangeNotifier, overrideSource: UnitsOverrideSource, applicationCoroutineScope: ApplicationCoroutineScope) : LocaleUnitsProvider
Link copied to clipboard

Represents the system's preferred measurement system.

Link copied to clipboard

A physical unit this app renders. symbol is fixed; the number beside it is localized.

Link copied to clipboard

Centralized metric formatting for display strings. Eliminates duplicated formatString patterns across Node, NodeItem, and metric screens.

Link copied to clipboard

Number formatting for display, and its locale-independent counterpart.

Link copied to clipboard

Where a timestamp falls relative to the local calendar day, for chat date separators.

Link copied to clipboard

The system's preferred temperature unit. Deliberately decoupled from MeasurementSystem: some locales mix systems (the UK measures road distance in miles but temperature in Celsius), so temperature must never be derived from the distance unit.

Link copied to clipboard

The user's in-app units choice. SYSTEM follows the OS locale; the other two force one system everywhere.

Link copied to clipboard

Where the user's units choice is read from; implemented over the UI preferences store.

Link copied to clipboard
object UrlUtils

Pure Kotlin URL encoding utility — no expect/actual needed.

Properties

Link copied to clipboard

Decimal, as every byte figure in the app is: 1 MB is 1,000,000 bytes, never 1,048,576.

Link copied to clipboard

Display symbols. Fixed rather than translated — see the note on MetricFormatter.

Link copied to clipboard

Mean radius of the Earth in meters, the sphere every distance here is measured on.

Link copied to clipboard
Link copied to clipboard
expect val ioDispatcher: CoroutineDispatcher

Access to the IO dispatcher in a multiplatform-safe way.

actual val ioDispatcher: CoroutineDispatcher

Access to the IO dispatcher in a multiplatform-safe way.

Link copied to clipboard
const val MIN_PLAUSIBLE_EPOCH_SECONDS: Int = 1577836800

2020-01-01: a boot-relative counter needs ~50 years of uptime to reach this, so it cannot be confused with a real epoch.

Link copied to clipboard

Accessor for the current time as a stable Instant.

Link copied to clipboard

Accessor for the current time in milliseconds.

Link copied to clipboard

Accessor for the current time in seconds.

Link copied to clipboard
val systemTimeZone: TimeZone

Accessor for the system default time zone.

Link copied to clipboard
const val VOLT_SYMBOL: String

Functions

Link copied to clipboard
fun bearing(lat1: Double, lon1: Double, lat2: Double, lon2: Double): Double

Computes the bearing in degrees between two points on Earth.

Link copied to clipboard
fun clampTimestampToNow(epochSeconds: Int): Int

Clamps a seconds-since-epoch timestamp so it never exceeds the current wall-clock time.

Link copied to clipboard
fun ByteString.crc32(): UInt
Link copied to clipboard

Returns the device's current locale as a 2-letter ISO 639-1 language code (e.g. "en", "es", "fr").

Returns the device's current locale as a 2-letter ISO 639-1 language code (e.g. "en", "es", "fr").

Returns the device's current locale as a 2-letter ISO 639-1 language code (e.g. "en", "es", "fr").

Link copied to clipboard
actual fun currentLocaleTag(): String

Returns the device locale as a BCP 47 language tag, script and region included: "sr-Latn-RS", "pt-BR", "fr".

expect fun currentLocaleTag(): String

Returns the device locale as a BCP 47 language tag, script and region included: "sr-Latn-RS", "pt-BR", "fr".

actual fun currentLocaleTag(): String

Returns the device locale as a BCP 47 language tag, script and region included: "sr-Latn-RS", "pt-BR", "fr".

Link copied to clipboard

Returns the device's current region as a 2-letter ISO 3166-1 alpha-2 country code (e.g. "US", "DE"), or an empty string when the region is unknown. Used to region-filter marketplace links.

Returns the device's current region as a 2-letter ISO 3166-1 alpha-2 country code (e.g. "US", "DE"), or an empty string when the region is unknown. Used to region-filter marketplace links.

Returns the device's current region as a 2-letter ISO 3166-1 alpha-2 country code (e.g. "US", "DE"), or an empty string when the region is unknown. Used to region-filter marketplace links.

Link copied to clipboard
fun exceptionReporter(inner: () -> Unit)

Wraps and discards exceptions, but reports them to the crash reporter before logging. Use this for operations that should not crash the process but are still unexpected.

Link copied to clipboard

Extracts WIFI SSID and password from a QR code string. Expected format: WIFI:S:SSID;P:PASSWORD;;

Link copied to clipboard

Formats a byte count for display with the thresholds and digits of Android's Formatter.formatFileSize: decimal units, the next unit once the value passes 900, two fraction digits below 100 and none from 100 up. So 1,500 bytes is "1.50 kB" and 16 GiB is "17.18 GB". The number follows the locale; so does the unit label where the platform can localize it.

Link copied to clipboard
expect fun formatDecimalLocalized(value: Double, fractionDigits: Int): String

Formats value to fractionDigits decimal places using the OS locale's decimal and grouping separators.

actual fun formatDecimalLocalized(value: Double, fractionDigits: Int): String

Android and the desktop JVM share this: both resolve separators and grouping from the platform locale data.

Link copied to clipboard
fun formatDuration(totalSeconds: Long, labels: DurationUnitLabels, smallest: DurationUnit = DurationUnit.SECONDS): String

Formats totalSeconds as its non-zero day, hour, minute and second parts, largest first: 1d 2h 3m 4s. Parts finer than smallest are dropped, and a duration with no part left prints zero of smallest. Negative input counts as zero.

Link copied to clipboard

See formatLengthLocalized; elevation pins the small unit (metres or feet) at every magnitude — 7,431 ft, never 1.4 mi — so only the rendering is CLDR's, not the unit choice.

See formatLengthLocalized; elevation pins the small unit (metres or feet) at every magnitude — 7,431 ft, never 1.4 mi — so only the rendering is CLDR's, not the unit choice.

See formatLengthLocalized; elevation pins the small unit (metres or feet) at every magnitude — 7,431 ft, never 1.4 mi — so only the rendering is CLDR's, not the unit choice.

Link copied to clipboard
actual fun formatLengthLocalized(meters: Double, system: MeasurementSystem): String?

CLDR-driven measure rendering: unit choice, conversion, digits, symbol, and spacing all come from the platform's ICU data for the current locale, forced onto system via the ms Unicode keyword — the mechanism Android 16's Measurement system setting itself uses. usage("road") is deliberately not used anywhere: CLDR road preferences snap values (87 m renders as "90 m") and pick yards for the UK, which is wrong for GNSS-accuracy labels and surprising for node distance.

expect fun formatLengthLocalized(meters: Double, system: MeasurementSystem): String?

CLDR-driven measure rendering: unit choice, conversion, digits, symbol, and spacing all come from the platform's ICU data for the current locale, forced onto system via the ms Unicode keyword — the mechanism Android 16's Measurement system setting itself uses. usage("road") is deliberately not used anywhere: CLDR road preferences snap values (87 m renders as "90 m") and pick yards for the UK, which is wrong for GNSS-accuracy labels and surprising for node distance.

actual fun formatLengthLocalized(meters: Double, system: MeasurementSystem): String?

CLDR-driven measure rendering: unit choice, conversion, digits, symbol, and spacing all come from the platform's ICU data for the current locale, forced onto system via the ms Unicode keyword — the mechanism Android 16's Measurement system setting itself uses. usage("road") is deliberately not used anywhere: CLDR road preferences snap values (87 m renders as "90 m") and pick yards for the UK, which is wrong for GNSS-accuracy labels and surprising for node distance.

Link copied to clipboard
fun formatMeasure(value: Double, unit: MeasureUnitKind, fractionDigits: Int): String

Formats value with its unit for display: the number follows the OS locale, the symbol does not.

Link copied to clipboard
fun formatMegabytes(megabytes: Double, fractionDigits: Int): String

Formats a value already in megabytes, in megabytes whatever its size. For places that must not change unit per value, such as the ticks of one chart axis.

Link copied to clipboard
actual fun formatRainfallLocalized(millimeters: Double, system: MeasurementSystem): String?

See formatLengthLocalized; input is mm under CLDR's rainfall usage, rendering mm or inches.

expect fun formatRainfallLocalized(millimeters: Double, system: MeasurementSystem): String?

See formatLengthLocalized; input is mm under CLDR's rainfall usage, rendering mm or inches.

actual fun formatRainfallLocalized(millimeters: Double, system: MeasurementSystem): String?

See formatLengthLocalized; input is mm under CLDR's rainfall usage, rendering mm or inches.

Link copied to clipboard
actual fun formatSpeedLocalized(metersPerSecond: Double, system: MeasurementSystem): String?

See formatLengthLocalized; input is m/s, CLDR renders km/h or mph.

expect fun formatSpeedLocalized(metersPerSecond: Double, system: MeasurementSystem): String?

See formatLengthLocalized; input is m/s, CLDR renders km/h or mph.

actual fun formatSpeedLocalized(metersPerSecond: Double, system: MeasurementSystem): String?

See formatLengthLocalized; input is m/s, CLDR renders km/h or mph.

Link copied to clipboard
fun formatString(pattern: String, vararg args: Any?): String

Pure-Kotlin multiplatform string formatting.

Link copied to clipboard
inline fun <reified T : Parcelable> Intent.getParcelableExtraCompat(key: String?): T?

Retrieves a Parcelable extra from an Intent in a backward-compatible way.

Link copied to clipboard

returns the system's preferred measurement system.

returns the system's preferred measurement system.

returns the system's preferred measurement system.

Link copied to clipboard

Returns the temperature unit preferred by the OS locale, honoring the user's regional-preference override where the platform supports one (Android 14+ Settings > System > Languages > Regional preferences).

Returns the temperature unit preferred by the OS locale, honoring the user's regional-preference override where the platform supports one (Android 14+ Settings > System > Languages > Regional preferences).

Returns the temperature unit preferred by the OS locale, honoring the user's regional-preference override where the platform supports one (Android 14+ Settings > System > Languages > Regional preferences).

Link copied to clipboard
fun CoroutineScope.handledLaunch(context: CoroutineContext = EmptyCoroutineContext, start: CoroutineStart = CoroutineStart.DEFAULT, block: suspend CoroutineScope.() -> Unit): Job

Launches a new coroutine with a central CoroutineExceptionHandler that reports errors to Exceptions.

Link copied to clipboard
fun ignoreException(silent: Boolean = false, inner: () -> Unit)

Wraps and discards exceptions, optionally logging them.

Link copied to clipboard
suspend fun ignoreExceptionSuspend(silent: Boolean = false, inner: suspend () -> Unit)

Suspend-compatible variant of ignoreException. Re-throws CancellationException.

Link copied to clipboard

True iff normalized (the output of normalizeAddress) is a no-device sentinel that DB naming collapses to the default database. Single source of truth for "no real device selected".

Link copied to clipboard
fun isSameLocalDay(firstMillis: Long, secondMillis: Long, timeZone: TimeZone = systemTimeZone): Boolean

True when both timestamps fall on the same local calendar day.

Link copied to clipboard

Validates if the given string is a valid network address (IP or domain).

Validates if the given string is a valid network address (IP or domain).

Validates if the given string is a valid network address (IP or domain).

Link copied to clipboard

True iff address refers to a real selected device. Rejects null/blank and all legacy no-device sentinels ("n", "null", ".n", "default", case-insensitive) by delegating to normalizeAddress and isNoDeviceSentinel. Any input that buildDbName would collapse to DEFAULT_DB_NAME is rejected here too, so the foreground-service stay-alive decision and the DB name resolution can never diverge.

Link copied to clipboard
fun latLongToMeter(latitudeA: Double, longitudeA: Double, latitudeB: Double, longitudeB: Double): Double
Link copied to clipboard

Normalizes a BLE/device address to a canonical uppercase form with colons removed. Returns "DEFAULT" for null, blank, or sentinel values ("N", "NULL").

Link copied to clipboard
fun Context.registerReceiverCompat(receiver: BroadcastReceiver, filter: IntentFilter, flag: Int = ContextCompat.RECEIVER_EXPORTED)

Registers a BroadcastReceiver using ContextCompat to ensure consistent behavior across Android versions.

Link copied to clipboard
fun relativeDayOf(timestampMillis: Long, referenceMillis: Long = nowMillis, timeZone: TimeZone = systemTimeZone): RelativeDay
Link copied to clipboard
inline fun <T> safeCatching(block: () -> T): Result<T>

Like kotlin.runCatching, but re-throws CancellationException to preserve structured concurrency. Use this instead of runCatching in coroutine contexts.

Link copied to clipboard
inline fun <T, R> T.safeCatching(block: T.() -> R): Result<R>

Like kotlin.runCatching receiver variant, but re-throws CancellationException.

Link copied to clipboard
inline fun <T> safeCatchingAll(block: () -> T): Result<T>

Like safeCatching but also catches JVM Errors (e.g. ExceptionInInitializerError raised by compose-resources' lazy skiko initialization on the desktop JVM test classpath). Still re-throws CancellationException so structured concurrency is preserved. Use when the block invokes code whose failure modes include static-initializer errors and the caller only needs a best-effort fallback.

Link copied to clipboard
fun Instant.toDate(): Date

Converts this Instant to a legacy Date.

Link copied to clipboard

Converts these milliseconds to an Instant.

Link copied to clipboard
fun validSecondsOrNull(seconds: Int?, maxValidTime: Int): Int?

Returns seconds when it is a plausible epoch no later than maxValidTime, else null