From f5330287e963ce385457cc048c6b66025c19a2e8 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 11 Apr 2021 16:02:53 +0200 Subject: [PATCH] Replace ValueWithUnit.StringResource by ValueWithUnit.SimpleString --- .../androidaps/dialogs/InsulinDialog.kt | 4 +- .../androidaps/dialogs/TreatmentDialog.kt | 4 +- .../androidaps/plugins/aps/loop/LoopPlugin.kt | 5 +- .../configBuilder/ConfigBuilderPlugin.kt | 12 +-- .../plugins/general/food/FoodFragment.kt | 4 +- .../smsCommunicator/SmsCommunicatorPlugin.kt | 88 ++++++++++--------- .../automation/actions/ActionLoopSuspend.kt | 4 +- .../actions/ActionProfileSwitchPercent.kt | 5 +- .../userEntry/UserEntryPresentationHelper.kt | 11 +-- .../utils/userEntry/ValueWithUnitMapper.kt | 4 - .../database/entities/ValueWithUnit.kt | 3 - 11 files changed, 70 insertions(+), 74 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 3eb3e7113e..dc98e019c4 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt @@ -214,8 +214,8 @@ class InsulinDialog : DialogFragmentWithDate() { detailedBolusInfo.timestamp = time if (recordOnlyChecked) { uel.log(Action.BOLUS, Sources.InsulinDialog, - notes, - ValueWithUnit.StringResource(R.string.record), + resourceHelper.gs(R.string.record) + if (notes.isNotEmpty()) ": " + notes else "", + ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.record)), ValueWithUnit.Insulin(insulinAfterConstraints), ValueWithUnit.Minute(timeOffset).takeIf { timeOffset!= 0 }) disposable += repository.runTransactionForResult(detailedBolusInfo.insertBolusTransaction()) 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 4490d433cf..9fd4dbb89b 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt @@ -149,9 +149,9 @@ class TreatmentDialog : DialogFragmentWithDate() { detailedBolusInfo.carbs = carbsAfterConstraints.toDouble() detailedBolusInfo.context = context if (recordOnlyChecked) { - uel.log(action, Sources.TreatmentDialog, + uel.log(action, Sources.TreatmentDialog, if (insulinAfterConstraints != 0.0) resourceHelper.gs(R.string.record) else "", ValueWithUnit.Timestamp(detailedBolusInfo.timestamp).takeIf { eventTimeChanged }, - ValueWithUnit.StringResource(R.string.record).takeIf { insulinAfterConstraints != 0.0 }, + ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.record)).takeIf { insulinAfterConstraints != 0.0 }, ValueWithUnit.Insulin(insulinAfterConstraints).takeIf { insulinAfterConstraints != 0.0 }, ValueWithUnit.Gram(carbsAfterConstraints).takeIf { carbsAfterConstraints != 0 }) if (detailedBolusInfo.insulin > 0) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt index 23c08ffef6..fd5934be9d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt @@ -378,8 +378,9 @@ open class LoopPlugin @Inject constructor( // mId allows you to update the notification later on. mNotificationManager.notify(Constants.notificationID, builder.build()) - uel.log(Action.CAREPORTAL, Sources.Loop, - ValueWithUnit.StringResource(info.nightscout.androidaps.core.R.string.carbsreq, listOf(ValueWithUnit.Gram(resultAfterConstraints.carbsReq), ValueWithUnit.Minute(resultAfterConstraints.carbsReqWithin)))) + uel.log(Action.CAREPORTAL, Sources.Loop, resourceHelper.gs(R.string.carbsreq, resultAfterConstraints.carbsReq, resultAfterConstraints.carbsReqWithin), + ValueWithUnit.Gram(resultAfterConstraints.carbsReq), + ValueWithUnit.Minute(resultAfterConstraints.carbsReqWithin)) rxBus.send(EventNewOpenLoopNotification()) //only send to wear if Native notifications are turned off diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt index 16656c73dc..e50f820091 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt @@ -148,8 +148,8 @@ class ConfigBuilderPlugin @Inject constructor( performPluginSwitch(changedPlugin, newState, type) pumpSync.connectNewPump() sp.putBoolean("allow_hardware_pump", true) - uel.log(Action.HW_PUMP_ALLOWED, Sources.ConfigBuilder, - ValueWithUnit.StringResource(changedPlugin.pluginDescription.pluginName)) + uel.log(Action.HW_PUMP_ALLOWED, Sources.ConfigBuilder, resourceHelper.gs(changedPlugin.pluginDescription.pluginName), + ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(changedPlugin.pluginDescription.pluginName))) aapsLogger.debug(LTag.PUMP, "First time HW pump allowed!") }, { rxBus.send(EventConfigBuilderUpdateGui()) @@ -160,12 +160,12 @@ class ConfigBuilderPlugin @Inject constructor( override fun performPluginSwitch(changedPlugin: PluginBase, enabled: Boolean, type: PluginType) { if(enabled && !changedPlugin.isEnabled()) { - uel.log(Action.PLUGIN_ENABLED, Sources.ConfigBuilder, - ValueWithUnit.StringResource(changedPlugin.pluginDescription.pluginName)) + uel.log(Action.PLUGIN_ENABLED, Sources.ConfigBuilder, resourceHelper.gs(changedPlugin.pluginDescription.pluginName), + ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(changedPlugin.pluginDescription.pluginName))) } else if(!enabled) { - uel.log(Action.PLUGIN_DISABLED, Sources.ConfigBuilder, - ValueWithUnit.StringResource(changedPlugin.pluginDescription.pluginName)) + uel.log(Action.PLUGIN_DISABLED, Sources.ConfigBuilder, resourceHelper.gs(changedPlugin.pluginDescription.pluginName), + ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(changedPlugin.pluginDescription.pluginName))) } changedPlugin.setPluginEnabled(type, enabled) changedPlugin.setFragmentVisible(type, enabled) 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 73c240264b..4d8105a655 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 @@ -76,8 +76,8 @@ class FoodFragment : DaggerFragment() { binding.refreshFromNightscout.setOnClickListener { context?.let { context -> OKDialog.showConfirmation(context, resourceHelper.gs(R.string.refresheventsfromnightscout) + " ?", { - uel.log(Action.FOOD, Sources.Food, - ValueWithUnit.StringResource(R.string.refresheventsfromnightscout)) + uel.log(Action.FOOD, Sources.Food, resourceHelper.gs(R.string.refresheventsfromnightscout), + ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.refresheventsfromnightscout))) disposable += Completable.fromAction { repository.deleteAllFoods() } .subscribeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.main) 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 3e7cca9f12..ee9fa3c40b 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 @@ -585,8 +585,8 @@ 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.PROFILE_SWITCH, Sources.SMS, - ValueWithUnit.StringResource(R.string.profileswitchcreated)) + uel.log(Action.PROFILE_SWITCH, Sources.SMS, resourceHelper.gs(R.string.profileswitchcreated), + ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.profileswitchcreated))) } }) } @@ -608,14 +608,14 @@ 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.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true), - ValueWithUnit.StringResource(R.string.smscommunicator_tempbasalcanceled)) + uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + resourceHelper.gs(R.string.smscommunicator_tempbasalcanceled), + ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.smscommunicator_tempbasalcanceled))) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalcancelfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true), - ValueWithUnit.StringResource(R.string.smscommunicator_tempbasalcancelfailed)) + uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + resourceHelper.gs(R.string.smscommunicator_tempbasalcancelfailed), + ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.smscommunicator_tempbasalcancelfailed))) } } }) @@ -645,18 +645,20 @@ class SmsCommunicatorPlugin @Inject constructor( sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) if (result.isPercent) uel.log(Action.TEMP_BASAL, Sources.SMS, - activePlugin.activePump.shortStatus(true), - ValueWithUnit.StringResource(R.string.smscommunicator_tempbasalset_percent, listOf(ValueWithUnit.Percent(result.percent), ValueWithUnit.Minute(result.duration))) ) + activePlugin.activePump.shortStatus(true) + "\n" + resourceHelper.gs(R.string.smscommunicator_tempbasalset_percent, result.percent, result.duration), + ValueWithUnit.Percent(result.percent), + ValueWithUnit.Minute(result.duration)) else uel.log(Action.TEMP_BASAL, Sources.SMS, - activePlugin.activePump.shortStatus(true), - ValueWithUnit.StringResource(R.string.smscommunicator_tempbasalset, listOf( ValueWithUnit.UnitPerHour(result.absolute), ValueWithUnit.Minute(result.duration)))) + activePlugin.activePump.shortStatus(true) + "\n" + resourceHelper.gs(R.string.smscommunicator_tempbasalset, result.absolute, result.duration), + ValueWithUnit.UnitPerHour(result.absolute), + ValueWithUnit.Minute(result.duration)) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true), - ValueWithUnit.StringResource(R.string.smscommunicator_tempbasalfailed)) + uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + resourceHelper.gs(R.string.smscommunicator_tempbasalfailed), + ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.smscommunicator_tempbasalfailed))) } } }) @@ -687,17 +689,19 @@ class SmsCommunicatorPlugin @Inject constructor( replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) if (result.isPercent) - uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true), - ValueWithUnit.StringResource(R.string.smscommunicator_tempbasalset_percent, listOf(ValueWithUnit.Percent(result.percent), ValueWithUnit.Minute(result.duration)))) + uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + resourceHelper.gs(R.string.smscommunicator_tempbasalset_percent, result.percent, result.duration), + ValueWithUnit.Percent(result.percent), + ValueWithUnit.Minute(result.duration)) else - uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true), - ValueWithUnit.StringResource(R.string.smscommunicator_tempbasalset, listOf(ValueWithUnit.UnitPerHour(result.absolute), ValueWithUnit.Minute(result.duration)))) + uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + resourceHelper.gs(R.string.smscommunicator_tempbasalset, result.absolute, result.duration), + ValueWithUnit.UnitPerHour(result.absolute), + ValueWithUnit.Minute(result.duration)) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true), - ValueWithUnit.StringResource(R.string.smscommunicator_tempbasalfailed)) + uel.log(Action.TEMP_BASAL, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + resourceHelper.gs(R.string.smscommunicator_tempbasalfailed), + ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.smscommunicator_tempbasalfailed))) } } }) @@ -724,8 +728,8 @@ 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.EXTENDED_BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true), - ValueWithUnit.StringResource(R.string.smscommunicator_extendedcanceled)) + uel.log(Action.EXTENDED_BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + resourceHelper.gs(R.string.smscommunicator_extendedcanceled), + ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.smscommunicator_extendedcanceled))) } } }) @@ -752,18 +756,20 @@ class SmsCommunicatorPlugin @Inject constructor( replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) if (config.APS) - uel.log(Action.EXTENDED_BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true), - ValueWithUnit.StringResource(R.string.smscommunicator_extendedset, listOf(ValueWithUnit.Insulin(aDouble ?: 0.0), ValueWithUnit.Minute(duration))), - ValueWithUnit.StringResource(R.string.loopsuspended)) + uel.log(Action.EXTENDED_BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + resourceHelper.gs(R.string.smscommunicator_extendedset, aDouble, duration) + " / " + resourceHelper.gs(R.string.loopsuspended), + ValueWithUnit.Insulin(aDouble ?: 0.0), + ValueWithUnit.Minute(duration), + ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.loopsuspended))) else - uel.log(Action.EXTENDED_BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true), - ValueWithUnit.StringResource(R.string.smscommunicator_extendedset, listOf( ValueWithUnit.Insulin(aDouble ?: 0.0), ValueWithUnit.Minute(duration)))) + uel.log(Action.EXTENDED_BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + resourceHelper.gs(R.string.smscommunicator_extendedset, aDouble, duration), + ValueWithUnit.Insulin(aDouble ?: 0.0), + ValueWithUnit.Minute(duration)) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_extendedfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log(Action.EXTENDED_BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true), - ValueWithUnit.StringResource(R.string.smscommunicator_extendedfailed)) + uel.log(Action.EXTENDED_BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + resourceHelper.gs(R.string.smscommunicator_extendedfailed), + ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.smscommunicator_extendedfailed))) } } }) @@ -840,8 +846,8 @@ class SmsCommunicatorPlugin @Inject constructor( var replyText = resourceHelper.gs(R.string.smscommunicator_bolusfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log(Action.BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true), - ValueWithUnit.StringResource(R.string.smscommunicator_bolusfailed)) + uel.log(Action.BOLUS, Sources.SMS, activePlugin.activePump.shortStatus(true) + "\n" + resourceHelper.gs(R.string.smscommunicator_bolusfailed), + ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.smscommunicator_bolusfailed))) } } }) @@ -879,14 +885,14 @@ 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.CARBS, Sources.SMS, activePlugin.activePump.shortStatus(true), - ValueWithUnit.StringResource(R.string.smscommunicator_carbsset, listOf(ValueWithUnit.Gram(anInteger ?: 0)))) + uel.log(Action.CARBS, Sources.SMS, activePlugin.activePump.shortStatus(true) + ": " + resourceHelper.gs(R.string.smscommunicator_carbsset, anInteger), + ValueWithUnit.Gram(anInteger ?: 0)) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_carbsfailed, anInteger) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log(Action.CARBS, Sources.SMS, activePlugin.activePump.shortStatus(true), - ValueWithUnit.StringResource(R.string.smscommunicator_carbsfailed, listOf(ValueWithUnit.Gram(anInteger ?: 0)))) + uel.log(Action.CARBS, Sources.SMS, activePlugin.activePump.shortStatus(true) + ": " + resourceHelper.gs(R.string.smscommunicator_carbsfailed, anInteger), + ValueWithUnit.Gram(anInteger ?: 0)) } } }) @@ -976,8 +982,8 @@ class SmsCommunicatorPlugin @Inject constructor( }) val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_tt_canceled)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log(Action.CANCEL_TT, Sources.SMS, - ValueWithUnit.StringResource(R.string.smscommunicator_tt_canceled)) + uel.log(Action.CANCEL_TT, Sources.SMS, resourceHelper.gs(R.string.smscommunicator_tt_canceled), + ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.smscommunicator_tt_canceled))) } }) } else @@ -996,8 +1002,8 @@ 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.STOP_SMS, Sources.SMS, - ValueWithUnit.StringResource(R.string.smscommunicator_stoppedsms)) + uel.log(Action.STOP_SMS, Sources.SMS, resourceHelper.gs(R.string.smscommunicator_stoppedsms), + ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.smscommunicator_stoppedsms))) } }) } else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat))) @@ -1016,11 +1022,11 @@ 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.CALIBRATION, Sources.SMS, - ValueWithUnit.StringResource(R.string.smscommunicator_calibrationsent)) + uel.log(Action.CALIBRATION, Sources.SMS, resourceHelper.gs(R.string.smscommunicator_calibrationsent), + ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.smscommunicator_calibrationsent))) else - uel.log(Action.CALIBRATION, Sources.SMS, - ValueWithUnit.StringResource(R.string.smscommunicator_calibrationfailed)) + uel.log(Action.CALIBRATION, Sources.SMS, resourceHelper.gs(R.string.smscommunicator_calibrationfailed), + ValueWithUnit.SimpleString(resourceHelper.gsNotLocalised(R.string.smscommunicator_calibrationfailed))) } }) } else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat))) diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopSuspend.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopSuspend.kt index 49d0ba461e..797250b443 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopSuspend.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopSuspend.kt @@ -37,8 +37,8 @@ class ActionLoopSuspend(injector: HasAndroidInjector) : Action(injector) { if (!loopPlugin.isSuspended) { loopPlugin.suspendLoop(minutes.getMinutes()) rxBus.send(EventRefreshOverview("ActionLoopSuspend")) - uel.log(UserEntry.Action.SUSPEND, Sources.Automation, title, - ValueWithUnit.StringResource(R.string.suspendloopforXmin, listOf(ValueWithUnit.Minute(minutes.getMinutes())))) + uel.log(UserEntry.Action.SUSPEND, Sources.Automation, title + ": " + resourceHelper.gs(R.string.suspendloopforXmin, minutes.getMinutes()), + ValueWithUnit.Minute(minutes.getMinutes())) callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run() } else { callback.result(PumpEnactResult(injector).success(true).comment(R.string.alreadysuspended))?.run() diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercent.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercent.kt index 3e024a4e00..3e07559032 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercent.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercent.kt @@ -42,8 +42,9 @@ class ActionProfileSwitchPercent(injector: HasAndroidInjector) : Action(injector } override fun doAction(callback: Callback) { - uel.log(UserEntry.Action.PROFILE_SWITCH, Sources.Automation, title, - ValueWithUnit.StringResource( R.string.startprofile, listOf(ValueWithUnit.Percent(pct.value.toInt()), ValueWithUnit.Minute(duration.value)))) + uel.log(UserEntry.Action.PROFILE_SWITCH, Sources.Automation, title + ": " + resourceHelper.gs(R.string.startprofile, pct.value.toInt(), duration.value), + ValueWithUnit.Percent(pct.value.toInt()), + ValueWithUnit.Minute(duration.value)) activePlugin.activeTreatments.doProfileSwitch(duration.value, pct.value.toInt(), 0) callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run() } diff --git a/core/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryPresentationHelper.kt b/core/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryPresentationHelper.kt index ee0f352413..b3a5049f9b 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryPresentationHelper.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryPresentationHelper.kt @@ -119,7 +119,6 @@ class UserEntryPresentationHelper @Inject constructor( is ValueWithUnit.UnitPerHour -> DecimalFormatter.to2Decimal(valueWithUnit.value) + translator.translate(valueWithUnit) is ValueWithUnit.SimpleInt -> valueWithUnit.value.toString() is ValueWithUnit.SimpleString -> valueWithUnit.value - is ValueWithUnit.StringResource -> resourceHelper.gs(valueWithUnit.value, *(valueWithUnit.params.map { it.value() }.toTypedArray())) is ValueWithUnit.TherapyEventMeterType -> translator.translate(valueWithUnit.value) is ValueWithUnit.TherapyEventTTReason -> translator.translate(valueWithUnit.value) is ValueWithUnit.TherapyEventType -> translator.translate(valueWithUnit.value) @@ -182,9 +181,6 @@ class UserEntryPresentationHelper @Inject constructor( var hour = "" var minute = "" var other = "" - for (valueWithUnit in entry.values) { - if (valueWithUnit is ValueWithUnit.StringResource) fullvalueWithUnitList.addAll(valueWithUnit.params) - } for (valueWithUnit in fullvalueWithUnitList.filterNotNull()) { when (valueWithUnit) { @@ -196,7 +192,6 @@ class UserEntryPresentationHelper @Inject constructor( is ValueWithUnit.UnitPerHour -> unitPerHour = DecimalFormatter.to2Decimal(valueWithUnit.value) is ValueWithUnit.SimpleInt -> other = other.addWithSeparator(valueWithUnit.value) is ValueWithUnit.SimpleString -> other = other.addWithSeparator(valueWithUnit.value) - is ValueWithUnit.StringResource -> stringResource = stringResource.addWithSeparator(resourceHelper.gs(valueWithUnit.value, *(valueWithUnit.params.map { it.value() }.toTypedArray()))) is ValueWithUnit.TherapyEventMeterType -> therapyEvent = therapyEvent.addWithSeparator(translator.translate(valueWithUnit.value)) is ValueWithUnit.TherapyEventTTReason -> therapyEvent = therapyEvent.addWithSeparator(translator.translate(valueWithUnit.value)) is ValueWithUnit.TherapyEventType -> therapyEvent = therapyEvent.addWithSeparator(translator.translate(valueWithUnit.value)) @@ -222,9 +217,9 @@ class UserEntryPresentationHelper @Inject constructor( return "$timestampRec;$dateTimestampRev;$utcOffset;$action;$therapyEvent;$source;$note;$stringResource;$timestamp;$bg;$gram;$insulin;$unitPerHour;$percent;$hour;$minute;$other" } - private fun csvString(action: Action): String = "\"" + translator.translate(action).replace("\"", "\"\"") + "\"" - private fun csvString(id: Int): String = if (id != 0) "\"" + resourceHelper.gs(id).replace("\"", "\"\"") + "\"" else "" - private fun csvString(s: String): String = if (s != "") "\"" + s.replace("\"", "\"\"") + "\"" else "" + private fun csvString(action: Action): String = "\"" + translator.translate(action).replace("\"", "\"\"").replace("\n"," / ") + "\"" + private fun csvString(id: Int): String = if (id != 0) "\"" + resourceHelper.gs(id).replace("\"", "\"\"").replace("\n"," / ") + "\"" else "" + private fun csvString(s: String): String = if (s != "") "\"" + s.replace("\"", "\"\"").replace("\n"," / ") + "\"" else "" private fun String.addWithSeparator(add: Any) = this + (if (this.isBlank()) "" else " / ") + add.toString() diff --git a/core/src/main/java/info/nightscout/androidaps/utils/userEntry/ValueWithUnitMapper.kt b/core/src/main/java/info/nightscout/androidaps/utils/userEntry/ValueWithUnitMapper.kt index 78858d07e0..88b8270df9 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/userEntry/ValueWithUnitMapper.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/userEntry/ValueWithUnitMapper.kt @@ -38,8 +38,6 @@ sealed class ValueWithUnitMapper { //I use a sealed class because of St data class TherapyEventTTReason(val value: TemporaryTarget.Reason) : ValueWithUnitMapper() - data class StringResource(@StringRes val value: Int, val params: List = listOf()) : ValueWithUnitMapper() - fun db(): ValueWithUnit? { return when(this) { is Gram -> ValueWithUnit.Gram(this.value) @@ -51,7 +49,6 @@ sealed class ValueWithUnitMapper { //I use a sealed class because of St is Percent -> ValueWithUnit.Percent(this.value) is SimpleInt -> ValueWithUnit.SimpleInt(this.value) is SimpleString -> ValueWithUnit.SimpleString(this.value) - is StringResource -> ValueWithUnit.StringResource(this.value, this.params.map {it.db()}.filterNotNull()) is TherapyEventMeterType -> ValueWithUnit.TherapyEventMeterType(this.value) is TherapyEventTTReason -> ValueWithUnit.TherapyEventTTReason(this.value) is TherapyEventType -> ValueWithUnit.TherapyEventType(this.value) @@ -72,7 +69,6 @@ sealed class ValueWithUnitMapper { //I use a sealed class because of St is Percent -> this.value is SimpleInt -> this.value is SimpleString -> this.value - is StringResource -> this.value is TherapyEventMeterType -> this.value is TherapyEventTTReason -> this.value is TherapyEventType -> this.value diff --git a/database/src/main/java/info/nightscout/androidaps/database/entities/ValueWithUnit.kt b/database/src/main/java/info/nightscout/androidaps/database/entities/ValueWithUnit.kt index 1ba04f7dcd..7cd94956f0 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/entities/ValueWithUnit.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/entities/ValueWithUnit.kt @@ -34,8 +34,6 @@ sealed class ValueWithUnit { data class TherapyEventTTReason(val value: TemporaryTarget.Reason) : ValueWithUnit() - data class StringResource(@StringRes val value: Int, val params: List = listOf()) : ValueWithUnit() - fun value(): Any? { return when(this) { is Gram -> this.value @@ -47,7 +45,6 @@ sealed class ValueWithUnit { is Percent -> this.value is SimpleInt -> this.value is SimpleString -> this.value - is StringResource -> this.value is TherapyEventMeterType -> this.value is TherapyEventTTReason -> this.value is TherapyEventType -> this.value