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 6c1c220078..9f02615eb6 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt @@ -271,16 +271,12 @@ class CarbsDialog : DialogFragmentWithDate() { } if (carbsAfterConstraints > 0) { if (duration == 0) { - if (eventTimeChanged) - uel.log(Action.CARBS, notes, ValueWithUnit(eventTime, Units.Timestamp), ValueWithUnit(carbsAfterConstraints, Units.G), ValueWithUnit(timeOffset, Units.M)) - else - uel.log(Action.CARBS, notes, ValueWithUnit(carbsAfterConstraints, Units.G), ValueWithUnit(timeOffset, Units.M)) carbsGenerator.createCarb(carbsAfterConstraints, time, TherapyEvent.Type.CARBS_CORRECTION.text, notes) } else { - uel.log(Action.CARBS, notes, ValueWithUnit(carbsAfterConstraints, Units.G), ValueWithUnit(timeOffset,Units.M), ValueWithUnit(duration, Units.H)) carbsGenerator.generateCarbs(carbsAfterConstraints, time, duration, notes) nsUpload.uploadEvent(TherapyEvent.Type.NOTE.text, DateUtil.now() - 2000, resourceHelper.gs(R.string.generated_ecarbs_note, carbsAfterConstraints, duration, timeOffset)) } + uel.log(Action.CARBS, notes, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(carbsAfterConstraints, Units.G), ValueWithUnit(timeOffset, Units.M, timeOffset != 0), ValueWithUnit(duration, Units.H, duration != 0)) } if (useAlarm && carbs > 0 && timeOffset > 0) { carbTimer.scheduleReminder(dateUtil._now() + T.mins(timeOffset.toLong()).msecs()) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt index 9b7f53d5bb..89bb770d01 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt @@ -208,7 +208,7 @@ class CareDialog : DialogFragmentWithDate() { if (options == EventType.NOTE || options == EventType.EXERCISE) { actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_duration_label) + ": " + resourceHelper.gs(R.string.format_mins, binding.duration.value.toInt())) therapyEvent.duration = T.mins(binding.duration.value.toLong()).msecs() - if (!binding.duration.value.equals(0.0)) valuesWithUnit.add(ValueWithUnit(binding.duration.value.toInt(), Units.M)) + valuesWithUnit.add(ValueWithUnit(binding.duration.value.toInt(), Units.M, !binding.duration.value.equals(0.0))) } val notes = binding.notesLayout.notes.text.toString() if (notes.isNotEmpty()) { @@ -216,10 +216,7 @@ class CareDialog : DialogFragmentWithDate() { therapyEvent.note = notes } - if (eventTimeChanged) { - actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime)) - valuesWithUnit.add(0, ValueWithUnit(eventTime, Units.Timestamp)) - } + if (eventTimeChanged) actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime)) therapyEvent.enteredBy = enteredBy @@ -230,7 +227,8 @@ class CareDialog : DialogFragmentWithDate() { }, { aapsLogger.error(LTag.BGSOURCE, "Error while saving therapy event", it) }) - valuesWithUnit.add(if (eventTimeChanged) 1 else 0, ValueWithUnit(therapyEvent.type.text, Units.CPEvent)) + valuesWithUnit.add(0, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged)) + valuesWithUnit.add(1, ValueWithUnit(therapyEvent.type.text, Units.CPEvent)) uel.log(Action.CAREPORTAL, notes, valuesWithUnit) }, null) } diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt index 76aa46537f..e26c035280 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt @@ -136,7 +136,7 @@ class FillDialog : DialogFragmentWithDate() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.primefill), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { if (insulinAfterConstraints > 0) { - uel.log(Action.PRIME_BOLUS, notes, ValueWithUnit(insulinAfterConstraints, Units.U)) + uel.log(Action.PRIME_BOLUS, notes, ValueWithUnit(insulinAfterConstraints, Units.U, insulinAfterConstraints != 0.0)) requestPrimeBolus(insulinAfterConstraints, notes) } if (siteChange) { 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 0934a84ffd..1613182fce 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt @@ -211,7 +211,7 @@ class InsulinDialog : DialogFragmentWithDate() { detailedBolusInfo.source = Source.USER detailedBolusInfo.notes = notes if (recordOnlyChecked) { - uel.log(Action.BOLUS_RECORD, notes, ValueWithUnit(insulinAfterConstraints, Units.U), ValueWithUnit(timeOffset, Units.M)) + uel.log(Action.BOLUS_RECORD, notes, ValueWithUnit(insulinAfterConstraints, Units.U), ValueWithUnit(timeOffset, Units.M, timeOffset!= 0)) detailedBolusInfo.date = time activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false) } else { diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt index 1fd0c158cd..726383db1b 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt @@ -125,10 +125,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { - if (eventTimeChanged) - uel.log(Action.PROFILE_SWITCH, notes, ValueWithUnit(eventTime, Units.Timestamp), ValueWithUnit(percent, Units.Percent), ValueWithUnit(timeShift, Units.H), ValueWithUnit(duration, Units.M)) - else - uel.log(Action.PROFILE_SWITCH, notes, ValueWithUnit(percent, Units.Percent), ValueWithUnit(timeShift, Units.H), ValueWithUnit(duration, Units.M)) + uel.log(Action.PROFILE_SWITCH, notes, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(percent, Units.Percent), ValueWithUnit(timeShift, Units.H, timeShift != 0), ValueWithUnit(duration, Units.M, duration != 0)) treatmentsPlugin.doProfileSwitch(profileStore, profile, duration, percent, timeShift, eventTime) }) } diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt index 02771f9971..bb5512c1d3 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt @@ -180,22 +180,13 @@ class TempTargetDialog : DialogFragmentWithDate() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { val units = profileFunction.getUnits() - if (eventTimeChanged) - when(reason) { - resourceHelper.gs(R.string.eatingsoon) -> uel.log(Action.TT_EATING_SOON, ValueWithUnit(eventTime, Units.Timestamp), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) - resourceHelper.gs(R.string.activity) -> uel.log(Action.TT_ACTIVITY, ValueWithUnit(eventTime, Units.Timestamp), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) - resourceHelper.gs(R.string.hypo) -> uel.log(Action.TT_HYPO, ValueWithUnit(eventTime, Units.Timestamp), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) - resourceHelper.gs(R.string.manual) -> uel.log(Action.TT, ValueWithUnit(eventTime, Units.Timestamp), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) - resourceHelper.gs(R.string.stoptemptarget) -> uel.log(Action.CANCEL_TT, ValueWithUnit(eventTime, Units.Timestamp)) - } - else - when(reason) { - resourceHelper.gs(R.string.eatingsoon) -> uel.log(Action.TT_EATING_SOON, ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) - resourceHelper.gs(R.string.activity) -> uel.log(Action.TT_ACTIVITY, ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) - resourceHelper.gs(R.string.hypo) -> uel.log(Action.TT_HYPO, ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) - resourceHelper.gs(R.string.manual) -> uel.log(Action.TT, ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) - resourceHelper.gs(R.string.stoptemptarget) -> uel.log(Action.CANCEL_TT) - } + when(reason) { + resourceHelper.gs(R.string.eatingsoon) -> uel.log(Action.TT_EATING_SOON, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) + resourceHelper.gs(R.string.activity) -> uel.log(Action.TT_ACTIVITY, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) + resourceHelper.gs(R.string.hypo) -> uel.log(Action.TT_HYPO, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) + resourceHelper.gs(R.string.manual) -> uel.log(Action.TT, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) + resourceHelper.gs(R.string.stoptemptarget) -> uel.log(Action.CANCEL_TT, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged)) + } if (target == 0.0 || duration == 0) { disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(eventTime)) .subscribe({ result -> 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 55b60f15aa..5f421134a3 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt @@ -130,7 +130,7 @@ class TreatmentDialog : DialogFragmentWithDate() { if (insulinAfterConstraints > 0 || carbsAfterConstraints > 0) { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_treatment_label), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { - uel.log(Action.TREATMENT, ValueWithUnit(insulin, Units.U), ValueWithUnit(carbs, Units.G)) + uel.log(Action.TREATMENT, ValueWithUnit(insulin, Units.U, insulin != 0.0), ValueWithUnit(carbs, Units.G, carbs != 0)) val detailedBolusInfo = DetailedBolusInfo() if (insulinAfterConstraints == 0.0) detailedBolusInfo.eventType = TherapyEvent.Type.CARBS_CORRECTION.text if (carbsAfterConstraints == 0) detailedBolusInfo.eventType = TherapyEvent.Type.CORRECTION_BOLUS.text diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientFragment.java index c9046f24ba..fdb22635c7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientFragment.java @@ -125,7 +125,7 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList break; case R.id.nsclientinternal_clearqueue: OKDialog.showConfirmation(getContext(), resourceHelper.gs(R.string.nsclientinternal), resourceHelper.gs(R.string.clearqueueconfirm), () -> { - uel.log(Action.NS_QUEUE_CLEARED, new ValueWithUnit(0, Units.None)); + uel.log(Action.NS_QUEUE_CLEARED); uploadQueue.clearQueue(); updateGui(); fabricPrivacy.logCustom("NSClientClearQueue"); @@ -141,7 +141,7 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { switch (buttonView.getId()) { case R.id.nsclientinternal_paused: - uel.log(Action.NS_PAUSED, new ValueWithUnit(isChecked ? 1 : 0, Units.None)); + uel.log(isChecked ? Action.NS_PAUSED : Action.NS_RESUME); nsClientPlugin.pause(isChecked); updateGui(); fabricPrivacy.logCustom("NSClientPause"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java index 1d5ee22af4..a46da21678 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java @@ -428,12 +428,12 @@ public class NSClientPlugin extends PluginBase { // room Temporary target TemporaryTarget temporaryTarget = temporaryTargetFromNsIdForInvalidating(_id); disposable.add(repository.runTransactionForResult(new SyncTemporaryTargetTransaction(temporaryTarget)).subscribe( - result -> result.getInvalidated().forEach(record -> uel.log(Action.TT_DELETED_FROM_NS, new ValueWithUnit(record.getReason().getText(), Units.TT_Reason), new ValueWithUnit(record.getLowTarget(), Units.Mg_Dl), new ValueWithUnit(record.getHighTarget(), Units.Mg_Dl), new ValueWithUnit((int) record.getDuration()/60000, Units.M))), + result -> result.getInvalidated().forEach(record -> uel.log(Action.TT_DELETED_FROM_NS, new ValueWithUnit(record.getReason().getText(), Units.TT_Reason), new ValueWithUnit(record.getLowTarget(), Units.Mg_Dl, true), new ValueWithUnit(record.getHighTarget(), Units.Mg_Dl, record.getLowTarget() != record.getHighTarget()), new ValueWithUnit((int) record.getDuration()/60000, Units.M, record.getDuration() != 0))), error -> aapsLogger.error(LTag.DATABASE, "Error while removing temporary target", error))); // room Therapy Event TherapyEvent therapyEvent = therapyEventFromNsIdForInvalidating(_id); disposable.add(repository.runTransactionForResult(new SyncTherapyEventTransaction(therapyEvent)).subscribe( - result -> result.getInvalidated().forEach(record -> uel.log(Action.CAREPORTAL_DELETED_FROM_NS, record.getNote() , new ValueWithUnit(record.getTimestamp(), Units.Timestamp), new ValueWithUnit(record.getType().getText(), Units.CPEvent))), + result -> result.getInvalidated().forEach(record -> uel.log(Action.CAREPORTAL_DELETED_FROM_NS, record.getNote() , new ValueWithUnit(record.getTimestamp(), Units.Timestamp, true), new ValueWithUnit(record.getType().getText(), Units.CPEvent))), error -> aapsLogger.error(LTag.DATABASE, "Error while removing therapy event", error))); // new DB model EventNsTreatment evtTreatment = new EventNsTreatment(EventNsTreatment.Companion.getREMOVE(), json); @@ -463,9 +463,9 @@ public class NSClientPlugin extends PluginBase { disposable.add(repository.runTransactionForResult(new SyncTemporaryTargetTransaction(temporaryTarget)) .subscribe( result -> { - result.getInserted().forEach(record -> uel.log(Action.TT_FROM_NS, new ValueWithUnit(record.getReason().getText(), Units.TT_Reason), new ValueWithUnit(record.getLowTarget(), Units.Mg_Dl), new ValueWithUnit(record.getHighTarget(), Units.Mg_Dl), new ValueWithUnit((int) record.getDuration()/60000, Units.M))); - result.getInvalidated().forEach(record -> uel.log(Action.TT_DELETED_FROM_NS, new ValueWithUnit(record.getReason().getText(), Units.TT_Reason), new ValueWithUnit(record.getLowTarget(), Units.Mg_Dl), new ValueWithUnit(record.getHighTarget(), Units.Mg_Dl), new ValueWithUnit((int) record.getDuration()/60000, Units.M))); - result.getEnded().forEach(record -> uel.log(Action.TT_CANCELED_FROM_NS, new ValueWithUnit(record.getReason().getText(), Units.TT_Reason), new ValueWithUnit(record.getLowTarget(), Units.Mg_Dl), new ValueWithUnit(record.getHighTarget(), Units.Mg_Dl), new ValueWithUnit((int) record.getDuration()/60000, Units.M))); + result.getInserted().forEach(record -> uel.log(Action.TT_FROM_NS, new ValueWithUnit(record.getReason().getText(), Units.TT_Reason), new ValueWithUnit(record.getLowTarget(), Units.Mg_Dl, true), new ValueWithUnit(record.getHighTarget(), Units.Mg_Dl, record.getLowTarget() != record.getHighTarget()), new ValueWithUnit((int) record.getDuration()/60000, Units.M, true))); + result.getInvalidated().forEach(record -> uel.log(Action.TT_DELETED_FROM_NS, new ValueWithUnit(record.getReason().getText(), Units.TT_Reason), new ValueWithUnit(record.getLowTarget(), Units.Mg_Dl, true), new ValueWithUnit(record.getHighTarget(), Units.Mg_Dl, record.getLowTarget() != record.getHighTarget()), new ValueWithUnit((int) record.getDuration()/60000, Units.M, true))); + result.getEnded().forEach(record -> uel.log(Action.TT_CANCELED_FROM_NS, new ValueWithUnit(record.getReason().getText(), Units.TT_Reason), new ValueWithUnit(record.getLowTarget(), Units.Mg_Dl, true), new ValueWithUnit(record.getHighTarget(), Units.Mg_Dl, record.getLowTarget() != record.getHighTarget()), new ValueWithUnit((int) record.getDuration()/60000, Units.M, true))); }, error -> aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", error))); } else { @@ -493,8 +493,8 @@ public class NSClientPlugin extends PluginBase { disposable.add(repository.runTransactionForResult(new SyncTherapyEventTransaction(therapyEvent)) .subscribe( result -> { - result.getInserted().forEach(record -> uel.log(Action.CAREPORTAL_FROM_NS, record.getNote() , new ValueWithUnit(record.getTimestamp(), Units.Timestamp), new ValueWithUnit(record.getType().getText(), Units.CPEvent))); - result.getInvalidated().forEach(record -> uel.log(Action.CAREPORTAL_DELETED_FROM_NS, record.getNote() , new ValueWithUnit(record.getTimestamp(), Units.Timestamp), new ValueWithUnit(record.getType().getText(), Units.CPEvent))); + result.getInserted().forEach(record -> uel.log(Action.CAREPORTAL_FROM_NS, record.getNote() , new ValueWithUnit(record.getTimestamp(), Units.Timestamp, true), new ValueWithUnit(record.getType().getText(), Units.CPEvent))); + result.getInvalidated().forEach(record -> uel.log(Action.CAREPORTAL_DELETED_FROM_NS, record.getNote() , new ValueWithUnit(record.getTimestamp(), Units.Timestamp, true), new ValueWithUnit(record.getType().getText(), Units.CPEvent))); }, error -> aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", error))); } else { 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 d85c3e3825..be4eeb41a2 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 @@ -758,9 +758,9 @@ class SmsCommunicatorPlugin @Inject constructor( replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) if (config.APS) - uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_extendedset, 2), ValueWithUnit(aDouble, Units.U), ValueWithUnit(duration, Units.M), ValueWithUnit(R.string.loopsuspended, Units.R_String)) + uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_extendedset, 2), ValueWithUnit(aDouble ?:0.0, Units.U), ValueWithUnit(duration, Units.M), ValueWithUnit(R.string.loopsuspended, Units.R_String)) else - uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_extendedset, 2), ValueWithUnit(aDouble, Units.U), ValueWithUnit(duration, Units.M)) + uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_extendedset, 2), ValueWithUnit(aDouble ?:0.0, Units.U), ValueWithUnit(duration, Units.M)) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_extendedfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) @@ -883,12 +883,12 @@ class SmsCommunicatorPlugin @Inject constructor( var replyText = String.format(resourceHelper.gs(R.string.smscommunicator_carbsset), anInteger) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_carbsset, 1), ValueWithUnit(anInteger,Units.G)) + uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_carbsset, 1), ValueWithUnit(anInteger ?:0,Units.G)) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_carbsfailed, anInteger) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_carbsfailed, 1), ValueWithUnit(anInteger,Units.G)) + uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_carbsfailed, 1), ValueWithUnit(anInteger ?:0,Units.G)) } } }) @@ -897,7 +897,7 @@ class SmsCommunicatorPlugin @Inject constructor( var replyText = String.format(resourceHelper.gs(R.string.smscommunicator_carbsset), anInteger) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_carbsset, 1), ValueWithUnit(anInteger,Units.G)) + uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_carbsset, 1), ValueWithUnit(anInteger ?:0,Units.G)) } } }) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt index 07d2d2e600..bdf2c3308d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt @@ -175,7 +175,7 @@ class TreatmentsBolusFragment : DaggerFragment() { resourceHelper.gs(R.string.carbs) + ": " + resourceHelper.gs(R.string.format_carbs, treatment.carbs.toInt()) + "\n" + resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(treatment.date) OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable { - uel.log(Action.TREATMENT_REMOVED, ValueWithUnit(treatment.date, Units.Timestamp), ValueWithUnit(treatment.insulin, Units.U), ValueWithUnit(treatment.carbs.toInt(), Units.G)) + uel.log(Action.TREATMENT_REMOVED, ValueWithUnit(treatment.date, Units.Timestamp), ValueWithUnit(treatment.insulin, Units.U, treatment.insulin != 0.0), ValueWithUnit(treatment.carbs.toInt(), Units.G, treatment.carbs != 0.0)) if (treatment.source == Source.PUMP) { treatment.isValid = false treatmentsPlugin.service.update(treatment) 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 98c004ff8b..023c397bb1 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 @@ -194,7 +194,7 @@ class TreatmentsTempTargetFragment : DaggerFragment() { ${dateUtil.dateAndTimeString(tempTarget.timestamp)} """.trimIndent(), { _: DialogInterface?, _: Int -> - uel.log(Action.TT_REMOVED, ValueWithUnit(tempTarget.reason.text, Units.TT_Reason), ValueWithUnit(tempTarget.timestamp, Units.Timestamp), ValueWithUnit(tempTarget.lowTarget, Units.Mg_Dl), ValueWithUnit(tempTarget.highTarget, Units.Mg_Dl), ValueWithUnit(tempTarget.duration.toInt(), Units.M)) + uel.log(Action.TT_REMOVED, ValueWithUnit(tempTarget.reason.text, Units.TT_Reason), ValueWithUnit(tempTarget.timestamp, Units.Timestamp), ValueWithUnit(tempTarget.lowTarget, Units.Mg_Dl), ValueWithUnit(tempTarget.highTarget, Units.Mg_Dl, tempTarget.lowTarget != tempTarget.highTarget), ValueWithUnit(tempTarget.duration.toInt(), Units.M)) disposable += repository.runTransactionForResult(InvalidateTemporaryTargetTransaction(tempTarget.id)) .subscribe({ val id = tempTarget.interfaceIDs.nightscoutId diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsUserEntryFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsUserEntryFragment.kt index 3882473f03..7a0e7f51a7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsUserEntryFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsUserEntryFragment.kt @@ -145,9 +145,8 @@ class TreatmentsUserEntryFragment : DaggerFragment() { else -> valuesWithUnitString += if (v.iValue != 0 || v.sValue != "") { v.value().toString() + if (!v.unit.stringId().equals(0)) resourceHelper.gs(v.unit.stringId()) + separator else separator } else "" } } - if (current.values.size > 0) - holder.binding.values.visibility = View.VISIBLE - holder.binding.values.text = valuesWithUnitString.trim() + holder.binding.values.text = valuesWithUnitString.trim() + holder.binding.values.visibility = if (current.values.size > 0) View.VISIBLE else View.GONE } inner class UserEntryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { 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 d5f35ad17d..7020b854dc 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 @@ -413,7 +413,7 @@ class BolusWizard @Inject constructor( boluscalc = nsJSON() source = Source.USER notes = this@BolusWizard.notes - uel.log(Action.BOLUS_WIZARD, notes, ValueWithUnit(insulinAfterConstraints, Units.U), ValueWithUnit(this@BolusWizard.carbs, Units.G), ValueWithUnit(carbTime, Units.M)) + uel.log(Action.BOLUS_WIZARD, notes, ValueWithUnit(insulinAfterConstraints, Units.U), ValueWithUnit(this@BolusWizard.carbs, Units.G, this@BolusWizard.carbs != 0), ValueWithUnit(carbTime, Units.M, carbTime != 0)) if (insulin > 0 || pump.pumpDescription.storesCarbInfo) { commandQueue.bolus(this, object : Callback() { override fun run() { diff --git a/app/src/main/res/layout/treatments_user_entry_item.xml b/app/src/main/res/layout/treatments_user_entry_item.xml index 18e2e96e37..31e45fb1d1 100644 --- a/app/src/main/res/layout/treatments_user_entry_item.xml +++ b/app/src/main/res/layout/treatments_user_entry_item.xml @@ -54,6 +54,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingStart="20dp" + android:visibility="gone" android:textAppearance="?android:attr/textAppearanceSmall" tools:ignore="HardcodedText,RtlSymmetry" /> diff --git a/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt b/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt index 1ddbca4d7f..1c2dd7a35d 100644 --- a/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt +++ b/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt @@ -23,7 +23,7 @@ class UserEntryLogger @Inject constructor( fun log(action: Action, s: String, vararg listvalues: ValueWithUnit) { val values = mutableListOf() for (v in listvalues){ - values.add(v) + if (v.condition) values.add(v) } compositeDisposable += repository.runTransaction(UserEntryTransaction( action = action, @@ -41,7 +41,7 @@ class UserEntryLogger @Inject constructor( fun log(action: Action, vararg listvalues: ValueWithUnit) { val values = mutableListOf() for (v in listvalues){ - values.add(v) + if (v.condition) values.add(v) } compositeDisposable += repository.runTransaction(UserEntryTransaction( action = action, diff --git a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt index 83c188382d..1ab17727fe 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt @@ -66,6 +66,7 @@ fun Action.stringId(): Int { Action.TREATMENT_REMOVED -> R.string.uel_treatment_removed Action.TT_REMOVED -> R.string.uel_tt_removed Action.NS_PAUSED -> R.string.uel_ns_paused + Action.NS_RESUME -> R.string.uel_ns_resume Action.NS_QUEUE_CLEARED -> R.string.uel_ns_queue_cleared Action.NS_SETTINGS_COPIED -> R.string.uel_ns_settings_copied Action.ERROR_DIALOG_OK -> R.string.uel_error_dialog_ok diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 3a7118d561..d188aae63e 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -452,6 +452,7 @@ TREATMENT REMOVED TT REMOVED NS PAUSED + NS RESUME NS QUEUE CLEARED NS SETTINGS COPIED ERROR DIALOG OK diff --git a/database/src/main/java/info/nightscout/androidaps/database/Converters.kt b/database/src/main/java/info/nightscout/androidaps/database/Converters.kt index 7954c8eafc..622846218a 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/Converters.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/Converters.kt @@ -12,28 +12,30 @@ import org.json.JSONObject class Converters { @TypeConverter - fun fromAction(action: UserEntry.Action?) = action?.name + fun fromAction(action: Action?) = action?.name @TypeConverter - fun toAction(action: String?) = action?.let { UserEntry.Action.fromString(it) } + fun toAction(action: String?) = action?.let { Action.fromString(it) } @TypeConverter - fun fromMutableListOfValueWithUnit(values: MutableList?): String? { + fun fromMutableListOfValueWithUnit(values: MutableList?): String? { if (values == null) return null val jsonArray = JSONArray() values.forEach { - val jsonObject = JSONObject() - jsonObject.put("dValue", it.dValue).put("iValue", it.iValue).put("lValue", it.lValue).put("sValue", it.sValue).put("unit", it.unit.name) - jsonArray.put(jsonObject) + if (it.condition) { + val jsonObject = JSONObject() + jsonObject.put("dValue", it.dValue).put("iValue", it.iValue).put("lValue", it.lValue).put("sValue", it.sValue).put("unit", it.unit.name) + jsonArray.put(jsonObject) + } } return jsonArray.toString() } @TypeConverter - fun toMutableListOfValueWithUnit(jsonString: String?): MutableList? { + fun toMutableListOfValueWithUnit(jsonString: String?): MutableList? { if (jsonString == null) return null val jsonArray = JSONArray(jsonString) - val list = mutableListOf() + val list = mutableListOf() for (i in 0 until jsonArray.length()) { val jsonObject = jsonArray.getJSONObject(i) list.add(ValueWithUnit(jsonObject.getDouble("dValue"), jsonObject.getInt("iValue"), jsonObject.getLong("lValue"), jsonObject.getString("sValue"), Units.fromString(jsonObject.getString("unit")))) diff --git a/database/src/main/java/info/nightscout/androidaps/database/entities/UserEntry.kt b/database/src/main/java/info/nightscout/androidaps/database/entities/UserEntry.kt index 002b43bd8e..5635d449a6 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/entities/UserEntry.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/entities/UserEntry.kt @@ -27,7 +27,7 @@ data class UserEntry( @SerializedName("SUPERBOLUS_TBR") SUPERBOLUS_TBR (ColorGroup.InsulinTreatment), @SerializedName("CARBS") CARBS (ColorGroup.CarbTreatment), @SerializedName("EXTENDED_CARBS") EXTENDED_CARBS (ColorGroup.CarbTreatment), - @SerializedName("TEMP_BASAL") TEMP_BASAL (ColorGroup.TT), + @SerializedName("TEMP_BASAL") TEMP_BASAL (ColorGroup.InsulinTreatment), @SerializedName("TT") TT (ColorGroup.TT), @SerializedName("TT_ACTIVITY") TT_ACTIVITY (ColorGroup.TT), @SerializedName("TT_EATING_SOON") TT_EATING_SOON (ColorGroup.TT), @@ -80,6 +80,7 @@ data class UserEntry( @SerializedName("TREATMENT_REMOVED") TREATMENT_REMOVED (ColorGroup.InsulinTreatment), @SerializedName("TT_REMOVED") TT_REMOVED (ColorGroup.TT), @SerializedName("NS_PAUSED") NS_PAUSED (ColorGroup.Aaps), + @SerializedName("NS_RESUME") NS_RESUME (ColorGroup.Aaps), @SerializedName("NS_QUEUE_CLEARED") NS_QUEUE_CLEARED (ColorGroup.Aaps), @SerializedName("NS_SETTINGS_COPIED") NS_SETTINGS_COPIED (ColorGroup.Aaps), @SerializedName("ERROR_DIALOG_OK") ERROR_DIALOG_OK (ColorGroup.Aaps), @@ -125,13 +126,13 @@ data class UserEntry( fun fromString(source: String?) = values().firstOrNull { it.name == source } ?: UNKNOWN } } - data class ValueWithUnit (val dValue: Double, val iValue: Int, val lValue: Long, val sValue: String, val unit: Units) { - constructor(dvalue:Double?, unit:Units) : this(dvalue ?:0.0,0, 0, "", unit) - constructor(ivalue:Int?, unit:Units) : this(0.0, ivalue ?:0, 0, "", unit) - constructor(lvalue:Long?, unit:Units) : this(0.0,0, lvalue ?:0, "", unit) - constructor(svalue:String?, unit:Units) : this(0.0,0, 0, svalue ?:"", unit) - constructor(dvalue:Double?, unit:String) : this(dvalue ?:0.0,0, 0, "", Units.fromText(unit)) - constructor(rStringRef:Int, nbParam: Long) : this(0.0, rStringRef, nbParam, "", Units.R_String) // additionnal constructors for formated strings with additional values as parameters (define number of parameters as long + data class ValueWithUnit (val dValue: Double=0.0, val iValue: Int=0, val lValue: Long=0, val sValue: String="", val unit: Units=Units.None, val condition:Boolean=true){ + constructor(dvalue: Double, unit: Units, condition:Boolean = true) : this(dvalue, 0, 0, "", unit, condition) + constructor(ivalue: Int, unit: Units, condition:Boolean = true) : this(0.0, ivalue, 0, "", unit, condition) + constructor(lvalue: Long, unit: Units, condition:Boolean = true) : this(0.0,0, lvalue, "", unit, condition) + constructor(svalue: String, unit:Units) : this(0.0,0, 0, svalue, unit, svalue != "") + constructor(dvalue: Double, unit:String) : this(dvalue,0, 0, "", Units.fromText(unit)) + constructor(rStringRef: Int, nbParam: Long) : this(0.0, rStringRef, nbParam, "", Units.R_String, !rStringRef.equals(0)) // additionnal constructors for formated strings with additional values as parameters (define number of parameters as long fun value() : Any { if (sValue != "") return sValue