Merge pull request #786 from Philoul/New/RemoveReminder
Remove EatReminder/BolusReminder if Carbs/Insulin entered before remind
This commit is contained in:
commit
51dcfd9a29
|
@ -27,7 +27,6 @@ import info.nightscout.androidaps.interfaces.ProfileFunction
|
|||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
|
||||
import info.nightscout.androidaps.queue.Callback
|
||||
import info.nightscout.androidaps.queue.CommandQueue
|
||||
|
@ -304,6 +303,7 @@ class CarbsDialog : DialogFragmentWithDate() {
|
|||
ValueWithUnit.Hour(duration).takeIf { duration != 0 })
|
||||
commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
||||
override fun run() {
|
||||
carbTimer.removeEatReminder()
|
||||
if (!result.success) {
|
||||
ErrorHelperActivity.runAlarm(ctx, result.comment, resourceHelper.gs(R.string.treatmentdeliveryerror), R.raw.boluserror)
|
||||
} else if (sp.getBoolean(R.string.key_usebolusreminder, false) && remindBolus)
|
||||
|
|
|
@ -49,6 +49,7 @@ class InsulinDialog : DialogFragmentWithDate() {
|
|||
@Inject lateinit var ctx: Context
|
||||
@Inject lateinit var repository: AppRepository
|
||||
@Inject lateinit var config: Config
|
||||
@Inject lateinit var bolusTimer: BolusTimer
|
||||
@Inject lateinit var uel: UserEntryLogger
|
||||
|
||||
companion object {
|
||||
|
@ -217,6 +218,8 @@ class InsulinDialog : DialogFragmentWithDate() {
|
|||
{ result -> result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted bolus $it") } },
|
||||
{ aapsLogger.error(LTag.DATABASE, "Error while saving bolus", it) }
|
||||
)
|
||||
if (timeOffset == 0)
|
||||
bolusTimer.removeBolusReminder()
|
||||
} else {
|
||||
uel.log(Action.BOLUS, Sources.InsulinDialog,
|
||||
notes,
|
||||
|
@ -225,6 +228,8 @@ class InsulinDialog : DialogFragmentWithDate() {
|
|||
override fun run() {
|
||||
if (!result.success) {
|
||||
ErrorHelperActivity.runAlarm(ctx, result.comment, resourceHelper.gs(R.string.treatmentdeliveryerror), R.raw.boluserror)
|
||||
} else {
|
||||
bolusTimer.removeBolusReminder()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -33,8 +33,12 @@ class BolusTimer @Inject constructor(
|
|||
|
||||
// Bg above 70 mgdl and delta positive mgdl
|
||||
list.add(TriggerBg(injector, 70.0, GlucoseUnit.MGDL, Comparator.Compare.IS_EQUAL_OR_GREATER))
|
||||
list.add(TriggerDelta(injector, InputDelta(resourceHelper, 0.0, -360.0, 360.0, 1.0, DecimalFormat("0"), InputDelta.DeltaType.DELTA), GlucoseUnit.MGDL, Comparator.Compare
|
||||
.IS_GREATER))
|
||||
list.add(
|
||||
TriggerDelta(
|
||||
injector, InputDelta(resourceHelper, 0.0, -360.0, 360.0, 1.0, DecimalFormat("0"), InputDelta.DeltaType.DELTA), GlucoseUnit.MGDL, Comparator.Compare
|
||||
.IS_GREATER
|
||||
)
|
||||
)
|
||||
}
|
||||
actions.add(ActionAlarm(injector, resourceHelper.gs(R.string.time_to_bolus)))
|
||||
}
|
||||
|
@ -42,4 +46,10 @@ class BolusTimer @Inject constructor(
|
|||
automationPlugin.addIfNotExists(event)
|
||||
}
|
||||
|
||||
fun removeBolusReminder() {
|
||||
val event = AutomationEvent(injector).apply {
|
||||
title = resourceHelper.gs(R.string.bolusreminder)
|
||||
}
|
||||
automationPlugin.removeIfExists(event)
|
||||
}
|
||||
}
|
|
@ -60,4 +60,10 @@ class CarbTimer @Inject constructor(
|
|||
automationPlugin.addIfNotExists(event)
|
||||
}
|
||||
|
||||
fun removeEatReminder() {
|
||||
val event = AutomationEvent(injector).apply {
|
||||
title = resourceHelper.gs(R.string.bolusadvisor)
|
||||
}
|
||||
automationPlugin.removeIfExists(event)
|
||||
}
|
||||
}
|
|
@ -29,13 +29,9 @@ import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
|||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
|
||||
import info.nightscout.androidaps.queue.Callback
|
||||
import info.nightscout.androidaps.utils.CarbTimer
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.HtmlHelper
|
||||
import info.nightscout.androidaps.utils.Round
|
||||
import info.nightscout.androidaps.utils.T
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.extensions.formatColor
|
||||
import info.nightscout.androidaps.utils.*
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
|
@ -62,6 +58,7 @@ class BolusWizard @Inject constructor(
|
|||
@Inject lateinit var config: Config
|
||||
@Inject lateinit var uel: UserEntryLogger
|
||||
@Inject lateinit var carbTimer: CarbTimer
|
||||
@Inject lateinit var bolusTimer: BolusTimer
|
||||
@Inject lateinit var glucoseStatusProvider: GlucoseStatusProvider
|
||||
@Inject lateinit var repository: AppRepository
|
||||
|
||||
|
@ -322,7 +319,10 @@ class BolusWizard @Inject constructor(
|
|||
return
|
||||
}
|
||||
accepted = true
|
||||
|
||||
if (calculatedTotalInsulin > 0.0)
|
||||
bolusTimer.removeBolusReminder()
|
||||
if (carbs > 0.0)
|
||||
carbTimer.removeEatReminder()
|
||||
if (sp.getBoolean(R.string.key_usebolusadvisor, false) && Profile.toMgdl(bg, profile.units) > 180 && carbs > 0 && carbTime >= 0)
|
||||
OKDialog.showYesNoCancel(ctx, resourceHelper.gs(R.string.bolusadvisor), resourceHelper.gs(R.string.bolusadvisormessage),
|
||||
{ bolusAdvisorProcessing(ctx) },
|
||||
|
|
|
@ -267,6 +267,16 @@ class AutomationPlugin @Inject constructor(
|
|||
rxBus.send(EventAutomationDataChanged())
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun removeIfExists(event: AutomationEvent) {
|
||||
for (e in automationEvents) {
|
||||
if (event.title == e.title) {
|
||||
automationEvents.remove(e)
|
||||
rxBus.send(EventAutomationDataChanged())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun set(event: AutomationEvent, index: Int) {
|
||||
automationEvents[index] = event
|
||||
|
|
Loading…
Reference in a new issue