From bb147deb92905350f9de515a295e73e729e100ac Mon Sep 17 00:00:00 2001 From: Philoul Date: Thu, 1 Apr 2021 23:22:22 +0200 Subject: [PATCH] CalibrationDialog + CarbDialog --- .../androidaps/dialogs/CalibrationDialog.kt | 4 +- .../androidaps/dialogs/CarbsDialog.kt | 51 +++++++------------ 2 files changed, 20 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt index 71dd0e2fb4..9d6e05f9ee 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt @@ -12,7 +12,6 @@ import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.database.entities.XXXValueWithUnit import info.nightscout.androidaps.database.entities.UserEntry.Action import info.nightscout.androidaps.database.entities.UserEntry.Sources -import info.nightscout.androidaps.database.entities.UserEntry.ValueWithUnit import info.nightscout.androidaps.databinding.DialogCalibrationBinding import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.logging.UserEntryLogger @@ -82,8 +81,7 @@ class CalibrationDialog : DialogFragmentWithDate() { if (bg > 0) { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_calibration), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { - //uel.log(Action.CALIBRATION, XXXValueWithUnit.fromGlucoseUnit(bg, units)) - uel.log(Action.CALIBRATION, ValueWithUnit(Sources.CalibrationDialog), ValueWithUnit(bg, units)) + uel.log(Action.CALIBRATION, Sources.CalibrationDialog, XXXValueWithUnit.fromGlucoseUnit(bg, units)) xdripCalibrations.sendIntent(bg) }) } diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt index 2429714909..dac9893685 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt @@ -18,8 +18,6 @@ import info.nightscout.androidaps.database.entities.XXXValueWithUnit import info.nightscout.androidaps.database.entities.TemporaryTarget import info.nightscout.androidaps.database.entities.UserEntry.Action import info.nightscout.androidaps.database.entities.UserEntry.Sources -import info.nightscout.androidaps.database.entities.UserEntry.Units -import info.nightscout.androidaps.database.entities.UserEntry.ValueWithUnit import info.nightscout.androidaps.database.transactions.InsertTemporaryTargetAndCancelCurrentTransaction import info.nightscout.androidaps.databinding.DialogCarbsBinding import info.nightscout.androidaps.interfaces.Constraint @@ -226,12 +224,10 @@ class CarbsDialog : DialogFragmentWithDate() { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.carbs), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { when { activitySelected -> { - //uel.log(Action.TT, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.ACTIVITY), XXXValueWithUnit.fromGlucoseUnit(activityTT, units) , XXXValueWithUnit.Minute(activityTTDuration)) - uel.log(Action.TT, - ValueWithUnit(Sources.CarbDialog), - ValueWithUnit(TemporaryTarget.Reason.ACTIVITY.text, Units.TherapyEvent), - ValueWithUnit(activityTT, units) , - ValueWithUnit(activityTTDuration, Units.M)) + uel.log(Action.TT, Sources.CarbDialog, + XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.ACTIVITY), + XXXValueWithUnit.fromGlucoseUnit(activityTT, units) , + XXXValueWithUnit.Minute(activityTTDuration)) disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction( timestamp = System.currentTimeMillis(), duration = TimeUnit.MINUTES.toMillis(activityTTDuration.toLong()), @@ -247,12 +243,10 @@ class CarbsDialog : DialogFragmentWithDate() { } eatingSoonSelected -> { - //uel.log(Action.TT, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.EATING_SOON), XXXValueWithUnit.fromGlucoseUnit(eatingSoonTT, units) , XXXValueWithUnit.Minute(eatingSoonTTDuration)) - uel.log(Action.TT, - ValueWithUnit(Sources.CarbDialog), - ValueWithUnit(TemporaryTarget.Reason.EATING_SOON.text, Units.TherapyEvent), - ValueWithUnit(eatingSoonTT, units) , - ValueWithUnit(eatingSoonTTDuration, Units.M)) + uel.log(Action.TT, Sources.CarbDialog, + XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.EATING_SOON), + XXXValueWithUnit.fromGlucoseUnit(eatingSoonTT, units) , + XXXValueWithUnit.Minute(eatingSoonTTDuration)) disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction( timestamp = System.currentTimeMillis(), duration = TimeUnit.MINUTES.toMillis(eatingSoonTTDuration.toLong()), @@ -268,12 +262,10 @@ class CarbsDialog : DialogFragmentWithDate() { } hypoSelected -> { - //uel.log(Action.TT, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.HYPOGLYCEMIA), XXXValueWithUnit.fromGlucoseUnit(hypoTT, units) , XXXValueWithUnit.Minute(hypoTTDuration)) - uel.log(Action.TT, - ValueWithUnit(Sources.CarbDialog), - ValueWithUnit(TemporaryTarget.Reason.HYPOGLYCEMIA.text, Units.TherapyEvent), - ValueWithUnit(hypoTT, units) , - ValueWithUnit(hypoTTDuration, Units.M)) + uel.log(Action.TT, Sources.CarbDialog, + XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.HYPOGLYCEMIA), + XXXValueWithUnit.fromGlucoseUnit(hypoTT, units) , + XXXValueWithUnit.Minute(hypoTTDuration)) disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction( timestamp = System.currentTimeMillis(), duration = TimeUnit.MINUTES.toMillis(hypoTTDuration.toLong()), @@ -296,22 +288,17 @@ class CarbsDialog : DialogFragmentWithDate() { detailedBolusInfo.notes = notes detailedBolusInfo.carbsDuration = T.hours(duration.toLong()).msecs() detailedBolusInfo.carbsTimestamp = time - uel.log(if (duration == 0) Action.CARBS else Action.EXTENDED_CARBS, - detailedBolusInfo.notes, - ValueWithUnit(Sources.CarbDialog), - ValueWithUnit(detailedBolusInfo.timestamp, Units.Timestamp, eventTimeChanged), - ValueWithUnit(carbsAfterConstraints, Units.G), - ValueWithUnit(timeOffset, Units.M, timeOffset != 0), - ValueWithUnit(duration, Units.H, duration != 0) - ) - //uel.log(Action.CARBS, notes, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, XXXValueWithUnit.Gram(carbsAfterConstraints), XXXValueWithUnit.Minute(timeOffset).takeIf { timeOffset != 0 }, XXXValueWithUnit.Hour(duration).takeIf { duration != 0 }) + uel.log(if (duration == 0) Action.CARBS else Action.EXTENDED_CARBS, Sources.CarbDialog, + notes, + XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, + XXXValueWithUnit.Gram(carbsAfterConstraints), + XXXValueWithUnit.Minute(timeOffset).takeIf { timeOffset != 0 }, + XXXValueWithUnit.Hour(duration).takeIf { duration != 0 }) commandQueue.bolus(detailedBolusInfo, object : Callback() { override fun run() { if (!result.success) { ErrorHelperActivity.runAlarm(ctx, result.comment, resourceHelper.gs(R.string.treatmentdeliveryerror), R.raw.boluserror) - } else - uel.log(Action.CARBS, notes, ValueWithUnit(carbsAfterConstraints, Units.G)) - + } } }) }