From d3a9947cb46fa086d6c87c9e8b484ae7c9fe21ac Mon Sep 17 00:00:00 2001 From: Philoul Date: Tue, 23 Mar 2021 15:42:55 +0100 Subject: [PATCH] Integrate Source for SMS, NS and Bolus Record (Simplify list of actions) --- .../androidaps/dialogs/InsulinDialog.kt | 2 +- .../plugins/general/food/FoodFragment.kt | 3 +- .../nsclient/NSClientAddUpdateWorker.kt | 14 ++--- .../general/nsclient/NSClientRemoveWorker.kt | 16 ++--- .../smsCommunicator/SmsCommunicatorPlugin.kt | 58 +++++++++---------- app/src/main/res/values/strings.xml | 2 - .../maintenance/formats/ClassicPrefsFormat.kt | 1 + .../nightscout/androidaps/utils/Translator.kt | 29 ++++------ core/src/main/res/values/strings.xml | 23 ++------ .../androidaps/database/entities/UserEntry.kt | 23 +------- 10 files changed, 65 insertions(+), 106 deletions(-) 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 da3347485a..b53375c916 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, timeOffset!= 0)) + uel.log(Action.BOLUS, notes, ValueWithUnit(Sources.Record), 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/plugins/general/food/FoodFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodFragment.kt index ceb0855819..fcd6e87b0c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodFragment.kt @@ -16,6 +16,7 @@ import dagger.android.support.DaggerFragment import info.nightscout.androidaps.R import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.entities.Food +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.database.entities.UserEntry.Action import info.nightscout.androidaps.database.transactions.InvalidateFoodTransaction import info.nightscout.androidaps.databinding.FoodFragmentBinding @@ -76,7 +77,7 @@ class FoodFragment : DaggerFragment() { binding.refreshFromNightscout.setOnClickListener { context?.let { context -> OKDialog.showConfirmation(context, resourceHelper.gs(R.string.refresheventsfromnightscout) + " ?", { - uel.log(Action.FOOD_FROM_NS) + uel.log(Action.FOOD, UserEntry.ValueWithUnit(UserEntry.Sources.NS)) disposable += Completable.fromAction { repository.deleteAllFoods() } .subscribeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.main) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt index 868993ddc8..197e015db9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt @@ -86,7 +86,7 @@ class NSClientAddUpdateWorker( .blockingGet() .also { result -> result.inserted.forEach { - uel.log(UserEntry.Action.TT_FROM_NS, + uel.log(UserEntry.Action.TT, ValueWithUnit(UserEntry.Sources.NS), ValueWithUnit(it.reason.text, UserEntry.Units.TherapyEvent), ValueWithUnit(it.lowTarget, UserEntry.Units.Mg_Dl, true), ValueWithUnit(it.highTarget, UserEntry.Units.Mg_Dl, it.lowTarget != it.highTarget), @@ -94,7 +94,7 @@ class NSClientAddUpdateWorker( ) } result.invalidated.forEach { - uel.log(UserEntry.Action.TT_DELETED_FROM_NS, + uel.log(UserEntry.Action.TT_REMOVED, ValueWithUnit(UserEntry.Sources.NS), ValueWithUnit(it.reason.text, UserEntry.Units.TherapyEvent), ValueWithUnit(it.lowTarget, UserEntry.Units.Mg_Dl, true), ValueWithUnit(it.highTarget, UserEntry.Units.Mg_Dl, it.lowTarget != it.highTarget), @@ -102,7 +102,7 @@ class NSClientAddUpdateWorker( ) } result.ended.forEach { - uel.log(UserEntry.Action.TT_CANCELED_FROM_NS, + uel.log(UserEntry.Action.CANCEL_TT, ValueWithUnit(UserEntry.Sources.NS), ValueWithUnit(it.reason.text, UserEntry.Units.TherapyEvent), ValueWithUnit(it.lowTarget, UserEntry.Units.Mg_Dl, true), ValueWithUnit(it.highTarget, UserEntry.Units.Mg_Dl, it.lowTarget != it.highTarget), @@ -131,15 +131,15 @@ class NSClientAddUpdateWorker( .blockingGet() .also { result -> result.inserted.forEach { - uel.log(UserEntry.Action.CAREPORTAL_FROM_NS, - it.note ?: "", + uel.log(UserEntry.Action.CAREPORTAL, + it.note ?: "", ValueWithUnit(UserEntry.Sources.NS), ValueWithUnit(it.timestamp, UserEntry.Units.Timestamp, true), ValueWithUnit(it.type.text, UserEntry.Units.TherapyEvent) ) } result.invalidated.forEach { - uel.log(UserEntry.Action.CAREPORTAL_DELETED_FROM_NS, - it.note ?: "", + uel.log(UserEntry.Action.CAREPORTAL_REMOVED, + it.note ?: "", ValueWithUnit(UserEntry.Sources.NS), ValueWithUnit(it.timestamp, UserEntry.Units.Timestamp, true), ValueWithUnit(it.type.text, UserEntry.Units.TherapyEvent) ) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientRemoveWorker.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientRemoveWorker.kt index a80c71c803..3bc04267a6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientRemoveWorker.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientRemoveWorker.kt @@ -7,7 +7,7 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.entities.UserEntry -import info.nightscout.androidaps.database.entities.UserEntry.ValueWithUnit +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.database.transactions.SyncTemporaryTargetTransaction import info.nightscout.androidaps.database.transactions.SyncTherapyEventTransaction import info.nightscout.androidaps.events.EventNsTreatment @@ -68,10 +68,10 @@ class NSClientRemoveWorker( .also { result -> result.invalidated.forEach { uel.log( - UserEntry.Action.TT_DELETED_FROM_NS, - ValueWithUnit(it.reason.text, UserEntry.Units.TherapyEvent), - ValueWithUnit(it.lowTarget, UserEntry.Units.Mg_Dl, true), - ValueWithUnit(it.highTarget, UserEntry.Units.Mg_Dl, it.lowTarget != it.highTarget), + Action.TT_REMOVED, ValueWithUnit(Sources.NS), + ValueWithUnit(it.reason.text, Units.TherapyEvent), + ValueWithUnit(it.lowTarget, Units.Mg_Dl, true), + ValueWithUnit(it.highTarget, Units.Mg_Dl, it.lowTarget != it.highTarget), ValueWithUnit(it.duration.toInt() / 60000, UserEntry.Units.M, it.duration != 0L) ) } @@ -88,9 +88,9 @@ class NSClientRemoveWorker( .also { result -> result.invalidated.forEach { uel.log( - UserEntry.Action.CAREPORTAL_DELETED_FROM_NS, (it.note ?: ""), - ValueWithUnit(it.timestamp, UserEntry.Units.Timestamp, true), - ValueWithUnit(it.type.text, UserEntry.Units.TherapyEvent)) + Action.CAREPORTAL_REMOVED, (it.note ?: ""), ValueWithUnit(Sources.NS), + ValueWithUnit(it.timestamp, Units.Timestamp, true), + ValueWithUnit(it.type.text, Units.TherapyEvent)) } } 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 e8e490bcf5..94bbb41f5e 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 @@ -348,7 +348,7 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - uel.log(Action.SMS_LOOP_DISABLED) + uel.log(Action.LOOP_DISABLED, ValueWithUnit(Sources.SMS)) loopPlugin.setPluginEnabled(PluginType.LOOP, false) commandQueue.cancelTempBasal(true, object : Callback() { override fun run() { @@ -372,7 +372,7 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - uel.log(Action.SMS_LOOP_ENABLED) + uel.log(Action.LOOP_ENABLED, ValueWithUnit(Sources.SMS)) loopPlugin.setPluginEnabled(PluginType.LOOP, true) sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_loophasbeenenabled))) rxBus.send(EventRefreshOverview("SMS_LOOP_START")) @@ -399,7 +399,7 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - uel.log(Action.SMS_LOOP_RESUME) + uel.log(Action.RESUME, ValueWithUnit(Sources.SMS)) loopPlugin.suspendTo(0L) rxBus.send(EventRefreshOverview("SMS_LOOP_RESUME")) commandQueue.cancelTempBasal(true, object : Callback() { @@ -432,7 +432,7 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(duration) { override fun run() { - uel.log(Action.SMS_LOOP_SUSPEND) + uel.log(Action.SUSPEND, ValueWithUnit(Sources.SMS)) commandQueue.cancelTempBasal(true, object : Callback() { override fun run() { if (result.success) { @@ -516,7 +516,7 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - uel.log(Action.SMS_PUMP_CONNECT) + uel.log(Action.RECONNECT, ValueWithUnit(Sources.SMS)) commandQueue.cancelTempBasal(true, object : Callback() { override fun run() { if (!result.success) { @@ -545,7 +545,7 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - uel.log(Action.SMS_PUMP_DISCONNECT) + uel.log(Action.DISCONNECT, ValueWithUnit(Sources.SMS)) val profile = profileFunction.getProfile() loopPlugin.disconnectPump(duration, profile) rxBus.send(EventRefreshOverview("SMS_PUMP_DISCONNECT")) @@ -602,7 +602,7 @@ class SmsCommunicatorPlugin @Inject constructor( activePlugin.activeTreatments.doProfileSwitch(store, list[pIndex - 1] as String, 0, finalPercentage, 0, DateUtil.now()) val replyText = resourceHelper.gs(R.string.profileswitchcreated) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log(Action.SMS_PROFILE, ValueWithUnit(R.string.profileswitchcreated, Units.R_String)) + uel.log(Action.PROFILE_SWITCH, ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.profileswitchcreated, Units.R_String)) } }) } @@ -624,12 +624,12 @@ class SmsCommunicatorPlugin @Inject constructor( var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalcanceled) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalcanceled, Units.R_String)) + uel.log(Action.TEMP_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_tempbasalcanceled, Units.R_String)) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalcancelfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalcancelfailed, Units.R_String)) + uel.log(Action.TEMP_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_tempbasalcancelfailed, Units.R_String)) } } }) @@ -658,14 +658,14 @@ class SmsCommunicatorPlugin @Inject constructor( replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) if (result.isPercent) - uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalset_percent, 2), ValueWithUnit(result.percent, Units.Percent), ValueWithUnit(result.duration, Units.M)) + uel.log(Action.TEMP_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_tempbasalset_percent, 2), ValueWithUnit(result.percent, Units.Percent), ValueWithUnit(result.duration, Units.M)) else - uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalset, 2), ValueWithUnit(result.absolute, Units.U_H), ValueWithUnit(result.duration, Units.M)) + uel.log(Action.TEMP_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_tempbasalset, 2), ValueWithUnit(result.absolute, Units.U_H), ValueWithUnit(result.duration, Units.M)) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalfailed, Units.R_String)) + uel.log(Action.TEMP_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_tempbasalfailed, Units.R_String)) } } }) @@ -696,14 +696,14 @@ class SmsCommunicatorPlugin @Inject constructor( replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) if (result.isPercent) - uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalset_percent, 2), ValueWithUnit(result.percent, Units.Percent), ValueWithUnit(result.duration, Units.M)) + uel.log(Action.TEMP_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_tempbasalset_percent, 2), ValueWithUnit(result.percent, Units.Percent), ValueWithUnit(result.duration, Units.M)) else - uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalset, 2), ValueWithUnit(result.absolute, Units.U_H), ValueWithUnit(result.duration, Units.M)) + uel.log(Action.TEMP_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_tempbasalset, 2), ValueWithUnit(result.absolute, Units.U_H), ValueWithUnit(result.duration, Units.M)) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalfailed, Units.R_String)) + uel.log(Action.TEMP_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_tempbasalfailed, Units.R_String)) } } }) @@ -730,7 +730,7 @@ class SmsCommunicatorPlugin @Inject constructor( var replyText = resourceHelper.gs(R.string.smscommunicator_extendedcancelfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_extendedcanceled, Units.R_String)) + uel.log(Action.EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_extendedcanceled, Units.R_String)) } } }) @@ -757,16 +757,16 @@ 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 + uel.log(Action.EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), 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 + uel.log(Action.EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), 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) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_extendedfailed, Units.R_String)) + uel.log(Action.EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_extendedfailed, Units.R_String)) } } }) @@ -839,12 +839,12 @@ class SmsCommunicatorPlugin @Inject constructor( } } sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log(Action.SMS_BOLUS, replyText) + uel.log(Action.BOLUS, replyText, ValueWithUnit(Sources.SMS)) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_bolusfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log(Action.SMS_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_bolusfailed, Units.R_String)) + uel.log(Action.BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_bolusfailed, Units.R_String)) } } }) @@ -884,13 +884,13 @@ 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 + uel.log(Action.CARBS, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), 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 + uel.log(Action.CARBS, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_carbsfailed, 1), ValueWithUnit(anInteger ?: 0, Units.G)) } } @@ -900,7 +900,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 + uel.log(Action.CARBS, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_carbsset, 1), ValueWithUnit(anInteger ?: 0, Units.G)) } } @@ -971,7 +971,7 @@ class SmsCommunicatorPlugin @Inject constructor( val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_tt_set), ttString, ttDuration) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) //uel.log(Action.SMS_TT, ValueWithUnit(R.string.smscommunicator_tt_set, 2), ValueWithUnit(tt, units), ValueWithUnit(ttDuration, Units.M)) - uel.log(Action.SMS_TT, ValueWithUnit(tt, units), ValueWithUnit(ttDuration, Units.M)) + uel.log(Action.TT, ValueWithUnit(Sources.SMS), ValueWithUnit(tt, units), ValueWithUnit(ttDuration, Units.M)) } }) } else if (isStop) { @@ -988,7 +988,7 @@ class SmsCommunicatorPlugin @Inject constructor( }) val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_tt_canceled)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log(Action.SMS_TT, ValueWithUnit(R.string.smscommunicator_tt_canceled, Units.R_String)) + uel.log(Action.CANCEL_TT, ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_tt_canceled, Units.R_String)) } }) } else @@ -1007,7 +1007,7 @@ class SmsCommunicatorPlugin @Inject constructor( sp.putBoolean(R.string.key_smscommunicator_remotecommandsallowed, false) val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_stoppedsms)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log(Action.SMS_SMS, ValueWithUnit(R.string.smscommunicator_stoppedsms, Units.R_String)) + uel.log(Action.SMS_SMS, ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_stoppedsms, Units.R_String)) } }) } else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat))) @@ -1026,9 +1026,9 @@ class SmsCommunicatorPlugin @Inject constructor( if (result) resourceHelper.gs(R.string.smscommunicator_calibrationsent) else resourceHelper.gs(R.string.smscommunicator_calibrationfailed) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) if (result) - uel.log(Action.SMS_CAL, ValueWithUnit(R.string.smscommunicator_calibrationsent, Units.R_String)) + uel.log(Action.CALIBRATION, ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_calibrationsent, Units.R_String)) else - uel.log(Action.SMS_CAL, ValueWithUnit(R.string.smscommunicator_calibrationfailed, Units.R_String)) + uel.log(Action.CALIBRATION, ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_calibrationfailed, Units.R_String)) } }) } else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat))) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 52a1be72c3..8dfbcdc78a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -131,7 +131,6 @@ Which constraints are applied? Constraints - Loop Loop Use this to activate AndroidAPS\' loop integration. APS @@ -511,7 +510,6 @@ Amount of hours in the past for sensitivity detection (carbs absorption time is excluded) openapsama_autosens_period nsclient_localbroadcasts - Pump OpenAPS Uploader Sensitivity detection diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/formats/ClassicPrefsFormat.kt b/core/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/formats/ClassicPrefsFormat.kt index d5088372df..ea412fce2f 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/formats/ClassicPrefsFormat.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/formats/ClassicPrefsFormat.kt @@ -124,6 +124,7 @@ class ClassicPrefsFormat @Inject constructor( when (v.unit) { Units.Timestamp -> timestamp = dateUtil.dateAndTimeAndSecondsString(v.lValue) Units.TherapyEvent -> therapyEvent = if (therapyEvent == "") translator.translate(v.sValue) else therapyEvent + " / " + translator.translate(v.sValue) + Units.Source -> source = csvString(translator.translate(v.sValue)) Units.R_String -> if (v.iValue != 0) { //Formated string lValue is the number of parameters, up to 3 var rStringParam = v.lValue.toInt() var tempString = "" 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 02aaecbbf3..d9768e7452 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/Translator.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/Translator.kt @@ -53,7 +53,6 @@ class Translator @Inject internal constructor( Action.BOLUS.name -> resourceHelper.gs(R.string.uel_bolus) Action.BOLUS_ADVISOR.name -> resourceHelper.gs(R.string.uel_bolus_advisor) - Action.BOLUS_RECORD.name -> resourceHelper.gs(R.string.uel_bolus_record) Action.EXTENDED_BOLUS.name -> resourceHelper.gs(R.string.uel_extended_bolus) Action.SUPERBOLUS_TBR.name -> resourceHelper.gs(R.string.uel_superbolus_tbr) Action.CARBS.name -> resourceHelper.gs(R.string.uel_carbs) @@ -118,25 +117,7 @@ class Translator @Inject internal constructor( Action.IMPORT_DATABASES.name -> resourceHelper.gs(R.string.uel_import_databases) Action.OTP_EXPORT.name -> resourceHelper.gs(R.string.uel_otp_export) Action.OTP_RESET.name -> resourceHelper.gs(R.string.uel_otp_reset) - Action.SMS_BASAL.name -> resourceHelper.gs(R.string.uel_sms_basal) - Action.SMS_BOLUS.name -> resourceHelper.gs(R.string.uel_sms_bolus) - Action.SMS_CAL.name -> resourceHelper.gs(R.string.uel_sms_cal) - Action.SMS_CARBS.name -> resourceHelper.gs(R.string.uel_sms_carbs) - Action.SMS_EXTENDED_BOLUS.name -> resourceHelper.gs(R.string.uel_sms_extended_bolus) - Action.SMS_LOOP_DISABLED.name -> resourceHelper.gs(R.string.uel_sms_loop_disabled) - Action.SMS_LOOP_ENABLED.name -> resourceHelper.gs(R.string.uel_sms_loop_enabled) - Action.SMS_LOOP_RESUME.name -> resourceHelper.gs(R.string.uel_sms_loop_resume) - Action.SMS_LOOP_SUSPEND.name -> resourceHelper.gs(R.string.uel_sms_loop_suspend) - Action.SMS_PROFILE.name -> resourceHelper.gs(R.string.uel_sms_profile) - Action.SMS_PUMP_CONNECT.name -> resourceHelper.gs(R.string.uel_sms_pump_connect) - Action.SMS_PUMP_DISCONNECT.name -> resourceHelper.gs(R.string.uel_sms_pump_disconnect) Action.SMS_SMS.name -> resourceHelper.gs(R.string.uel_sms_sms) - Action.SMS_TT.name -> resourceHelper.gs(R.string.uel_sms_tt) - Action.TT_DELETED_FROM_NS.name -> resourceHelper.gs(R.string.uel_tt_deleted_from_ns) - Action.TT_FROM_NS.name -> resourceHelper.gs(R.string.uel_tt_from_ns) - Action.TT_CANCELED_FROM_NS.name -> resourceHelper.gs(R.string.uel_tt_canceleted_from_ns) - Action.CAREPORTAL_DELETED_FROM_NS.name -> resourceHelper.gs(R.string.uel_careportal_deleted_from_ns) - Action.CAREPORTAL_FROM_NS.name -> resourceHelper.gs(R.string.uel_careportal_from_ns) Action.EXPORT_CSV.name -> resourceHelper.gs(R.string.uel_export_csv) Units.Mg_Dl.name -> resourceHelper.gs(R.string.mgdl) @@ -149,6 +130,16 @@ class Translator @Inject internal constructor( Units.Percent.name -> resourceHelper.gs(R.string.shortpercent) Units.None.name -> "" + Sources.Manual.text -> resourceHelper.gs(R.string.manual) + Sources.Record.text -> resourceHelper.gs(R.string.record) + Sources.Automation.text -> resourceHelper.gs(R.string.automation) + Sources.Loop.text -> resourceHelper.gs(R.string.loop) + Sources.NS.text -> resourceHelper.gs(R.string.ns) + Sources.Pump.text -> resourceHelper.gs(R.string.pump) + Sources.SMS.text -> resourceHelper.gs(R.string.smb_shortname) + Sources.Wear.text -> resourceHelper.gs(R.string.wear) + Sources.Unknown.text -> resourceHelper.gs(R.string.unknown) + else -> resourceHelper.gs(R.string.unknown) } } \ No newline at end of file diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 1fc0113c7c..73beededf4 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -276,6 +276,10 @@ Wear Automation Custom + Pump + Loop + NS + Record Connection timed out @@ -401,7 +405,6 @@ BOLUS BOLUS ADVISOR - BOLUS RECORD EXTENDED BOLUS SUPERBOLUS TBR CARBS @@ -466,25 +469,7 @@ IMPORT DATABASES OTP EXPORT OTP RESET - SMS BASAL - SMS BOLUS - SMS CAL - SMS CARBS - SMS EXTENDED BOLUS - SMS LOOP DISABLED - SMS LOOP ENABLED - SMS LOOP RESUME - SMS LOOP SUSPEND - SMS PROFILE - SMS PUMP CONNECT - SMS PUMP DISCONNECT SMS SMS - SMS TT - TT DELETED FROM NS - CAREPORTAL DELETED FROM NS - CAREPORTAL FROM NS - TT FROM NS - TT CANCELED FROM NS EXPORT USER ENTRIES 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 a93401b7ba..ef46c63bd0 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 @@ -86,26 +86,8 @@ data class UserEntry( @SerializedName("IMPORT_DATABASES") IMPORT_DATABASES (ColorGroup.Aaps), @SerializedName("OTP_EXPORT") OTP_EXPORT (ColorGroup.Aaps), @SerializedName("OTP_RESET") OTP_RESET (ColorGroup.Aaps), - @SerializedName("SMS_BASAL") SMS_BASAL (ColorGroup.InsulinTreatment), - @SerializedName("SMS_BOLUS") SMS_BOLUS (ColorGroup.InsulinTreatment), - @SerializedName("SMS_CAL") SMS_CAL (ColorGroup.Careportal), - @SerializedName("SMS_CARBS") SMS_CARBS (ColorGroup.CarbTreatment), - @SerializedName("SMS_EXTENDED_BOLUS") SMS_EXTENDED_BOLUS (ColorGroup.InsulinTreatment), - @SerializedName("SMS_LOOP_DISABLED") SMS_LOOP_DISABLED (ColorGroup.Loop), - @SerializedName("SMS_LOOP_ENABLED") SMS_LOOP_ENABLED (ColorGroup.Loop), - @SerializedName("SMS_LOOP_RESUME") SMS_LOOP_RESUME (ColorGroup.Loop), - @SerializedName("SMS_LOOP_SUSPEND") SMS_LOOP_SUSPEND (ColorGroup.Loop), - @SerializedName("SMS_PROFILE") SMS_PROFILE (ColorGroup.Profile), - @SerializedName("SMS_PUMP_CONNECT") SMS_PUMP_CONNECT (ColorGroup.Pump), - @SerializedName("SMS_PUMP_DISCONNECT") SMS_PUMP_DISCONNECT (ColorGroup.Pump), @SerializedName("SMS_SMS") SMS_SMS (ColorGroup.Aaps), - @SerializedName("SMS_TT") SMS_TT (ColorGroup.TT), - @SerializedName("TT_DELETED_FROM_NS") TT_DELETED_FROM_NS (ColorGroup.TT), - @SerializedName("CAREPORTAL_DELETED_FROM_NS") CAREPORTAL_DELETED_FROM_NS (ColorGroup.Careportal), - @SerializedName("CAREPORTAL_FROM_NS") CAREPORTAL_FROM_NS (ColorGroup.Careportal), - @SerializedName("FOOD_FROM_NS") FOOD_FROM_NS (ColorGroup.Careportal), - @SerializedName("TT_FROM_NS") TT_FROM_NS (ColorGroup.TT), - @SerializedName("TT_CANCELED_FROM_NS") TT_CANCELED_FROM_NS (ColorGroup.TT), + @SerializedName("FOOD") FOOD (ColorGroup.Careportal), @SerializedName("EXPORT_CSV") EXPORT_CSV (ColorGroup.Aaps), @SerializedName("UNKNOWN") UNKNOWN (ColorGroup.Aaps) ; @@ -119,6 +101,7 @@ data class UserEntry( 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(source: Sources) : this(0.0,0, 0, source.text, Units.Source, true) 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 @@ -152,7 +135,7 @@ data class UserEntry( } enum class Sources(val text: String) { @SerializedName("Manual") Manual ("Manual"), //Manual entry by user, given through AAPS (default) - @SerializedName("External") External ("External"), //Manual entry by user, treatment given outside AAPS (for example Bolus with Serynge) + @SerializedName("Record") Record ("Record"), //Manual entry by user, treatment given outside AAPS (for example Bolus with Serynge) @SerializedName("Automation") Automation ("Automation"), //From Automation plugin @SerializedName("Loop") Loop ("Loop"), //From Loop plugin @SerializedName("NS") NS ("NS"), //From NSClient plugin