fix expiring intervals
This commit is contained in:
parent
84cc4d0c00
commit
43e6ba43b6
3 changed files with 12 additions and 7 deletions
|
@ -15,11 +15,7 @@ import info.nightscout.androidaps.database.entities.ExtendedBolus
|
||||||
import info.nightscout.androidaps.database.entities.GlucoseValue
|
import info.nightscout.androidaps.database.entities.GlucoseValue
|
||||||
import info.nightscout.androidaps.database.entities.TemporaryBasal
|
import info.nightscout.androidaps.database.entities.TemporaryBasal
|
||||||
import info.nightscout.androidaps.database.entities.TemporaryTarget
|
import info.nightscout.androidaps.database.entities.TemporaryTarget
|
||||||
import info.nightscout.androidaps.extensions.convertedToPercent
|
import info.nightscout.androidaps.extensions.*
|
||||||
import info.nightscout.androidaps.extensions.target
|
|
||||||
import info.nightscout.androidaps.extensions.toStringFull
|
|
||||||
import info.nightscout.androidaps.extensions.toStringShort
|
|
||||||
import info.nightscout.androidaps.extensions.valueToUnits
|
|
||||||
import info.nightscout.androidaps.interfaces.*
|
import info.nightscout.androidaps.interfaces.*
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
@ -152,6 +148,7 @@ class OverviewData @Inject constructor(
|
||||||
val temporaryBasalText: String
|
val temporaryBasalText: String
|
||||||
get() =
|
get() =
|
||||||
profile?.let { profile ->
|
profile?.let { profile ->
|
||||||
|
if (temporaryBasal?.isInProgress == false) temporaryBasal = null
|
||||||
temporaryBasal?.let { "T:" + it.toStringShort() }
|
temporaryBasal?.let { "T:" + it.toStringShort() }
|
||||||
?: resourceHelper.gs(R.string.pump_basebasalrate, profile.getBasal())
|
?: resourceHelper.gs(R.string.pump_basebasalrate, profile.getBasal())
|
||||||
} ?: resourceHelper.gs(R.string.notavailable)
|
} ?: resourceHelper.gs(R.string.notavailable)
|
||||||
|
@ -191,7 +188,10 @@ class OverviewData @Inject constructor(
|
||||||
val extendedBolusText: String
|
val extendedBolusText: String
|
||||||
get() =
|
get() =
|
||||||
extendedBolus?.let { extendedBolus ->
|
extendedBolus?.let { extendedBolus ->
|
||||||
if (activePlugin.activePump.isFakingTempsByExtendedBoluses) resourceHelper.gs(R.string.pump_basebasalrate, extendedBolus.rate)
|
if (!extendedBolus.isInProgress(dateUtil)) {
|
||||||
|
this@OverviewData.extendedBolus = null
|
||||||
|
""
|
||||||
|
} else if (activePlugin.activePump.isFakingTempsByExtendedBoluses) resourceHelper.gs(R.string.pump_basebasalrate, extendedBolus.rate)
|
||||||
else ""
|
else ""
|
||||||
} ?: ""
|
} ?: ""
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange
|
||||||
import info.nightscout.androidaps.events.EventPumpStatusChanged
|
import info.nightscout.androidaps.events.EventPumpStatusChanged
|
||||||
import info.nightscout.androidaps.events.EventRefreshOverview
|
import info.nightscout.androidaps.events.EventRefreshOverview
|
||||||
import info.nightscout.androidaps.extensions.directionToIcon
|
import info.nightscout.androidaps.extensions.directionToIcon
|
||||||
|
import info.nightscout.androidaps.extensions.isInProgress
|
||||||
import info.nightscout.androidaps.extensions.toVisibility
|
import info.nightscout.androidaps.extensions.toVisibility
|
||||||
import info.nightscout.androidaps.extensions.valueToUnitsString
|
import info.nightscout.androidaps.extensions.valueToUnitsString
|
||||||
import info.nightscout.androidaps.interfaces.*
|
import info.nightscout.androidaps.interfaces.*
|
||||||
|
@ -702,6 +703,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
|
|
||||||
OverviewData.Property.TEMPORARY_TARGET -> {
|
OverviewData.Property.TEMPORARY_TARGET -> {
|
||||||
// temp target
|
// temp target
|
||||||
|
if (overviewData.temporaryTarget?.isInProgress(dateUtil) == false) overviewData.temporaryTarget = null
|
||||||
val tempTarget = overviewData.temporaryTarget
|
val tempTarget = overviewData.temporaryTarget
|
||||||
if (tempTarget != null) {
|
if (tempTarget != null) {
|
||||||
binding.loopPumpStatusLayout.tempTarget.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning))
|
binding.loopPumpStatusLayout.tempTarget.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning))
|
||||||
|
|
|
@ -2,10 +2,10 @@ package info.nightscout.androidaps.extensions
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants
|
import info.nightscout.androidaps.Constants
|
||||||
import info.nightscout.androidaps.core.R
|
import info.nightscout.androidaps.core.R
|
||||||
import info.nightscout.androidaps.interfaces.Profile
|
|
||||||
import info.nightscout.androidaps.database.entities.TemporaryTarget
|
import info.nightscout.androidaps.database.entities.TemporaryTarget
|
||||||
import info.nightscout.androidaps.database.entities.TherapyEvent
|
import info.nightscout.androidaps.database.entities.TherapyEvent
|
||||||
import info.nightscout.androidaps.interfaces.GlucoseUnit
|
import info.nightscout.androidaps.interfaces.GlucoseUnit
|
||||||
|
import info.nightscout.androidaps.interfaces.Profile
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||||
import info.nightscout.androidaps.utils.JsonHelper
|
import info.nightscout.androidaps.utils.JsonHelper
|
||||||
|
@ -14,6 +14,9 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
|
fun TemporaryTarget.isInProgress(dateUtil: DateUtil): Boolean =
|
||||||
|
dateUtil.now() in timestamp..timestamp + duration
|
||||||
|
|
||||||
fun TemporaryTarget.lowValueToUnitsToString(units: GlucoseUnit): String =
|
fun TemporaryTarget.lowValueToUnitsToString(units: GlucoseUnit): String =
|
||||||
if (units == GlucoseUnit.MGDL) DecimalFormatter.to0Decimal(this.lowTarget)
|
if (units == GlucoseUnit.MGDL) DecimalFormatter.to0Decimal(this.lowTarget)
|
||||||
else DecimalFormatter.to1Decimal(this.lowTarget * Constants.MGDL_TO_MMOLL)
|
else DecimalFormatter.to1Decimal(this.lowTarget * Constants.MGDL_TO_MMOLL)
|
||||||
|
|
Loading…
Reference in a new issue