From accfc2433250598e1efec6afd7e668f66250a54f Mon Sep 17 00:00:00 2001 From: Philoul Date: Wed, 17 Mar 2021 22:45:08 +0100 Subject: [PATCH] Optimize Actions --- .../androidaps/dialogs/CalibrationDialog.kt | 1 - .../androidaps/dialogs/CarbsDialog.kt | 6 +-- .../androidaps/dialogs/CareDialog.kt | 4 +- .../androidaps/dialogs/FillDialog.kt | 4 +- .../androidaps/dialogs/InsulinDialog.kt | 2 +- .../androidaps/dialogs/LoopDialog.kt | 18 ++++---- .../androidaps/dialogs/TempTargetDialog.kt | 7 +-- .../general/nsclient/NSClientPlugin.java | 6 +-- .../fragments/TreatmentsCareportalFragment.kt | 2 +- .../fragments/TreatmentsUserEntryFragment.kt | 6 +-- .../androidaps/utils/wizard/BolusWizard.kt | 4 +- app/src/main/res/values/strings.xml | 1 - .../maintenance/formats/ClassicPrefsFormat.kt | 6 +-- .../nightscout/androidaps/utils/Translator.kt | 18 ++------ core/src/main/res/values/strings.xml | 18 ++------ .../androidaps/database/entities/UserEntry.kt | 43 +++++++------------ 16 files changed, 54 insertions(+), 92 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt index ddd91b96fe..52dea0d14e 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt @@ -13,7 +13,6 @@ import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.databinding.DialogCalibrationBinding import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.logging.UserEntryLogger -import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider import info.nightscout.androidaps.utils.HtmlHelper import info.nightscout.androidaps.utils.XdripCalibrations 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 9f02615eb6..73697e65c4 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt @@ -222,7 +222,7 @@ class CarbsDialog : DialogFragmentWithDate() { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.carbs), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { when { activitySelected -> { - uel.log(Action.TT_ACTIVITY, ValueWithUnit(activityTT, units) , ValueWithUnit(activityTTDuration, Units.M)) + uel.log(Action.TT, ValueWithUnit(TemporaryTarget.Reason.ACTIVITY.text, Units.TT_Reason), ValueWithUnit(activityTT, units) , ValueWithUnit(activityTTDuration, Units.M)) disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction( timestamp = System.currentTimeMillis(), duration = TimeUnit.MINUTES.toMillis(activityTTDuration.toLong()), @@ -238,7 +238,7 @@ class CarbsDialog : DialogFragmentWithDate() { } eatingSoonSelected -> { - uel.log(Action.TT_EATING_SOON, ValueWithUnit(eatingSoonTT, units) , ValueWithUnit(eatingSoonTTDuration, Units.M)) + uel.log(Action.TT, ValueWithUnit(TemporaryTarget.Reason.EATING_SOON.text, Units.TT_Reason), ValueWithUnit(eatingSoonTT, units) , ValueWithUnit(eatingSoonTTDuration, Units.M)) disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction( timestamp = System.currentTimeMillis(), duration = TimeUnit.MINUTES.toMillis(eatingSoonTTDuration.toLong()), @@ -254,7 +254,7 @@ class CarbsDialog : DialogFragmentWithDate() { } hypoSelected -> { - uel.log(Action.TT_HYPO, ValueWithUnit(hypoTT, units) , ValueWithUnit(hypoTTDuration, Units.M)) + uel.log(Action.TT, ValueWithUnit(TemporaryTarget.Reason.HYPOGLYCEMIA.text, Units.TT_Reason), ValueWithUnit(hypoTT, units) , ValueWithUnit(hypoTTDuration, Units.M)) disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction( timestamp = System.currentTimeMillis(), duration = TimeUnit.MINUTES.toMillis(hypoTTDuration.toLong()), 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 89bb770d01..122b38cd81 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt @@ -203,7 +203,7 @@ class CareDialog : DialogFragmentWithDate() { therapyEvent.glucoseType = meterType therapyEvent.glucose = binding.bg.value valuesWithUnit.add(ValueWithUnit(binding.bg.value.toDouble(), profileFunction.getUnits())) - valuesWithUnit.add(ValueWithUnit(meterType.text, Units.CPEvent)) + valuesWithUnit.add(ValueWithUnit(meterType.text, Units.TherapyEvent)) } 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())) @@ -228,7 +228,7 @@ class CareDialog : DialogFragmentWithDate() { aapsLogger.error(LTag.BGSOURCE, "Error while saving therapy event", it) }) valuesWithUnit.add(0, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged)) - valuesWithUnit.add(1, ValueWithUnit(therapyEvent.type.text, Units.CPEvent)) + valuesWithUnit.add(1, ValueWithUnit(therapyEvent.type.text, Units.TherapyEvent)) 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 e26c035280..09f9234937 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt @@ -140,7 +140,7 @@ class FillDialog : DialogFragmentWithDate() { requestPrimeBolus(insulinAfterConstraints, notes) } if (siteChange) { - uel.log(Action.SITE_CHANGE, notes) + uel.log(Action.CAREPORTAL, notes, ValueWithUnit(TherapyEvent.Type.CANNULA_CHANGE.text, Units.TherapyEvent)) disposable += repository.runTransactionForResult(InsertTherapyEventIfNewTransaction( timestamp = eventTime, type = TherapyEvent.Type.CANNULA_CHANGE, @@ -154,7 +154,7 @@ class FillDialog : DialogFragmentWithDate() { } if (insulinChange) { // add a second for case of both checked - uel.log(Action.INSULIN_CHANGE, notes) + uel.log(Action.CAREPORTAL, notes, ValueWithUnit(TherapyEvent.Type.INSULIN_CHANGE.text, Units.TherapyEvent)) disposable += repository.runTransactionForResult(InsertTherapyEventIfNewTransaction( timestamp = eventTime + 1000, type = TherapyEvent.Type.INSULIN_CHANGE, 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 1613182fce..6c1e653928 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt @@ -189,7 +189,7 @@ class InsulinDialog : DialogFragmentWithDate() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.bolus), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { if (eatingSoonChecked) { - uel.log(Action.TT_EATING_SOON, notes, ValueWithUnit(eatingSoonTT, units), ValueWithUnit(eatingSoonTTDuration, Units.M)) + uel.log(Action.TT, notes, ValueWithUnit(TemporaryTarget.Reason.EATING_SOON.text, Units.TT_Reason), ValueWithUnit(eatingSoonTT, units), ValueWithUnit(eatingSoonTTDuration, Units.M)) disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction( timestamp = System.currentTimeMillis(), duration = TimeUnit.MINUTES.toMillis(eatingSoonTTDuration.toLong()), diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt index 77be1a538f..9b10142c8c 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt @@ -303,49 +303,49 @@ class LoopDialog : DaggerDialogFragment() { } R.id.overview_suspend_1h -> { - uel.log(Action.SUSPEND_1H) + uel.log(Action.SUSPEND, ValueWithUnit(1, Units.H)) loopPlugin.suspendLoop(60) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_suspend_2h -> { - uel.log(Action.SUSPEND_2H) + uel.log(Action.SUSPEND, ValueWithUnit(2, Units.H)) loopPlugin.suspendLoop(120) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_suspend_3h -> { - uel.log(Action.SUSPEND_3H) + uel.log(Action.SUSPEND, ValueWithUnit(3, Units.H)) loopPlugin.suspendLoop(180) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_suspend_10h -> { - uel.log(Action.SUSPEND_10H) + uel.log(Action.SUSPEND, ValueWithUnit(10, Units.H)) loopPlugin.suspendLoop(600) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_disconnect_15m -> { - uel.log(Action.DISCONNECT_15M) + uel.log(Action.DISCONNECT, ValueWithUnit(15, Units.M)) loopPlugin.disconnectPump(15, profile) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_disconnect_30m -> { - uel.log(Action.DISCONNECT_30M) + uel.log(Action.DISCONNECT, ValueWithUnit(30, Units.M)) loopPlugin.disconnectPump(30, profile) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_disconnect_1h -> { - uel.log(Action.DISCONNECT_1H) + uel.log(Action.DISCONNECT, ValueWithUnit(1, Units.H)) loopPlugin.disconnectPump(60, profile) sp.putBoolean(R.string.key_objectiveusedisconnect, true) rxBus.send(EventRefreshOverview("suspendmenu")) @@ -353,14 +353,14 @@ class LoopDialog : DaggerDialogFragment() { } R.id.overview_disconnect_2h -> { - uel.log(Action.DISCONNECT_2H) + uel.log(Action.DISCONNECT, ValueWithUnit(2, Units.H)) loopPlugin.disconnectPump(120, profile) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_disconnect_3h -> { - uel.log(Action.DISCONNECT_3H) + uel.log(Action.DISCONNECT, ValueWithUnit(3, Units.H)) loopPlugin.disconnectPump(180, profile) rxBus.send(EventRefreshOverview("suspendmenu")) return true 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 fb956efadd..c11f7b344a 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt @@ -181,9 +181,9 @@ class TempTargetDialog : DialogFragmentWithDate() { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { val units = profileFunction.getUnits() 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.eatingsoon) -> uel.log(Action.TT, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.EATING_SOON.text, Units.TT_Reason), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) + resourceHelper.gs(R.string.activity) -> uel.log(Action.TT, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.ACTIVITY.text, Units.TT_Reason), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) + resourceHelper.gs(R.string.hypo) -> uel.log(Action.TT, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.HYPOGLYCEMIA.text, Units.TT_Reason), 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)) } @@ -213,6 +213,7 @@ class TempTargetDialog : DialogFragmentWithDate() { aapsLogger.error(LTag.BGSOURCE, "Error while saving temporary target", it) }) } + if (duration == 10) sp.putBoolean(R.string.key_objectiveusetemptarget, true) }) } 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 a46da21678..dc0eca7339 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 @@ -433,7 +433,7 @@ public class NSClientPlugin extends PluginBase { // 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, true), 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.TherapyEvent))), error -> aapsLogger.error(LTag.DATABASE, "Error while removing therapy event", error))); // new DB model EventNsTreatment evtTreatment = new EventNsTreatment(EventNsTreatment.Companion.getREMOVE(), json); @@ -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, 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))); + 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.TherapyEvent))); + 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.TherapyEvent))); }, error -> aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", error))); } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsCareportalFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsCareportalFragment.kt index 423be9dfa5..ae09c0a6cc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsCareportalFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsCareportalFragment.kt @@ -196,7 +196,7 @@ class TreatmentsCareportalFragment : DaggerFragment() { resourceHelper.gs(R.string.notes_label) + ": " + (therapyEvent.note ?: "") + "\n" + resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(therapyEvent.timestamp) OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable { - uel.log(Action.CAREPORTAL_REMOVED, therapyEvent.note ?: "", ValueWithUnit(therapyEvent.type.text, Units.CPEvent), ValueWithUnit(therapyEvent.timestamp, Units.Timestamp)) + uel.log(Action.CAREPORTAL_REMOVED, therapyEvent.note ?: "", ValueWithUnit(therapyEvent.type.text, Units.TherapyEvent), ValueWithUnit(therapyEvent.timestamp, Units.Timestamp)) disposable += repository.runTransactionForResult(InvalidateTherapyEventTransaction(therapyEvent.id)) .subscribe({ val id = therapyEvent.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 e6b99eaf8a..c067813b99 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 @@ -126,9 +126,9 @@ class TreatmentsUserEntryFragment : DaggerFragment() { rStringParam-- else when (v.unit) { - Units.Timestamp -> valuesWithUnitString += dateUtil.dateAndTimeAndSecondsString(v.lValue) + separator - Units.CPEvent -> valuesWithUnitString += translator.translate(v.sValue) + separator - Units.TT_Reason -> valuesWithUnitString += translator.translate(v.sValue) + separator + Units.Timestamp -> valuesWithUnitString += dateUtil.dateAndTimeAndSecondsString(v.lValue) + separator + Units.TherapyEvent -> valuesWithUnitString += translator.translate(v.sValue) + separator + Units.TT_Reason -> valuesWithUnitString += translator.translate(v.sValue) + separator Units.R_String -> { rStringParam = v.lValue.toInt() when (rStringParam) { // 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 7020b854dc..05c441b369 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 @@ -349,7 +349,7 @@ class BolusWizard @Inject constructor( boluscalc = nsJSON() source = Source.USER notes = this@BolusWizard.notes - uel.log(Action.BOLUS_ADVISOR, ValueWithUnit(insulinAfterConstraints, Units.U)) + uel.log(Action.BOLUS_ADVISOR, notes, ValueWithUnit(eventType, Units.TherapyEvent), ValueWithUnit(insulinAfterConstraints, Units.U)) if (insulin > 0) { commandQueue.bolus(this, object : Callback() { override fun run() { @@ -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, this@BolusWizard.carbs != 0), ValueWithUnit(carbTime, Units.M, carbTime != 0)) + uel.log(Action.BOLUS, notes, ValueWithUnit(eventType,Units.TherapyEvent), 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/values/strings.xml b/app/src/main/res/values/strings.xml index 2683e10459..dd550020b4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -933,7 +933,6 @@ %1$.0fg IC: %2$.1f %1$.1fg IC: %2$.1f %1$d%% - Bolus wizard min Profile name: Selected: 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 93372126df..63866ce32c 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 @@ -111,9 +111,9 @@ class ClassicPrefsFormat @Inject constructor( fun valueWithUnitToCsv(v: ValueWithUnit): String { return when (v.unit) { - Units.Timestamp -> dateUtil.dateAndTimeAndSecondsString(v.lValue) + ";" + csvString(R.string.date) - Units.CPEvent -> csvString(translator.translate(v.sValue)) + ";" - Units.TT_Reason -> csvString(translator.translate(v.sValue)) + ";" + Units.Timestamp -> dateUtil.dateAndTimeAndSecondsString(v.lValue) + ";" + csvString(R.string.date) + Units.TherapyEvent -> csvString(translator.translate(v.sValue)) + ";" + Units.TT_Reason -> csvString(translator.translate(v.sValue)) + ";" Units.R_String -> if (v.lValue.toInt() == 0) csvString(v.iValue) + ";" else ";" //If lValue > 0 it's a formated string, so hidden for Units.Mg_Dl -> if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue) + ";" + csvString(Units.Mg_Dl) else DecimalFormatter.to1Decimal(v.dValue/Constants.MMOLL_TO_MGDL) + ";" + csvString(Units.Mmol_L) Units.Mmol_L -> if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue*Constants.MMOLL_TO_MGDL) + ";" + csvString(Units.Mg_Dl) else DecimalFormatter.to1Decimal(v.dValue) + ";" + csvString(Units.Mmol_L) 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 1557bc7c3a..f964bad609 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/Translator.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/Translator.kt @@ -20,6 +20,7 @@ class Translator @Inject internal constructor( TherapyEvent.Type.MEAL_BOLUS.text -> resourceHelper.gs(R.string.careportal_mealbolus) TherapyEvent.Type.CORRECTION_BOLUS.text -> resourceHelper.gs(R.string.careportal_correctionbolus) TherapyEvent.Type.CARBS_CORRECTION.text -> resourceHelper.gs(R.string.careportal_carbscorrection) + TherapyEvent.Type.BOLUS_WIZARD.text -> resourceHelper.gs(R.string.boluswizard) TherapyEvent.Type.COMBO_BOLUS.text -> resourceHelper.gs(R.string.careportal_combobolus) TherapyEvent.Type.ANNOUNCEMENT.text -> resourceHelper.gs(R.string.careportal_announcement) TherapyEvent.Type.NOTE.text -> resourceHelper.gs(R.string.careportal_note) @@ -51,7 +52,6 @@ class Translator @Inject internal constructor( TemporaryTarget.Reason.WEAR.text -> resourceHelper.gs(R.string.wear) Action.BOLUS.name -> resourceHelper.gs(R.string.uel_bolus) - Action.BOLUS_WIZARD.name -> resourceHelper.gs(R.string.uel_bolus_wizard) 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) @@ -60,9 +60,6 @@ class Translator @Inject internal constructor( Action.EXTENDED_CARBS.name -> resourceHelper.gs(R.string.uel_extended_carbs) Action.TEMP_BASAL.name -> resourceHelper.gs(R.string.uel_temp_basal) Action.TT.name -> resourceHelper.gs(R.string.uel_tt) - Action.TT_ACTIVITY.name -> resourceHelper.gs(R.string.uel_tt_activity) - Action.TT_EATING_SOON.name -> resourceHelper.gs(R.string.uel_tt_eating_soon) - Action.TT_HYPO.name -> resourceHelper.gs(R.string.uel_tt_hypo) Action.NEW_PROFILE.name -> resourceHelper.gs(R.string.uel_new_profile) Action.CLONE_PROFILE.name -> resourceHelper.gs(R.string.uel_clone_profile) Action.STORE_PROFILE.name -> resourceHelper.gs(R.string.uel_store_profile) @@ -74,16 +71,9 @@ class Translator @Inject internal constructor( Action.LOOP_DISABLED.name -> resourceHelper.gs(R.string.uel_loop_disabled) Action.LOOP_ENABLED.name -> resourceHelper.gs(R.string.uel_loop_enabled) Action.RECONNECT.name -> resourceHelper.gs(R.string.uel_reconnect) - Action.DISCONNECT_15M.name -> resourceHelper.gs(R.string.uel_disconnect_15m) - Action.DISCONNECT_30M.name -> resourceHelper.gs(R.string.uel_disconnect_30m) - Action.DISCONNECT_1H.name -> resourceHelper.gs(R.string.uel_disconnect_1h) - Action.DISCONNECT_2H.name -> resourceHelper.gs(R.string.uel_disconnect_2h) - Action.DISCONNECT_3H.name -> resourceHelper.gs(R.string.uel_disconnect_3h) + Action.DISCONNECT.name -> resourceHelper.gs(R.string.uel_disconnect) Action.RESUME.name -> resourceHelper.gs(R.string.uel_resume) - Action.SUSPEND_1H.name -> resourceHelper.gs(R.string.uel_suspend_1h) - Action.SUSPEND_2H.name -> resourceHelper.gs(R.string.uel_suspend_2h) - Action.SUSPEND_3H.name -> resourceHelper.gs(R.string.uel_suspend_3h) - Action.SUSPEND_10H.name -> resourceHelper.gs(R.string.uel_suspend_10h) + Action.SUSPEND.name -> resourceHelper.gs(R.string.uel_suspend) Action.HW_PUMP_ALLOWED.name -> resourceHelper.gs(R.string.uel_hw_pump_allowed) Action.CLEAR_PAIRING_KEYS.name -> resourceHelper.gs(R.string.uel_clear_pairing_keys) Action.ACCEPTS_TEMP_BASAL.name -> resourceHelper.gs(R.string.uel_accepts_temp_basal) @@ -92,9 +82,7 @@ class Translator @Inject internal constructor( Action.CANCEL_TT.name -> resourceHelper.gs(R.string.uel_cancel_tt) Action.CAREPORTAL.name -> resourceHelper.gs(R.string.uel_careportal) Action.CALIBRATION.name -> resourceHelper.gs(R.string.uel_calibration) - Action.INSULIN_CHANGE.name -> resourceHelper.gs(R.string.uel_insulin_change) Action.PRIME_BOLUS.name -> resourceHelper.gs(R.string.uel_prime_bolus) - Action.SITE_CHANGE.name -> resourceHelper.gs(R.string.uel_site_change) Action.TREATMENT.name -> resourceHelper.gs(R.string.uel_treatment) Action.CAREPORTAL_NS_REFRESH.name -> resourceHelper.gs(R.string.uel_careportal_ns_refresh) Action.PROFILE_SWITCH_NS_REFRESH.name -> resourceHelper.gs(R.string.uel_profile_switch_ns_refresh) diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index e83726d383..7ccc01f2af 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -265,6 +265,7 @@ Pump Battery Change Temporary target Temporary target cancel + Bolus wizard Finger Sensor Manual @@ -399,7 +400,6 @@ BOLUS - BOLUS WIZARD BOLUS ADVISOR BOLUS RECORD EXTENDED BOLUS @@ -408,9 +408,6 @@ EXTENDED CARBS TEMP BASAL TT - TT ACTIVITY - TT EATING SOON - TT HYPO NEW PROFILE CLONE PROFILE STORE PROFILE @@ -422,16 +419,9 @@ LOOP DISABLED LOOP ENABLED RECONNECT - DISCONNECT 15M - DISCONNECT 30M - DISCONNECT 1H - DISCONNECT 2H - DISCONNECT 3H + DISCONNECT RESUME - SUSPEND 1H - SUSPEND 2H - SUSPEND 3H - SUSPEND 10H + SUSPEND HW PUMP ALLOWED CLEAR PAIRING KEYS ACCEPTS TEMP BASAL @@ -440,9 +430,7 @@ CANCEL TT CAREPORTAL CALIBRATION - INSULIN CHANGE PRIME BOLUS - SITE CHANGE TREATMENT CAREPORTAL NS REFRESH PROFILE SWITCH NS REFRESH 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 5635d449a6..191ab79637 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 @@ -20,7 +20,6 @@ data class UserEntry( ) : DBEntry, DBEntryWithTime { enum class Action (val colorGroup: ColorGroup) { @SerializedName("BOLUS") BOLUS (ColorGroup.InsulinTreatment), - @SerializedName("BOLUS_WIZARD") BOLUS_WIZARD (ColorGroup.InsulinTreatment), @SerializedName("BOLUS_ADVISOR") BOLUS_ADVISOR (ColorGroup.InsulinTreatment), @SerializedName("BOLUS_RECORD") BOLUS_RECORD (ColorGroup.InsulinTreatment), @SerializedName("EXTENDED_BOLUS") EXTENDED_BOLUS (ColorGroup.InsulinTreatment), @@ -29,9 +28,6 @@ data class UserEntry( @SerializedName("EXTENDED_CARBS") EXTENDED_CARBS (ColorGroup.CarbTreatment), @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), - @SerializedName("TT_HYPO") TT_HYPO (ColorGroup.TT), @SerializedName("NEW_PROFILE") NEW_PROFILE (ColorGroup.Profile), @SerializedName("CLONE_PROFILE") CLONE_PROFILE (ColorGroup.Profile), @SerializedName("STORE_PROFILE") STORE_PROFILE (ColorGroup.Profile), @@ -43,16 +39,9 @@ data class UserEntry( @SerializedName("LOOP_DISABLED") LOOP_DISABLED (ColorGroup.Loop), @SerializedName("LOOP_ENABLED") LOOP_ENABLED (ColorGroup.Loop), @SerializedName("RECONNECT") RECONNECT (ColorGroup.Pump), - @SerializedName("DISCONNECT_15M") DISCONNECT_15M (ColorGroup.Pump), - @SerializedName("DISCONNECT_30M") DISCONNECT_30M (ColorGroup.Pump), - @SerializedName("DISCONNECT_1H") DISCONNECT_1H (ColorGroup.Pump), - @SerializedName("DISCONNECT_2H") DISCONNECT_2H (ColorGroup.Pump), - @SerializedName("DISCONNECT_3H") DISCONNECT_3H (ColorGroup.Pump), + @SerializedName("DISCONNECT") DISCONNECT (ColorGroup.Pump), @SerializedName("RESUME") RESUME (ColorGroup.Loop), - @SerializedName("SUSPEND_1H") SUSPEND_1H (ColorGroup.Loop), - @SerializedName("SUSPEND_2H") SUSPEND_2H (ColorGroup.Loop), - @SerializedName("SUSPEND_3H") SUSPEND_3H (ColorGroup.Loop), - @SerializedName("SUSPEND_10H") SUSPEND_10H (ColorGroup.Loop), + @SerializedName("SUSPEND") SUSPEND (ColorGroup.Loop), @SerializedName("HW_PUMP_ALLOWED") HW_PUMP_ALLOWED (ColorGroup.Pump), @SerializedName("CLEAR_PAIRING_KEYS") CLEAR_PAIRING_KEYS (ColorGroup.Pump), @SerializedName("ACCEPTS_TEMP_BASAL") ACCEPTS_TEMP_BASAL (ColorGroup.InsulinTreatment), @@ -61,9 +50,7 @@ data class UserEntry( @SerializedName("CANCEL_TT") CANCEL_TT (ColorGroup.TT), @SerializedName("CAREPORTAL") CAREPORTAL (ColorGroup.Careportal), @SerializedName("CALIBRATION") CALIBRATION (ColorGroup.Careportal), - @SerializedName("INSULIN_CHANGE") INSULIN_CHANGE (ColorGroup.InsulinTreatment), @SerializedName("PRIME_BOLUS") PRIME_BOLUS (ColorGroup.Careportal), - @SerializedName("SITE_CHANGE") SITE_CHANGE (ColorGroup.Careportal), @SerializedName("TREATMENT") TREATMENT (ColorGroup.InsulinTreatment), @SerializedName("CAREPORTAL_NS_REFRESH") CAREPORTAL_NS_REFRESH (ColorGroup.Aaps), @SerializedName("PROFILE_SWITCH_NS_REFRESH") PROFILE_SWITCH_NS_REFRESH (ColorGroup.Aaps), @@ -142,19 +129,19 @@ data class UserEntry( } } enum class Units(val text: String) { - @SerializedName("None") None (""), //Int or String - @SerializedName("Mg_Dl") Mg_Dl ("mg/dl"), //Double - @SerializedName("Mmol_L") Mmol_L ("mmol"), //Double - @SerializedName("Timestamp") Timestamp("Timestamp"), //long - @SerializedName("U") U ("U"), //Double - @SerializedName("U_H") U_H ("U/h"), //Double - @SerializedName("G") G ("g"), //Int - @SerializedName("M") M ("m"), //Int - @SerializedName("H") H ("h"), //Int - @SerializedName("Percent") Percent ("%"), //Int - @SerializedName("CPEvent") CPEvent ("CPEvent"), //String (CareportalEvent.Event => Translated by Translator function) - @SerializedName("TT_Reason") TT_Reason ("TTReason"), //TemporaryTarget.Reason => String (to Improve for translation) - @SerializedName("R_String") R_String ("R.string") //Int + @SerializedName("None") None (""), //Int or String + @SerializedName("Mg_Dl") Mg_Dl ("mg/dl"), //Double + @SerializedName("Mmol_L") Mmol_L ("mmol"), //Double + @SerializedName("Timestamp") Timestamp("Timestamp"), //long + @SerializedName("U") U ("U"), //Double + @SerializedName("U_H") U_H ("U/h"), //Double + @SerializedName("G") G ("g"), //Int + @SerializedName("M") M ("m"), //Int + @SerializedName("H") H ("h"), //Int + @SerializedName("Percent") Percent ("%"), //Int + @SerializedName("TherapyEvent") TherapyEvent ("TherapyEvent"), //String (CareportalEvent.Event => Translated by Translator function) + @SerializedName("TT_Reason") TT_Reason ("TTReason"), //TemporaryTarget.Reason => String (to Improve for translation) + @SerializedName("R_String") R_String ("R.string") //Int ; companion object {