From e829a6918c93d9b6a8099f7f995444774e2d78ee Mon Sep 17 00:00:00 2001 From: Philoul Date: Mon, 29 Mar 2021 22:30:44 +0200 Subject: [PATCH] Fix uel after merge --- .../androidaps/dialogs/CarbsDialog.kt | 12 ++++++------ .../androidaps/dialogs/InsulinDialog.kt | 18 ++++++++++-------- .../androidaps/dialogs/TreatmentDialog.kt | 19 ++++++++++++------- .../smsCommunicator/SmsCommunicatorPlugin.kt | 4 +--- .../fragments/TreatmentsTempTargetFragment.kt | 4 +--- .../androidaps/utils/wizard/BolusWizard.kt | 6 +++--- .../nightscout/androidaps/utils/Translator.kt | 2 +- 7 files changed, 34 insertions(+), 31 deletions(-) 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 5f2b32e336..5eab35974c 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt @@ -281,13 +281,13 @@ class CarbsDialog : DialogFragmentWithDate() { detailedBolusInfo.notes = notes detailedBolusInfo.carbsDuration = T.mins(duration.toLong()).msecs() detailedBolusInfo.carbsTimestamp = time - uel.log(if (detailedBolusInfo.carbsDuration == 0) Action.CARBS else Action.EXTENDED_CARBS, + uel.log(if (duration == 0) Action.CARBS else Action.EXTENDED_CARBS, detailedBolusInfo.notes, ValueWithUnit(Sources.CarbDialog), - ValueWithUnit(detailedBolusInfo.timestamp, Units.Timestamp), - ValueWithUnit(detailedBolusInfo.carbs, Units.G), - ValueWithUnit(detailedBolusInfo.carbTime, Units.M, detailedBolusInfo.carbTime != 0), - ValueWithUnit(detailedBolusInfo.carbsDuration, Units.H, detailedBolusInfo.carbsDuration != 0L) + 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 }) commandQueue.bolus(detailedBolusInfo, object : Callback() { @@ -295,7 +295,7 @@ class CarbsDialog : DialogFragmentWithDate() { if (!result.success) { ErrorHelperActivity.runAlarm(ctx, result.comment, resourceHelper.gs(R.string.treatmentdeliveryerror), R.raw.boluserror) } else - uel.log(Action.BOLUS, notes, ValueWithUnit(carbsAfterConstraints, Units.G)) + uel.log(Action.CARBS, notes, ValueWithUnit(carbsAfterConstraints, Units.G)) } }) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt index 4c5a708028..83fc315f45 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt @@ -210,14 +210,14 @@ class InsulinDialog : DialogFragmentWithDate() { detailedBolusInfo.context = context detailedBolusInfo.notes = notes detailedBolusInfo.timestamp = time - //uel.log(Action.BOLUS_RECORD, notes, XXXValueWithUnit.Insulin(insulinAfterConstraints), XXXValueWithUnit.Minute(timeOffset).takeIf { timeOffset!= 0 }) - uel.log(Action.BOLUS, notes, - ValueWithUnit(detailedBolusInfo.timestamp, Units.Timestamp), - , ValueWithUnit(R.string.record, Units.R_String, recordOnlyChecked), - ValueWithUnit(detailedBolusInfo.insulin, Units.U), - ValueWithUnit(timeOffset, Units.M, timeOffset != 0) - ) if (recordOnlyChecked) { + //uel.log(Action.BOLUS_RECORD, notes, XXXValueWithUnit.Insulin(insulinAfterConstraints), XXXValueWithUnit.Minute(timeOffset).takeIf { timeOffset!= 0 }) + uel.log(Action.BOLUS, notes, + ValueWithUnit(Sources.InsulinDialog), + ValueWithUnit(detailedBolusInfo.timestamp, Units.Timestamp, eventTimeChanged), + ValueWithUnit(R.string.record, Units.R_String), + ValueWithUnit(detailedBolusInfo.insulin, Units.U), + ValueWithUnit(timeOffset, Units.M, timeOffset != 0)) disposable += repository.runTransactionForResult(detailedBolusInfo.insertBolusTransaction()) .subscribe( { result -> result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted bolus $it") } }, @@ -229,7 +229,9 @@ class InsulinDialog : DialogFragmentWithDate() { if (!result.success) { ErrorHelperActivity.runAlarm(ctx, result.comment, resourceHelper.gs(R.string.treatmentdeliveryerror), info.nightscout.androidaps.dana.R.raw.boluserror) } else - uel.log(Action.BOLUS, notes, ValueWithUnit(insulinAfterConstraints, Units.U)) + uel.log(Action.BOLUS, notes, + ValueWithUnit(Sources.InsulinDialog), + ValueWithUnit(insulinAfterConstraints, Units.U)) } }) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt index e7fafc3db9..b6e056b0cb 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt @@ -144,19 +144,19 @@ class TreatmentDialog : DialogFragmentWithDate() { carbsAfterConstraints.equals(0) -> Action.BOLUS else -> Action.TREATMENT } - uel.log(action, ValueWithUnit(Sources.TreatmentDialog), ValueWithUnit(insulin, Units.U, insulin != 0.0), ValueWithUnit(carbs, Units.G, carbs != 0)) val detailedBolusInfo = DetailedBolusInfo() if (insulinAfterConstraints == 0.0) detailedBolusInfo.eventType = DetailedBolusInfo.EventType.CARBS_CORRECTION if (carbsAfterConstraints == 0) detailedBolusInfo.eventType = DetailedBolusInfo.EventType.CORRECTION_BOLUS detailedBolusInfo.insulin = insulinAfterConstraints detailedBolusInfo.carbs = carbsAfterConstraints.toDouble() detailedBolusInfo.context = context - uel.log(Action.TREATMENT, - ValueWithUnit(detailedBolusInfo.timestamp, Units.Timestamp), - ValueWithUnit(insulin, Units.U, insulin != 0.0), - ValueWithUnit(carbs, Units.G, carbs != 0) - ) if (recordOnlyChecked) { + uel.log(action, + ValueWithUnit(Sources.TreatmentDialog), + ValueWithUnit(detailedBolusInfo.timestamp, Units.Timestamp, eventTimeChanged), + ValueWithUnit(R.string.record, Units.R_String), + ValueWithUnit(insulinAfterConstraints, Units.U, insulin != 0.0), + ValueWithUnit(carbsAfterConstraints, Units.G, carbs != 0)) disposable += repository.runTransactionForResult(detailedBolusInfo.insertBolusTransaction()) .subscribe( { result -> result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted bolus $it") } }, @@ -172,7 +172,12 @@ class TreatmentDialog : DialogFragmentWithDate() { override fun run() { if (!result.success) { ErrorHelperActivity.runAlarm(ctx, result.comment, resourceHelper.gs(R.string.treatmentdeliveryerror), info.nightscout.androidaps.dana.R.raw.boluserror) - } + } else + uel.log(action, + ValueWithUnit(Sources.TreatmentDialog), + ValueWithUnit(insulin, Units.U, insulin != 0.0), + ValueWithUnit(carbs, Units.G, carbs != 0) + ) } }) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt index 8da673d6e0..2e1e305543 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt @@ -18,9 +18,7 @@ import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.database.AppRepository 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.Units -import info.nightscout.androidaps.database.entities.UserEntry.ValueWithUnit +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.database.transactions.CancelCurrentTemporaryTargetIfAnyTransaction import info.nightscout.androidaps.database.transactions.InsertTemporaryTargetAndCancelCurrentTransaction import info.nightscout.androidaps.events.EventPreferenceChange diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt index a8768fa4be..6ee6a0ab0d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt @@ -15,9 +15,7 @@ import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.ValueWrapper 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.Units -import info.nightscout.androidaps.database.entities.UserEntry.ValueWithUnit +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.database.interfaces.end import info.nightscout.androidaps.database.transactions.InvalidateTemporaryTargetTransaction import info.nightscout.androidaps.databinding.TreatmentsTemptargetFragmentBinding diff --git a/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt b/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt index 4490ada0ff..297f9682b5 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt @@ -348,7 +348,7 @@ class BolusWizard @Inject constructor( bolusCalculatorResult = createBolusCalculatorResult() notes = this@BolusWizard.notes //uel.log(Action.BOLUS_ADVISOR, notes, XXXValueWithUnit.TherapyEventType(eventType), XXXValueWithUnit.Insulin(insulinAfterConstraints)) - uel.log(Action.BOLUS_ADVISOR, notes, ValueWithUnit(Sources.WizardDialog), ValueWithUnit(eventType.toDBbEventType(), Units.TherapyEvent), ValueWithUnit(insulinAfterConstraints, Units.U)) + uel.log(Action.BOLUS_ADVISOR, notes, ValueWithUnit(Sources.WizardDialog), ValueWithUnit(eventType.toDBbEventType().text, Units.TherapyEvent), ValueWithUnit(insulinAfterConstraints, Units.U)) if (insulin > 0) { commandQueue.bolus(this, object : Callback() { override fun run() { @@ -420,8 +420,8 @@ class BolusWizard @Inject constructor( } uel.log(action, notes, ValueWithUnit(Sources.WizardDialog), - ValueWithUnit(eventType.toDBbEventType(), Units.TherapyEvent), - ValueWithUnit(insulinAfterConstraints, Units.U), + ValueWithUnit(eventType.toDBbEventType().text, Units.TherapyEvent), + ValueWithUnit(insulinAfterConstraints, Units.U, insulinAfterConstraints != 0.0), ValueWithUnit(this@BolusWizard.carbs, Units.G, this@BolusWizard.carbs != 0), ValueWithUnit(carbTime, Units.M, carbTime != 0) ) diff --git a/core/src/main/java/info/nightscout/androidaps/utils/Translator.kt b/core/src/main/java/info/nightscout/androidaps/utils/Translator.kt index 634fcf16c4..d4be0cee83 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/Translator.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/Translator.kt @@ -14,7 +14,7 @@ class Translator @Inject internal constructor( ) { @Deprecated("use type instead of string") - fun translate(text: String): String = "" + fun translate(text: String): String = text fun translate(action: Action): String = when(action) { Action.BOLUS -> resourceHelper.gs(R.string.uel_bolus)