Modern Apps git

← Modern-Apps.git

astronomy: detekt clean (125 tests)

Commit
43864a538b13a5bc6966cce0c277666e924ae698
Author
Vayun Mathur <[email protected]>
When
2026-11-14 23:16 UTC (21 days ago)
Parents
fe473c4
Fix all 70 detekt findings: real KDoc for 58 undocumented public classes; 8 MagicNumber literals became MIN/MAX_LAT/LON_DEG constants in the AstronomyViewModel companion covering both validation sites; ComplexCondition extracted to latInRange/lonInRange; two test EmptyElseBlock findings fixed by reformatting while bodies; MaxLineLength fixed by splitting the visibleSky flow chain.

Verified: ./gradlew :astronomy:detekt :astronomy:testDevUnitTest :astronomy:lint --max-workers=32 — BUILD SUCCESSFUL, 125 unit tests pass. No @Suppress added.

Diff

astronomy/src/main/java/com/vayunmathur/astronomy/MainActivity.kt
diff --git a/astronomy/src/main/java/com/vayunmathur/astronomy/MainActivity.kt b/astronomy/src/main/java/com/vayunmathur/astronomy/MainActivity.ktindex 43c031ccb1..2bf4485c16 100644--- a/astronomy/src/main/java/com/vayunmathur/astronomy/MainActivity.kt+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/MainActivity.kt@@ -9,6 +9,7 @@ import com.vayunmathur.library.ui.AppPermissionsSpec import com.vayunmathur.library.ui.MaActivity import com.vayunmathur.library.ui.PermissionRequirement +/** Entry activity for the offline sky viewer; requires location permission, then shows navigation. */ class MainActivity : MaActivity() {     private val viewModel: AstronomyViewModel by viewModels() 
astronomy/src/main/java/com/vayunmathur/astronomy/Route.kt
diff --git a/astronomy/src/main/java/com/vayunmathur/astronomy/Route.kt b/astronomy/src/main/java/com/vayunmathur/astronomy/Route.ktindex 91d59016c4..a1d9684d7a 100644--- a/astronomy/src/main/java/com/vayunmathur/astronomy/Route.kt+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/Route.kt@@ -4,11 +4,21 @@ import com.vayunmathur.library.util.NavKey import kotlinx.datetime.LocalDate import kotlinx.serialization.Serializable +/** Navigation destinations for the astronomy app. */ @Serializable sealed interface Route : NavKey {+    /** The live sky-map screen. */     @Serializable data object SkyMap : Route++    /** Detail screen for the celestial object identified by [id]. */     @Serializable data class ObjectDetail(val id: String) : Route++    /** Search screen for catalog objects. */     @Serializable data object Search : Route++    /** Settings screen for display and observer options. */     @Serializable data object Settings : Route++    /** Date picker for scrubbing to a historical date, starting at [initialDate]. */     @Serializable data class HistoryDatePicker(val initialDate: LocalDate) : Route }
astronomy/src/main/java/com/vayunmathur/astronomy/data/CatalogRepository.kt
diff --git a/astronomy/src/main/java/com/vayunmathur/astronomy/data/CatalogRepository.kt b/astronomy/src/main/java/com/vayunmathur/astronomy/data/CatalogRepository.ktindex 4a0a658898..3a093506e2 100644--- a/astronomy/src/main/java/com/vayunmathur/astronomy/data/CatalogRepository.kt+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/data/CatalogRepository.kt@@ -15,6 +15,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import kotlinx.serialization.json.Json +/** Loads bundled catalogs from assets, falling back to built-in data when unreadable. */ class CatalogRepository(     private val context: Context,     /** Reads one bundled asset as text, or null when it cannot be read. Injectable for tests. */@@ -95,6 +96,7 @@ class CatalogRepository(     } } +/** Small built-in fallback catalogs used when a bundled asset is missing or unreadable. */ object BuiltInCatalogs {     val stars: List<Star> = listOf(         Star(1, 2.0632318, 0.68092, -1.44, 0.0, "Sirius", "Sirius", "Alpha", null, "CMa", 8.6, "A1V"),
astronomy/src/main/java/com/vayunmathur/astronomy/data/model/Models.kt
diff --git a/astronomy/src/main/java/com/vayunmathur/astronomy/data/model/Models.kt b/astronomy/src/main/java/com/vayunmathur/astronomy/data/model/Models.ktindex 6314a541c1..e26eeeb981 100644--- a/astronomy/src/main/java/com/vayunmathur/astronomy/data/model/Models.kt+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/data/model/Models.kt@@ -4,6 +4,7 @@ import androidx.annotation.StringRes import com.vayunmathur.astronomy.R import kotlinx.serialization.Serializable +/** A catalog star at J2000 equatorial coordinates, with magnitude and optional identity data. */ @Serializable data class Star(     val id: Int,@@ -20,6 +21,7 @@ data class Star(     val spectralClass: String? = null ) +/** A constellation identified by abbreviation, with stick-figure lines joining star ids. */ @Serializable data class Constellation(     val abbr: String,@@ -27,6 +29,7 @@ data class Constellation(     val lines: List<List<Int>> ) +/** One alignment point tying a figure-image pixel to the catalog star it must overlay. */ @Serializable data class ArtAnchor(     val x: Int, // pixel x in the figure image@@ -34,6 +37,7 @@ data class ArtAnchor(     val hip: Int // star (catalog id) this pixel should align to ) +/** A constellation figure image and its three anchors defining its sky placement. */ @Serializable data class ConstellationArt(     val abbr: String,@@ -41,6 +45,7 @@ data class ConstellationArt(     val anchors: List<ArtAnchor> // exactly 3, defines the affine placement ) +/** A deep-sky catalog entry (galaxy, nebula, or cluster) at J2000 coordinates. */ @Serializable data class DeepSkyObject(     val id: String,@@ -53,6 +58,7 @@ data class DeepSkyObject(     val constellation: String? = null ) +/** Keplerian orbital elements for a solar-system body, used to compute its position. */ @Serializable data class OrbitalElements(     val id: String,@@ -70,21 +76,27 @@ data class OrbitalElements(     val magBase: Double? = null ) +/** Serialized wrapper for the bundled star catalog. */ @Serializable data class StarsCatalog(val stars: List<Star>) +/** Serialized wrapper for the bundled constellation catalog. */ @Serializable data class ConstellationsCatalog(val constellations: List<Constellation>) +/** Serialized wrapper for the bundled constellation-art catalog. */ @Serializable data class ConstellationArtCatalog(val art: List<ConstellationArt>) +/** Serialized wrapper for the bundled deep-sky catalog. */ @Serializable data class DeepSkyCatalog(val objects: List<DeepSkyObject>) +/** Serialized wrapper for the bundled orbital-elements catalog. */ @Serializable data class OrbitalElementsCatalog(val planets: List<OrbitalElements>) +/** Solar-system bodies shown as planets, each with its display-name string resource. */ enum class PlanetId(@StringRes val displayNameRes: Int) {     SUN(R.string.planet_sun),     MOON(R.string.planet_moon),
astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/CoordinateTransforms.kt
diff --git a/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/CoordinateTransforms.kt b/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/CoordinateTransforms.ktindex 67e2a5cbc8..e52d7c829f 100644--- a/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/CoordinateTransforms.kt+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/CoordinateTransforms.kt@@ -9,19 +9,23 @@ import kotlin.math.cos import kotlin.math.sin import kotlin.math.tan +/** Equatorial coordinates: right ascension and declination in radians (J2000). */ data class RaDec(val raRad: Double, val decRad: Double) {     val raDeg get() = raRad.toDeg()     val decDeg get() = decRad.toDeg()     val raHours get() = raDeg / 15.0 } +/** Horizontal coordinates: azimuth and altitude in radians for an observer. */ data class AltAz(val azRad: Double, val altRad: Double) {     val azDeg get() = azRad.toDeg()     val altDeg get() = altRad.toDeg() } +/** Ecliptic longitude and latitude in radians. */ data class Ecliptic(val lonRad: Double, val latRad: Double) +/** Conversions between equatorial, horizontal, and ecliptic coordinates. */ object CoordinateTransforms {      fun raDecToAltAz(raDec: RaDec, lstRad: Double, latRad: Double): AltAz {
astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/LunarCalculator.kt
diff --git a/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/LunarCalculator.kt b/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/LunarCalculator.ktindex be77d06b4c..97cfacc5c5 100644--- a/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/LunarCalculator.kt+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/LunarCalculator.kt@@ -3,7 +3,9 @@ package com.vayunmathur.astronomy.domain.engine import kotlin.math.cos import kotlin.math.sin +/** Computes the Moon's position, distance, and phase from the Julian date. */ object LunarCalculator {+    /** The Moon's equatorial position, distance, and phase quantities at one instant. */     data class MoonResult(         val raDec: RaDec,         val distanceKm: Double,
astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/PlanetaryCalculator.kt
diff --git a/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/PlanetaryCalculator.kt b/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/PlanetaryCalculator.ktindex 0dadd0f89a..2e1004d6e9 100644--- a/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/PlanetaryCalculator.kt+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/PlanetaryCalculator.kt@@ -9,7 +9,9 @@ import kotlin.math.log10 import kotlin.math.sin import kotlin.math.sqrt +/** Computes planetary positions from Keplerian orbital elements. */ object PlanetaryCalculator {+    /** A planet's geocentric position, distances, and estimated magnitude at one instant. */     data class PlanetResult(         val id: String,         val name: String,
astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/RiseSetCalculator.kt
diff --git a/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/RiseSetCalculator.kt b/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/RiseSetCalculator.ktindex 3206a5873f..3927be2653 100644--- a/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/RiseSetCalculator.kt+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/RiseSetCalculator.kt@@ -5,7 +5,9 @@ import kotlin.math.acos import kotlin.math.cos import kotlin.math.sin +/** Computes rise, transit, and set times for celestial objects. */ object RiseSetCalculator {+    /** Rise, transit, and set Julian dates, or circumpolar flags when no crossing occurs. */     data class RiseTransitSet(         val riseJd: Double?,         val transitJd: Double?,
astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/SolarCalculator.kt
diff --git a/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/SolarCalculator.kt b/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/SolarCalculator.ktindex 168a4d1f41..5f500565bf 100644--- a/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/SolarCalculator.kt+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/SolarCalculator.kt@@ -6,7 +6,9 @@ import kotlin.math.atan2 import kotlin.math.cos import kotlin.math.sin +/** Computes the Sun's position and equation of time from the Julian date. */ object SolarCalculator {+    /** The Sun's equatorial position, distance, declination, and equation of time. */     data class SolarResult(         val raDec: RaDec,         val distanceAu: Double,
astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/TimeEngine.kt
diff --git a/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/TimeEngine.kt b/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/TimeEngine.ktindex 53418cdfbf..6afb922fc7 100644--- a/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/TimeEngine.kt+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/domain/engine/TimeEngine.kt@@ -4,6 +4,7 @@ import kotlin.math.PI import kotlin.time.ExperimentalTime import kotlin.time.Instant +/** Julian-date, sidereal-time, and obliquity conversions for the ephemeris. */ object TimeEngine {     const val J2000 = 2451545.0 
astronomy/src/main/java/com/vayunmathur/astronomy/domain/projection/SkyProjection.kt
diff --git a/astronomy/src/main/java/com/vayunmathur/astronomy/domain/projection/SkyProjection.kt b/astronomy/src/main/java/com/vayunmathur/astronomy/domain/projection/SkyProjection.ktindex 90460a016e..d0b427c20a 100644--- a/astronomy/src/main/java/com/vayunmathur/astronomy/domain/projection/SkyProjection.kt+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/domain/projection/SkyProjection.kt@@ -3,6 +3,7 @@ package com.vayunmathur.astronomy.domain.projection import androidx.compose.ui.geometry.Offset import com.vayunmathur.astronomy.domain.engine.AltAz +/** Maps horizontal coordinates to screen points and back for one sky view. */ interface SkyProjection {     fun project(altAz: AltAz): Offset?     fun unproject(screen: Offset): AltAz?
astronomy/src/main/java/com/vayunmathur/astronomy/domain/projection/StereographicProjection.kt
diff --git a/astronomy/src/main/java/com/vayunmathur/astronomy/domain/projection/StereographicProjection.kt b/astronomy/src/main/java/com/vayunmathur/astronomy/domain/projection/StereographicProjection.ktindex 3bb9b51f2d..1cd0e0a6e3 100644--- a/astronomy/src/main/java/com/vayunmathur/astronomy/domain/projection/StereographicProjection.kt+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/domain/projection/StereographicProjection.kt@@ -47,6 +47,7 @@ fun projectAll(viewState: ViewState, altAzList: List<AltAz>): List<Offset?> {     } } +/** Stereographic projection of the sky onto the screen for a single view state. */ class StereographicProjection(private val viewState: ViewState) : SkyProjection {     private val sinCenterAlt = sin(viewState.centerAltRad)     private val cosCenterAlt = cos(viewState.centerAltRad)
astronomy/src/main/java/com/vayunmathur/astronomy/domain/projection/ViewState.kt
diff --git a/astronomy/src/main/java/com/vayunmathur/astronomy/domain/projection/ViewState.kt b/astronomy/src/main/java/com/vayunmathur/astronomy/domain/projection/ViewState.ktindex 4c57896607..99f0a9a9b5 100644--- a/astronomy/src/main/java/com/vayunmathur/astronomy/domain/projection/ViewState.kt+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/domain/projection/ViewState.kt@@ -1,5 +1,6 @@ package com.vayunmathur.astronomy.domain.projection +/** The sky view's center direction, field of view, screen size, and rotation. */ data class ViewState(     val centerAzRad: Double,     val centerAltRad: Double,
astronomy/src/main/java/com/vayunmathur/astronomy/platform/AstronomyUiContract.kt
diff --git a/astronomy/src/main/java/com/vayunmathur/astronomy/platform/AstronomyUiContract.kt b/astronomy/src/main/java/com/vayunmathur/astronomy/platform/AstronomyUiContract.ktindex d4722e67b9..c9ac86cabc 100644--- a/astronomy/src/main/java/com/vayunmathur/astronomy/platform/AstronomyUiContract.kt+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/platform/AstronomyUiContract.kt@@ -53,6 +53,7 @@ interface SkyMapActions {     fun selectObject(id: String) {}     fun setTime(instant: Instant, live: Boolean = false) {} +    /** Holds the shared no-op [SkyMapActions] instance for previews. */     companion object {         val Noop: SkyMapActions = object : SkyMapActions {}     }@@ -66,6 +67,7 @@ interface SearchActions {     fun search(query: String): List<SearchResult> = emptyList()     fun selectObject(id: String) {} +    /** Holds the shared no-op [SearchActions] instance for previews. */     companion object {         val Noop: SearchActions = object : SearchActions {}     }@@ -101,6 +103,7 @@ interface SettingsActions {     fun setManualLocation(latDeg: Double, lonDeg: Double) {}     fun refreshLocation() {} +    /** Holds the shared no-op [SettingsActions] instance for previews. */     companion object {         val Noop: SettingsActions = object : SettingsActions {}     }
astronomy/src/main/java/com/vayunmathur/astronomy/platform/AstronomyViewModel.kt
diff --git a/astronomy/src/main/java/com/vayunmathur/astronomy/platform/AstronomyViewModel.kt b/astronomy/src/main/java/com/vayunmathur/astronomy/platform/AstronomyViewModel.ktindex f15f9245d3..f84fe19caf 100644--- a/astronomy/src/main/java/com/vayunmathur/astronomy/platform/AstronomyViewModel.kt+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/platform/AstronomyViewModel.kt@@ -35,6 +35,7 @@ import kotlin.time.Clock import kotlin.time.ExperimentalTime import kotlin.time.Instant +/** The observer's geographic position in degrees and radians, with altitude in metres. */ data class ObserverLocation(     val latRad: Double,     val lonRad: Double,@@ -43,17 +44,26 @@ data class ObserverLocation(     val altM: Double = 0.0, ) +/** How the sky-map view center is determined. */ sealed interface CenterOption {+    /** Center follows the device pointing direction. */     data object DevicePointing : CenterOption++    /** Center is fixed at an explicit azimuth and altitude. */     data class Manual(val azRad: Double, val altRad: Double) : CenterOption++    /** Center is locked to a selected object at an explicit azimuth and altitude. */     data class TargetObject(val objectId: String, val azRad: Double, val altRad: Double) : CenterOption } +/** A catalog star placed in the sky for the current time and observer. */ data class VisibleStar(     val star: com.vayunmathur.astronomy.data.model.Star,     val altAz: AltAz,     val raDec: RaDec, )++/** A planet placed in the sky for the current time and observer. */ data class VisiblePlanet(     val id: String,     val name: String,@@ -62,7 +72,10 @@ data class VisiblePlanet(     val mag: Double?,     val distanceAu: Double, )+/** The Sun placed in the sky for the current time and observer. */ data class VisibleSun(val altAz: AltAz, val raDec: RaDec, val distanceAu: Double)++/** The Moon placed in the sky, with its phase and illumination. */ data class VisibleMoon(     val altAz: AltAz,     val raDec: RaDec,@@ -70,18 +83,22 @@ data class VisibleMoon(     val illumination: Double,     val ageDays: Double, )+/** A deep-sky object placed in the sky for the current time and observer. */ data class VisibleDeepSky(     val obj: com.vayunmathur.astronomy.data.model.DeepSkyObject,     val altAz: AltAz,     val raDec: RaDec, ) +/** Whether constellation lines and artwork are hidden, lines-only, or combined. */ enum class ConstellationMode { OFF, LINES, LINES_AND_ART }  /** One anchor of a constellation figure: the image pixel and where it currently sits on the sky. */ data class VisibleArtAnchor(val srcX: Float, val srcY: Float, val altAz: AltAz)+/** A constellation figure placed in the sky via its resolved anchors. */ data class VisibleArt(val abbr: String, val image: String, val anchors: List<VisibleArtAnchor>) +/** The fully computed sky at one instant for one observer. */ @OptIn(ExperimentalTime::class) data class VisibleSky(     val stars: List<VisibleStar> = emptyList(),@@ -97,15 +114,25 @@ data class VisibleSky(     val art: List<VisibleArt> = emptyList() ) +/** A constellation's stick-figure segments as star-id polylines for drawing. */ data class ConstellationLine(val abbr: String, val name: String, val segments: List<List<Int>>)++/** One sampled point of an object's path: Julian date with horizontal and equatorial positions. */ data class TrajectoryPoint(val jd: Double, val altAz: AltAz, val raDec: RaDec)++/** One search hit: stable id, display title and subtitle, and optional equatorial position. */ data class SearchResult(val id: String, val title: String, val subtitle: String, val raDec: Pair<Double, Double>?) +/** ViewModel owning the computed sky, observer, time, and settings state for the screens. */ @OptIn(ExperimentalTime::class) class AstronomyViewModel(app: Application) : AndroidViewModel(app), SkyMapActions, SearchActions, SettingsActions {     private companion object {         const val MIN_FOV_DEG = 10f         const val MAX_FOV_DEG = 120f+        const val MIN_LAT_DEG = -90.0+        const val MAX_LAT_DEG = 90.0+        const val MIN_LON_DEG = -180.0+        const val MAX_LON_DEG = 180.0         const val TICKER_DELAY_MS = 1000L         const val LOCATION_TIMEOUT_MS = 8000L         const val TRAJECTORY_HALF_STEPS = 48@@ -166,10 +193,15 @@ class AstronomyViewModel(app: Application) : AndroidViewModel(app), SkyMapAction     // list), so it must be one of the combined flows: without it, changing     // the magnitude limit in Settings only took effect on the next     // one-second live tick, and never while time was scrubbed/paused.-    val visibleSky: StateFlow<VisibleSky> = combine(_simTime, _observer, _catalogReady, _magLimit) { time, obs, ready, _ ->-        if (!ready || obs == null) VisibleSky(observer = obs, time = time, jd = TimeEngine.instantToJulianDate(time))-        else computeVisibleSky(time, obs)-    }.flowOn(Dispatchers.Default).stateIn(viewModelScope, SharingStarted.Eagerly, VisibleSky())+    val visibleSky: StateFlow<VisibleSky> =+        combine(_simTime, _observer, _catalogReady, _magLimit) { time, obs, ready, _ ->+            if (!ready || obs == null) {+                VisibleSky(observer = obs, time = time, jd = TimeEngine.instantToJulianDate(time))+            } else {+                computeVisibleSky(time, obs)+            }+        }.flowOn(Dispatchers.Default)+            .stateIn(viewModelScope, SharingStarted.Eagerly, VisibleSky())      private var tickerJob: Job? = null     private var locationJob: Job? = null@@ -336,8 +368,12 @@ class AstronomyViewModel(app: Application) : AndroidViewModel(app), SkyMapAction         val lonDeg = snapshot.lonDeg         // Ignore an out-of-range persisted pair from an older build         // instead of resurrecting a nonsense observer every launch.-        if (latDeg != null && lonDeg != null && latDeg in -90.0..90.0 && lonDeg in -180.0..180.0) {-            _observer.value = ObserverLocation(latDeg.toRad(), lonDeg.toRad(), latDeg, lonDeg, 0.0)+        if (latDeg != null && lonDeg != null) {+            val latInRange = latDeg in MIN_LAT_DEG..MAX_LAT_DEG+            val lonInRange = lonDeg in MIN_LON_DEG..MAX_LON_DEG+            if (latInRange && lonInRange) {+                _observer.value = ObserverLocation(latDeg.toRad(), lonDeg.toRad(), latDeg, lonDeg, 0.0)+            }         }     } @@ -390,7 +426,7 @@ class AstronomyViewModel(app: Application) : AndroidViewModel(app), SkyMapAction         // Double, so e.g. latitude 999 was applied and persisted; the         // alt-az formulas then silently produced a sky for a latitude         // outside [-90, 90] (likewise longitude outside [-180, 180]).-        if (latDeg !in -90.0..90.0 || lonDeg !in -180.0..180.0) return+        if (latDeg !in MIN_LAT_DEG..MAX_LAT_DEG || lonDeg !in MIN_LON_DEG..MAX_LON_DEG) return         _observer.value = ObserverLocation(latDeg.toRad(), lonDeg.toRad(), latDeg, lonDeg)         prefs.saveDouble("astro_lat", latDeg)         prefs.saveDouble("astro_lon", lonDeg)
astronomy/src/main/java/com/vayunmathur/astronomy/platform/sensor/LocationProvider.kt
diff --git a/astronomy/src/main/java/com/vayunmathur/astronomy/platform/sensor/LocationProvider.kt b/astronomy/src/main/java/com/vayunmathur/astronomy/platform/sensor/LocationProvider.ktindex 346bc76677..b7c8e19ca0 100644--- a/astronomy/src/main/java/com/vayunmathur/astronomy/platform/sensor/LocationProvider.kt+++ b/astronomy/src/main/java/com/vayunmathur/astronomy/platform/sensor/LocationProvider.kt@@ -10,6 +10,7 @@ import androidx.core.content.ContextCompat import kotlinx.coroutines.suspendCancellableCoroutine import kotlin.coroutines.resume +/** Reads the device's last-known or freshly requested location for the observer position. */ object LocationProvider {     fun hasPermission(context: Context): Boolean {         val fine = ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION)
astronomy/src/test/java/com/vayunmathur/astronomy/platform/AstronomyViewModelTest.kt
diff --git a/astronomy/src/test/java/com/vayunmathur/astronomy/platform/AstronomyViewModelTest.kt b/astronomy/src/test/java/com/vayunmathur/astronomy/platform/AstronomyViewModelTest.ktindex c7dc04b969..972c8908fd 100644--- a/astronomy/src/test/java/com/vayunmathur/astronomy/platform/AstronomyViewModelTest.kt+++ b/astronomy/src/test/java/com/vayunmathur/astronomy/platform/AstronomyViewModelTest.kt@@ -28,7 +28,10 @@ class AstronomyViewModelTest {      private fun await(desc: String, cond: () -> Boolean) {         val deadline = System.currentTimeMillis() + 20_000-        while (System.currentTimeMillis() < deadline) { if (cond()) return; Thread.sleep(50) }+        while (System.currentTimeMillis() < deadline) {+            if (cond()) return+            Thread.sleep(50)+        }         assertTrue(cond(), "timed out: $desc")     } 
astronomy/src/test/java/com/vayunmathur/astronomy/ui/AstronomyPagesTest.kt
diff --git a/astronomy/src/test/java/com/vayunmathur/astronomy/ui/AstronomyPagesTest.kt b/astronomy/src/test/java/com/vayunmathur/astronomy/ui/AstronomyPagesTest.ktindex a0cb97ce16..0f25d5472b 100644--- a/astronomy/src/test/java/com/vayunmathur/astronomy/ui/AstronomyPagesTest.kt+++ b/astronomy/src/test/java/com/vayunmathur/astronomy/ui/AstronomyPagesTest.kt@@ -35,7 +35,10 @@ class AstronomyPagesTest {      private fun await(desc: String, cond: () -> Boolean) {         val deadline = System.currentTimeMillis() + 20_000-        while (System.currentTimeMillis() < deadline) { if (cond()) return; Thread.sleep(50) }+        while (System.currentTimeMillis() < deadline) {+            if (cond()) return+            Thread.sleep(50)+        }         assertTrue(cond(), "timed out: $desc")     }