TT,TBR Dialog -> ui
This commit is contained in:
parent
71f01a00ab
commit
db8f853805
11 changed files with 104 additions and 74 deletions
|
@ -5,8 +5,6 @@ import dagger.android.ContributesAndroidInjector
|
|||
import info.nightscout.androidaps.activities.MyPreferenceFragment
|
||||
import info.nightscout.androidaps.dialogs.LoopDialog
|
||||
import info.nightscout.androidaps.dialogs.NtpProgressDialog
|
||||
import info.nightscout.androidaps.dialogs.TempBasalDialog
|
||||
import info.nightscout.androidaps.dialogs.TempTargetDialog
|
||||
import info.nightscout.androidaps.dialogs.WizardDialog
|
||||
import info.nightscout.androidaps.plugins.aps.OpenAPSFragment
|
||||
import info.nightscout.androidaps.plugins.aps.loop.LoopFragment
|
||||
|
@ -39,8 +37,6 @@ abstract class FragmentsModule {
|
|||
|
||||
@ContributesAndroidInjector abstract fun contributesLoopDialog(): LoopDialog
|
||||
@ContributesAndroidInjector abstract fun contributesObjectivesExamDialog(): ObjectivesExamDialog
|
||||
@ContributesAndroidInjector abstract fun contributesTempBasalDialog(): TempBasalDialog
|
||||
@ContributesAndroidInjector abstract fun contributesTempTargetDialog(): TempTargetDialog
|
||||
@ContributesAndroidInjector abstract fun contributesWizardDialog(): WizardDialog
|
||||
@ContributesAndroidInjector abstract fun contributesNtpProgressDialog(): NtpProgressDialog
|
||||
@ContributesAndroidInjector abstract fun contributesPasswordCheck(): PasswordCheck
|
||||
|
|
|
@ -14,8 +14,8 @@ import info.nightscout.androidaps.R
|
|||
import info.nightscout.androidaps.activities.HistoryBrowseActivity
|
||||
import info.nightscout.androidaps.databinding.ActionsFragmentBinding
|
||||
import info.nightscout.ui.dialogs.ProfileSwitchDialog
|
||||
import info.nightscout.androidaps.dialogs.TempBasalDialog
|
||||
import info.nightscout.androidaps.dialogs.TempTargetDialog
|
||||
import info.nightscout.ui.dialogs.TempBasalDialog
|
||||
import info.nightscout.ui.dialogs.TempTargetDialog
|
||||
import info.nightscout.androidaps.extensions.toStringMedium
|
||||
import info.nightscout.androidaps.extensions.toStringShort
|
||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||
|
|
|
@ -32,7 +32,7 @@ import info.nightscout.androidaps.data.ProfileSealed
|
|||
import info.nightscout.androidaps.databinding.OverviewFragmentBinding
|
||||
import info.nightscout.androidaps.dialogs.LoopDialog
|
||||
import info.nightscout.ui.dialogs.ProfileSwitchDialog
|
||||
import info.nightscout.androidaps.dialogs.TempTargetDialog
|
||||
import info.nightscout.ui.dialogs.TempTargetDialog
|
||||
import info.nightscout.androidaps.dialogs.WizardDialog
|
||||
import info.nightscout.androidaps.events.EventEffectiveProfileSwitchChanged
|
||||
import info.nightscout.androidaps.events.EventNewBG
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
<resources>
|
||||
<string name="key_objectiveusedisconnect" translatable="false">ObjectivesDisconnectUsed</string>
|
||||
<string name="key_objectiveusereconnect" translatable="false">ObjectivesReconnectUsed</string>
|
||||
<string name="key_objectiveusetemptarget" translatable="false">ObjectivesTempTargetUsed</string>
|
||||
<string name="key_objectiveuseactions" translatable="false">ObjectivesActionsUsed</string>
|
||||
<string name="key_objectiveuseloop" translatable="false">ObjectivesLoopUsed</string>
|
||||
<string name="key_objectiveusescale" translatable="false">ObjectivesScaleUsed</string>
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
<string name="sendsmsactiondescription">Send SMS to all numbers</string>
|
||||
<string name="sendsmsactiontext">Send SMS with text</string>
|
||||
<string name="starttemptarget">Start temp target</string>
|
||||
<string name="stoptemptarget">Stop temp target</string>
|
||||
<string name="islesser">is lesser than</string>
|
||||
<string name="isequalorlesser">is equal or lesser than</string>
|
||||
<string name="isequal">is equal to</string>
|
||||
|
|
|
@ -92,6 +92,7 @@
|
|||
<string name="key_ns_receive_offline_event" translatable="false">ns_receive_offline_event</string>
|
||||
<string name="key_ns_receive_temp_target" translatable="false">ns_receive_temp_target</string>
|
||||
<string name="key_objectiveuseprofileswitch" translatable="false">ObjectivesProfileSwitchUsed</string>
|
||||
<string name="key_objectiveusetemptarget" translatable="false">ObjectivesTempTargetUsed</string>
|
||||
|
||||
<!-- General-->
|
||||
<string name="refresh">Refresh</string>
|
||||
|
@ -257,6 +258,7 @@
|
|||
<string name="upload_now">Upload now</string>
|
||||
<string name="prime_fill">Prime/Fill</string>
|
||||
<string name="overview_insulin_label">Insulin</string>
|
||||
<string name="stoptemptarget">Stop temp target</string>
|
||||
|
||||
<!-- Constraints-->
|
||||
<string name="limitingbasalratio">Limiting max basal rate to %1$.2f U/h because of %2$s</string>
|
||||
|
|
|
@ -24,6 +24,8 @@ import info.nightscout.ui.dialogs.FillDialog
|
|||
import info.nightscout.ui.dialogs.InsulinDialog
|
||||
import info.nightscout.ui.dialogs.ProfileSwitchDialog
|
||||
import info.nightscout.ui.dialogs.ProfileViewerDialog
|
||||
import info.nightscout.ui.dialogs.TempBasalDialog
|
||||
import info.nightscout.ui.dialogs.TempTargetDialog
|
||||
import info.nightscout.ui.dialogs.TreatmentDialog
|
||||
import info.nightscout.ui.dialogs.WizardInfoDialog
|
||||
|
||||
|
@ -41,6 +43,8 @@ abstract class UiModule {
|
|||
@ContributesAndroidInjector abstract fun contributesInsulinDialog(): InsulinDialog
|
||||
@ContributesAndroidInjector abstract fun contributesTreatmentDialog(): TreatmentDialog
|
||||
@ContributesAndroidInjector abstract fun contributesProfileSwitchDialog(): ProfileSwitchDialog
|
||||
@ContributesAndroidInjector abstract fun contributesTempBasalDialog(): TempBasalDialog
|
||||
@ContributesAndroidInjector abstract fun contributesTempTargetDialog(): TempTargetDialog
|
||||
|
||||
@ContributesAndroidInjector abstract fun contributesTDDStatsActivity(): TDDStatsActivity
|
||||
@ContributesAndroidInjector abstract fun contributeBolusProgressHelperActivity(): BolusProgressHelperActivity
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.dialogs
|
||||
package info.nightscout.ui.dialogs
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
|
@ -6,8 +6,7 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.google.common.base.Joiner
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.databinding.DialogTempbasalBinding
|
||||
import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
|
||||
import info.nightscout.androidaps.extensions.formatColor
|
||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||
import info.nightscout.androidaps.interfaces.CommandQueue
|
||||
|
@ -17,9 +16,7 @@ import info.nightscout.androidaps.logging.UserEntryLogger
|
|||
import info.nightscout.androidaps.utils.ToastUtils
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS
|
||||
import info.nightscout.database.entities.UserEntry.Action
|
||||
import info.nightscout.database.entities.UserEntry.Sources
|
||||
import info.nightscout.database.entities.UserEntry
|
||||
import info.nightscout.database.entities.ValueWithUnit
|
||||
import info.nightscout.interfaces.constraints.Constraint
|
||||
import info.nightscout.interfaces.pump.PumpSync
|
||||
|
@ -30,6 +27,8 @@ import info.nightscout.interfaces.utils.HtmlHelper
|
|||
import info.nightscout.rx.logging.LTag
|
||||
import info.nightscout.shared.SafeParse
|
||||
import info.nightscout.shared.interfaces.ResourceHelper
|
||||
import info.nightscout.ui.R
|
||||
import info.nightscout.ui.databinding.DialogTempbasalBinding
|
||||
import java.text.DecimalFormat
|
||||
import java.util.LinkedList
|
||||
import javax.inject.Inject
|
||||
|
@ -76,16 +75,22 @@ class TempBasalDialog : DialogFragmentWithDate() {
|
|||
val maxTempPercent = pumpDescription.maxTempPercent.toDouble()
|
||||
val tempPercentStep = pumpDescription.tempPercentStep.toDouble()
|
||||
|
||||
binding.basalPercentInput.setParams(savedInstanceState?.getDouble("basalPercentInput")
|
||||
?: 100.0, 0.0, maxTempPercent, tempPercentStep, DecimalFormat("0"), true, binding.okcancel.ok)
|
||||
binding.basalPercentInput.setParams(
|
||||
savedInstanceState?.getDouble("basalPercentInput")
|
||||
?: 100.0, 0.0, maxTempPercent, tempPercentStep, DecimalFormat("0"), true, binding.okcancel.ok
|
||||
)
|
||||
|
||||
binding.basalAbsoluteInput.setParams(savedInstanceState?.getDouble("basalAbsoluteInput")
|
||||
?: profile.getBasal(), 0.0, pumpDescription.maxTempAbsolute, pumpDescription.tempAbsoluteStep, DecimalFormat("0.00"), true, binding.okcancel.ok)
|
||||
binding.basalAbsoluteInput.setParams(
|
||||
savedInstanceState?.getDouble("basalAbsoluteInput")
|
||||
?: profile.getBasal(), 0.0, pumpDescription.maxTempAbsolute, pumpDescription.tempAbsoluteStep, DecimalFormat("0.00"), true, binding.okcancel.ok
|
||||
)
|
||||
|
||||
val tempDurationStep = pumpDescription.tempDurationStep.toDouble()
|
||||
val tempMaxDuration = pumpDescription.tempMaxDuration.toDouble()
|
||||
binding.duration.setParams(savedInstanceState?.getDouble("duration")
|
||||
?: tempDurationStep, tempDurationStep, tempMaxDuration, tempDurationStep, DecimalFormat("0"), false, binding.okcancel.ok)
|
||||
binding.duration.setParams(
|
||||
savedInstanceState?.getDouble("duration")
|
||||
?: tempDurationStep, tempDurationStep, tempMaxDuration, tempDurationStep, DecimalFormat("0"), false, binding.okcancel.ok
|
||||
)
|
||||
|
||||
isPercentPump = pumpDescription.tempBasalStyle and PumpDescription.PERCENT == PumpDescription.PERCENT
|
||||
if (isPercentPump) {
|
||||
|
@ -136,14 +141,18 @@ class TempBasalDialog : DialogFragmentWithDate() {
|
|||
}
|
||||
}
|
||||
if (isPercentPump) {
|
||||
uel.log(Action.TEMP_BASAL, Sources.TempBasalDialog,
|
||||
ValueWithUnit.Percent(percent),
|
||||
ValueWithUnit.Minute(durationInMinutes))
|
||||
uel.log(
|
||||
UserEntry.Action.TEMP_BASAL, UserEntry.Sources.TempBasalDialog,
|
||||
ValueWithUnit.Percent(percent),
|
||||
ValueWithUnit.Minute(durationInMinutes)
|
||||
)
|
||||
commandQueue.tempBasalPercent(percent, durationInMinutes, true, profile, PumpSync.TemporaryBasalType.NORMAL, callback)
|
||||
} else {
|
||||
uel.log(Action.TEMP_BASAL, Sources.TempBasalDialog,
|
||||
ValueWithUnit.Insulin(absolute),
|
||||
ValueWithUnit.Minute(durationInMinutes))
|
||||
uel.log(
|
||||
UserEntry.Action.TEMP_BASAL, UserEntry.Sources.TempBasalDialog,
|
||||
ValueWithUnit.Insulin(absolute),
|
||||
ValueWithUnit.Minute(durationInMinutes)
|
||||
)
|
||||
commandQueue.tempBasalAbsolute(absolute, durationInMinutes, true, profile, PumpSync.TemporaryBasalType.NORMAL, callback)
|
||||
}
|
||||
})
|
||||
|
@ -153,7 +162,7 @@ class TempBasalDialog : DialogFragmentWithDate() {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if(!queryingProtection) {
|
||||
if (!queryingProtection) {
|
||||
queryingProtection = true
|
||||
activity?.let { activity ->
|
||||
val cancelFail = {
|
||||
|
@ -162,7 +171,7 @@ class TempBasalDialog : DialogFragmentWithDate() {
|
|||
ToastUtils.warnToast(ctx, R.string.dialog_canceled)
|
||||
dismiss()
|
||||
}
|
||||
protectionCheck.queryProtection(activity, BOLUS, { queryingProtection = false }, cancelFail, cancelFail)
|
||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, { queryingProtection = false }, cancelFail, cancelFail)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package info.nightscout.androidaps.dialogs
|
||||
package info.nightscout.ui.dialogs
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
|
@ -8,8 +8,7 @@ import android.view.ViewGroup
|
|||
import android.widget.ArrayAdapter
|
||||
import com.google.common.base.Joiner
|
||||
import com.google.common.collect.Lists
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.databinding.DialogTemptargetBinding
|
||||
import info.nightscout.androidaps.dialogs.DialogFragmentWithDate
|
||||
import info.nightscout.androidaps.interfaces.Constraints
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||
|
@ -17,12 +16,10 @@ import info.nightscout.androidaps.utils.DefaultValueHelper
|
|||
import info.nightscout.androidaps.utils.ToastUtils
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck
|
||||
import info.nightscout.androidaps.utils.protection.ProtectionCheck.Protection.BOLUS
|
||||
import info.nightscout.core.profile.toCurrentUnitsString
|
||||
import info.nightscout.core.profile.toMgdl
|
||||
import info.nightscout.database.entities.TemporaryTarget
|
||||
import info.nightscout.database.entities.UserEntry.Action
|
||||
import info.nightscout.database.entities.UserEntry.Sources
|
||||
import info.nightscout.database.entities.UserEntry
|
||||
import info.nightscout.database.entities.ValueWithUnit
|
||||
import info.nightscout.database.impl.AppRepository
|
||||
import info.nightscout.database.impl.ValueWrapper
|
||||
|
@ -34,6 +31,8 @@ import info.nightscout.interfaces.profile.Profile
|
|||
import info.nightscout.interfaces.utils.HtmlHelper
|
||||
import info.nightscout.rx.logging.LTag
|
||||
import info.nightscout.shared.interfaces.ResourceHelper
|
||||
import info.nightscout.ui.R
|
||||
import info.nightscout.ui.databinding.DialogTemptargetBinding
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
import io.reactivex.rxjava3.kotlin.plusAssign
|
||||
import java.text.DecimalFormat
|
||||
|
@ -76,19 +75,23 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
binding.duration.setParams(savedInstanceState?.getDouble("duration")
|
||||
?: 0.0, 0.0, Constants.MAX_PROFILE_SWITCH_DURATION, 10.0, DecimalFormat("0"), false, binding.okcancel.ok)
|
||||
binding.duration.setParams(
|
||||
savedInstanceState?.getDouble("duration")
|
||||
?: 0.0, 0.0, Constants.MAX_PROFILE_SWITCH_DURATION, 10.0, DecimalFormat("0"), false, binding.okcancel.ok
|
||||
)
|
||||
|
||||
if (profileFunction.getUnits() == GlucoseUnit.MMOL)
|
||||
binding.temptarget.setParams(
|
||||
savedInstanceState?.getDouble("tempTarget")
|
||||
?: 8.0,
|
||||
Constants.MIN_TT_MMOL, Constants.MAX_TT_MMOL, 0.1, DecimalFormat("0.0"), false, binding.okcancel.ok)
|
||||
Constants.MIN_TT_MMOL, Constants.MAX_TT_MMOL, 0.1, DecimalFormat("0.0"), false, binding.okcancel.ok
|
||||
)
|
||||
else
|
||||
binding.temptarget.setParams(
|
||||
savedInstanceState?.getDouble("tempTarget")
|
||||
?: 144.0,
|
||||
Constants.MIN_TT_MGDL, Constants.MAX_TT_MGDL, 1.0, DecimalFormat("0"), false, binding.okcancel.ok)
|
||||
Constants.MIN_TT_MGDL, Constants.MAX_TT_MGDL, 1.0, DecimalFormat("0"), false, binding.okcancel.ok
|
||||
)
|
||||
|
||||
val units = profileFunction.getUnits()
|
||||
binding.units.text = if (units == GlucoseUnit.MMOL) rh.gs(R.string.mmol) else rh.gs(R.string.mgdl)
|
||||
|
@ -184,42 +187,60 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
|||
activity?.let { activity ->
|
||||
OKDialog.showConfirmation(activity, rh.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
|
||||
val units = profileFunction.getUnits()
|
||||
when(reason) {
|
||||
rh.gs(R.string.eatingsoon) -> uel.log(Action.TT, Sources.TTDialog, ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, ValueWithUnit.TherapyEventTTReason(
|
||||
TemporaryTarget.Reason.EATING_SOON), ValueWithUnit.fromGlucoseUnit(target, units.asText), ValueWithUnit.Minute(duration))
|
||||
rh.gs(R.string.activity) -> uel.log(Action.TT, Sources.TTDialog, ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, ValueWithUnit.TherapyEventTTReason(
|
||||
TemporaryTarget.Reason.ACTIVITY), ValueWithUnit.fromGlucoseUnit(target, units.asText), ValueWithUnit.Minute(duration))
|
||||
rh.gs(R.string.hypo) -> uel.log(Action.TT, Sources.TTDialog, ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, ValueWithUnit.TherapyEventTTReason(
|
||||
TemporaryTarget.Reason.HYPOGLYCEMIA), ValueWithUnit.fromGlucoseUnit(target, units.asText), ValueWithUnit.Minute(duration))
|
||||
rh.gs(R.string.manual) -> uel.log(Action.TT, Sources.TTDialog, ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, ValueWithUnit.TherapyEventTTReason(
|
||||
TemporaryTarget.Reason.CUSTOM), ValueWithUnit.fromGlucoseUnit(target, units.asText), ValueWithUnit.Minute(duration))
|
||||
rh.gs(R.string.stoptemptarget) -> uel.log(Action.CANCEL_TT, Sources.TTDialog, ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged })
|
||||
when (reason) {
|
||||
rh.gs(R.string.eatingsoon) -> uel.log(
|
||||
UserEntry.Action.TT, UserEntry.Sources.TTDialog, ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, ValueWithUnit.TherapyEventTTReason(
|
||||
TemporaryTarget.Reason.EATING_SOON
|
||||
), ValueWithUnit.fromGlucoseUnit(target, units.asText), ValueWithUnit.Minute(duration)
|
||||
)
|
||||
|
||||
rh.gs(R.string.activity) -> uel.log(
|
||||
UserEntry.Action.TT, UserEntry.Sources.TTDialog, ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, ValueWithUnit.TherapyEventTTReason(
|
||||
TemporaryTarget.Reason.ACTIVITY
|
||||
), ValueWithUnit.fromGlucoseUnit(target, units.asText), ValueWithUnit.Minute(duration)
|
||||
)
|
||||
|
||||
rh.gs(R.string.hypo) -> uel.log(
|
||||
UserEntry.Action.TT, UserEntry.Sources.TTDialog, ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, ValueWithUnit.TherapyEventTTReason(
|
||||
TemporaryTarget.Reason.HYPOGLYCEMIA
|
||||
), ValueWithUnit.fromGlucoseUnit(target, units.asText), ValueWithUnit.Minute(duration)
|
||||
)
|
||||
|
||||
rh.gs(R.string.manual) -> uel.log(
|
||||
UserEntry.Action.TT, UserEntry.Sources.TTDialog, ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, ValueWithUnit.TherapyEventTTReason(
|
||||
TemporaryTarget.Reason.CUSTOM
|
||||
), ValueWithUnit.fromGlucoseUnit(target, units.asText), ValueWithUnit.Minute(duration)
|
||||
)
|
||||
|
||||
rh.gs(R.string.stoptemptarget) -> uel.log(UserEntry.Action.CANCEL_TT, UserEntry.Sources.TTDialog, ValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged })
|
||||
}
|
||||
if (target == 0.0 || duration == 0) {
|
||||
disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(eventTime))
|
||||
.subscribe({ result ->
|
||||
result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") }
|
||||
}, {
|
||||
aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it)
|
||||
})
|
||||
result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") }
|
||||
}, {
|
||||
aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it)
|
||||
})
|
||||
} else {
|
||||
disposable += repository.runTransactionForResult(InsertAndCancelCurrentTemporaryTargetTransaction(
|
||||
timestamp = eventTime,
|
||||
duration = TimeUnit.MINUTES.toMillis(duration.toLong()),
|
||||
reason = when (reason) {
|
||||
rh.gs(R.string.eatingsoon) -> TemporaryTarget.Reason.EATING_SOON
|
||||
rh.gs(R.string.activity) -> TemporaryTarget.Reason.ACTIVITY
|
||||
rh.gs(R.string.hypo) -> TemporaryTarget.Reason.HYPOGLYCEMIA
|
||||
else -> TemporaryTarget.Reason.CUSTOM
|
||||
},
|
||||
lowTarget = Profile.toMgdl(target, profileFunction.getUnits()),
|
||||
highTarget = Profile.toMgdl(target, profileFunction.getUnits())
|
||||
)).subscribe({ result ->
|
||||
result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted temp target $it") }
|
||||
result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") }
|
||||
}, {
|
||||
aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it)
|
||||
})
|
||||
disposable += repository.runTransactionForResult(
|
||||
InsertAndCancelCurrentTemporaryTargetTransaction(
|
||||
timestamp = eventTime,
|
||||
duration = TimeUnit.MINUTES.toMillis(duration.toLong()),
|
||||
reason = when (reason) {
|
||||
rh.gs(R.string.eatingsoon) -> TemporaryTarget.Reason.EATING_SOON
|
||||
rh.gs(R.string.activity) -> TemporaryTarget.Reason.ACTIVITY
|
||||
rh.gs(R.string.hypo) -> TemporaryTarget.Reason.HYPOGLYCEMIA
|
||||
else -> TemporaryTarget.Reason.CUSTOM
|
||||
},
|
||||
lowTarget = Profile.toMgdl(target, profileFunction.getUnits()),
|
||||
highTarget = Profile.toMgdl(target, profileFunction.getUnits())
|
||||
)
|
||||
).subscribe({ result ->
|
||||
result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted temp target $it") }
|
||||
result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") }
|
||||
}, {
|
||||
aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it)
|
||||
})
|
||||
}
|
||||
|
||||
if (duration == 10) sp.putBoolean(R.string.key_objectiveusetemptarget, true)
|
||||
|
@ -230,7 +251,7 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if(!queryingProtection) {
|
||||
if (!queryingProtection) {
|
||||
queryingProtection = true
|
||||
activity?.let { activity ->
|
||||
val cancelFail = {
|
||||
|
@ -239,7 +260,7 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
|||
ToastUtils.warnToast(ctx, R.string.dialog_canceled)
|
||||
dismiss()
|
||||
}
|
||||
protectionCheck.queryProtection(activity, BOLUS, { queryingProtection = false }, cancelFail, cancelFail)
|
||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, { queryingProtection = false }, cancelFail, cancelFail)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue