Improve readable durations in Omnipod fragment
This commit is contained in:
parent
02e818c92d
commit
8c5683faaa
2 changed files with 37 additions and 9 deletions
|
@ -358,19 +358,33 @@ class OmnipodFragment : DaggerFragment() {
|
|||
}
|
||||
|
||||
private fun readableDuration(dateTime: DateTime): String {
|
||||
val minutes = Duration(dateTime, DateTime.now()).standardMinutes
|
||||
val minutes = Duration(dateTime, DateTime.now()).standardMinutes.toInt()
|
||||
when {
|
||||
minutes == 0L -> {
|
||||
return resourceHelper.gs(R.string.omnipod_connected_now)
|
||||
minutes == 0 -> {
|
||||
return resourceHelper.gs(R.string.omnipod_moments_ago)
|
||||
}
|
||||
|
||||
minutes < 60 -> {
|
||||
return resourceHelper.gs(R.string.minago, minutes)
|
||||
return resourceHelper.gs(R.string.omnipod_time_ago, resourceHelper.gq(R.plurals.omnipod_minutes, minutes, minutes))
|
||||
}
|
||||
|
||||
minutes < 1440 -> {
|
||||
val hours = minutes / 60
|
||||
val minutesLeft = minutes % 60
|
||||
if (minutesLeft > 0)
|
||||
return resourceHelper.gs(R.string.omnipod_time_ago,
|
||||
resourceHelper.gs(R.string.omnipod_composite_time, resourceHelper.gq(R.plurals.omnipod_hours, hours, hours), resourceHelper.gq(R.plurals.omnipod_minutes, minutesLeft, minutesLeft)))
|
||||
return resourceHelper.gs(R.string.omnipod_time_ago, resourceHelper.gq(R.plurals.omnipod_hours, hours, hours))
|
||||
}
|
||||
|
||||
else -> {
|
||||
val hours = (minutes / 60).toInt()
|
||||
return resourceHelper.gs(R.string.hoursago, hours)
|
||||
val hours = minutes / 60
|
||||
val days = hours / 24
|
||||
val hoursLeft = hours % 24
|
||||
if (hoursLeft > 0)
|
||||
return resourceHelper.gs(R.string.omnipod_time_ago,
|
||||
resourceHelper.gs(R.string.omnipod_composite_time, resourceHelper.gq(R.plurals.omnipod_days, days, days), resourceHelper.gq(R.plurals.omnipod_hours, hoursLeft, hoursLeft)))
|
||||
return resourceHelper.gs(R.string.omnipod_time_ago, resourceHelper.gq(R.plurals.omnipod_days, days, days))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<string name="omnipod_config_timechange_enabled">DST/Timezone Detection Enabled</string>
|
||||
|
||||
<!-- Omnipod - Fragment -->
|
||||
<string name="omnipod_connected_now">Now</string>
|
||||
<string name="omnipod_moments_ago">Moments ago</string>
|
||||
<string name="omnipod_pod_mgmt">Pod Mgmt</string>
|
||||
<string name="omnipod_pod_status">Pod Status</string>
|
||||
<string name="omnipod_reservoir_left">%1$.2f U left</string>
|
||||
|
@ -144,5 +144,19 @@
|
|||
<string name="omnipod_cmd_basal_profile_not_set_is_same">Basal profile is the same, so it will not be set again.</string>
|
||||
<string name="omnipod_custom_action_reset_rileylink">Reset RileyLink Config</string>
|
||||
<string name="omnipod_time_or_timezone_change">Time and/or Timezone change on pump</string>
|
||||
<string name="omnipod_composite_time">%1$s and %2$s</string>
|
||||
<string name="omnipod_time_ago">%1$s ago</string>
|
||||
|
||||
<plurals name="omnipod_minutes">
|
||||
<item quantity="one">%1$d minute</item>
|
||||
<item quantity="other">%1$d minutes</item>
|
||||
</plurals>
|
||||
<plurals name="omnipod_hours">
|
||||
<item quantity="one">%1$d hour</item>
|
||||
<item quantity="other">%1$d hours</item>
|
||||
</plurals>
|
||||
<plurals name="omnipod_days">
|
||||
<item quantity="one">%1$d day</item>
|
||||
<item quantity="other">%1$d days</item>
|
||||
</plurals>
|
||||
</resources>
|
Loading…
Reference in a new issue