Skip to content

Commit

Permalink
Show sun/moon altitude in details dialog
Browse files Browse the repository at this point in the history
Closes #2289
  • Loading branch information
kylecorry31 committed Mar 23, 2024
1 parent 941b1e4 commit 001878e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class MoonListItemProducer(context: Context) : BaseAstroListItemProducer(context
// Advanced
val isSuperMoon = astronomyService.isSuperMoon(date)
val peak = times.transit?.let { astronomyService.getMoonAltitude(location, it) }
val azimuth =
if (date == LocalDate.now()) astronomyService.getMoonAzimuth(location) else null
val altitude =
if (date == LocalDate.now()) astronomyService.getMoonAltitude(location) else null

list(
2,
Expand All @@ -39,7 +43,13 @@ class MoonListItemProducer(context: Context) : BaseAstroListItemProducer(context
context.getString(R.string.moon_phase) to data(formatter.formatMoonPhase(phase.phase)),
context.getString(R.string.illumination) to percent(phase.illumination),
context.getString(R.string.astronomy_altitude_peak) to peak?.let { degrees(it) },
context.getString(R.string.supermoon) to data(formatter.formatBooleanYesNo(isSuperMoon))
context.getString(R.string.supermoon) to data(
formatter.formatBooleanYesNo(
isSuperMoon
)
),
context.getString(R.string.astronomy_altitude) to altitude?.let { degrees(it) },
context.getString(R.string.direction) to azimuth?.let { degrees(it.value) }
)

showAdvancedData(context.getString(R.string.moon), advancedData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class SunListItemProducer(context: Context) : BaseAstroListItemProducer(context)
}
val night = Duration.ofDays(1) - daylight
val season = astronomyService.getSeason(location, date)
val azimuth =
if (date == LocalDate.now()) astronomyService.getSunAzimuth(location) else null
val altitude =
if (date == LocalDate.now()) astronomyService.getSunAltitude(location) else null

list(
1,
Expand All @@ -49,8 +53,10 @@ class SunListItemProducer(context: Context) : BaseAstroListItemProducer(context)
context.getString(R.string.astronomy_altitude_peak) to peak?.let { degrees(it) },
context.getString(R.string.daylight) to duration(daylight),
context.getString(R.string.night) to duration(night),
context.getString(R.string.season) to data(formatter.formatSeason(season))
).filter { it.second != null }
context.getString(R.string.season) to data(formatter.formatSeason(season)),
context.getString(R.string.astronomy_altitude) to altitude?.let { degrees(it) },
context.getString(R.string.direction) to azimuth?.let { degrees(it.value) }
)

showAdvancedData(context.getString(R.string.sun), advancedData)
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,7 @@
<string name="obscuration">Obscuration</string>
<!-- The astronomical altitude of the sun / moon in the sky -->
<string name="astronomy_altitude_peak">Peak altitude</string>
<string name="astronomy_altitude">Altitude</string>
<string name="astronomy_direction_peak">Peak direction</string>
<string name="supermoon">Supermoon</string>
<string name="season_winter">Winter</string>
Expand Down

0 comments on commit 001878e

Please sign in to comment.