diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt index b33a90e935..776d33fed8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt @@ -154,7 +154,7 @@ class ActionsFragment : DaggerFragment() { } } extendedBolusCancel?.setOnClickListener { - if (activePlugin.activeTreatments.isInHistoryExtendedBoluslInProgress) { + if (activePlugin.activeTreatments.isInHistoryExtendedBolusInProgress) { uel.log(Action.CANCEL_EXTENDED_BOLUS) commandQueue.cancelExtended(object : Callback() { override fun run() { 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 341422469c..367678021a 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 @@ -30,6 +30,7 @@ import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.R; import info.nightscout.androidaps.database.AppRepository; import info.nightscout.androidaps.database.entities.TemporaryTarget; +import info.nightscout.androidaps.database.entities.UserEntry.*; import info.nightscout.androidaps.database.transactions.SyncTemporaryTargetTransaction; import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.events.EventAppExit; @@ -423,7 +424,7 @@ 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("TT DELETED FROM NS", record.getReason().getText(), record.getLowTarget(), record.getHighTarget(), (int) record.getDuration(), 0)), + 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(), Units.M))), error -> aapsLogger.error(LTag.BGSOURCE, "Error while saving temporary target", error))); // new DB model EventNsTreatment evtTreatment = new EventNsTreatment(EventNsTreatment.Companion.getREMOVE(), json); @@ -453,9 +454,9 @@ public class NSClientPlugin extends PluginBase { if (temporaryTarget != null) { disposable.add(repository.runTransactionForResult(new SyncTemporaryTargetTransaction(temporaryTarget)).subscribe( result -> { - result.getInserted().forEach(record -> uel.log("TT FROM NS", record.getReason().getText(), record.getLowTarget(), record.getHighTarget(), (int) record.getDuration(), 0)); - result.getInvalidated().forEach(record -> uel.log("TT DELETED FROM NS", record.getReason().getText(), record.getLowTarget(), record.getHighTarget(), (int) record.getDuration(), 0)); - result.getEnded().forEach(record -> uel.log("TT CANCELED FROM NS", record.getReason().getText(), record.getLowTarget(), record.getHighTarget(), (int) record.getDuration(), 0)); + 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(), 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(), 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(), Units.M))); }, error -> aapsLogger.error(LTag.BGSOURCE, "Error while saving temporary target", error))); } else { 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 987e63527f..98c004ff8b 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, Units.TT_Reason), ValueWithUnit(tempTarget.date, Units.Timestamp), ValueWithUnit(tempTarget.low, Units.Mg_Dl), ValueWithUnit(tempTarget.high, Units.Mg_Dl), ValueWithUnit(tempTarget.durationInMinutes, 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), ValueWithUnit(tempTarget.duration.toInt(), Units.M)) disposable += repository.runTransactionForResult(InvalidateTemporaryTargetTransaction(tempTarget.id)) .subscribe({ val id = tempTarget.interfaceIDs.nightscoutId 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 ecc3eeaa57..a6b84bf7e7 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 @@ -1,5 +1,6 @@ package info.nightscout.androidaps.utils.extensions +import com.google.gson.annotations.SerializedName import info.nightscout.androidaps.core.R import info.nightscout.androidaps.database.entities.UserEntry @@ -98,6 +99,9 @@ fun UserEntry.Action.stringId(): Int { this == UserEntry.Action.SMS_PUMP_DISCONNECT -> R.string.uel_sms_pump_disconnect this == UserEntry.Action.SMS_SMS -> R.string.uel_sms_sms this == UserEntry.Action.SMS_TT -> R.string.uel_sms_tt + this == UserEntry.Action.TT_DELETED_FROM_NS -> R.string.uel_tt_deleted_from_ns + this == UserEntry.Action.TT_FROM_NS -> R.string.uel_tt_from_ns + this == UserEntry.Action.TT_CANCELED_FROM_NS -> R.string.uel_tt_canceleted_from_ns else -> R.string.uel_unknown } } diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 73f784408c..13081a0743 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -481,6 +481,9 @@ SMS PUMP DISCONNECT SMS SMS SMS TT + TT DELETED FROM NS + TT FROM NS + TT CANCELED FROM NS UNKNOWN Formated string 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 aa51ad55c1..73adb845d9 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 @@ -112,6 +112,9 @@ data class UserEntry( @SerializedName("SMS_PUMP_DISCONNECT") SMS_PUMP_DISCONNECT, @SerializedName("SMS_SMS") SMS_SMS, @SerializedName("SMS_TT") SMS_TT, + @SerializedName("TT_DELETED_FROM_NS") TT_DELETED_FROM_NS, + @SerializedName("TT_FROM_NS") TT_FROM_NS, + @SerializedName("TT_CANCELED_FROM_NS") TT_CANCELED_FROM_NS, @SerializedName("UNKNOWN") UNKNOWN ;