SMS: set TT type correctly

This commit is contained in:
Milos Kozak 2022-06-13 18:56:13 +02:00
parent 1932966a63
commit f980d2f73c

View file

@ -966,6 +966,7 @@ class SmsCommunicatorPlugin @Inject constructor(
var keyTarget = 0 var keyTarget = 0
var defaultTargetMMOL = 0.0 var defaultTargetMMOL = 0.0
var defaultTargetMGDL = 0.0 var defaultTargetMGDL = 0.0
var reason = TemporaryTarget.Reason.EATING_SOON
when { when {
isMeal -> { isMeal -> {
keyDuration = R.string.key_eatingsoon_duration keyDuration = R.string.key_eatingsoon_duration
@ -973,6 +974,7 @@ class SmsCommunicatorPlugin @Inject constructor(
keyTarget = R.string.key_eatingsoon_target keyTarget = R.string.key_eatingsoon_target
defaultTargetMMOL = Constants.defaultEatingSoonTTmmol defaultTargetMMOL = Constants.defaultEatingSoonTTmmol
defaultTargetMGDL = Constants.defaultEatingSoonTTmgdl defaultTargetMGDL = Constants.defaultEatingSoonTTmgdl
reason = TemporaryTarget.Reason.EATING_SOON
} }
isActivity -> { isActivity -> {
@ -981,6 +983,7 @@ class SmsCommunicatorPlugin @Inject constructor(
keyTarget = R.string.key_activity_target keyTarget = R.string.key_activity_target
defaultTargetMMOL = Constants.defaultActivityTTmmol defaultTargetMMOL = Constants.defaultActivityTTmmol
defaultTargetMGDL = Constants.defaultActivityTTmgdl defaultTargetMGDL = Constants.defaultActivityTTmgdl
reason = TemporaryTarget.Reason.ACTIVITY
} }
isHypo -> { isHypo -> {
@ -989,6 +992,7 @@ class SmsCommunicatorPlugin @Inject constructor(
keyTarget = R.string.key_hypo_target keyTarget = R.string.key_hypo_target
defaultTargetMMOL = Constants.defaultHypoTTmmol defaultTargetMMOL = Constants.defaultHypoTTmmol
defaultTargetMGDL = Constants.defaultHypoTTmgdl defaultTargetMGDL = Constants.defaultHypoTTmgdl
reason = TemporaryTarget.Reason.HYPOGLYCEMIA
} }
} }
var ttDuration = sp.getInt(keyDuration, defaultTargetDuration) var ttDuration = sp.getInt(keyDuration, defaultTargetDuration)
@ -999,7 +1003,7 @@ class SmsCommunicatorPlugin @Inject constructor(
disposable += repository.runTransactionForResult(InsertAndCancelCurrentTemporaryTargetTransaction( disposable += repository.runTransactionForResult(InsertAndCancelCurrentTemporaryTargetTransaction(
timestamp = dateUtil.now(), timestamp = dateUtil.now(),
duration = TimeUnit.MINUTES.toMillis(ttDuration.toLong()), duration = TimeUnit.MINUTES.toMillis(ttDuration.toLong()),
reason = TemporaryTarget.Reason.EATING_SOON, reason = reason,
lowTarget = Profile.toMgdl(tt, profileFunction.getUnits()), lowTarget = Profile.toMgdl(tt, profileFunction.getUnits()),
highTarget = Profile.toMgdl(tt, profileFunction.getUnits()) highTarget = Profile.toMgdl(tt, profileFunction.getUnits())
)).subscribe({ result -> )).subscribe({ result ->