From 14454f6c15319bbbc2d09388458c1f6bb41e2063 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sat, 20 Feb 2021 13:30:34 +0100 Subject: [PATCH 01/66] Create keys for uel.log --- .../androidaps/activities/StatsActivity.kt | 2 +- .../androidaps/dialogs/CalibrationDialog.kt | 2 +- .../androidaps/dialogs/CarbsDialog.kt | 10 +-- .../androidaps/dialogs/CareDialog.kt | 2 +- .../androidaps/dialogs/ExtendedBolusDialog.kt | 2 +- .../androidaps/dialogs/FillDialog.kt | 6 +- .../androidaps/dialogs/InsulinDialog.kt | 6 +- .../androidaps/dialogs/LoopDialog.kt | 30 +++---- .../androidaps/dialogs/ProfileSwitchDialog.kt | 2 +- .../androidaps/dialogs/TempBasalDialog.kt | 4 +- .../androidaps/dialogs/TempTargetDialog.kt | 2 +- .../androidaps/dialogs/TreatmentDialog.kt | 2 +- .../configBuilder/ConfigBuilderPlugin.kt | 2 +- .../objectives/ObjectivesFragment.kt | 2 +- .../objectives/ObjectivesPlugin.kt | 2 +- .../general/actions/ActionsFragment.kt | 4 +- .../general/automation/AutomationFragment.kt | 4 +- .../plugins/general/food/FoodFragment.kt | 2 +- .../general/maintenance/ImportExportPrefs.kt | 2 +- .../maintenance/MaintenanceFragment.kt | 8 +- .../general/nsclient/NSClientFragment.java | 4 +- .../general/nsclient/data/NSSettingsStatus.kt | 2 +- .../general/overview/OverviewFragment.kt | 2 +- .../smsCommunicator/SmsCommunicatorPlugin.kt | 50 +++++------ .../activities/SmsCommunicatorOtpActivity.kt | 4 +- .../profile/local/LocalProfileFragment.kt | 6 +- .../profile/local/LocalProfilePlugin.kt | 2 +- .../plugins/profile/ns/NSProfileFragment.kt | 2 +- .../plugins/source/BGSourceFragment.kt | 2 +- .../fragments/TreatmentsBolusFragment.kt | 6 +- .../fragments/TreatmentsCareportalFragment.kt | 6 +- .../TreatmentsExtendedBolusesFragment.kt | 2 +- .../TreatmentsProfileSwitchFragment.kt | 6 +- .../fragments/TreatmentsTempTargetFragment.kt | 4 +- .../TreatmentsTemporaryBasalsFragment.kt | 2 +- .../androidaps/utils/wizard/BolusWizard.kt | 4 +- app/src/main/res/values/strings.xml | 86 +++++++++++++++++++ .../androidaps/dialogs/ErrorDialog.kt | 8 +- core/src/main/res/values/strings.xml | 6 ++ .../androidaps/dana/DanaFragment.kt | 2 +- dana/src/main/res/values/strings.xml | 1 + 41 files changed, 199 insertions(+), 104 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt index 233c293f12..2f9afc895f 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt @@ -31,7 +31,7 @@ class StatsActivity : NoSplashAppCompatActivity() { binding.ok.setOnClickListener { finish() } binding.reset.setOnClickListener { OKDialog.showConfirmation(this, resourceHelper.gs(R.string.doyouwantresetstats)) { - uel.log("STATS RESET") + uel.log(resourceHelper.gs(R.string.key_uel_stat_reset)) activityMonitor.reset() recreate() } 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 63acaef52c..14ebd600de 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt @@ -77,7 +77,7 @@ class CalibrationDialog : DialogFragmentWithDate() { if (bg > 0) { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_calibration), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { - uel.log("CALIBRATION", d1 = bg) + uel.log(resourceHelper.gs(R.string.key_uel_calibration), d1 = bg) xdripCalibrations.sendIntent(bg) }) } 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 c2f0986820..fa9c17d4b9 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt @@ -212,7 +212,7 @@ class CarbsDialog : DialogFragmentWithDate() { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.carbs), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { when { activitySelected -> { - uel.log("TT ACTIVITY", d1 = activityTT, i1 = activityTTDuration) + uel.log(resourceHelper.gs(R.string.key_uel_tt_activity), d1 = activityTT, i1 = activityTTDuration) val tempTarget = TempTarget() .date(System.currentTimeMillis()) .duration(activityTTDuration) @@ -224,7 +224,7 @@ class CarbsDialog : DialogFragmentWithDate() { } eatingSoonSelected -> { - uel.log("TT EATING SOON", d1 = eatingSoonTT, i1 = eatingSoonTTDuration) + uel.log(resourceHelper.gs(R.string.key_uel_tt_eating_soon), d1 = eatingSoonTT, i1 = eatingSoonTTDuration) val tempTarget = TempTarget() .date(System.currentTimeMillis()) .duration(eatingSoonTTDuration) @@ -236,7 +236,7 @@ class CarbsDialog : DialogFragmentWithDate() { } hypoSelected -> { - uel.log("TT HYPO", d1 = hypoTT, i1 = hypoTTDuration) + uel.log(resourceHelper.gs(R.string.key_uel_tt_hypo), d1 = hypoTT, i1 = hypoTTDuration) val tempTarget = TempTarget() .date(System.currentTimeMillis()) .duration(hypoTTDuration) @@ -249,10 +249,10 @@ class CarbsDialog : DialogFragmentWithDate() { } if (carbsAfterConstraints > 0) { if (duration == 0) { - uel.log("CARBS", d1 = carbsAfterConstraints.toDouble(), i1 = timeOffset) + uel.log(resourceHelper.gs(R.string.key_uel_carb), d1 = carbsAfterConstraints.toDouble(), i1 = timeOffset) carbsGenerator.createCarb(carbsAfterConstraints, time, CareportalEvent.CARBCORRECTION, notes) } else { - uel.log("CARBS", d1 = carbsAfterConstraints.toDouble(), i1 = timeOffset, i2 = duration) + uel.log(resourceHelper.gs(R.string.key_uel_carb), d1 = carbsAfterConstraints.toDouble(), i1 = timeOffset, i2 = duration) carbsGenerator.generateCarbs(carbsAfterConstraints, time, duration, notes) nsUpload.uploadEvent(CareportalEvent.NOTE, DateUtil.now() - 2000, resourceHelper.gs(R.string.generated_ecarbs_note, carbsAfterConstraints, duration, timeOffset)) } 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 4f34ffe8d4..c75334b014 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt @@ -222,7 +222,7 @@ class CareDialog : DialogFragmentWithDate() { EventType.ANNOUNCEMENT -> CareportalEvent.ANNOUNCEMENT } careportalEvent.json = json.toString() - uel.log("CAREPORTAL", careportalEvent.eventType) + uel.log(resourceHelper.gs(R.string.key_uel_careportal), careportalEvent.eventType) MainApp.getDbHelper().createOrUpdate(careportalEvent) nsUpload.uploadCareportalEntryToNS(json) }, null) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/ExtendedBolusDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/ExtendedBolusDialog.kt index 36246c4c2c..66914d3a30 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/ExtendedBolusDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/ExtendedBolusDialog.kt @@ -87,7 +87,7 @@ class ExtendedBolusDialog : DialogFragmentWithDate() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.extended_bolus), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { - uel.log("EXTENDED BOLUS", d1 = insulinAfterConstraint, i1 = durationInMinutes) + uel.log(resourceHelper.gs(R.string.key_uel_extended_bolus), d1 = insulinAfterConstraint, i1 = durationInMinutes) commandQueue.extendedBolus(insulinAfterConstraint, durationInMinutes, object : Callback() { override fun run() { if (!result.success) { 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 90ee51cf63..f3bab670de 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt @@ -127,16 +127,16 @@ class FillDialog : DialogFragmentWithDate() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.primefill), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { if (insulinAfterConstraints > 0) { - uel.log("PRIME BOLUS", d1 = insulinAfterConstraints) + uel.log(resourceHelper.gs(R.string.key_uel_prime_bolus), d1 = insulinAfterConstraints) requestPrimeBolus(insulinAfterConstraints, notes) } if (siteChange) { - uel.log("SITE CHANGE") + uel.log(resourceHelper.gs(R.string.key_uel_site_change)) nsUpload.generateCareportalEvent(CareportalEvent.SITECHANGE, eventTime, notes) } if (insulinChange) { // add a second for case of both checked - uel.log("INSULIN CHANGE") + uel.log(resourceHelper.gs(R.string.key_uel_insulin_change)) nsUpload.generateCareportalEvent(CareportalEvent.INSULINCHANGE, eventTime + 1000, notes) } }, null) 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 afc68a1e30..1fb1ce4ff0 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt @@ -178,7 +178,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("TT EATING SOON", d1 = eatingSoonTT, i1 = eatingSoonTTDuration) + uel.log(resourceHelper.gs(R.string.key_uel_tt_eating_soon), d1 = eatingSoonTT, i1 = eatingSoonTTDuration) val tempTarget = TempTarget() .date(System.currentTimeMillis()) .duration(eatingSoonTTDuration) @@ -196,11 +196,11 @@ class InsulinDialog : DialogFragmentWithDate() { detailedBolusInfo.source = Source.USER detailedBolusInfo.notes = notes if (recordOnlyChecked) { - uel.log("BOLUS RECORD", d1 = insulinAfterConstraints, i1 = timeOffset) + uel.log(resourceHelper.gs(R.string.key_uel_bolus_record), d1 = insulinAfterConstraints, i1 = timeOffset) detailedBolusInfo.date = time activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false) } else { - uel.log("BOLUS", d1 = insulinAfterConstraints) + uel.log(resourceHelper.gs(R.string.key_uel_bolus), d1 = insulinAfterConstraints) detailedBolusInfo.date = DateUtil.now() commandQueue.bolus(detailedBolusInfo, object : Callback() { override fun run() { 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 0e11aea05d..e235f47db1 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt @@ -238,28 +238,28 @@ class LoopDialog : DaggerDialogFragment() { val profile = profileFunction.getProfile() ?: return true when (v.id) { R.id.overview_closeloop -> { - uel.log("CLOSED LOOP MODE") + uel.log(resourceHelper.gs(R.string.key_uel_closed_loop_mode)) sp.putString(R.string.key_aps_mode, "closed") rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.closedloop))) return true } R.id.overview_lgsloop -> { - uel.log("LGS LOOP MODE") + uel.log(resourceHelper.gs(R.string.key_uel_lgs_loop_mode)) sp.putString(R.string.key_aps_mode, "lgs") rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend))) return true } R.id.overview_openloop -> { - uel.log("OPEN LOOP MODE") + uel.log(resourceHelper.gs(R.string.key_uel_open_loop_mode)) sp.putString(R.string.key_aps_mode, "open") rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend))) return true } R.id.overview_disable -> { - uel.log("LOOP DISABLED") + uel.log(resourceHelper.gs(R.string.key_uel_loop_disabled)) loopPlugin.setPluginEnabled(PluginType.LOOP, false) loopPlugin.setFragmentVisible(PluginType.LOOP, false) configBuilderPlugin.storeSettings("DisablingLoop") @@ -276,7 +276,7 @@ class LoopDialog : DaggerDialogFragment() { } R.id.overview_enable -> { - uel.log("LOOP ENABLED") + uel.log(resourceHelper.gs(R.string.key_uel_loop_enabled)) loopPlugin.setPluginEnabled(PluginType.LOOP, true) loopPlugin.setFragmentVisible(PluginType.LOOP, true) configBuilderPlugin.storeSettings("EnablingLoop") @@ -286,7 +286,7 @@ class LoopDialog : DaggerDialogFragment() { } R.id.overview_resume, R.id.overview_reconnect -> { - uel.log("RESUME") + uel.log(resourceHelper.gs(R.string.key_uel_resume)) loopPlugin.suspendTo(0L) rxBus.send(EventRefreshOverview("suspendmenu")) commandQueue.cancelTempBasal(true, object : Callback() { @@ -302,49 +302,49 @@ class LoopDialog : DaggerDialogFragment() { } R.id.overview_suspend_1h -> { - uel.log("SUSPEND 1h") + uel.log(resourceHelper.gs(R.string.key_uel_suspend_1h)) loopPlugin.suspendLoop(60) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_suspend_2h -> { - uel.log("SUSPEND 2h") + uel.log(resourceHelper.gs(R.string.key_uel_suspend_2h)) loopPlugin.suspendLoop(120) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_suspend_3h -> { - uel.log("SUSPEND 3h") + uel.log(resourceHelper.gs(R.string.key_uel_suspend_3h)) loopPlugin.suspendLoop(180) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_suspend_10h -> { - uel.log("SUSPEND 10h") + uel.log(resourceHelper.gs(R.string.key_uel_suspend_10h)) loopPlugin.suspendLoop(600) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_disconnect_15m -> { - uel.log("DISCONNECT 15m") + uel.log(resourceHelper.gs(R.string.key_uel_disconnect_15m)) loopPlugin.disconnectPump(15, profile) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_disconnect_30m -> { - uel.log("DISCONNECT 30m") + uel.log(resourceHelper.gs(R.string.key_uel_disconnect_30m)) loopPlugin.disconnectPump(30, profile) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_disconnect_1h -> { - uel.log("DISCONNECT 1h") + uel.log(resourceHelper.gs(R.string.key_uel_disconnect_1h)) loopPlugin.disconnectPump(60, profile) sp.putBoolean(R.string.key_objectiveusedisconnect, true) rxBus.send(EventRefreshOverview("suspendmenu")) @@ -352,14 +352,14 @@ class LoopDialog : DaggerDialogFragment() { } R.id.overview_disconnect_2h -> { - uel.log("DISCONNECT 2h") + uel.log(resourceHelper.gs(R.string.key_uel_disconnect_2h)) loopPlugin.disconnectPump(120, profile) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_disconnect_3h -> { - uel.log("DISCONNECT 3h") + uel.log(resourceHelper.gs(R.string.key_uel_disconnect_3h)) loopPlugin.disconnectPump(180, profile) rxBus.send(EventRefreshOverview("suspendmenu")) return true diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt index c4ed84ba45..ff7136b296 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt @@ -124,7 +124,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { - uel.log("PROFILE SWITCH", d1 = percent.toDouble(), i1 = timeShift, i2 = duration) + uel.log(resourceHelper.gs(R.string.key_uel_profile_switch), d1 = percent.toDouble(), i1 = timeShift, i2 = duration) treatmentsPlugin.doProfileSwitch(profileStore, profile, duration, percent, timeShift, eventTime) }) } diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt index b72625a664..385ab061e2 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt @@ -125,10 +125,10 @@ class TempBasalDialog : DialogFragmentWithDate() { } } if (isPercentPump) { - uel.log("TEMP BASAL", d1 = percent.toDouble(), i1 = durationInMinutes) + uel.log(resourceHelper.gs(R.string.key_uel_temp_basal), d1 = percent.toDouble(), i1 = durationInMinutes) commandQueue.tempBasalPercent(percent, durationInMinutes, true, profile, callback) } else { - uel.log("TEMP BASAL", d1 = absolute, i1 = durationInMinutes) + uel.log(resourceHelper.gs(R.string.key_uel_temp_basal), d1 = absolute, i1 = durationInMinutes) commandQueue.tempBasalAbsolute(absolute, durationInMinutes, true, profile, callback) } }) 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 fbe5123035..c7d384a7f1 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt @@ -164,7 +164,7 @@ class TempTargetDialog : DialogFragmentWithDate() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { - uel.log("TT", d1 = target, i1 = duration) + uel.log(resourceHelper.gs(R.string.key_uel_tt), d1 = target, i1 = duration) if (target == 0.0 || duration == 0) { val tempTarget = TempTarget() .date(eventTime) 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 fe45d727a2..14c106b416 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt @@ -129,7 +129,7 @@ class TreatmentDialog : DialogFragmentWithDate() { if (insulinAfterConstraints > 0 || carbsAfterConstraints > 0) { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_treatment_label), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { - uel.log("TREATMENT", d1 = insulin, i1 = carbs) + uel.log(resourceHelper.gs(R.string.key_uel_treatment), d1 = insulin, i1 = carbs) val detailedBolusInfo = DetailedBolusInfo() if (insulinAfterConstraints == 0.0) detailedBolusInfo.eventType = CareportalEvent.CARBCORRECTION if (carbsAfterConstraints == 0) detailedBolusInfo.eventType = CareportalEvent.CORRECTIONBOLUS 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 3f54b6e616..09833a74f3 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 @@ -142,7 +142,7 @@ class ConfigBuilderPlugin @Inject constructor( OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.allow_hardware_pump_text), Runnable { performPluginSwitch(changedPlugin, newState, type) sp.putBoolean("allow_hardware_pump", true) - uel.log("HW PUMP ALLOWED") + uel.log(resourceHelper.gs(R.string.key_uel_hw_pump_allowed)) aapsLogger.debug(LTag.PUMP, "First time HW pump allowed!") }, Runnable { rxBus.send(EventConfigBuilderUpdateGui()) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt index 63c1719a45..ae30d34530 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt @@ -307,7 +307,7 @@ class ObjectivesFragment : DaggerFragment() { holder.binding.unstart.setOnClickListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.objectives), resourceHelper.gs(R.string.doyouwantresetstart), Runnable { - uel.log("OBJECTIVE UNSTARTED", i1 = position + 1) + uel.log(resourceHelper.gs(R.string.key_uel_objective_unstarted), i1 = position + 1) objective.startedOn = 0 scrollToCurrentObjective() rxBus.send(EventObjectivesUpdateGui()) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt index 561760abe7..ad7fb6a7d9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt @@ -142,7 +142,7 @@ class ObjectivesPlugin @Inject constructor( sp.putLong("Objectives_" + "auto" + "_accomplished", DateUtil.now()) setupObjectives() OKDialog.show(activity, resourceHelper.gs(R.string.objectives), resourceHelper.gs(R.string.codeaccepted)) - uel.log("OBJECTIVES SKIPPED") + uel.log(resourceHelper.gs(R.string.key_uel_objectives_skipped)) } else { OKDialog.show(activity, resourceHelper.gs(R.string.objectives), resourceHelper.gs(R.string.codeinvalid)) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt index b0a28f92b2..500016399a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt @@ -154,7 +154,7 @@ class ActionsFragment : DaggerFragment() { } extendedBolusCancel?.setOnClickListener { if (activePlugin.activeTreatments.isInHistoryExtendedBoluslInProgress) { - uel.log("CANCEL EXTENDED BOLUS") + uel.log(resourceHelper.gs(R.string.key_uel_cancel_extended_bolus)) commandQueue.cancelExtended(object : Callback() { override fun run() { if (!result.success) { @@ -169,7 +169,7 @@ class ActionsFragment : DaggerFragment() { } cancelTempBasal?.setOnClickListener { if (activePlugin.activeTreatments.isTempBasalInProgress) { - uel.log("CANCEL TEMP BASAL") + uel.log(resourceHelper.gs(R.string.key_uel_cancel_temp_basal)) commandQueue.cancelTempBasal(true, object : Callback() { override fun run() { if (!result.success) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt index 31819ac0bb..45f7c04236 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt @@ -216,7 +216,7 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener { holder.binding.iconTrash.setOnClickListener { OKDialog.showConfirmation(requireContext(), resourceHelper.gs(R.string.removerecord) + " " + automationPlugin.at(position).title, { - uel.log("AUTOM REMOVED", automationPlugin.at(position).title) + uel.log(resourceHelper.gs(R.string.key_uel_autom_removed), automationPlugin.at(position).title) automationPlugin.removeAt(position) notifyItemRemoved(position) }, { @@ -239,7 +239,7 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord) + " " + automationPlugin.at(position).title, Runnable { - uel.log("AUTOM REMOVED", automationPlugin.at(position).title) + uel.log(resourceHelper.gs(R.string.key_uel_autom_removed), automationPlugin.at(position).title) automationPlugin.removeAt(position) notifyItemRemoved(position) rxBus.send(EventAutomationDataChanged()) 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 fe08c9a3ab..316667838a 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 @@ -216,7 +216,7 @@ class FoodFragment : DaggerFragment() { val food = v.tag as Food activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.confirmation), resourceHelper.gs(R.string.removerecord) + "\n" + food.name, DialogInterface.OnClickListener { _: DialogInterface?, _: Int -> - uel.log("FOOD REMOVED", food.name) + uel.log(resourceHelper.gs(R.string.key_uel_food_removed), food.name) if (food._id != null && food._id != "") { nsUpload.removeFoodFromNS(food._id) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt index 98fc711d25..4108668a97 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt @@ -344,7 +344,7 @@ class ImportExportPrefs @Inject constructor( private fun restartAppAfterImport(context: Context) { sp.putBoolean(R.string.key_setupwizard_processed, true) OKDialog.show(context, resourceHelper.gs(R.string.setting_imported), resourceHelper.gs(R.string.restartingapp), Runnable { - uel.log("IMPORT") + uel.log(resourceHelper.gs(R.string.key_uel_import)) log.debug(LTag.CORE, "Exiting") rxBus.send(EventAppExit()) if (context is AppCompatActivity) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenanceFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenanceFragment.kt index 7f44689ebc..c26cd1665c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenanceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenanceFragment.kt @@ -56,13 +56,13 @@ class MaintenanceFragment : DaggerFragment() { super.onViewCreated(view, savedInstanceState) binding.logSend.setOnClickListener { maintenancePlugin.sendLogs() } binding.logDelete.setOnClickListener { - uel.log("DELETE LOGS") + uel.log(resourceHelper.gs(R.string.key_uel_delete_logs)) maintenancePlugin.deleteLogs() } binding.navResetdb.setOnClickListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.maintenance), resourceHelper.gs(R.string.reset_db_confirm), Runnable { - uel.log("RESET DATABASES") + uel.log(resourceHelper.gs(R.string.key_uel_reset_databases)) compositeDisposable.add( fromAction { MainApp.getDbHelper().resetDatabases() @@ -83,14 +83,14 @@ class MaintenanceFragment : DaggerFragment() { } } binding.navExport.setOnClickListener { - uel.log("EXPORT SETTINGS") + uel.log(resourceHelper.gs(R.string.key_uel_export_settings)) // start activity for checking permissions... importExportPrefs.verifyStoragePermissions(this) { importExportPrefs.exportSharedPreferences(this) } } binding.navImport.setOnClickListener { - uel.log("IMPORT SETTINGS") + uel.log(resourceHelper.gs(R.string.key_uel_import_settings)) // start activity for checking permissions... importExportPrefs.verifyStoragePermissions(this) { importExportPrefs.importSharedPreferences(this) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientFragment.java index 58bacbbf4c..4b1464f213 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientFragment.java @@ -123,7 +123,7 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList break; case R.id.nsclientinternal_clearqueue: OKDialog.showConfirmation(getContext(), resourceHelper.gs(R.string.nsclientinternal), resourceHelper.gs(R.string.clearqueueconfirm), () -> { - uel.log("NS QUEUE CLEARED", "", 0.0, 0.0, 0, 0); + uel.log(resourceHelper.gs(R.string.key_uel_ns_queue_cleared), "", 0.0, 0.0, 0, 0); uploadQueue.clearQueue(); updateGui(); fabricPrivacy.logCustom("NSClientClearQueue"); @@ -139,7 +139,7 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { switch (buttonView.getId()) { case R.id.nsclientinternal_paused: - uel.log("NS PAUSED", "", 0.0, 0.0, isChecked ? 1 : 0, 0); + uel.log(resourceHelper.gs(R.string.key_uel_ns_paused), "", 0.0, 0.0, isChecked ? 1 : 0, 0); nsClientPlugin.pause(isChecked); updateGui(); fabricPrivacy.logCustom("NSClientPause"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSSettingsStatus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSSettingsStatus.kt index fe53640252..291f735e61 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSSettingsStatus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSSettingsStatus.kt @@ -235,7 +235,7 @@ class NSSettingsStatus @Inject constructor( getExtendedWarnValue("sage", "urgent")?.let { sp.putDouble(R.string.key_statuslights_sage_critical, it) } getExtendedWarnValue("bage", "warn")?.let { sp.putDouble(R.string.key_statuslights_bage_warning, it) } getExtendedWarnValue("bage", "urgent")?.let { sp.putDouble(R.string.key_statuslights_bage_critical, it) } - uel.log("NS SETTINGS COPIED") + uel.log(resourceHelper.gs(R.string.key_uel_ns_settings_copied)) } if (context != null) OKDialog.showConfirmation(context, resourceHelper.gs(R.string.statuslights), resourceHelper.gs(R.string.copyexistingvalues), action) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt index 7dd0ea848a..efb4b9d8bc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt @@ -342,7 +342,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.tempbasal_label), lastRun.constraintsProcessed?.toSpanned() ?: "".toSpanned(), { - uel.log("ACCEPT TEMP BASAL") + uel.log(resourceHelper.gs(R.string.key_uel_accepts_temp_basal)) binding.buttonsLayout.acceptTempButton.visibility = View.GONE (context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).cancel(Constants.notificationID) rxBus.send(EventWearDoAction("cancelChangeRequest")) 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 c44460c604..0bcb37d67c 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 @@ -337,7 +337,7 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - uel.log("SMS LOOP DISABLE") + uel.log(resourceHelper.gs(R.string.key_uel_sms_loop_disable)) loopPlugin.setPluginEnabled(PluginType.LOOP, false) commandQueue.cancelTempBasal(true, object : Callback() { override fun run() { @@ -361,7 +361,7 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - uel.log("SMS LOOP ENABLE") + uel.log(resourceHelper.gs(R.string.key_uel_sms_loop_enable)) loopPlugin.setPluginEnabled(PluginType.LOOP, true) sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_loophasbeenenabled))) rxBus.send(EventRefreshOverview("SMS_LOOP_START")) @@ -388,7 +388,7 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - uel.log("SMS LOOP RESUME") + uel.log(resourceHelper.gs(R.string.key_uel_sms_loop_resume)) loopPlugin.suspendTo(0L) rxBus.send(EventRefreshOverview("SMS_LOOP_RESUME")) commandQueue.cancelTempBasal(true, object : Callback() { @@ -421,7 +421,7 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(duration) { override fun run() { - uel.log("SMS LOOP SUSPEND") + uel.log(resourceHelper.gs(R.string.key_uel_sms_loop_suspend)) commandQueue.cancelTempBasal(true, object : Callback() { override fun run() { if (result.success) { @@ -505,7 +505,7 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - uel.log("SMS PUMP CONNECT") + uel.log(resourceHelper.gs(R.string.key_uel_sms_pump_connect)) commandQueue.cancelTempBasal(true, object : Callback() { override fun run() { if (!result.success) { @@ -534,7 +534,7 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - uel.log("SMS PUMP DISCONNECT") + uel.log(resourceHelper.gs(R.string.key_uel_sms_pump_disconnect)) val profile = profileFunction.getProfile() loopPlugin.disconnectPump(duration, profile) rxBus.send(EventRefreshOverview("SMS_PUMP_DISCONNECT")) @@ -591,7 +591,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("SMS PROFILE", replyText) + uel.log(resourceHelper.gs(R.string.key_uel_sms_profile), replyText) } }) } @@ -613,12 +613,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("SMS BASAL", replyText) + uel.log(resourceHelper.gs(R.string.key_uel_sms_basal), replyText) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalcancelfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log("SMS BASAL", replyText) + uel.log(resourceHelper.gs(R.string.key_uel_sms_basal), replyText) } } }) @@ -646,12 +646,12 @@ class SmsCommunicatorPlugin @Inject constructor( var replyText = if (result.isPercent) String.format(resourceHelper.gs(R.string.smscommunicator_tempbasalset_percent), result.percent, result.duration) else String.format(resourceHelper.gs(R.string.smscommunicator_tempbasalset), result.absolute, result.duration) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log("SMS BASAL", replyText) + uel.log(resourceHelper.gs(R.string.key_uel_sms_basal), replyText) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log("SMS BASAL", replyText) + uel.log(resourceHelper.gs(R.string.key_uel_sms_basal), replyText) } } }) @@ -681,12 +681,12 @@ class SmsCommunicatorPlugin @Inject constructor( else String.format(resourceHelper.gs(R.string.smscommunicator_tempbasalset), result.absolute, result.duration) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log("SMS BASAL", replyText) + uel.log(resourceHelper.gs(R.string.key_uel_sms_basal), replyText) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log("SMS BASAL", replyText) + uel.log(resourceHelper.gs(R.string.key_uel_sms_basal), replyText) } } }) @@ -713,7 +713,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("SMS EXTENDED", replyText) + uel.log(resourceHelper.gs(R.string.key_uel_sms_extended), replyText) } } }) @@ -739,12 +739,12 @@ class SmsCommunicatorPlugin @Inject constructor( if (config.APS) replyText += "\n" + resourceHelper.gs(R.string.loopsuspended) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log("SMS EXTENDED", replyText) + uel.log(resourceHelper.gs(R.string.key_uel_sms_extended), replyText) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_extendedfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log("SMS EXTENDED", replyText) + uel.log(resourceHelper.gs(R.string.key_uel_sms_extended), replyText) } } }) @@ -813,12 +813,12 @@ class SmsCommunicatorPlugin @Inject constructor( } } sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log("SMS BOLUS", replyText) + uel.log(resourceHelper.gs(R.string.key_uel_sms_bolus), replyText) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_bolusfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log("SMS BOLUS", replyText) + uel.log(resourceHelper.gs(R.string.key_uel_sms_bolus), replyText) } } }) @@ -858,12 +858,12 @@ class SmsCommunicatorPlugin @Inject constructor( var replyText = String.format(resourceHelper.gs(R.string.smscommunicator_carbsset), anInteger) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log("SMS CARBS", replyText) + uel.log(resourceHelper.gs(R.string.key_uel_sms_carbs), replyText) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_carbsfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log("SMS CARBS", replyText) + uel.log(resourceHelper.gs(R.string.key_uel_sms_carbs), replyText) } } }) @@ -872,7 +872,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("SMS CARBS", replyText) + uel.log(resourceHelper.gs(R.string.key_uel_sms_carbs), replyText) } } }) @@ -937,7 +937,7 @@ class SmsCommunicatorPlugin @Inject constructor( val ttString = if (units == Constants.MMOL) DecimalFormatter.to1Decimal(tt) else DecimalFormatter.to0Decimal(tt) val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_tt_set), ttString, ttDuration) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log("SMS TARGET", replyText) + uel.log(resourceHelper.gs(R.string.key_uel_sms_target), replyText) } }) } else if (isStop) { @@ -955,7 +955,7 @@ class SmsCommunicatorPlugin @Inject constructor( activePlugin.activeTreatments.addToHistoryTempTarget(tempTarget) val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_tt_canceled)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log("SMS TARGET", reply) + uel.log(resourceHelper.gs(R.string.key_uel_sms_target), reply) } }) } else @@ -974,7 +974,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("SMS SMS", replyText) + uel.log(resourceHelper.gs(R.string.key_uel_sms_sms), replyText) } }) } else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat))) @@ -992,7 +992,7 @@ class SmsCommunicatorPlugin @Inject constructor( val replyText = if (result) resourceHelper.gs(R.string.smscommunicator_calibrationsent) else resourceHelper.gs(R.string.smscommunicator_calibrationfailed) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log("SMS CAL", replyText) + uel.log(resourceHelper.gs(R.string.key_uel_sms_cal), replyText) } }) } else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat))) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt index 162c128c58..45f1a77579 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt @@ -72,7 +72,7 @@ class SmsCommunicatorOtpActivity : NoSplashAppCompatActivity() { resourceHelper.gs(R.string.smscommunicator_otp_reset_title), resourceHelper.gs(R.string.smscommunicator_otp_reset_prompt), Runnable { - uel.log("OTP RESET") + uel.log(resourceHelper.gs(R.string.key_uel_otp_reset)) otp.ensureKey(true) updateGui() ToastUtils.Long.infoToast(this, resourceHelper.gs(R.string.smscommunicator_otp_reset_successful)) @@ -88,7 +88,7 @@ class SmsCommunicatorOtpActivity : NoSplashAppCompatActivity() { val clip = ClipData.newPlainText("OTP Secret", otp.provisioningSecret()) clipboard.primaryClip = clip ToastUtils.Long.infoToast(this, resourceHelper.gs(R.string.smscommunicator_otp_export_successful)) - uel.log("OTP EXPORT") + uel.log(resourceHelper.gs(R.string.key_uel_otp_export)) }) true diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt index 368df27e4b..c5dd68f18c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt @@ -162,7 +162,7 @@ class LocalProfileFragment : DaggerFragment() { if (localProfilePlugin.isEdited) { activity?.let { OKDialog.show(it, "", resourceHelper.gs(R.string.saveorresetchangesfirst)) } } else { - uel.log("NEW PROFILE") + uel.log(resourceHelper.gs(R.string.key_new_profile)) localProfilePlugin.addNewProfile() build() } @@ -172,7 +172,7 @@ class LocalProfileFragment : DaggerFragment() { if (localProfilePlugin.isEdited) { activity?.let { OKDialog.show(it, "", resourceHelper.gs(R.string.saveorresetchangesfirst)) } } else { - uel.log("CLONE PROFILE", localProfilePlugin.currentProfile()?.name ?: "") + uel.log(resourceHelper.gs(R.string.key_uel_clone_profile), localProfilePlugin.currentProfile()?.name ?: "") localProfilePlugin.cloneProfile() build() } @@ -181,7 +181,7 @@ class LocalProfileFragment : DaggerFragment() { binding.profileRemove.setOnClickListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.deletecurrentprofile), { - uel.log("REMOVE PROFILE", localProfilePlugin.currentProfile()?.name ?: "") + uel.log(resourceHelper.gs(R.string.key_uel_remove_profile), localProfilePlugin.currentProfile()?.name ?: "") localProfilePlugin.removeCurrentProfile() build() }, null) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt index e8d5dba65d..0c97939a51 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt @@ -115,7 +115,7 @@ class LocalProfilePlugin @Inject constructor( createAndStoreConvertedProfile() isEdited = false aapsLogger.debug(LTag.PROFILE, "Storing settings: " + rawProfile?.data.toString()) - uel.log("STORE PROFILE") + uel.log(resourceHelper.gs(R.string.key_uel_store_profile)) rxBus.send(EventProfileStoreChanged()) var namesOK = true profiles.forEach { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfileFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfileFragment.kt index f8c8c0ed25..6ba247ab14 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfileFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfileFragment.kt @@ -61,7 +61,7 @@ class NSProfileFragment : DaggerFragment() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.nsprofile), resourceHelper.gs(R.string.activate_profile) + ": " + name + " ?", Runnable { - uel.log("PROFILE SWITCH", name, i1 = 100) + uel.log(resourceHelper.gs(R.string.key_uel_profile_switch), name, i1 = 100) treatmentsPlugin.doProfileSwitch(store, name, 0, 100, 0, DateUtil.now()) }) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt index 07038a50e5..7303b90d50 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt @@ -128,7 +128,7 @@ class BGSourceFragment : DaggerFragment() { activity?.let { activity -> val text = dateUtil.dateAndTimeString(glucoseValue.timestamp) + "\n" + glucoseValue.valueToUnitsString(profileFunction.getUnits()) OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable { - uel.log("BG REMOVED", dateUtil.dateAndTimeString(glucoseValue.timestamp)) + uel.log(resourceHelper.gs(R.string.key_uel_bg_removed), dateUtil.dateAndTimeString(glucoseValue.timestamp)) disposable += repository.runTransaction(InvalidateGlucoseValueTransaction(glucoseValue.id)).subscribe() }) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt index d830ca5414..2f81401713 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt @@ -68,7 +68,7 @@ class TreatmentsBolusFragment : DaggerFragment() { binding.refreshFromNightscout.setOnClickListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.refresheventsfromnightscout) + "?") { - uel.log("TREAT NS REFRESH") + uel.log(resourceHelper.gs(R.string.key_uel_treat_ns_refresh)) treatmentsPlugin.service.resetTreatments() rxBus.send(EventNSClientRestart()) } @@ -77,7 +77,7 @@ class TreatmentsBolusFragment : DaggerFragment() { binding.deleteFutureTreatments.setOnClickListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_treatment_label), resourceHelper.gs(R.string.deletefuturetreatments) + "?", Runnable { - uel.log("DELETE FUTURE TREATMENTS") + uel.log(resourceHelper.gs(R.string.key_uel_delete_future_treatments)) val futureTreatments = treatmentsPlugin.service.getTreatmentDataFromTime(DateUtil.now() + 1000, true) for (treatment in futureTreatments) { if (NSUpload.isIdValid(treatment._id)) @@ -174,7 +174,7 @@ class TreatmentsBolusFragment : DaggerFragment() { resourceHelper.gs(R.string.carbs) + ": " + resourceHelper.gs(R.string.format_carbs, treatment.carbs.toInt()) + "\n" + resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(treatment.date) OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable { - uel.log("REMOVED TREATMENT", text) + uel.log(resourceHelper.gs(R.string.key_uel_removed_treatment), text) if (treatment.source == Source.PUMP) { treatment.isValid = false treatmentsPlugin.service.update(treatment) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsCareportalFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsCareportalFragment.kt index 58269316be..f2f28be3b0 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 @@ -64,7 +64,7 @@ class TreatmentsCareportalFragment : DaggerFragment() { binding.refreshFromNightscout.setOnClickListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal), resourceHelper.gs(R.string.refresheventsfromnightscout) + " ?", Runnable { - uel.log("CAREPORTAL NS REFRESH") + uel.log(resourceHelper.gs(R.string.key_uel_careportal_ns_refresh)) MainApp.getDbHelper().resetCareportalEvents() rxBus.send(EventNSClientRestart()) }) @@ -73,7 +73,7 @@ class TreatmentsCareportalFragment : DaggerFragment() { binding.removeAndroidapsStartedEvents.setOnClickListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal), resourceHelper.gs(R.string.careportal_removestartedevents), Runnable { - uel.log("REMOVED RESTART EVENTS") + uel.log(resourceHelper.gs(R.string.key_uel_removed_restart_events)) val events = MainApp.getDbHelper().getCareportalEvents(false) for (i in events.indices) { val careportalEvent = events[i] @@ -154,7 +154,7 @@ class TreatmentsCareportalFragment : DaggerFragment() { resourceHelper.gs(R.string.careportal_newnstreatment_notes_label) + ": " + careportalEvent.notes + "\n" + resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(careportalEvent.date) OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable { - uel.log("REMOVED CAREP", text) + uel.log(resourceHelper.gs(R.string.key_uel_removed_carep), text) if (NSUpload.isIdValid(careportalEvent._id)) nsUpload.removeCareportalEntryFromNS(careportalEvent._id) else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt index e223fd150a..3cc7fb734e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt @@ -121,7 +121,7 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() { ${resourceHelper.gs(R.string.extended_bolus)} ${resourceHelper.gs(R.string.date)}: ${dateUtil.dateAndTimeString(extendedBolus.date)} """.trimIndent(), { _: DialogInterface, _: Int -> - uel.log("REMOVED EB") + uel.log(resourceHelper.gs(R.string.key_uel_removed_eb)) val id = extendedBolus._id if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id) else uploadQueue.removeID("dbAdd", id) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt index 1d7ba6041d..c282053c4c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt @@ -69,7 +69,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() { binding.refreshFromNightscout.setOnClickListener { activity?.let { activity -> - uel.log("PROFILE SWITCH NS REFRESH") + uel.log(resourceHelper.gs(R.string.key_uel_profile_switch_ns_refresh)) OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.refresheventsfromnightscout) + "?") { MainApp.getDbHelper().resetProfileSwitch() rxBus.send(EventNSClientRestart()) @@ -146,7 +146,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), resourceHelper.gs(R.string.careportal_profileswitch) + ": " + profileSwitch.profileName + "\n" + resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(profileSwitch.date), Runnable { - uel.log("REMOVED PROFILE SWITCH", profileSwitch.profileName + " " + dateUtil.dateAndTimeString(profileSwitch.date)) + uel.log(resourceHelper.gs(R.string.key_uel_removed_profile_switch), profileSwitch.profileName + " " + dateUtil.dateAndTimeString(profileSwitch.date)) val id = profileSwitch._id if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id) else uploadQueue.removeID("dbAdd", id) @@ -159,7 +159,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() { val profileSwitch = it.tag as ProfileSwitch OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), resourceHelper.gs(R.string.copytolocalprofile) + "\n" + profileSwitch.customizedName + "\n" + dateUtil.dateAndTimeString(profileSwitch.date), Runnable { profileSwitch.profileObject?.let { - uel.log("PROFILE SWITCH CLONE", profileSwitch.profileName + " " + dateUtil.dateAndTimeString(profileSwitch.date)) + uel.log(resourceHelper.gs(R.string.key_uel_profile_switch_clone), profileSwitch.profileName + " " + dateUtil.dateAndTimeString(profileSwitch.date)) val nonCustomized = it.convertToNonCustomizedProfile() if (nonCustomized.isValid(resourceHelper.gs(R.string.careportal_profileswitch, false))) { localProfilePlugin.addProfile(localProfilePlugin.copyFrom(nonCustomized, profileSwitch.customizedName + " " + dateUtil.dateAndTimeString(profileSwitch.date).replace(".", "_"))) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt index 3265275e36..b6eb9a05bf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt @@ -69,7 +69,7 @@ class TreatmentsTempTargetFragment : DaggerFragment() { binding.refreshFromNightscout.setOnClickListener { context?.let { context -> OKDialog.showConfirmation(context, resourceHelper.gs(R.string.refresheventsfromnightscout) + " ?", { - uel.log("TT NS REFRESH") + uel.log(resourceHelper.gs(R.string.key_uel_tt_ns_refresh)) MainApp.getDbHelper().resetTempTargets() rxBus.send(EventNSClientRestart()) }) @@ -161,7 +161,7 @@ class TreatmentsTempTargetFragment : DaggerFragment() { ${dateUtil.dateAndTimeString(tempTarget.date)} """.trimIndent(), { _: DialogInterface?, _: Int -> - uel.log("TT REMOVE", tempTarget.friendlyDescription(profileFunction.getUnits(), resourceHelper)) + uel.log(resourceHelper.gs(R.string.key_uel_tt_remove), tempTarget.friendlyDescription(profileFunction.getUnits(), resourceHelper)) val id = tempTarget._id if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id) else uploadQueue.removeID("dbAdd", id) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt index b17933471c..e6361768b3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt @@ -163,7 +163,7 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() { ${resourceHelper.gs(R.string.date)}: ${dateUtil.dateAndTimeString(tempBasal.date)} """.trimIndent(), { _: DialogInterface?, _: Int -> - uel.log("REMOVED TT", dateUtil.dateAndTimeString(tempBasal.date)) + uel.log(resourceHelper.gs(R.string.key_uel_removed_tt), dateUtil.dateAndTimeString(tempBasal.date)) activePlugin.activeTreatments.removeTempBasal(tempBasal) }, null) } 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 37fccabd8c..a5977f9e79 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 @@ -346,7 +346,7 @@ class BolusWizard @Inject constructor( boluscalc = nsJSON() source = Source.USER notes = this@BolusWizard.notes - uel.log("BOLUS ADVISOR", d1 = insulinAfterConstraints) + uel.log(resourceHelper.gs(R.string.key_uel_bolus_advisor), d1 = insulinAfterConstraints) if (insulin > 0) { commandQueue.bolus(this, object : Callback() { override fun run() { @@ -369,7 +369,7 @@ class BolusWizard @Inject constructor( OKDialog.showConfirmation(ctx, resourceHelper.gs(R.string.boluswizard), confirmMessage, { if (insulinAfterConstraints > 0 || carbs > 0) { if (useSuperBolus) { - uel.log("SUPERBOLUS TBR") + uel.log(resourceHelper.gs(R.string.key_uel_superbolus_tbr)) if (loopPlugin.isEnabled(PluginType.LOOP)) { loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000) rxBus.send(EventRefreshOverview("WizardDialog")) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9c0acd512a..7e096d3696 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1382,4 +1382,90 @@ User entry Use values of your largest food you usually eat\n + STATS RESET + CALIBRATION + TT ACTIVITY + TT EATING SOON + TT HYPO + CARBS + CAREPORTAL + EXTENDED BOLUS + PRIME BOLUS + SITE CHANGE + INSULIN CHANGE + BOLUS RECORD + BOLUS + CLOSED LOOP MODE + LGS LOOP MODE + OPEN LOOP MODE + LOOP DISABLED + LOOP ENABLED + RESUME + RECONNECT + SUSPEND 1h + SUSPEND 2h + SUSPEND 3h + SUSPEND 10h + DISCONNECT 15m + DISCONNECT 30m + DISCONNECT 1h + DISCONNECT 2h + DISCONNECT 3h + PROFILE SWITCH + TEMP BASAL + TT + TREATMENT + OBJECTIVE UNSTARTED + CANCEL EXTENDED BOLUS + CANCEL TEMP BASAL + AUTOM REMOVED + FOOD REMOVED + DELETE LOGS + RESET DATABASES + EXPORT SETTINGS + IMPORT SETTINGS + ACCEPT TEMP BASAL + OTP RESET + OTP EXPORT + NEW PROFILE + CLONE PROFILE + REMOVE PROFILE + BG REMOVED + TREAT NS REFRESH + DELETE FUTURE TREATMENTS + REMOVED TREATMENT + CAREPORTAL NS REFRESH + REMOVED RESTART EVENTS + REMOVED CAREP + REMOVED EB + PROFILE SWITCH NS REFRESH + REMOVED PROFILE SWITCH + PROFILE SWITCH CLONE + REMOVED TT + TT NS REFRESH + TT REMOVE + BOLUS ADVISOR + SUPERBOLUS TBR + NS QUEUE CLEARED + NS PAUSED + HW PUMP ALLOWED + OBJECTIVES SKIPPED + IMPORT + NS SETTINGS COPIED + SMS LOOP DISABLE + SMS LOOP ENABLE + SMS LOOP RESUME + SMS LOOP SUSPEND + SMS PUMP CONNECT + SMS PUMP DISCONNECT + SMS PROFILE + SMS BASAL + SMS EXTENDED + SMS BOLUS + SMS CARBS + SMS TARGET + SMS SMS + SMS CAL + STORE PROFILE + diff --git a/core/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt b/core/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt index 110096c0bd..071a061d5e 100644 --- a/core/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt +++ b/core/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt @@ -15,12 +15,14 @@ import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.services.AlarmSoundServiceHelper import info.nightscout.androidaps.utils.T +import info.nightscout.androidaps.utils.resources.ResourceHelper import javax.inject.Inject class ErrorDialog : DaggerDialogFragment() { @Inject lateinit var alarmSoundServiceHelper: AlarmSoundServiceHelper @Inject lateinit var aapsLogger: AAPSLogger + @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var uel: UserEntryLogger var helperActivity: ErrorHelperActivity? = null @@ -58,15 +60,15 @@ class ErrorDialog : DaggerDialogFragment() { binding.title.text = title binding.ok.setOnClickListener { - uel.log("Error dialog ok button pressed") + uel.log(resourceHelper.gs(R.string.key_uel_error_dialog_ok)) dismiss() } binding.mute.setOnClickListener { - uel.log("Error dialog mute button pressed") + uel.log(resourceHelper.gs(R.string.key_uel_error_dialog_mute)) stopAlarm() } binding.mute5min.setOnClickListener { - uel.log("Error dialog mute 5 min button pressed") + uel.log(resourceHelper.gs(R.string.key_uel_error_dialog_mute_5min)) stopAlarm() loopHandler.postDelayed(this::startAlarm, T.mins(5).msecs()) } diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 7d22c30592..6131a51226 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -30,8 +30,14 @@ virtualpump_type QuickWizard wearcontrol + ERROR DIALOG OK + ERROR DIALOG MUTE + ERROR DIALOG MUTE 5MIN + Error dialog ok pressed + Error dialog mute pressed + Error dialog mute 5 min pressed Refresh Error Not set diff --git a/dana/src/main/java/info/nightscout/androidaps/dana/DanaFragment.kt b/dana/src/main/java/info/nightscout/androidaps/dana/DanaFragment.kt index 1fca6ed5ef..d40f6beded 100644 --- a/dana/src/main/java/info/nightscout/androidaps/dana/DanaFragment.kt +++ b/dana/src/main/java/info/nightscout/androidaps/dana/DanaFragment.kt @@ -108,7 +108,7 @@ class DanaFragment : DaggerFragment() { binding.btconnection.setOnLongClickListener { activity?.let { OKDialog.showConfirmation(it, resourceHelper.gs(R.string.resetpairing)) { - uel.log("CLEAR PAIRING KEYS") + uel.log(resourceHelper.gs(R.string.key_uel_clear_pairing_keys)) (activePlugin.activePump as DanaPumpInterface).clearPairing() } } diff --git a/dana/src/main/res/values/strings.xml b/dana/src/main/res/values/strings.xml index c6ec142c94..84ff82e413 100644 --- a/dana/src/main/res/values/strings.xml +++ b/dana/src/main/res/values/strings.xml @@ -13,6 +13,7 @@ rs_loginsulinchange rs_last_clear_key_request danar_bt_name + CLEAR PAIRING KEYS Pairing No device found so far From 73ebc000856d58bd6ff74c0e41baa3dd327e1b89 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sat, 20 Feb 2021 20:25:52 +0100 Subject: [PATCH 02/66] Fix key --- .../androidaps/plugins/profile/local/LocalProfileFragment.kt | 2 +- .../info/nightscout/androidaps/utils/wizard/BolusWizard.kt | 2 +- app/src/main/res/values/strings.xml | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt index c5dd68f18c..69ab8c1c72 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt @@ -162,7 +162,7 @@ class LocalProfileFragment : DaggerFragment() { if (localProfilePlugin.isEdited) { activity?.let { OKDialog.show(it, "", resourceHelper.gs(R.string.saveorresetchangesfirst)) } } else { - uel.log(resourceHelper.gs(R.string.key_new_profile)) + uel.log(resourceHelper.gs(R.string.key_uel_new_profile)) localProfilePlugin.addNewProfile() build() } 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 a5977f9e79..a579368ad3 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 @@ -410,7 +410,7 @@ class BolusWizard @Inject constructor( boluscalc = nsJSON() source = Source.USER notes = this@BolusWizard.notes - uel.log("BOLUS WIZARD", "", insulinAfterConstraints, carbs) + uel.log(resourceHelper.gs(R.string.key_uel_bolus_wizard), "", insulinAfterConstraints, carbs) 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 7e096d3696..327f81ee20 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1427,7 +1427,7 @@ ACCEPT TEMP BASAL OTP RESET OTP EXPORT - NEW PROFILE + NEW PROFILE CLONE PROFILE REMOVE PROFILE BG REMOVED @@ -1446,6 +1446,7 @@ TT REMOVE BOLUS ADVISOR SUPERBOLUS TBR + BOLUS WIZARD NS QUEUE CLEARED NS PAUSED HW PUMP ALLOWED From 865bc004c0c48288ab2a821fc2f3b818af24f552 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sat, 20 Feb 2021 20:26:27 +0100 Subject: [PATCH 03/66] Initialize Enum class for User Entry --- .../androidaps/database/entities/UserEntry.kt | 111 +++++++++++++++++- 1 file changed, 110 insertions(+), 1 deletion(-) 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 8bd711a82c..f31eb01021 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 @@ -19,4 +19,113 @@ data class UserEntry( var d2: Double, var i1: Int, var i2: Int -) : DBEntry, DBEntryWithTime \ No newline at end of file +) : DBEntry, DBEntryWithTime { + enum class Type { + BOLUS, + BOLUS_WIZARD, + BOLUS_ADVISOR, + BOLUS_RECORD, + EXTENDED_BOLUS, + SUPERBOLUS_TBR, + CARBS, + EXTENDED_CARBS, + TEMP_BASAL, + + TT, + TT_ACTIVITY, + TT_EATING_SOON, + TT_HYPO, + + NEW_PROFILE, + CLONE_PROFILE, + STORE_PROFILE, + PROFILE_SWITCH, + PROFILE_SWITCH_CLONE, + + CLOSED_LOOP_MODE, + LGS_LOOP_MODE, + OPEN_LOOP_MODE, + LOOP_DISABLED, + LOOP_ENABLED, + RECONNECT, + DISCONNECT_15M, + DISCONNECT_30M, + DISCONNECT_1H, + DISCONNECT_2H, + DISCONNECT_3H, + RESUME, + SUSPEND_1H, + SUSPEND_2H, + SUSPEND_3H, + SUSPEND_10H, + + HW_PUMP_ALLOWED, + CLEAR_PAIRING_KEYS, + ACCEPTS_TEMP_BASAL, + CANCEL_TEMP_BASAL, + CANCEL_EXTENDED_BOLUS, + CANCEL_TT, + + CAREPORTAL, + CALIBRATION, + INSULIN_CHANGE, + PRIME_BOLUS, + SITE_CHANGE, + + TREATMENT, + CAREPORTAL_NS_REFRESH, + PROFILE_SWITCH_NS_REFRESH, + TREATMENTS_NS_REFRESH, + TT_NS_REFRESH, + + AUTOMATION_REMOVED, + BG_REMOVED, + CAREPORTAL_REMOVED, + EXTENDED_BOLUS_REMOVED, + FOOD_REMOVED, + PROFILE_REMOVED, + PROFILE_SWITCH_REMOVED, + RESTART_EVENTS_REMOVED, + TREATMENT_REMOVED, + TT_REMOVED, + + NS_PAUSED, + NS_QUEUE_CLEARED, + NS_SETTINGS_COPIED, + + ERROR_DIALOG_OK, + ERROR_DIALOG_MUTE , + ERROR_DIALOG_MUTE_5MIN, + + OBJECTIVE_STARTED, + OBJECTIVE_UNSTARTED, + OBJECTIVES_SKIPPED, + + STAT_RESET, + + DELETE_LOGS, + DELETE_FUTURE_TREATMENTS, + EXPORT_SETTINGS, + IMPORT_SETTINGS, + RESET_DATABASES, + EXPORT_DATABASES, + IMPORT_DATABASES, + + OTP_EXPORT, + OTP_RESET, + SMS_BASAL, + SMS_BOLUS, + SMS_CAL, + SMS_CARBS, + SMS_EXTENDED_BOLUS, + SMS_LOOP_DISABLE, + SMS_LOOP_ENABLE, + SMS_LOOP_RESUME, + SMS_LOOP_SUSPEND, + SMS_PROFILE, + SMS_PUMP_CONNECT, + SMS_PUMP_DISCONNECT, + SMS_SMS, + SMS_TARGET + } +} \ No newline at end of file From 820566fa6251b7c75c3452075ad024138a21ee1c Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 21 Feb 2021 00:28:44 +0100 Subject: [PATCH 04/66] Switched to Enum class for UserEntryLogger --- .../androidaps/activities/StatsActivity.kt | 3 +- .../androidaps/dialogs/CalibrationDialog.kt | 3 +- .../androidaps/dialogs/CarbsDialog.kt | 11 ++-- .../androidaps/dialogs/CareDialog.kt | 3 +- .../androidaps/dialogs/ExtendedBolusDialog.kt | 3 +- .../androidaps/dialogs/FillDialog.kt | 7 +-- .../androidaps/dialogs/InsulinDialog.kt | 7 +-- .../androidaps/dialogs/LoopDialog.kt | 31 +++++------ .../androidaps/dialogs/ProfileSwitchDialog.kt | 3 +- .../androidaps/dialogs/TempBasalDialog.kt | 5 +- .../androidaps/dialogs/TempTargetDialog.kt | 3 +- .../androidaps/dialogs/TreatmentDialog.kt | 3 +- .../configBuilder/ConfigBuilderPlugin.kt | 3 +- .../objectives/ObjectivesFragment.kt | 3 +- .../objectives/ObjectivesPlugin.kt | 3 +- .../general/actions/ActionsFragment.kt | 5 +- .../general/automation/AutomationFragment.kt | 5 +- .../plugins/general/food/FoodFragment.kt | 3 +- .../general/maintenance/ImportExportPrefs.kt | 3 +- .../maintenance/MaintenanceFragment.kt | 9 ++-- .../general/nsclient/NSClientFragment.java | 5 +- .../general/nsclient/data/NSSettingsStatus.kt | 3 +- .../general/overview/OverviewFragment.kt | 3 +- .../smsCommunicator/SmsCommunicatorPlugin.kt | 51 ++++++++++--------- .../activities/SmsCommunicatorOtpActivity.kt | 5 +- .../profile/local/LocalProfileFragment.kt | 7 +-- .../profile/local/LocalProfilePlugin.kt | 3 +- .../plugins/profile/ns/NSProfileFragment.kt | 3 +- .../plugins/source/BGSourceFragment.kt | 3 +- .../fragments/TreatmentsBolusFragment.kt | 7 +-- .../fragments/TreatmentsCareportalFragment.kt | 7 +-- .../TreatmentsExtendedBolusesFragment.kt | 3 +- .../TreatmentsProfileSwitchFragment.kt | 7 +-- .../fragments/TreatmentsTempTargetFragment.kt | 5 +- .../TreatmentsTemporaryBasalsFragment.kt | 3 +- .../androidaps/utils/wizard/BolusWizard.kt | 7 +-- .../androidaps/dialogs/ErrorDialog.kt | 9 ++-- .../androidaps/logging/UserEntryLogger.kt | 3 +- dana/build.gradle | 1 + .../androidaps/dana/DanaFragment.kt | 3 +- .../androidaps/database/entities/UserEntry.kt | 12 ++--- .../transactions/UserEntryTransaction.kt | 2 +- 42 files changed, 153 insertions(+), 115 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt index 2f9afc895f..647c449f1a 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt @@ -2,6 +2,7 @@ package info.nightscout.androidaps.activities import android.os.Bundle import info.nightscout.androidaps.R +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.ActivityStatsBinding import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.utils.ActivityMonitor @@ -31,7 +32,7 @@ class StatsActivity : NoSplashAppCompatActivity() { binding.ok.setOnClickListener { finish() } binding.reset.setOnClickListener { OKDialog.showConfirmation(this, resourceHelper.gs(R.string.doyouwantresetstats)) { - uel.log(resourceHelper.gs(R.string.key_uel_stat_reset)) + uel.log(UserEntry.Action.STAT_RESET) activityMonitor.reset() recreate() } 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 14ebd600de..5e2b29dd03 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt @@ -9,6 +9,7 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile +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 @@ -77,7 +78,7 @@ class CalibrationDialog : DialogFragmentWithDate() { if (bg > 0) { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_calibration), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { - uel.log(resourceHelper.gs(R.string.key_uel_calibration), d1 = bg) + uel.log(UserEntry.Action.CALIBRATION, d1 = bg) xdripCalibrations.sendIntent(bg) }) } 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 fa9c17d4b9..f8a334f7b0 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt @@ -11,6 +11,7 @@ import info.nightscout.androidaps.Constants import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.DialogCarbsBinding import info.nightscout.androidaps.db.CareportalEvent import info.nightscout.androidaps.db.Source @@ -212,7 +213,7 @@ class CarbsDialog : DialogFragmentWithDate() { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.carbs), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { when { activitySelected -> { - uel.log(resourceHelper.gs(R.string.key_uel_tt_activity), d1 = activityTT, i1 = activityTTDuration) + uel.log(UserEntry.Action.TT_ACTIVITY, d1 = activityTT, i1 = activityTTDuration) val tempTarget = TempTarget() .date(System.currentTimeMillis()) .duration(activityTTDuration) @@ -224,7 +225,7 @@ class CarbsDialog : DialogFragmentWithDate() { } eatingSoonSelected -> { - uel.log(resourceHelper.gs(R.string.key_uel_tt_eating_soon), d1 = eatingSoonTT, i1 = eatingSoonTTDuration) + uel.log(UserEntry.Action.TT_EATING_SOON, d1 = eatingSoonTT, i1 = eatingSoonTTDuration) val tempTarget = TempTarget() .date(System.currentTimeMillis()) .duration(eatingSoonTTDuration) @@ -236,7 +237,7 @@ class CarbsDialog : DialogFragmentWithDate() { } hypoSelected -> { - uel.log(resourceHelper.gs(R.string.key_uel_tt_hypo), d1 = hypoTT, i1 = hypoTTDuration) + uel.log(UserEntry.Action.TT_HYPO, d1 = hypoTT, i1 = hypoTTDuration) val tempTarget = TempTarget() .date(System.currentTimeMillis()) .duration(hypoTTDuration) @@ -249,10 +250,10 @@ class CarbsDialog : DialogFragmentWithDate() { } if (carbsAfterConstraints > 0) { if (duration == 0) { - uel.log(resourceHelper.gs(R.string.key_uel_carb), d1 = carbsAfterConstraints.toDouble(), i1 = timeOffset) + uel.log(UserEntry.Action.CARBS, d1 = carbsAfterConstraints.toDouble(), i1 = timeOffset) carbsGenerator.createCarb(carbsAfterConstraints, time, CareportalEvent.CARBCORRECTION, notes) } else { - uel.log(resourceHelper.gs(R.string.key_uel_carb), d1 = carbsAfterConstraints.toDouble(), i1 = timeOffset, i2 = duration) + uel.log(UserEntry.Action.CARBS, d1 = carbsAfterConstraints.toDouble(), i1 = timeOffset, i2 = duration) carbsGenerator.generateCarbs(carbsAfterConstraints, time, duration, notes) nsUpload.uploadEvent(CareportalEvent.NOTE, DateUtil.now() - 2000, resourceHelper.gs(R.string.generated_ecarbs_note, carbsAfterConstraints, duration, timeOffset)) } 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 c75334b014..1941500fdf 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt @@ -13,6 +13,7 @@ import info.nightscout.androidaps.Constants import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.DialogCareBinding import info.nightscout.androidaps.db.CareportalEvent import info.nightscout.androidaps.db.Source @@ -222,7 +223,7 @@ class CareDialog : DialogFragmentWithDate() { EventType.ANNOUNCEMENT -> CareportalEvent.ANNOUNCEMENT } careportalEvent.json = json.toString() - uel.log(resourceHelper.gs(R.string.key_uel_careportal), careportalEvent.eventType) + uel.log(UserEntry.Action.CAREPORTAL, careportalEvent.eventType) MainApp.getDbHelper().createOrUpdate(careportalEvent) nsUpload.uploadCareportalEntryToNS(json) }, null) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/ExtendedBolusDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/ExtendedBolusDialog.kt index 66914d3a30..2bf7700f95 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/ExtendedBolusDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/ExtendedBolusDialog.kt @@ -8,6 +8,7 @@ import android.view.ViewGroup import com.google.common.base.Joiner import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.ErrorHelperActivity +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.DialogExtendedbolusBinding import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider @@ -87,7 +88,7 @@ class ExtendedBolusDialog : DialogFragmentWithDate() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.extended_bolus), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { - uel.log(resourceHelper.gs(R.string.key_uel_extended_bolus), d1 = insulinAfterConstraint, i1 = durationInMinutes) + uel.log(UserEntry.Action.EXTENDED_BOLUS, d1 = insulinAfterConstraint, i1 = durationInMinutes) commandQueue.extendedBolus(insulinAfterConstraint, durationInMinutes, object : Callback() { override fun run() { if (!result.success) { 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 f3bab670de..aebf1f439d 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt @@ -9,6 +9,7 @@ import com.google.common.base.Joiner import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.data.DetailedBolusInfo +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.DialogFillBinding import info.nightscout.androidaps.db.CareportalEvent import info.nightscout.androidaps.db.Source @@ -127,16 +128,16 @@ class FillDialog : DialogFragmentWithDate() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.primefill), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { if (insulinAfterConstraints > 0) { - uel.log(resourceHelper.gs(R.string.key_uel_prime_bolus), d1 = insulinAfterConstraints) + uel.log(UserEntry.Action.PRIME_BOLUS, d1 = insulinAfterConstraints) requestPrimeBolus(insulinAfterConstraints, notes) } if (siteChange) { - uel.log(resourceHelper.gs(R.string.key_uel_site_change)) + uel.log(UserEntry.Action.SITE_CHANGE) nsUpload.generateCareportalEvent(CareportalEvent.SITECHANGE, eventTime, notes) } if (insulinChange) { // add a second for case of both checked - uel.log(resourceHelper.gs(R.string.key_uel_insulin_change)) + uel.log(UserEntry.Action.INSULIN_CHANGE) nsUpload.generateCareportalEvent(CareportalEvent.INSULINCHANGE, eventTime + 1000, notes) } }, null) 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 1fb1ce4ff0..adcf1e74a0 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt @@ -15,6 +15,7 @@ import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.data.DetailedBolusInfo import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.database.AppRepository +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.DialogInsulinBinding import info.nightscout.androidaps.db.CareportalEvent import info.nightscout.androidaps.db.Source @@ -178,7 +179,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(resourceHelper.gs(R.string.key_uel_tt_eating_soon), d1 = eatingSoonTT, i1 = eatingSoonTTDuration) + uel.log(UserEntry.Action.TT_EATING_SOON, d1 = eatingSoonTT, i1 = eatingSoonTTDuration) val tempTarget = TempTarget() .date(System.currentTimeMillis()) .duration(eatingSoonTTDuration) @@ -196,11 +197,11 @@ class InsulinDialog : DialogFragmentWithDate() { detailedBolusInfo.source = Source.USER detailedBolusInfo.notes = notes if (recordOnlyChecked) { - uel.log(resourceHelper.gs(R.string.key_uel_bolus_record), d1 = insulinAfterConstraints, i1 = timeOffset) + uel.log(UserEntry.Action.BOLUS_RECORD, d1 = insulinAfterConstraints, i1 = timeOffset) detailedBolusInfo.date = time activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false) } else { - uel.log(resourceHelper.gs(R.string.key_uel_bolus), d1 = insulinAfterConstraints) + uel.log(UserEntry.Action.BOLUS, d1 = insulinAfterConstraints) detailedBolusInfo.date = DateUtil.now() commandQueue.bolus(detailedBolusInfo, object : Callback() { override fun run() { 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 e235f47db1..e201a7f1bb 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt @@ -12,6 +12,7 @@ import androidx.fragment.app.FragmentManager import dagger.android.support.DaggerDialogFragment import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.ErrorHelperActivity +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.DialogLoopBinding import info.nightscout.androidaps.events.EventPreferenceChange import info.nightscout.androidaps.events.EventRefreshOverview @@ -238,28 +239,28 @@ class LoopDialog : DaggerDialogFragment() { val profile = profileFunction.getProfile() ?: return true when (v.id) { R.id.overview_closeloop -> { - uel.log(resourceHelper.gs(R.string.key_uel_closed_loop_mode)) + uel.log(UserEntry.Action.CLOSED_LOOP_MODE) sp.putString(R.string.key_aps_mode, "closed") rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.closedloop))) return true } R.id.overview_lgsloop -> { - uel.log(resourceHelper.gs(R.string.key_uel_lgs_loop_mode)) + uel.log(UserEntry.Action.LGS_LOOP_MODE) sp.putString(R.string.key_aps_mode, "lgs") rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend))) return true } R.id.overview_openloop -> { - uel.log(resourceHelper.gs(R.string.key_uel_open_loop_mode)) + uel.log(UserEntry.Action.OPEN_LOOP_MODE) sp.putString(R.string.key_aps_mode, "open") rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend))) return true } R.id.overview_disable -> { - uel.log(resourceHelper.gs(R.string.key_uel_loop_disabled)) + uel.log(UserEntry.Action.LOOP_DISABLED) loopPlugin.setPluginEnabled(PluginType.LOOP, false) loopPlugin.setFragmentVisible(PluginType.LOOP, false) configBuilderPlugin.storeSettings("DisablingLoop") @@ -276,7 +277,7 @@ class LoopDialog : DaggerDialogFragment() { } R.id.overview_enable -> { - uel.log(resourceHelper.gs(R.string.key_uel_loop_enabled)) + uel.log(UserEntry.Action.LOOP_ENABLED) loopPlugin.setPluginEnabled(PluginType.LOOP, true) loopPlugin.setFragmentVisible(PluginType.LOOP, true) configBuilderPlugin.storeSettings("EnablingLoop") @@ -286,7 +287,7 @@ class LoopDialog : DaggerDialogFragment() { } R.id.overview_resume, R.id.overview_reconnect -> { - uel.log(resourceHelper.gs(R.string.key_uel_resume)) + uel.log(if (v.id==R.id.overview_resume) UserEntry.Action.RESUME else UserEntry.Action.RECONNECT ) loopPlugin.suspendTo(0L) rxBus.send(EventRefreshOverview("suspendmenu")) commandQueue.cancelTempBasal(true, object : Callback() { @@ -302,49 +303,49 @@ class LoopDialog : DaggerDialogFragment() { } R.id.overview_suspend_1h -> { - uel.log(resourceHelper.gs(R.string.key_uel_suspend_1h)) + uel.log(UserEntry.Action.SUSPEND_1H) loopPlugin.suspendLoop(60) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_suspend_2h -> { - uel.log(resourceHelper.gs(R.string.key_uel_suspend_2h)) + uel.log(UserEntry.Action.SUSPEND_2H) loopPlugin.suspendLoop(120) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_suspend_3h -> { - uel.log(resourceHelper.gs(R.string.key_uel_suspend_3h)) + uel.log(UserEntry.Action.SUSPEND_3H) loopPlugin.suspendLoop(180) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_suspend_10h -> { - uel.log(resourceHelper.gs(R.string.key_uel_suspend_10h)) + uel.log(UserEntry.Action.SUSPEND_10H) loopPlugin.suspendLoop(600) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_disconnect_15m -> { - uel.log(resourceHelper.gs(R.string.key_uel_disconnect_15m)) + uel.log(UserEntry.Action.DISCONNECT_15M) loopPlugin.disconnectPump(15, profile) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_disconnect_30m -> { - uel.log(resourceHelper.gs(R.string.key_uel_disconnect_30m)) + uel.log(UserEntry.Action.DISCONNECT_30M) loopPlugin.disconnectPump(30, profile) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_disconnect_1h -> { - uel.log(resourceHelper.gs(R.string.key_uel_disconnect_1h)) + uel.log(UserEntry.Action.DISCONNECT_1H) loopPlugin.disconnectPump(60, profile) sp.putBoolean(R.string.key_objectiveusedisconnect, true) rxBus.send(EventRefreshOverview("suspendmenu")) @@ -352,14 +353,14 @@ class LoopDialog : DaggerDialogFragment() { } R.id.overview_disconnect_2h -> { - uel.log(resourceHelper.gs(R.string.key_uel_disconnect_2h)) + uel.log(UserEntry.Action.DISCONNECT_2H) loopPlugin.disconnectPump(120, profile) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_disconnect_3h -> { - uel.log(resourceHelper.gs(R.string.key_uel_disconnect_3h)) + uel.log(UserEntry.Action.DISCONNECT_3H) loopPlugin.disconnectPump(180, profile) rxBus.send(EventRefreshOverview("suspendmenu")) return true diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt index ff7136b296..b834c17af3 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt @@ -8,6 +8,7 @@ import android.widget.ArrayAdapter import com.google.common.base.Joiner import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.DialogProfileswitchBinding import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.ProfileFunction @@ -124,7 +125,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { - uel.log(resourceHelper.gs(R.string.key_uel_profile_switch), d1 = percent.toDouble(), i1 = timeShift, i2 = duration) + uel.log(UserEntry.Action.PROFILE_SWITCH, d1 = percent.toDouble(), i1 = timeShift, i2 = duration) treatmentsPlugin.doProfileSwitch(profileStore, profile, duration, percent, timeShift, eventTime) }) } diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt index 385ab061e2..78038f22f4 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt @@ -8,6 +8,7 @@ import android.view.ViewGroup import com.google.common.base.Joiner import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.ErrorHelperActivity +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.DialogTempbasalBinding import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider @@ -125,10 +126,10 @@ class TempBasalDialog : DialogFragmentWithDate() { } } if (isPercentPump) { - uel.log(resourceHelper.gs(R.string.key_uel_temp_basal), d1 = percent.toDouble(), i1 = durationInMinutes) + uel.log(UserEntry.Action.TEMP_BASAL, d1 = percent.toDouble(), i1 = durationInMinutes) commandQueue.tempBasalPercent(percent, durationInMinutes, true, profile, callback) } else { - uel.log(resourceHelper.gs(R.string.key_uel_temp_basal), d1 = absolute, i1 = durationInMinutes) + uel.log(UserEntry.Action.TEMP_BASAL, d1 = absolute, i1 = durationInMinutes) commandQueue.tempBasalAbsolute(absolute, durationInMinutes, true, profile, callback) } }) 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 c7d384a7f1..a111a95e64 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt @@ -10,6 +10,7 @@ import com.google.common.collect.Lists import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.DialogTemptargetBinding import info.nightscout.androidaps.db.Source import info.nightscout.androidaps.db.TempTarget @@ -164,7 +165,7 @@ class TempTargetDialog : DialogFragmentWithDate() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { - uel.log(resourceHelper.gs(R.string.key_uel_tt), d1 = target, i1 = duration) + uel.log(UserEntry.Action.TT, d1 = target, i1 = duration) if (target == 0.0 || duration == 0) { val tempTarget = TempTarget() .date(eventTime) 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 14c106b416..8be73db915 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt @@ -12,6 +12,7 @@ import info.nightscout.androidaps.Config import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.data.DetailedBolusInfo +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.DialogTreatmentBinding import info.nightscout.androidaps.db.CareportalEvent import info.nightscout.androidaps.db.Source @@ -129,7 +130,7 @@ class TreatmentDialog : DialogFragmentWithDate() { if (insulinAfterConstraints > 0 || carbsAfterConstraints > 0) { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_treatment_label), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { - uel.log(resourceHelper.gs(R.string.key_uel_treatment), d1 = insulin, i1 = carbs) + uel.log(UserEntry.Action.TREATMENT, d1 = insulin, i1 = carbs) val detailedBolusInfo = DetailedBolusInfo() if (insulinAfterConstraints == 0.0) detailedBolusInfo.eventType = CareportalEvent.CARBCORRECTION if (carbsAfterConstraints == 0) detailedBolusInfo.eventType = CareportalEvent.CORRECTIONBOLUS 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 09833a74f3..8bd3025b1c 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 @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.configBuilder import androidx.fragment.app.FragmentActivity import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.events.EventAppInitialized import info.nightscout.androidaps.events.EventConfigBuilderChange import info.nightscout.androidaps.events.EventRebuildTabs @@ -142,7 +143,7 @@ class ConfigBuilderPlugin @Inject constructor( OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.allow_hardware_pump_text), Runnable { performPluginSwitch(changedPlugin, newState, type) sp.putBoolean("allow_hardware_pump", true) - uel.log(resourceHelper.gs(R.string.key_uel_hw_pump_allowed)) + uel.log(UserEntry.Action.HW_PUMP_ALLOWED) aapsLogger.debug(LTag.PUMP, "First time HW pump allowed!") }, Runnable { rxBus.send(EventConfigBuilderUpdateGui()) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt index ae30d34530..769d1d033d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt @@ -17,6 +17,7 @@ import androidx.recyclerview.widget.LinearSmoothScroller import androidx.recyclerview.widget.RecyclerView import dagger.android.support.DaggerFragment import info.nightscout.androidaps.R +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.ObjectivesFragmentBinding import info.nightscout.androidaps.databinding.ObjectivesItemBinding import info.nightscout.androidaps.dialogs.NtpProgressDialog @@ -307,7 +308,7 @@ class ObjectivesFragment : DaggerFragment() { holder.binding.unstart.setOnClickListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.objectives), resourceHelper.gs(R.string.doyouwantresetstart), Runnable { - uel.log(resourceHelper.gs(R.string.key_uel_objective_unstarted), i1 = position + 1) + uel.log(UserEntry.Action.OBJECTIVE_UNSTARTED, i1 = position + 1) objective.startedOn = 0 scrollToCurrentObjective() rxBus.send(EventObjectivesUpdateGui()) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt index ad7fb6a7d9..b4a5144e2e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt @@ -7,6 +7,7 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.BuildConfig import info.nightscout.androidaps.Config import info.nightscout.androidaps.R +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.interfaces.* import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.UserEntryLogger @@ -142,7 +143,7 @@ class ObjectivesPlugin @Inject constructor( sp.putLong("Objectives_" + "auto" + "_accomplished", DateUtil.now()) setupObjectives() OKDialog.show(activity, resourceHelper.gs(R.string.objectives), resourceHelper.gs(R.string.codeaccepted)) - uel.log(resourceHelper.gs(R.string.key_uel_objectives_skipped)) + uel.log(UserEntry.Action.OBJECTIVES_SKIPPED) } else { OKDialog.show(activity, resourceHelper.gs(R.string.objectives), resourceHelper.gs(R.string.codeinvalid)) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt index 500016399a..2ee007e225 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt @@ -16,6 +16,7 @@ import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.activities.TDDStatsActivity +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.dialogs.* import info.nightscout.androidaps.events.* import info.nightscout.androidaps.historyBrowser.HistoryBrowseActivity @@ -154,7 +155,7 @@ class ActionsFragment : DaggerFragment() { } extendedBolusCancel?.setOnClickListener { if (activePlugin.activeTreatments.isInHistoryExtendedBoluslInProgress) { - uel.log(resourceHelper.gs(R.string.key_uel_cancel_extended_bolus)) + uel.log(UserEntry.Action.CANCEL_EXTENDED_BOLUS) commandQueue.cancelExtended(object : Callback() { override fun run() { if (!result.success) { @@ -169,7 +170,7 @@ class ActionsFragment : DaggerFragment() { } cancelTempBasal?.setOnClickListener { if (activePlugin.activeTreatments.isTempBasalInProgress) { - uel.log(resourceHelper.gs(R.string.key_uel_cancel_temp_basal)) + uel.log(UserEntry.Action.CANCEL_TEMP_BASAL) commandQueue.cancelTempBasal(true, object : Callback() { override fun run() { if (!result.success) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt index 45f7c04236..cdcb5e317f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt @@ -18,6 +18,7 @@ import androidx.recyclerview.widget.RecyclerView import dagger.android.HasAndroidInjector import dagger.android.support.DaggerFragment import info.nightscout.androidaps.R +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.AutomationEventItemBinding import info.nightscout.androidaps.databinding.AutomationFragmentBinding import info.nightscout.androidaps.logging.UserEntryLogger @@ -216,7 +217,7 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener { holder.binding.iconTrash.setOnClickListener { OKDialog.showConfirmation(requireContext(), resourceHelper.gs(R.string.removerecord) + " " + automationPlugin.at(position).title, { - uel.log(resourceHelper.gs(R.string.key_uel_autom_removed), automationPlugin.at(position).title) + uel.log(UserEntry.Action.AUTOMATION_REMOVED, automationPlugin.at(position).title) automationPlugin.removeAt(position) notifyItemRemoved(position) }, { @@ -239,7 +240,7 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord) + " " + automationPlugin.at(position).title, Runnable { - uel.log(resourceHelper.gs(R.string.key_uel_autom_removed), automationPlugin.at(position).title) + uel.log(UserEntry.Action.AUTOMATION_REMOVED, automationPlugin.at(position).title) automationPlugin.removeAt(position) notifyItemRemoved(position) rxBus.send(EventAutomationDataChanged()) 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 316667838a..1624022ca0 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 @@ -15,6 +15,7 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import dagger.android.support.DaggerFragment import info.nightscout.androidaps.R +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.FoodFragmentBinding import info.nightscout.androidaps.databinding.FoodItemBinding import info.nightscout.androidaps.events.EventFoodDatabaseChanged @@ -216,7 +217,7 @@ class FoodFragment : DaggerFragment() { val food = v.tag as Food activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.confirmation), resourceHelper.gs(R.string.removerecord) + "\n" + food.name, DialogInterface.OnClickListener { _: DialogInterface?, _: Int -> - uel.log(resourceHelper.gs(R.string.key_uel_food_removed), food.name) + uel.log(UserEntry.Action.FOOD_REMOVED, food.name) if (food._id != null && food._id != "") { nsUpload.removeFoodFromNS(food._id) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt index 4108668a97..538f0dc166 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt @@ -15,6 +15,7 @@ import info.nightscout.androidaps.BuildConfig import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.DaggerAppCompatActivityWithResult import info.nightscout.androidaps.activities.PreferencesActivity +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.events.EventAppExit import info.nightscout.androidaps.interfaces.ConfigInterface import info.nightscout.androidaps.interfaces.ImportExportPrefsInterface @@ -344,7 +345,7 @@ class ImportExportPrefs @Inject constructor( private fun restartAppAfterImport(context: Context) { sp.putBoolean(R.string.key_setupwizard_processed, true) OKDialog.show(context, resourceHelper.gs(R.string.setting_imported), resourceHelper.gs(R.string.restartingapp), Runnable { - uel.log(resourceHelper.gs(R.string.key_uel_import)) + uel.log(UserEntry.Action.IMPORT_SETTINGS) log.debug(LTag.CORE, "Exiting") rxBus.send(EventAppExit()) if (context is AppCompatActivity) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenanceFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenanceFragment.kt index c26cd1665c..b1af7acdcf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenanceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenanceFragment.kt @@ -9,6 +9,7 @@ import dagger.android.support.DaggerFragment import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R import info.nightscout.androidaps.database.AppRepository +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.MaintenanceFragmentBinding import info.nightscout.androidaps.events.EventNewBG import info.nightscout.androidaps.interfaces.ImportExportPrefsInterface @@ -56,13 +57,13 @@ class MaintenanceFragment : DaggerFragment() { super.onViewCreated(view, savedInstanceState) binding.logSend.setOnClickListener { maintenancePlugin.sendLogs() } binding.logDelete.setOnClickListener { - uel.log(resourceHelper.gs(R.string.key_uel_delete_logs)) + uel.log(UserEntry.Action.DELETE_LOGS) maintenancePlugin.deleteLogs() } binding.navResetdb.setOnClickListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.maintenance), resourceHelper.gs(R.string.reset_db_confirm), Runnable { - uel.log(resourceHelper.gs(R.string.key_uel_reset_databases)) + uel.log(UserEntry.Action.RESET_DATABASES) compositeDisposable.add( fromAction { MainApp.getDbHelper().resetDatabases() @@ -83,14 +84,14 @@ class MaintenanceFragment : DaggerFragment() { } } binding.navExport.setOnClickListener { - uel.log(resourceHelper.gs(R.string.key_uel_export_settings)) + uel.log(UserEntry.Action.EXPORT_SETTINGS) // start activity for checking permissions... importExportPrefs.verifyStoragePermissions(this) { importExportPrefs.exportSharedPreferences(this) } } binding.navImport.setOnClickListener { - uel.log(resourceHelper.gs(R.string.key_uel_import_settings)) + uel.log(UserEntry.Action.IMPORT_SETTINGS) // start activity for checking permissions... importExportPrefs.verifyStoragePermissions(this) { importExportPrefs.importSharedPreferences(this) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientFragment.java index 4b1464f213..2bf19b771d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientFragment.java @@ -16,6 +16,7 @@ import javax.inject.Inject; import dagger.android.support.DaggerFragment; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.database.entities.UserEntry; import info.nightscout.androidaps.logging.UserEntryLogger; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientNewLog; @@ -123,7 +124,7 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList break; case R.id.nsclientinternal_clearqueue: OKDialog.showConfirmation(getContext(), resourceHelper.gs(R.string.nsclientinternal), resourceHelper.gs(R.string.clearqueueconfirm), () -> { - uel.log(resourceHelper.gs(R.string.key_uel_ns_queue_cleared), "", 0.0, 0.0, 0, 0); + uel.log(UserEntry.Action.NS_QUEUE_CLEARED, "", 0.0, 0.0, 0, 0); uploadQueue.clearQueue(); updateGui(); fabricPrivacy.logCustom("NSClientClearQueue"); @@ -139,7 +140,7 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { switch (buttonView.getId()) { case R.id.nsclientinternal_paused: - uel.log(resourceHelper.gs(R.string.key_uel_ns_paused), "", 0.0, 0.0, isChecked ? 1 : 0, 0); + uel.log(UserEntry.Action.NS_PAUSED, "", 0.0, 0.0, isChecked ? 1 : 0, 0); nsClientPlugin.pause(isChecked); updateGui(); fabricPrivacy.logCustom("NSClientPause"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSSettingsStatus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSSettingsStatus.kt index 291f735e61..ca2283e545 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSSettingsStatus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSSettingsStatus.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.general.nsclient.data import android.content.Context import info.nightscout.androidaps.Config import info.nightscout.androidaps.R +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.UserEntryLogger @@ -235,7 +236,7 @@ class NSSettingsStatus @Inject constructor( getExtendedWarnValue("sage", "urgent")?.let { sp.putDouble(R.string.key_statuslights_sage_critical, it) } getExtendedWarnValue("bage", "warn")?.let { sp.putDouble(R.string.key_statuslights_bage_warning, it) } getExtendedWarnValue("bage", "urgent")?.let { sp.putDouble(R.string.key_statuslights_bage_critical, it) } - uel.log(resourceHelper.gs(R.string.key_uel_ns_settings_copied)) + uel.log(UserEntry.Action.NS_SETTINGS_COPIED) } if (context != null) OKDialog.showConfirmation(context, resourceHelper.gs(R.string.statuslights), resourceHelper.gs(R.string.copyexistingvalues), action) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt index efb4b9d8bc..d33c3df7ed 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt @@ -28,6 +28,7 @@ import info.nightscout.androidaps.Config import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.OverviewFragmentBinding import info.nightscout.androidaps.dialogs.* import info.nightscout.androidaps.events.* @@ -342,7 +343,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.tempbasal_label), lastRun.constraintsProcessed?.toSpanned() ?: "".toSpanned(), { - uel.log(resourceHelper.gs(R.string.key_uel_accepts_temp_basal)) + uel.log(UserEntry.Action.ACCEPTS_TEMP_BASAL) binding.buttonsLayout.acceptTempButton.visibility = View.GONE (context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).cancel(Constants.notificationID) rxBus.send(EventWearDoAction("cancelChangeRequest")) 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 0bcb37d67c..fe4b616bb4 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 @@ -15,6 +15,7 @@ import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.data.DetailedBolusInfo import info.nightscout.androidaps.data.Profile +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.db.Source import info.nightscout.androidaps.db.TempTarget import info.nightscout.androidaps.events.EventPreferenceChange @@ -337,7 +338,7 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - uel.log(resourceHelper.gs(R.string.key_uel_sms_loop_disable)) + uel.log(UserEntry.Action.SMS_LOOP_DISABLED) loopPlugin.setPluginEnabled(PluginType.LOOP, false) commandQueue.cancelTempBasal(true, object : Callback() { override fun run() { @@ -361,7 +362,7 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - uel.log(resourceHelper.gs(R.string.key_uel_sms_loop_enable)) + uel.log(UserEntry.Action.SMS_LOOP_ENABLED) loopPlugin.setPluginEnabled(PluginType.LOOP, true) sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_loophasbeenenabled))) rxBus.send(EventRefreshOverview("SMS_LOOP_START")) @@ -388,7 +389,7 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - uel.log(resourceHelper.gs(R.string.key_uel_sms_loop_resume)) + uel.log(UserEntry.Action.SMS_LOOP_RESUME) loopPlugin.suspendTo(0L) rxBus.send(EventRefreshOverview("SMS_LOOP_RESUME")) commandQueue.cancelTempBasal(true, object : Callback() { @@ -421,7 +422,7 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(duration) { override fun run() { - uel.log(resourceHelper.gs(R.string.key_uel_sms_loop_suspend)) + uel.log(UserEntry.Action.SMS_LOOP_SUSPEND) commandQueue.cancelTempBasal(true, object : Callback() { override fun run() { if (result.success) { @@ -505,7 +506,7 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - uel.log(resourceHelper.gs(R.string.key_uel_sms_pump_connect)) + uel.log(UserEntry.Action.SMS_PUMP_CONNECT) commandQueue.cancelTempBasal(true, object : Callback() { override fun run() { if (!result.success) { @@ -534,7 +535,7 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - uel.log(resourceHelper.gs(R.string.key_uel_sms_pump_disconnect)) + uel.log(UserEntry.Action.SMS_PUMP_DISCONNECT) val profile = profileFunction.getProfile() loopPlugin.disconnectPump(duration, profile) rxBus.send(EventRefreshOverview("SMS_PUMP_DISCONNECT")) @@ -591,7 +592,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(resourceHelper.gs(R.string.key_uel_sms_profile), replyText) + uel.log(UserEntry.Action.SMS_PROFILE, replyText) } }) } @@ -613,12 +614,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(resourceHelper.gs(R.string.key_uel_sms_basal), replyText) + uel.log(UserEntry.Action.SMS_BASAL, replyText) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalcancelfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log(resourceHelper.gs(R.string.key_uel_sms_basal), replyText) + uel.log(UserEntry.Action.SMS_BASAL, replyText) } } }) @@ -646,12 +647,12 @@ class SmsCommunicatorPlugin @Inject constructor( var replyText = if (result.isPercent) String.format(resourceHelper.gs(R.string.smscommunicator_tempbasalset_percent), result.percent, result.duration) else String.format(resourceHelper.gs(R.string.smscommunicator_tempbasalset), result.absolute, result.duration) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log(resourceHelper.gs(R.string.key_uel_sms_basal), replyText) + uel.log(UserEntry.Action.SMS_BASAL, replyText) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log(resourceHelper.gs(R.string.key_uel_sms_basal), replyText) + uel.log(UserEntry.Action.SMS_BASAL, replyText) } } }) @@ -681,12 +682,12 @@ class SmsCommunicatorPlugin @Inject constructor( else String.format(resourceHelper.gs(R.string.smscommunicator_tempbasalset), result.absolute, result.duration) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log(resourceHelper.gs(R.string.key_uel_sms_basal), replyText) + uel.log(UserEntry.Action.SMS_BASAL, replyText) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log(resourceHelper.gs(R.string.key_uel_sms_basal), replyText) + uel.log(UserEntry.Action.SMS_BASAL, replyText) } } }) @@ -713,7 +714,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(resourceHelper.gs(R.string.key_uel_sms_extended), replyText) + uel.log(UserEntry.Action.SMS_EXTENDED_BOLUS, replyText) } } }) @@ -739,12 +740,12 @@ class SmsCommunicatorPlugin @Inject constructor( if (config.APS) replyText += "\n" + resourceHelper.gs(R.string.loopsuspended) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log(resourceHelper.gs(R.string.key_uel_sms_extended), replyText) + uel.log(UserEntry.Action.SMS_EXTENDED_BOLUS, replyText) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_extendedfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log(resourceHelper.gs(R.string.key_uel_sms_extended), replyText) + uel.log(UserEntry.Action.SMS_EXTENDED_BOLUS, replyText) } } }) @@ -813,12 +814,12 @@ class SmsCommunicatorPlugin @Inject constructor( } } sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log(resourceHelper.gs(R.string.key_uel_sms_bolus), replyText) + uel.log(UserEntry.Action.SMS_BOLUS, replyText) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_bolusfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log(resourceHelper.gs(R.string.key_uel_sms_bolus), replyText) + uel.log(UserEntry.Action.SMS_BOLUS, replyText) } } }) @@ -858,12 +859,12 @@ class SmsCommunicatorPlugin @Inject constructor( var replyText = String.format(resourceHelper.gs(R.string.smscommunicator_carbsset), anInteger) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log(resourceHelper.gs(R.string.key_uel_sms_carbs), replyText) + uel.log(UserEntry.Action.SMS_CARBS, replyText) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_carbsfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log(resourceHelper.gs(R.string.key_uel_sms_carbs), replyText) + uel.log(UserEntry.Action.SMS_CARBS, replyText) } } }) @@ -872,7 +873,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(resourceHelper.gs(R.string.key_uel_sms_carbs), replyText) + uel.log(UserEntry.Action.SMS_CARBS, replyText) } } }) @@ -937,7 +938,7 @@ class SmsCommunicatorPlugin @Inject constructor( val ttString = if (units == Constants.MMOL) DecimalFormatter.to1Decimal(tt) else DecimalFormatter.to0Decimal(tt) val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_tt_set), ttString, ttDuration) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log(resourceHelper.gs(R.string.key_uel_sms_target), replyText) + uel.log(UserEntry.Action.SMS_TT, replyText) } }) } else if (isStop) { @@ -955,7 +956,7 @@ class SmsCommunicatorPlugin @Inject constructor( activePlugin.activeTreatments.addToHistoryTempTarget(tempTarget) val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_tt_canceled)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log(resourceHelper.gs(R.string.key_uel_sms_target), reply) + uel.log(UserEntry.Action.SMS_TT, reply) } }) } else @@ -974,7 +975,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(resourceHelper.gs(R.string.key_uel_sms_sms), replyText) + uel.log(UserEntry.Action.SMS_SMS, replyText) } }) } else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat))) @@ -992,7 +993,7 @@ class SmsCommunicatorPlugin @Inject constructor( val replyText = if (result) resourceHelper.gs(R.string.smscommunicator_calibrationsent) else resourceHelper.gs(R.string.smscommunicator_calibrationfailed) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log(resourceHelper.gs(R.string.key_uel_sms_cal), replyText) + uel.log(UserEntry.Action.SMS_CAL, replyText) } }) } else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat))) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt index 45f1a77579..e5ef8e1416 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt @@ -14,6 +14,7 @@ import com.google.common.primitives.Ints.min import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.NoSplashAppCompatActivity +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.ActivitySmscommunicatorOtpBinding import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper @@ -72,7 +73,7 @@ class SmsCommunicatorOtpActivity : NoSplashAppCompatActivity() { resourceHelper.gs(R.string.smscommunicator_otp_reset_title), resourceHelper.gs(R.string.smscommunicator_otp_reset_prompt), Runnable { - uel.log(resourceHelper.gs(R.string.key_uel_otp_reset)) + uel.log(UserEntry.Action.OTP_RESET) otp.ensureKey(true) updateGui() ToastUtils.Long.infoToast(this, resourceHelper.gs(R.string.smscommunicator_otp_reset_successful)) @@ -88,7 +89,7 @@ class SmsCommunicatorOtpActivity : NoSplashAppCompatActivity() { val clip = ClipData.newPlainText("OTP Secret", otp.provisioningSecret()) clipboard.primaryClip = clip ToastUtils.Long.infoToast(this, resourceHelper.gs(R.string.smscommunicator_otp_export_successful)) - uel.log(resourceHelper.gs(R.string.key_uel_otp_export)) + uel.log(UserEntry.Action.OTP_EXPORT) }) true diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt index 69ab8c1c72..cc7087ff43 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt @@ -12,6 +12,7 @@ import dagger.android.support.DaggerFragment import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.LocalprofileFragmentBinding import info.nightscout.androidaps.dialogs.ProfileSwitchDialog import info.nightscout.androidaps.interfaces.ActivePluginProvider @@ -162,7 +163,7 @@ class LocalProfileFragment : DaggerFragment() { if (localProfilePlugin.isEdited) { activity?.let { OKDialog.show(it, "", resourceHelper.gs(R.string.saveorresetchangesfirst)) } } else { - uel.log(resourceHelper.gs(R.string.key_uel_new_profile)) + uel.log(UserEntry.Action.NEW_PROFILE) localProfilePlugin.addNewProfile() build() } @@ -172,7 +173,7 @@ class LocalProfileFragment : DaggerFragment() { if (localProfilePlugin.isEdited) { activity?.let { OKDialog.show(it, "", resourceHelper.gs(R.string.saveorresetchangesfirst)) } } else { - uel.log(resourceHelper.gs(R.string.key_uel_clone_profile), localProfilePlugin.currentProfile()?.name ?: "") + uel.log(UserEntry.Action.CLONE_PROFILE, localProfilePlugin.currentProfile()?.name ?: "") localProfilePlugin.cloneProfile() build() } @@ -181,7 +182,7 @@ class LocalProfileFragment : DaggerFragment() { binding.profileRemove.setOnClickListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.deletecurrentprofile), { - uel.log(resourceHelper.gs(R.string.key_uel_remove_profile), localProfilePlugin.currentProfile()?.name ?: "") + uel.log(UserEntry.Action.PROFILE_REMOVED, localProfilePlugin.currentProfile()?.name ?: "") localProfilePlugin.removeCurrentProfile() build() }, null) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt index 0c97939a51..5bbeda0a9f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt @@ -5,6 +5,7 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.events.EventProfileStoreChanged import info.nightscout.androidaps.interfaces.* import info.nightscout.androidaps.logging.AAPSLogger @@ -115,7 +116,7 @@ class LocalProfilePlugin @Inject constructor( createAndStoreConvertedProfile() isEdited = false aapsLogger.debug(LTag.PROFILE, "Storing settings: " + rawProfile?.data.toString()) - uel.log(resourceHelper.gs(R.string.key_uel_store_profile)) + uel.log(UserEntry.Action.STORE_PROFILE) rxBus.send(EventProfileStoreChanged()) var namesOK = true profiles.forEach { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfileFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfileFragment.kt index 6ba247ab14..48ca291497 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfileFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfileFragment.kt @@ -8,6 +8,7 @@ import android.widget.AdapterView import android.widget.ArrayAdapter import dagger.android.support.DaggerFragment import info.nightscout.androidaps.R +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.NsprofileFragmentBinding import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.logging.UserEntryLogger @@ -61,7 +62,7 @@ class NSProfileFragment : DaggerFragment() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.nsprofile), resourceHelper.gs(R.string.activate_profile) + ": " + name + " ?", Runnable { - uel.log(resourceHelper.gs(R.string.key_uel_profile_switch), name, i1 = 100) + uel.log(UserEntry.Action.PROFILE_SWITCH, name, i1 = 100) treatmentsPlugin.doProfileSwitch(store, name, 0, 100, 0, DateUtil.now()) }) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt index 7303b90d50..81e96e5df6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt @@ -11,6 +11,7 @@ import dagger.android.support.DaggerFragment import info.nightscout.androidaps.R import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.entities.GlucoseValue +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.database.transactions.InvalidateGlucoseValueTransaction import info.nightscout.androidaps.databinding.BgsourceFragmentBinding import info.nightscout.androidaps.databinding.BgsourceItemBinding @@ -128,7 +129,7 @@ class BGSourceFragment : DaggerFragment() { activity?.let { activity -> val text = dateUtil.dateAndTimeString(glucoseValue.timestamp) + "\n" + glucoseValue.valueToUnitsString(profileFunction.getUnits()) OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable { - uel.log(resourceHelper.gs(R.string.key_uel_bg_removed), dateUtil.dateAndTimeString(glucoseValue.timestamp)) + uel.log(UserEntry.Action.BG_REMOVED, dateUtil.dateAndTimeString(glucoseValue.timestamp)) disposable += repository.runTransaction(InvalidateGlucoseValueTransaction(glucoseValue.id)).subscribe() }) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt index 2f81401713..362a1783dd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt @@ -9,6 +9,7 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import dagger.android.support.DaggerFragment import info.nightscout.androidaps.R +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.TreatmentsBolusFragmentBinding import info.nightscout.androidaps.databinding.TreatmentsBolusItemBinding import info.nightscout.androidaps.db.Source @@ -68,7 +69,7 @@ class TreatmentsBolusFragment : DaggerFragment() { binding.refreshFromNightscout.setOnClickListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.refresheventsfromnightscout) + "?") { - uel.log(resourceHelper.gs(R.string.key_uel_treat_ns_refresh)) + uel.log(UserEntry.Action.TREATMENTS_NS_REFRESH) treatmentsPlugin.service.resetTreatments() rxBus.send(EventNSClientRestart()) } @@ -77,7 +78,7 @@ class TreatmentsBolusFragment : DaggerFragment() { binding.deleteFutureTreatments.setOnClickListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_treatment_label), resourceHelper.gs(R.string.deletefuturetreatments) + "?", Runnable { - uel.log(resourceHelper.gs(R.string.key_uel_delete_future_treatments)) + uel.log(UserEntry.Action.DELETE_FUTURE_TREATMENTS) val futureTreatments = treatmentsPlugin.service.getTreatmentDataFromTime(DateUtil.now() + 1000, true) for (treatment in futureTreatments) { if (NSUpload.isIdValid(treatment._id)) @@ -174,7 +175,7 @@ class TreatmentsBolusFragment : DaggerFragment() { resourceHelper.gs(R.string.carbs) + ": " + resourceHelper.gs(R.string.format_carbs, treatment.carbs.toInt()) + "\n" + resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(treatment.date) OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable { - uel.log(resourceHelper.gs(R.string.key_uel_removed_treatment), text) + uel.log(UserEntry.Action.TREATMENT_REMOVED, text) if (treatment.source == Source.PUMP) { treatment.isValid = false treatmentsPlugin.service.update(treatment) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsCareportalFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsCareportalFragment.kt index f2f28be3b0..8e1d69a099 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 @@ -10,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView import dagger.android.support.DaggerFragment import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.TreatmentsCareportalFragmentBinding import info.nightscout.androidaps.databinding.TreatmentsCareportalItemBinding import info.nightscout.androidaps.db.CareportalEvent @@ -64,7 +65,7 @@ class TreatmentsCareportalFragment : DaggerFragment() { binding.refreshFromNightscout.setOnClickListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal), resourceHelper.gs(R.string.refresheventsfromnightscout) + " ?", Runnable { - uel.log(resourceHelper.gs(R.string.key_uel_careportal_ns_refresh)) + uel.log(UserEntry.Action.CAREPORTAL_NS_REFRESH) MainApp.getDbHelper().resetCareportalEvents() rxBus.send(EventNSClientRestart()) }) @@ -73,7 +74,7 @@ class TreatmentsCareportalFragment : DaggerFragment() { binding.removeAndroidapsStartedEvents.setOnClickListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal), resourceHelper.gs(R.string.careportal_removestartedevents), Runnable { - uel.log(resourceHelper.gs(R.string.key_uel_removed_restart_events)) + uel.log(UserEntry.Action.RESTART_EVENTS_REMOVED) val events = MainApp.getDbHelper().getCareportalEvents(false) for (i in events.indices) { val careportalEvent = events[i] @@ -154,7 +155,7 @@ class TreatmentsCareportalFragment : DaggerFragment() { resourceHelper.gs(R.string.careportal_newnstreatment_notes_label) + ": " + careportalEvent.notes + "\n" + resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(careportalEvent.date) OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable { - uel.log(resourceHelper.gs(R.string.key_uel_removed_carep), text) + uel.log(UserEntry.Action.CAREPORTAL_REMOVED, text) if (NSUpload.isIdValid(careportalEvent._id)) nsUpload.removeCareportalEntryFromNS(careportalEvent._id) else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt index 3cc7fb734e..3e5f1b5bef 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt @@ -13,6 +13,7 @@ import dagger.android.support.DaggerFragment import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Intervals +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.TreatmentsExtendedbolusFragmentBinding import info.nightscout.androidaps.databinding.TreatmentsExtendedbolusItemBinding import info.nightscout.androidaps.db.ExtendedBolus @@ -121,7 +122,7 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() { ${resourceHelper.gs(R.string.extended_bolus)} ${resourceHelper.gs(R.string.date)}: ${dateUtil.dateAndTimeString(extendedBolus.date)} """.trimIndent(), { _: DialogInterface, _: Int -> - uel.log(resourceHelper.gs(R.string.key_uel_removed_eb)) + uel.log(UserEntry.Action.EXTENDED_BOLUS_REMOVED) val id = extendedBolus._id if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id) else uploadQueue.removeID("dbAdd", id) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt index c282053c4c..7af0e5debc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt @@ -10,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView import dagger.android.support.DaggerFragment import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.TreatmentsProfileswitchFragmentBinding import info.nightscout.androidaps.databinding.TreatmentsProfileswitchItemBinding import info.nightscout.androidaps.db.ProfileSwitch @@ -69,7 +70,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() { binding.refreshFromNightscout.setOnClickListener { activity?.let { activity -> - uel.log(resourceHelper.gs(R.string.key_uel_profile_switch_ns_refresh)) + uel.log(UserEntry.Action.PROFILE_SWITCH_NS_REFRESH) OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.refresheventsfromnightscout) + "?") { MainApp.getDbHelper().resetProfileSwitch() rxBus.send(EventNSClientRestart()) @@ -146,7 +147,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), resourceHelper.gs(R.string.careportal_profileswitch) + ": " + profileSwitch.profileName + "\n" + resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(profileSwitch.date), Runnable { - uel.log(resourceHelper.gs(R.string.key_uel_removed_profile_switch), profileSwitch.profileName + " " + dateUtil.dateAndTimeString(profileSwitch.date)) + uel.log(UserEntry.Action.PROFILE_SWITCH_REMOVED, profileSwitch.profileName + " " + dateUtil.dateAndTimeString(profileSwitch.date)) val id = profileSwitch._id if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id) else uploadQueue.removeID("dbAdd", id) @@ -159,7 +160,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() { val profileSwitch = it.tag as ProfileSwitch OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), resourceHelper.gs(R.string.copytolocalprofile) + "\n" + profileSwitch.customizedName + "\n" + dateUtil.dateAndTimeString(profileSwitch.date), Runnable { profileSwitch.profileObject?.let { - uel.log(resourceHelper.gs(R.string.key_uel_profile_switch_clone), profileSwitch.profileName + " " + dateUtil.dateAndTimeString(profileSwitch.date)) + uel.log(UserEntry.Action.PROFILE_SWITCH_CLONED, profileSwitch.profileName + " " + dateUtil.dateAndTimeString(profileSwitch.date)) val nonCustomized = it.convertToNonCustomizedProfile() if (nonCustomized.isValid(resourceHelper.gs(R.string.careportal_profileswitch, false))) { localProfilePlugin.addProfile(localProfilePlugin.copyFrom(nonCustomized, profileSwitch.customizedName + " " + dateUtil.dateAndTimeString(profileSwitch.date).replace(".", "_"))) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt index b6eb9a05bf..f72e042988 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt @@ -13,6 +13,7 @@ import dagger.android.support.DaggerFragment import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Intervals +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.TreatmentsTemptargetFragmentBinding import info.nightscout.androidaps.databinding.TreatmentsTemptargetItemBinding import info.nightscout.androidaps.db.Source @@ -69,7 +70,7 @@ class TreatmentsTempTargetFragment : DaggerFragment() { binding.refreshFromNightscout.setOnClickListener { context?.let { context -> OKDialog.showConfirmation(context, resourceHelper.gs(R.string.refresheventsfromnightscout) + " ?", { - uel.log(resourceHelper.gs(R.string.key_uel_tt_ns_refresh)) + uel.log(UserEntry.Action.TT_NS_REFRESH) MainApp.getDbHelper().resetTempTargets() rxBus.send(EventNSClientRestart()) }) @@ -161,7 +162,7 @@ class TreatmentsTempTargetFragment : DaggerFragment() { ${dateUtil.dateAndTimeString(tempTarget.date)} """.trimIndent(), { _: DialogInterface?, _: Int -> - uel.log(resourceHelper.gs(R.string.key_uel_tt_remove), tempTarget.friendlyDescription(profileFunction.getUnits(), resourceHelper)) + uel.log(UserEntry.Action.TT_REMOVED, tempTarget.friendlyDescription(profileFunction.getUnits(), resourceHelper)) val id = tempTarget._id if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id) else uploadQueue.removeID("dbAdd", id) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt index e6361768b3..8fb6e08998 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt @@ -12,6 +12,7 @@ import dagger.android.support.DaggerFragment import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Intervals import info.nightscout.androidaps.data.IobTotal +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.TreatmentsTempbasalsFragmentBinding import info.nightscout.androidaps.databinding.TreatmentsTempbasalsItemBinding import info.nightscout.androidaps.db.Source @@ -163,7 +164,7 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() { ${resourceHelper.gs(R.string.date)}: ${dateUtil.dateAndTimeString(tempBasal.date)} """.trimIndent(), { _: DialogInterface?, _: Int -> - uel.log(resourceHelper.gs(R.string.key_uel_removed_tt), dateUtil.dateAndTimeString(tempBasal.date)) + uel.log(UserEntry.Action.TT_REMOVED, dateUtil.dateAndTimeString(tempBasal.date)) activePlugin.activeTreatments.removeTempBasal(tempBasal) }, null) } 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 a579368ad3..ce3e3b6f1d 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 @@ -10,6 +10,7 @@ import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.data.DetailedBolusInfo import info.nightscout.androidaps.data.Profile +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.db.CareportalEvent import info.nightscout.androidaps.db.Source import info.nightscout.androidaps.db.TempTarget @@ -346,7 +347,7 @@ class BolusWizard @Inject constructor( boluscalc = nsJSON() source = Source.USER notes = this@BolusWizard.notes - uel.log(resourceHelper.gs(R.string.key_uel_bolus_advisor), d1 = insulinAfterConstraints) + uel.log(UserEntry.Action.BOLUS_ADVISOR, d1 = insulinAfterConstraints) if (insulin > 0) { commandQueue.bolus(this, object : Callback() { override fun run() { @@ -369,7 +370,7 @@ class BolusWizard @Inject constructor( OKDialog.showConfirmation(ctx, resourceHelper.gs(R.string.boluswizard), confirmMessage, { if (insulinAfterConstraints > 0 || carbs > 0) { if (useSuperBolus) { - uel.log(resourceHelper.gs(R.string.key_uel_superbolus_tbr)) + uel.log(UserEntry.Action.SUPERBOLUS_TBR) if (loopPlugin.isEnabled(PluginType.LOOP)) { loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000) rxBus.send(EventRefreshOverview("WizardDialog")) @@ -410,7 +411,7 @@ class BolusWizard @Inject constructor( boluscalc = nsJSON() source = Source.USER notes = this@BolusWizard.notes - uel.log(resourceHelper.gs(R.string.key_uel_bolus_wizard), "", insulinAfterConstraints, carbs) + uel.log(UserEntry.Action.BOLUS_WIZARD, "", insulinAfterConstraints, carbs) if (insulin > 0 || pump.pumpDescription.storesCarbInfo) { commandQueue.bolus(this, object : Callback() { override fun run() { diff --git a/core/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt b/core/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt index 071a061d5e..91ce1f5a19 100644 --- a/core/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt +++ b/core/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt @@ -11,18 +11,17 @@ import dagger.android.support.DaggerDialogFragment import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.core.R import info.nightscout.androidaps.core.databinding.DialogErrorBinding +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.services.AlarmSoundServiceHelper import info.nightscout.androidaps.utils.T -import info.nightscout.androidaps.utils.resources.ResourceHelper import javax.inject.Inject class ErrorDialog : DaggerDialogFragment() { @Inject lateinit var alarmSoundServiceHelper: AlarmSoundServiceHelper @Inject lateinit var aapsLogger: AAPSLogger - @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var uel: UserEntryLogger var helperActivity: ErrorHelperActivity? = null @@ -60,15 +59,15 @@ class ErrorDialog : DaggerDialogFragment() { binding.title.text = title binding.ok.setOnClickListener { - uel.log(resourceHelper.gs(R.string.key_uel_error_dialog_ok)) + uel.log(UserEntry.Action.ERROR_DIALOG_OK) dismiss() } binding.mute.setOnClickListener { - uel.log(resourceHelper.gs(R.string.key_uel_error_dialog_mute)) + uel.log(UserEntry.Action.ERROR_DIALOG_MUTE) stopAlarm() } binding.mute5min.setOnClickListener { - uel.log(resourceHelper.gs(R.string.key_uel_error_dialog_mute_5min)) + uel.log(UserEntry.Action.ERROR_DIALOG_MUTE_5MIN) stopAlarm() loopHandler.postDelayed(this::startAlarm, T.mins(5).msecs()) } diff --git a/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt b/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt index 1692be20fc..f2270ac57d 100644 --- a/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt +++ b/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt @@ -1,6 +1,7 @@ package info.nightscout.androidaps.logging import info.nightscout.androidaps.database.AppRepository +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.database.transactions.UserEntryTransaction import info.nightscout.androidaps.utils.rx.AapsSchedulers import io.reactivex.disposables.CompositeDisposable @@ -18,7 +19,7 @@ class UserEntryLogger @Inject constructor( private val compositeDisposable = CompositeDisposable() - fun log(action: String, s: String = "", d1: Double = 0.0, d2: Double = 0.0, i1: Int = 0, i2: Int = 0) { + fun log(action: UserEntry.Action, s: String = "", d1: Double = 0.0, d2: Double = 0.0, i1: Int = 0, i2: Int = 0) { compositeDisposable += repository.runTransaction(UserEntryTransaction( action = action, s = s, diff --git a/dana/build.gradle b/dana/build.gradle index 8020051b31..55565f892b 100644 --- a/dana/build.gradle +++ b/dana/build.gradle @@ -17,4 +17,5 @@ android { dependencies { implementation project(':core') + implementation project(':database') } \ No newline at end of file diff --git a/dana/src/main/java/info/nightscout/androidaps/dana/DanaFragment.kt b/dana/src/main/java/info/nightscout/androidaps/dana/DanaFragment.kt index d40f6beded..fc5ca3db9f 100644 --- a/dana/src/main/java/info/nightscout/androidaps/dana/DanaFragment.kt +++ b/dana/src/main/java/info/nightscout/androidaps/dana/DanaFragment.kt @@ -10,6 +10,7 @@ import android.view.ViewGroup import dagger.android.support.DaggerFragment import info.nightscout.androidaps.activities.TDDStatsActivity import info.nightscout.androidaps.dana.databinding.DanarFragmentBinding +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.dialogs.ProfileViewerDialog import info.nightscout.androidaps.events.EventExtendedBolusChange import info.nightscout.androidaps.events.EventInitializationChanged @@ -108,7 +109,7 @@ class DanaFragment : DaggerFragment() { binding.btconnection.setOnLongClickListener { activity?.let { OKDialog.showConfirmation(it, resourceHelper.gs(R.string.resetpairing)) { - uel.log(resourceHelper.gs(R.string.key_uel_clear_pairing_keys)) + uel.log(UserEntry.Action.CLEAR_PAIRING_KEYS) (activePlugin.activePump as DanaPumpInterface).clearPairing() } } 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 f31eb01021..de3b4e8806 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 @@ -13,14 +13,14 @@ data class UserEntry( override var id: Long = 0L, override var timestamp: Long, override var utcOffset: Long = TimeZone.getDefault().getOffset(timestamp).toLong(), - var action: String, + var action: Action, var s: String, var d1: Double, var d2: Double, var i1: Int, var i2: Int ) : DBEntry, DBEntryWithTime { - enum class Type { + enum class Action { BOLUS, BOLUS_WIZARD, BOLUS_ADVISOR, @@ -40,7 +40,7 @@ data class UserEntry( CLONE_PROFILE, STORE_PROFILE, PROFILE_SWITCH, - PROFILE_SWITCH_CLONE, + PROFILE_SWITCH_CLONED, CLOSED_LOOP_MODE, LGS_LOOP_MODE, @@ -118,14 +118,14 @@ data class UserEntry( SMS_CAL, SMS_CARBS, SMS_EXTENDED_BOLUS, - SMS_LOOP_DISABLE, - SMS_LOOP_ENABLE, + SMS_LOOP_DISABLED, + SMS_LOOP_ENABLED, SMS_LOOP_RESUME, SMS_LOOP_SUSPEND, SMS_PROFILE, SMS_PUMP_CONNECT, SMS_PUMP_DISCONNECT, SMS_SMS, - SMS_TARGET + SMS_TT } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UserEntryTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UserEntryTransaction.kt index dc3b138848..c4d4ce2755 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UserEntryTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UserEntryTransaction.kt @@ -3,7 +3,7 @@ package info.nightscout.androidaps.database.transactions import info.nightscout.androidaps.database.entities.UserEntry class UserEntryTransaction( - val action: String, + val action: UserEntry.Action, val s: String = "", val d1: Double = 0.0, val d2: Double = 0.0, From db23a5e9f74394c66218cb4a2344075ed92548f1 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 21 Feb 2021 10:35:04 +0100 Subject: [PATCH 05/66] Update Strings (translatable and key removed) --- .../fragments/TreatmentsUserEntryFragment.kt | 102 +++++++++- app/src/main/res/values/strings.xml | 176 +++++++++--------- core/src/main/res/values/strings.xml | 6 - dana/src/main/res/values/strings.xml | 1 - 4 files changed, 191 insertions(+), 94 deletions(-) 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 0e4f7cc200..925e926d42 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 @@ -13,6 +13,7 @@ import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.TreatmentsUserEntryFragmentBinding import info.nightscout.androidaps.databinding.TreatmentsUserEntryItemBinding import info.nightscout.androidaps.utils.DateUtil +import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.rx.AapsSchedulers import io.reactivex.disposables.CompositeDisposable import io.reactivex.rxkotlin.plusAssign @@ -22,6 +23,7 @@ class TreatmentsUserEntryFragment : DaggerFragment() { @Inject lateinit var repository: AppRepository @Inject lateinit var aapsSchedulers: AapsSchedulers + @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var dateUtil: DateUtil private val disposable = CompositeDisposable() @@ -63,7 +65,7 @@ class TreatmentsUserEntryFragment : DaggerFragment() { override fun onBindViewHolder(holder: UserEntryViewHolder, position: Int) { val current = entries[position] holder.binding.date.text = dateUtil.dateAndTimeAndSecondsString(current.timestamp) - holder.binding.action.text = current.action + holder.binding.action.text = action2String(current.action) if (current.s != "") holder.binding.s.text = current.s else holder.binding.s.visibility = View.GONE if (current.d1 != 0.0) holder.binding.d1.text = current.d1.toString() else holder.binding.d1.visibility = View.GONE if (current.d2 != 0.0) holder.binding.d2.text = current.d2.toString() else holder.binding.d2.visibility = View.GONE @@ -78,5 +80,103 @@ class TreatmentsUserEntryFragment : DaggerFragment() { override fun getItemCount(): Int = entries.size + private fun action2String(action: UserEntry.Action): String { + return when (action) { + UserEntry.Action.BOLUS -> resourceHelper.gs(R.string.uel_bolus) + UserEntry.Action.BOLUS_WIZARD -> resourceHelper.gs(R.string.uel_bolus_wizard) + UserEntry.Action.BOLUS_ADVISOR -> resourceHelper.gs(R.string.uel_bolus_advisor) + UserEntry.Action.BOLUS_RECORD -> resourceHelper.gs(R.string.uel_bolus_record) + UserEntry.Action.EXTENDED_BOLUS -> resourceHelper.gs(R.string.uel_extended_bolus) + UserEntry.Action.SUPERBOLUS_TBR -> resourceHelper.gs(R.string.uel_superbolus_tbr) + UserEntry.Action.CARBS -> resourceHelper.gs(R.string.uel_carbs) + + UserEntry.Action.TEMP_BASAL -> resourceHelper.gs(R.string.uel_temp_basal) + UserEntry.Action.TT -> resourceHelper.gs(R.string.uel_tt) + UserEntry.Action.TT_ACTIVITY -> resourceHelper.gs(R.string.uel_tt_activity) + UserEntry.Action.TT_EATING_SOON -> resourceHelper.gs(R.string.uel_tt_eating_soon) + UserEntry.Action.TT_HYPO -> resourceHelper.gs(R.string.uel_tt_hypo) + UserEntry.Action.NEW_PROFILE -> resourceHelper.gs(R.string.uel_new_profile) + UserEntry.Action.CLONE_PROFILE -> resourceHelper.gs(R.string.uel_clone_profile) + UserEntry.Action.STORE_PROFILE -> resourceHelper.gs(R.string.uel_store_profile) + UserEntry.Action.PROFILE_SWITCH -> resourceHelper.gs(R.string.uel_profile_switch) + UserEntry.Action.PROFILE_SWITCH_CLONED -> resourceHelper.gs(R.string.uel_profile_switch_clone) + UserEntry.Action.CLOSED_LOOP_MODE -> resourceHelper.gs(R.string.uel_closed_loop_mode) + UserEntry.Action.LGS_LOOP_MODE -> resourceHelper.gs(R.string.uel_lgs_loop_mode) + UserEntry.Action.OPEN_LOOP_MODE -> resourceHelper.gs(R.string.uel_open_loop_mode) + UserEntry.Action.LOOP_DISABLED -> resourceHelper.gs(R.string.uel_loop_disabled) + UserEntry.Action.LOOP_ENABLED -> resourceHelper.gs(R.string.uel_loop_enabled) + UserEntry.Action.RECONNECT -> resourceHelper.gs(R.string.uel_reconnect) + UserEntry.Action.DISCONNECT_15M -> resourceHelper.gs(R.string.uel_disconnect_15m) + UserEntry.Action.DISCONNECT_30M -> resourceHelper.gs(R.string.uel_disconnect_30m) + UserEntry.Action.DISCONNECT_1H -> resourceHelper.gs(R.string.uel_disconnect_1h) + UserEntry.Action.DISCONNECT_2H -> resourceHelper.gs(R.string.uel_disconnect_2h) + UserEntry.Action.DISCONNECT_3H -> resourceHelper.gs(R.string.uel_disconnect_3h) + UserEntry.Action.RESUME -> resourceHelper.gs(R.string.uel_resume) + UserEntry.Action.SUSPEND_1H -> resourceHelper.gs(R.string.uel_suspend_1h) + UserEntry.Action.SUSPEND_2H -> resourceHelper.gs(R.string.uel_suspend_2h) + UserEntry.Action.SUSPEND_3H -> resourceHelper.gs(R.string.uel_suspend_3h) + UserEntry.Action.SUSPEND_10H -> resourceHelper.gs(R.string.uel_suspend_10h) + UserEntry.Action.HW_PUMP_ALLOWED -> resourceHelper.gs(R.string.uel_hw_pump_allowed) + UserEntry.Action.CLEAR_PAIRING_KEYS -> resourceHelper.gs(R.string.uel_clear_pairing_keys) + UserEntry.Action.ACCEPTS_TEMP_BASAL -> resourceHelper.gs(R.string.uel_accepts_temp_basal) + UserEntry.Action.CANCEL_TEMP_BASAL -> resourceHelper.gs(R.string.uel_cancel_temp_basal) + UserEntry.Action.CANCEL_EXTENDED_BOLUS -> resourceHelper.gs(R.string.uel_cancel_extended_bolus) + + UserEntry.Action.CAREPORTAL -> resourceHelper.gs(R.string.uel_careportal) + UserEntry.Action.CALIBRATION -> resourceHelper.gs(R.string.uel_calibration) + UserEntry.Action.INSULIN_CHANGE -> resourceHelper.gs(R.string.uel_insulin_change) + UserEntry.Action.PRIME_BOLUS -> resourceHelper.gs(R.string.uel_prime_bolus) + UserEntry.Action.SITE_CHANGE -> resourceHelper.gs(R.string.uel_site_change) + UserEntry.Action.TREATMENT -> resourceHelper.gs(R.string.uel_treatment) + UserEntry.Action.CAREPORTAL_NS_REFRESH -> resourceHelper.gs(R.string.uel_careportal_ns_refresh) + UserEntry.Action.PROFILE_SWITCH_NS_REFRESH -> resourceHelper.gs(R.string.uel_profile_switch_ns_refresh) + UserEntry.Action.TREATMENTS_NS_REFRESH -> resourceHelper.gs(R.string.uel_treat_ns_refresh) + UserEntry.Action.TT_NS_REFRESH -> resourceHelper.gs(R.string.uel_tt_ns_refresh) + UserEntry.Action.AUTOMATION_REMOVED -> resourceHelper.gs(R.string.uel_autom_removed) + UserEntry.Action.BG_REMOVED -> resourceHelper.gs(R.string.uel_bg_removed) + UserEntry.Action.CAREPORTAL_REMOVED -> resourceHelper.gs(R.string.uel_removed_carep) + UserEntry.Action.EXTENDED_BOLUS_REMOVED -> resourceHelper.gs(R.string.uel_removed_eb) + UserEntry.Action.FOOD_REMOVED -> resourceHelper.gs(R.string.uel_food_removed) + UserEntry.Action.PROFILE_REMOVED -> resourceHelper.gs(R.string.uel_remove_profile) + UserEntry.Action.PROFILE_SWITCH_REMOVED -> resourceHelper.gs(R.string.uel_removed_profile_switch) + UserEntry.Action.RESTART_EVENTS_REMOVED -> resourceHelper.gs(R.string.uel_removed_restart_events) + UserEntry.Action.TREATMENT_REMOVED -> resourceHelper.gs(R.string.uel_removed_treatment) + UserEntry.Action.TT_REMOVED -> resourceHelper.gs(R.string.uel_removed_tt) + UserEntry.Action.NS_PAUSED -> resourceHelper.gs(R.string.uel_ns_paused) + UserEntry.Action.NS_QUEUE_CLEARED -> resourceHelper.gs(R.string.uel_ns_queue_cleared) + UserEntry.Action.NS_SETTINGS_COPIED -> resourceHelper.gs(R.string.uel_ns_settings_copied) + UserEntry.Action.ERROR_DIALOG_OK -> resourceHelper.gs(R.string.uel_error_dialog_ok) + UserEntry.Action.ERROR_DIALOG_MUTE -> resourceHelper.gs(R.string.uel_error_dialog_mute) + UserEntry.Action.ERROR_DIALOG_MUTE_5MIN -> resourceHelper.gs(R.string.uel_error_dialog_mute_5min) + UserEntry.Action.OBJECTIVE_UNSTARTED -> resourceHelper.gs(R.string.uel_objective_unstarted) + UserEntry.Action.OBJECTIVES_SKIPPED -> resourceHelper.gs(R.string.uel_objectives_skipped) + UserEntry.Action.STAT_RESET -> resourceHelper.gs(R.string.uel_stat_reset) + UserEntry.Action.DELETE_LOGS -> resourceHelper.gs(R.string.uel_delete_logs) + UserEntry.Action.DELETE_FUTURE_TREATMENTS -> resourceHelper.gs(R.string.uel_delete_future_treatments) + UserEntry.Action.EXPORT_SETTINGS -> resourceHelper.gs(R.string.uel_export_settings) + UserEntry.Action.IMPORT_SETTINGS -> resourceHelper.gs(R.string.uel_import_settings) + UserEntry.Action.RESET_DATABASES -> resourceHelper.gs(R.string.uel_reset_databases) + + UserEntry.Action.OTP_EXPORT -> resourceHelper.gs(R.string.uel_otp_export) + UserEntry.Action.OTP_RESET -> resourceHelper.gs(R.string.uel_otp_reset) + UserEntry.Action.SMS_BASAL -> resourceHelper.gs(R.string.uel_sms_basal) + UserEntry.Action.SMS_BOLUS -> resourceHelper.gs(R.string.uel_sms_bolus) + UserEntry.Action.SMS_CAL -> resourceHelper.gs(R.string.uel_sms_cal) + UserEntry.Action.SMS_CARBS -> resourceHelper.gs(R.string.uel_sms_carbs) + UserEntry.Action.SMS_EXTENDED_BOLUS -> resourceHelper.gs(R.string.uel_sms_extended) + UserEntry.Action.SMS_LOOP_DISABLED -> resourceHelper.gs(R.string.uel_sms_loop_disable) + UserEntry.Action.SMS_LOOP_ENABLED -> resourceHelper.gs(R.string.uel_sms_loop_enable) + UserEntry.Action.SMS_LOOP_RESUME -> resourceHelper.gs(R.string.uel_sms_loop_resume) + UserEntry.Action.SMS_LOOP_SUSPEND -> resourceHelper.gs(R.string.uel_sms_loop_suspend) + UserEntry.Action.SMS_PROFILE -> resourceHelper.gs(R.string.uel_sms_profile) + UserEntry.Action.SMS_PUMP_CONNECT -> resourceHelper.gs(R.string.uel_sms_pump_connect) + UserEntry.Action.SMS_PUMP_DISCONNECT -> resourceHelper.gs(R.string.uel_sms_pump_disconnect) + UserEntry.Action.SMS_SMS -> resourceHelper.gs(R.string.uel_sms_sms) + UserEntry.Action.SMS_TT -> resourceHelper.gs(R.string.uel_sms_target) + + else -> "To be defined" + + } + } } } \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 327f81ee20..95a50e1d9d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1382,91 +1382,95 @@ User entry Use values of your largest food you usually eat\n - STATS RESET - CALIBRATION - TT ACTIVITY - TT EATING SOON - TT HYPO - CARBS - CAREPORTAL - EXTENDED BOLUS - PRIME BOLUS - SITE CHANGE - INSULIN CHANGE - BOLUS RECORD - BOLUS - CLOSED LOOP MODE - LGS LOOP MODE - OPEN LOOP MODE - LOOP DISABLED - LOOP ENABLED - RESUME - RECONNECT - SUSPEND 1h - SUSPEND 2h - SUSPEND 3h - SUSPEND 10h - DISCONNECT 15m - DISCONNECT 30m - DISCONNECT 1h - DISCONNECT 2h - DISCONNECT 3h - PROFILE SWITCH - TEMP BASAL - TT - TREATMENT - OBJECTIVE UNSTARTED - CANCEL EXTENDED BOLUS - CANCEL TEMP BASAL - AUTOM REMOVED - FOOD REMOVED - DELETE LOGS - RESET DATABASES - EXPORT SETTINGS - IMPORT SETTINGS - ACCEPT TEMP BASAL - OTP RESET - OTP EXPORT - NEW PROFILE - CLONE PROFILE - REMOVE PROFILE - BG REMOVED - TREAT NS REFRESH - DELETE FUTURE TREATMENTS - REMOVED TREATMENT - CAREPORTAL NS REFRESH - REMOVED RESTART EVENTS - REMOVED CAREP - REMOVED EB - PROFILE SWITCH NS REFRESH - REMOVED PROFILE SWITCH - PROFILE SWITCH CLONE - REMOVED TT - TT NS REFRESH - TT REMOVE - BOLUS ADVISOR - SUPERBOLUS TBR - BOLUS WIZARD - NS QUEUE CLEARED - NS PAUSED - HW PUMP ALLOWED - OBJECTIVES SKIPPED - IMPORT - NS SETTINGS COPIED - SMS LOOP DISABLE - SMS LOOP ENABLE - SMS LOOP RESUME - SMS LOOP SUSPEND - SMS PUMP CONNECT - SMS PUMP DISCONNECT - SMS PROFILE - SMS BASAL - SMS EXTENDED - SMS BOLUS - SMS CARBS - SMS TARGET - SMS SMS - SMS CAL - STORE PROFILE + STATS RESET + CALIBRATION + TT ACTIVITY + TT EATING SOON + TT HYPO + CARBS + CAREPORTAL + EXTENDED BOLUS + PRIME BOLUS + SITE CHANGE + INSULIN CHANGE + BOLUS RECORD + BOLUS + CLOSED LOOP MODE + LGS LOOP MODE + OPEN LOOP MODE + LOOP DISABLED + LOOP ENABLED + RESUME + RECONNECT + SUSPEND 1h + SUSPEND 2h + SUSPEND 3h + SUSPEND 10h + DISCONNECT 15m + DISCONNECT 30m + DISCONNECT 1h + DISCONNECT 2h + DISCONNECT 3h + PROFILE SWITCH + TEMP BASAL + TT + TREATMENT + OBJECTIVE UNSTARTED + CANCEL EXTENDED BOLUS + CANCEL TEMP BASAL + AUTOM REMOVED + FOOD REMOVED + DELETE LOGS + RESET DATABASES + EXPORT SETTINGS + IMPORT SETTINGS + ACCEPT TEMP BASAL + OTP RESET + OTP EXPORT + NEW PROFILE + CLONE PROFILE + REMOVE PROFILE + BG REMOVED + TREAT NS REFRESH + DELETE FUTURE TREATMENTS + REMOVED TREATMENT + CAREPORTAL NS REFRESH + REMOVED RESTART EVENTS + REMOVED CAREP + REMOVED EB + PROFILE SWITCH NS REFRESH + REMOVED PROFILE SWITCH + PROFILE SWITCH CLONE + REMOVED TT + TT NS REFRESH + TT REMOVE + BOLUS ADVISOR + SUPERBOLUS TBR + BOLUS WIZARD + NS QUEUE CLEARED + NS PAUSED + HW PUMP ALLOWED + OBJECTIVES SKIPPED + IMPORT + NS SETTINGS COPIED + SMS LOOP DISABLE + SMS LOOP ENABLE + SMS LOOP RESUME + SMS LOOP SUSPEND + SMS PUMP CONNECT + SMS PUMP DISCONNECT + SMS PROFILE + SMS BASAL + SMS EXTENDED + SMS BOLUS + SMS CARBS + SMS TARGET + SMS SMS + SMS CAL + STORE PROFILE + ERROR DIALOG OK + ERROR DIALOG MUTE + ERROR DIALOG MUTE 5MIN + CLEAR PAIRING KEYS diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 6131a51226..7d22c30592 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -30,14 +30,8 @@ virtualpump_type QuickWizard wearcontrol - ERROR DIALOG OK - ERROR DIALOG MUTE - ERROR DIALOG MUTE 5MIN - Error dialog ok pressed - Error dialog mute pressed - Error dialog mute 5 min pressed Refresh Error Not set diff --git a/dana/src/main/res/values/strings.xml b/dana/src/main/res/values/strings.xml index 84ff82e413..c6ec142c94 100644 --- a/dana/src/main/res/values/strings.xml +++ b/dana/src/main/res/values/strings.xml @@ -13,7 +13,6 @@ rs_loginsulinchange rs_last_clear_key_request danar_bt_name - CLEAR PAIRING KEYS Pairing No device found so far From bdd5fe383cd97a06b6e7e9f565a1f3ee1f47ca18 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 21 Feb 2021 12:03:15 +0100 Subject: [PATCH 06/66] Update enum class => Need help for strings location --- .../fragments/TreatmentsUserEntryFragment.kt | 100 +-------- app/src/main/res/values/strings.xml | 91 +------- core/src/main/res/values/strings.xml | 95 ++++++++ .../androidaps/database/entities/UserEntry.kt | 202 +++++++++--------- 4 files changed, 193 insertions(+), 295 deletions(-) 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 925e926d42..998be127d0 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 @@ -65,7 +65,7 @@ class TreatmentsUserEntryFragment : DaggerFragment() { override fun onBindViewHolder(holder: UserEntryViewHolder, position: Int) { val current = entries[position] holder.binding.date.text = dateUtil.dateAndTimeAndSecondsString(current.timestamp) - holder.binding.action.text = action2String(current.action) + holder.binding.action.text = resourceHelper.gs(current.action.stringId) if (current.s != "") holder.binding.s.text = current.s else holder.binding.s.visibility = View.GONE if (current.d1 != 0.0) holder.binding.d1.text = current.d1.toString() else holder.binding.d1.visibility = View.GONE if (current.d2 != 0.0) holder.binding.d2.text = current.d2.toString() else holder.binding.d2.visibility = View.GONE @@ -80,103 +80,5 @@ class TreatmentsUserEntryFragment : DaggerFragment() { override fun getItemCount(): Int = entries.size - private fun action2String(action: UserEntry.Action): String { - return when (action) { - UserEntry.Action.BOLUS -> resourceHelper.gs(R.string.uel_bolus) - UserEntry.Action.BOLUS_WIZARD -> resourceHelper.gs(R.string.uel_bolus_wizard) - UserEntry.Action.BOLUS_ADVISOR -> resourceHelper.gs(R.string.uel_bolus_advisor) - UserEntry.Action.BOLUS_RECORD -> resourceHelper.gs(R.string.uel_bolus_record) - UserEntry.Action.EXTENDED_BOLUS -> resourceHelper.gs(R.string.uel_extended_bolus) - UserEntry.Action.SUPERBOLUS_TBR -> resourceHelper.gs(R.string.uel_superbolus_tbr) - UserEntry.Action.CARBS -> resourceHelper.gs(R.string.uel_carbs) - - UserEntry.Action.TEMP_BASAL -> resourceHelper.gs(R.string.uel_temp_basal) - UserEntry.Action.TT -> resourceHelper.gs(R.string.uel_tt) - UserEntry.Action.TT_ACTIVITY -> resourceHelper.gs(R.string.uel_tt_activity) - UserEntry.Action.TT_EATING_SOON -> resourceHelper.gs(R.string.uel_tt_eating_soon) - UserEntry.Action.TT_HYPO -> resourceHelper.gs(R.string.uel_tt_hypo) - UserEntry.Action.NEW_PROFILE -> resourceHelper.gs(R.string.uel_new_profile) - UserEntry.Action.CLONE_PROFILE -> resourceHelper.gs(R.string.uel_clone_profile) - UserEntry.Action.STORE_PROFILE -> resourceHelper.gs(R.string.uel_store_profile) - UserEntry.Action.PROFILE_SWITCH -> resourceHelper.gs(R.string.uel_profile_switch) - UserEntry.Action.PROFILE_SWITCH_CLONED -> resourceHelper.gs(R.string.uel_profile_switch_clone) - UserEntry.Action.CLOSED_LOOP_MODE -> resourceHelper.gs(R.string.uel_closed_loop_mode) - UserEntry.Action.LGS_LOOP_MODE -> resourceHelper.gs(R.string.uel_lgs_loop_mode) - UserEntry.Action.OPEN_LOOP_MODE -> resourceHelper.gs(R.string.uel_open_loop_mode) - UserEntry.Action.LOOP_DISABLED -> resourceHelper.gs(R.string.uel_loop_disabled) - UserEntry.Action.LOOP_ENABLED -> resourceHelper.gs(R.string.uel_loop_enabled) - UserEntry.Action.RECONNECT -> resourceHelper.gs(R.string.uel_reconnect) - UserEntry.Action.DISCONNECT_15M -> resourceHelper.gs(R.string.uel_disconnect_15m) - UserEntry.Action.DISCONNECT_30M -> resourceHelper.gs(R.string.uel_disconnect_30m) - UserEntry.Action.DISCONNECT_1H -> resourceHelper.gs(R.string.uel_disconnect_1h) - UserEntry.Action.DISCONNECT_2H -> resourceHelper.gs(R.string.uel_disconnect_2h) - UserEntry.Action.DISCONNECT_3H -> resourceHelper.gs(R.string.uel_disconnect_3h) - UserEntry.Action.RESUME -> resourceHelper.gs(R.string.uel_resume) - UserEntry.Action.SUSPEND_1H -> resourceHelper.gs(R.string.uel_suspend_1h) - UserEntry.Action.SUSPEND_2H -> resourceHelper.gs(R.string.uel_suspend_2h) - UserEntry.Action.SUSPEND_3H -> resourceHelper.gs(R.string.uel_suspend_3h) - UserEntry.Action.SUSPEND_10H -> resourceHelper.gs(R.string.uel_suspend_10h) - UserEntry.Action.HW_PUMP_ALLOWED -> resourceHelper.gs(R.string.uel_hw_pump_allowed) - UserEntry.Action.CLEAR_PAIRING_KEYS -> resourceHelper.gs(R.string.uel_clear_pairing_keys) - UserEntry.Action.ACCEPTS_TEMP_BASAL -> resourceHelper.gs(R.string.uel_accepts_temp_basal) - UserEntry.Action.CANCEL_TEMP_BASAL -> resourceHelper.gs(R.string.uel_cancel_temp_basal) - UserEntry.Action.CANCEL_EXTENDED_BOLUS -> resourceHelper.gs(R.string.uel_cancel_extended_bolus) - - UserEntry.Action.CAREPORTAL -> resourceHelper.gs(R.string.uel_careportal) - UserEntry.Action.CALIBRATION -> resourceHelper.gs(R.string.uel_calibration) - UserEntry.Action.INSULIN_CHANGE -> resourceHelper.gs(R.string.uel_insulin_change) - UserEntry.Action.PRIME_BOLUS -> resourceHelper.gs(R.string.uel_prime_bolus) - UserEntry.Action.SITE_CHANGE -> resourceHelper.gs(R.string.uel_site_change) - UserEntry.Action.TREATMENT -> resourceHelper.gs(R.string.uel_treatment) - UserEntry.Action.CAREPORTAL_NS_REFRESH -> resourceHelper.gs(R.string.uel_careportal_ns_refresh) - UserEntry.Action.PROFILE_SWITCH_NS_REFRESH -> resourceHelper.gs(R.string.uel_profile_switch_ns_refresh) - UserEntry.Action.TREATMENTS_NS_REFRESH -> resourceHelper.gs(R.string.uel_treat_ns_refresh) - UserEntry.Action.TT_NS_REFRESH -> resourceHelper.gs(R.string.uel_tt_ns_refresh) - UserEntry.Action.AUTOMATION_REMOVED -> resourceHelper.gs(R.string.uel_autom_removed) - UserEntry.Action.BG_REMOVED -> resourceHelper.gs(R.string.uel_bg_removed) - UserEntry.Action.CAREPORTAL_REMOVED -> resourceHelper.gs(R.string.uel_removed_carep) - UserEntry.Action.EXTENDED_BOLUS_REMOVED -> resourceHelper.gs(R.string.uel_removed_eb) - UserEntry.Action.FOOD_REMOVED -> resourceHelper.gs(R.string.uel_food_removed) - UserEntry.Action.PROFILE_REMOVED -> resourceHelper.gs(R.string.uel_remove_profile) - UserEntry.Action.PROFILE_SWITCH_REMOVED -> resourceHelper.gs(R.string.uel_removed_profile_switch) - UserEntry.Action.RESTART_EVENTS_REMOVED -> resourceHelper.gs(R.string.uel_removed_restart_events) - UserEntry.Action.TREATMENT_REMOVED -> resourceHelper.gs(R.string.uel_removed_treatment) - UserEntry.Action.TT_REMOVED -> resourceHelper.gs(R.string.uel_removed_tt) - UserEntry.Action.NS_PAUSED -> resourceHelper.gs(R.string.uel_ns_paused) - UserEntry.Action.NS_QUEUE_CLEARED -> resourceHelper.gs(R.string.uel_ns_queue_cleared) - UserEntry.Action.NS_SETTINGS_COPIED -> resourceHelper.gs(R.string.uel_ns_settings_copied) - UserEntry.Action.ERROR_DIALOG_OK -> resourceHelper.gs(R.string.uel_error_dialog_ok) - UserEntry.Action.ERROR_DIALOG_MUTE -> resourceHelper.gs(R.string.uel_error_dialog_mute) - UserEntry.Action.ERROR_DIALOG_MUTE_5MIN -> resourceHelper.gs(R.string.uel_error_dialog_mute_5min) - UserEntry.Action.OBJECTIVE_UNSTARTED -> resourceHelper.gs(R.string.uel_objective_unstarted) - UserEntry.Action.OBJECTIVES_SKIPPED -> resourceHelper.gs(R.string.uel_objectives_skipped) - UserEntry.Action.STAT_RESET -> resourceHelper.gs(R.string.uel_stat_reset) - UserEntry.Action.DELETE_LOGS -> resourceHelper.gs(R.string.uel_delete_logs) - UserEntry.Action.DELETE_FUTURE_TREATMENTS -> resourceHelper.gs(R.string.uel_delete_future_treatments) - UserEntry.Action.EXPORT_SETTINGS -> resourceHelper.gs(R.string.uel_export_settings) - UserEntry.Action.IMPORT_SETTINGS -> resourceHelper.gs(R.string.uel_import_settings) - UserEntry.Action.RESET_DATABASES -> resourceHelper.gs(R.string.uel_reset_databases) - - UserEntry.Action.OTP_EXPORT -> resourceHelper.gs(R.string.uel_otp_export) - UserEntry.Action.OTP_RESET -> resourceHelper.gs(R.string.uel_otp_reset) - UserEntry.Action.SMS_BASAL -> resourceHelper.gs(R.string.uel_sms_basal) - UserEntry.Action.SMS_BOLUS -> resourceHelper.gs(R.string.uel_sms_bolus) - UserEntry.Action.SMS_CAL -> resourceHelper.gs(R.string.uel_sms_cal) - UserEntry.Action.SMS_CARBS -> resourceHelper.gs(R.string.uel_sms_carbs) - UserEntry.Action.SMS_EXTENDED_BOLUS -> resourceHelper.gs(R.string.uel_sms_extended) - UserEntry.Action.SMS_LOOP_DISABLED -> resourceHelper.gs(R.string.uel_sms_loop_disable) - UserEntry.Action.SMS_LOOP_ENABLED -> resourceHelper.gs(R.string.uel_sms_loop_enable) - UserEntry.Action.SMS_LOOP_RESUME -> resourceHelper.gs(R.string.uel_sms_loop_resume) - UserEntry.Action.SMS_LOOP_SUSPEND -> resourceHelper.gs(R.string.uel_sms_loop_suspend) - UserEntry.Action.SMS_PROFILE -> resourceHelper.gs(R.string.uel_sms_profile) - UserEntry.Action.SMS_PUMP_CONNECT -> resourceHelper.gs(R.string.uel_sms_pump_connect) - UserEntry.Action.SMS_PUMP_DISCONNECT -> resourceHelper.gs(R.string.uel_sms_pump_disconnect) - UserEntry.Action.SMS_SMS -> resourceHelper.gs(R.string.uel_sms_sms) - UserEntry.Action.SMS_TT -> resourceHelper.gs(R.string.uel_sms_target) - - else -> "To be defined" - - } - } } } \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 95a50e1d9d..7a50e98553 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1382,95 +1382,6 @@ User entry Use values of your largest food you usually eat\n - STATS RESET - CALIBRATION - TT ACTIVITY - TT EATING SOON - TT HYPO - CARBS - CAREPORTAL - EXTENDED BOLUS - PRIME BOLUS - SITE CHANGE - INSULIN CHANGE - BOLUS RECORD - BOLUS - CLOSED LOOP MODE - LGS LOOP MODE - OPEN LOOP MODE - LOOP DISABLED - LOOP ENABLED - RESUME - RECONNECT - SUSPEND 1h - SUSPEND 2h - SUSPEND 3h - SUSPEND 10h - DISCONNECT 15m - DISCONNECT 30m - DISCONNECT 1h - DISCONNECT 2h - DISCONNECT 3h - PROFILE SWITCH - TEMP BASAL - TT - TREATMENT - OBJECTIVE UNSTARTED - CANCEL EXTENDED BOLUS - CANCEL TEMP BASAL - AUTOM REMOVED - FOOD REMOVED - DELETE LOGS - RESET DATABASES - EXPORT SETTINGS - IMPORT SETTINGS - ACCEPT TEMP BASAL - OTP RESET - OTP EXPORT - NEW PROFILE - CLONE PROFILE - REMOVE PROFILE - BG REMOVED - TREAT NS REFRESH - DELETE FUTURE TREATMENTS - REMOVED TREATMENT - CAREPORTAL NS REFRESH - REMOVED RESTART EVENTS - REMOVED CAREP - REMOVED EB - PROFILE SWITCH NS REFRESH - REMOVED PROFILE SWITCH - PROFILE SWITCH CLONE - REMOVED TT - TT NS REFRESH - TT REMOVE - BOLUS ADVISOR - SUPERBOLUS TBR - BOLUS WIZARD - NS QUEUE CLEARED - NS PAUSED - HW PUMP ALLOWED - OBJECTIVES SKIPPED - IMPORT - NS SETTINGS COPIED - SMS LOOP DISABLE - SMS LOOP ENABLE - SMS LOOP RESUME - SMS LOOP SUSPEND - SMS PUMP CONNECT - SMS PUMP DISCONNECT - SMS PROFILE - SMS BASAL - SMS EXTENDED - SMS BOLUS - SMS CARBS - SMS TARGET - SMS SMS - SMS CAL - STORE PROFILE - ERROR DIALOG OK - ERROR DIALOG MUTE - ERROR DIALOG MUTE 5MIN - CLEAR PAIRING KEYS + diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 7d22c30592..c53af0a267 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -325,6 +325,101 @@ S S + + BOLUS + BOLUS WIZARD + BOLUS ADVISOR + BOLUS RECORD + EXTENDED BOLUS + SUPERBOLUS TBR + CARBS + EXTENDED CARBS + TEMP BASAL + TT + TT ACTIVITY + TT EATING SOON + TT HYPO + NEW PROFILE + CLONE PROFILE + STORE PROFILE + PROFILE SWITCH + PROFILE SWITCH CLONED + CLOSED LOOP MODE + LGS LOOP MODE + OPEN LOOP MODE + LOOP DISABLED + LOOP ENABLED + RECONNECT + DISCONNECT 15M + DISCONNECT 30M + DISCONNECT 1H + DISCONNECT 2H + DISCONNECT 3H + RESUME + SUSPEND 1H + SUSPEND 2H + SUSPEND 3H + SUSPEND 10H + HW PUMP ALLOWED + CLEAR PAIRING KEYS + ACCEPTS TEMP BASAL + CANCEL TEMP BASAL + CANCEL EXTENDED BOLUS + CANCEL TT + CAREPORTAL + CALIBRATION + INSULIN CHANGE + PRIME BOLUS + SITE CHANGE + TREATMENT + CAREPORTAL NS REFRESH + PROFILE SWITCH NS REFRESH + TREATMENTS NS REFRESH + TT NS REFRESH + AUTOMATION REMOVED + BG REMOVED + CAREPORTAL REMOVED + EXTENDED BOLUS REMOVED + FOOD REMOVED + PROFILE REMOVED + PROFILE SWITCH REMOVED + RESTART EVENTS REMOVED + TREATMENT REMOVED + TT REMOVED + NS PAUSED + NS QUEUE CLEARED + NS SETTINGS COPIED + ERROR DIALOG OK + ERROR DIALOG MUTE + ERROR DIALOG MUTE 5MIN + OBJECTIVE STARTED + OBJECTIVE UNSTARTED + OBJECTIVES SKIPPED + STAT RESET + DELETE LOGS + DELETE FUTURE TREATMENTS + EXPORT SETTINGS + IMPORT SETTINGS + RESET DATABASES + EXPORT DATABASES + 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 + %1$d day %1$d days 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 de3b4e8806..0f1f66c574 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 @@ -2,6 +2,8 @@ package info.nightscout.androidaps.database.entities import androidx.room.Entity import androidx.room.PrimaryKey +import com.google.gson.annotations.SerializedName +import info.nightscout.androidaps.database.R import info.nightscout.androidaps.database.TABLE_USER_ENTRY import info.nightscout.androidaps.database.interfaces.DBEntry import info.nightscout.androidaps.database.interfaces.DBEntryWithTime @@ -20,112 +22,100 @@ data class UserEntry( var i1: Int, var i2: Int ) : DBEntry, DBEntryWithTime { - enum class Action { - BOLUS, - BOLUS_WIZARD, - BOLUS_ADVISOR, - BOLUS_RECORD, - EXTENDED_BOLUS, - SUPERBOLUS_TBR, - CARBS, - EXTENDED_CARBS, - TEMP_BASAL, + enum class Action (val stringId:Int) { + @SerializedName("BOLUS") BOLUS (R.string.uel_bolus), + @SerializedName("BOLUS_WIZARD") BOLUS_WIZARD (R.string.uel_bolus_wizard), + @SerializedName("BOLUS_ADVISOR") BOLUS_ADVISOR (R.string.uel_bolus_advisor), + @SerializedName("BOLUS_RECORD") BOLUS_RECORD (R.string.uel_bolus_record), + @SerializedName("EXTENDED_BOLUS") EXTENDED_BOLUS (R.string.uel_extended_bolus), + @SerializedName("SUPERBOLUS_TBR") SUPERBOLUS_TBR (R.string.uel_superbolus_tbr), + @SerializedName("CARBS") CARBS (R.string.uel_carbs), + @SerializedName("EXTENDED_CARBS") EXTENDED_CARBS (R.string.uel_extended_carbs), + @SerializedName("TEMP_BASAL") TEMP_BASAL (R.string.uel_temp_basal), + @SerializedName("TT") TT (R.string.uel_tt), + @SerializedName("TT_ACTIVITY") TT_ACTIVITY (R.string.uel_tt_activity), + @SerializedName("TT_EATING_SOON") TT_EATING_SOON (R.string.uel_tt_eating_soon), + @SerializedName("TT_HYPO") TT_HYPO (R.string.uel_tt_hypo), + @SerializedName("NEW_PROFILE") NEW_PROFILE (R.string.uel_new_profile), + @SerializedName("CLONE_PROFILE") CLONE_PROFILE (R.string.uel_clone_profile), + @SerializedName("STORE_PROFILE") STORE_PROFILE (R.string.uel_store_profile), + @SerializedName("PROFILE_SWITCH") PROFILE_SWITCH (R.string.uel_profile_switch), + @SerializedName("PROFILE_SWITCH_CLONED") PROFILE_SWITCH_CLONED (R.string.uel_profile_switch_cloned), + @SerializedName("CLOSED_LOOP_MODE") CLOSED_LOOP_MODE (R.string.uel_closed_loop_mode), + @SerializedName("LGS_LOOP_MODE") LGS_LOOP_MODE (R.string.uel_lgs_loop_mode), + @SerializedName("OPEN_LOOP_MODE") OPEN_LOOP_MODE (R.string.uel_open_loop_mode), + @SerializedName("LOOP_DISABLED") LOOP_DISABLED (R.string.uel_loop_disabled), + @SerializedName("LOOP_ENABLED") LOOP_ENABLED (R.string.uel_loop_enabled), + @SerializedName("RECONNECT") RECONNECT (R.string.uel_reconnect), + @SerializedName("DISCONNECT_15M") DISCONNECT_15M (R.string.uel_disconnect_15m), + @SerializedName("DISCONNECT_30M") DISCONNECT_30M (R.string.uel_disconnect_30m), + @SerializedName("DISCONNECT_1H") DISCONNECT_1H (R.string.uel_disconnect_1h), + @SerializedName("DISCONNECT_2H") DISCONNECT_2H (R.string.uel_disconnect_2h), + @SerializedName("DISCONNECT_3H") DISCONNECT_3H (R.string.uel_disconnect_3h), + @SerializedName("RESUME") RESUME (R.string.uel_resume), + @SerializedName("SUSPEND_1H") SUSPEND_1H (R.string.uel_suspend_1h), + @SerializedName("SUSPEND_2H") SUSPEND_2H (R.string.uel_suspend_2h), + @SerializedName("SUSPEND_3H") SUSPEND_3H (R.string.uel_suspend_3h), + @SerializedName("SUSPEND_10H") SUSPEND_10H (R.string.uel_suspend_10h), + @SerializedName("HW_PUMP_ALLOWED") HW_PUMP_ALLOWED (R.string.uel_hw_pump_allowed), + @SerializedName("CLEAR_PAIRING_KEYS") CLEAR_PAIRING_KEYS (R.string.uel_clear_pairing_keys), + @SerializedName("ACCEPTS_TEMP_BASAL") ACCEPTS_TEMP_BASAL (R.string.uel_accepts_temp_basal), + @SerializedName("CANCEL_TEMP_BASAL") CANCEL_TEMP_BASAL (R.string.uel_cancel_temp_basal), + @SerializedName("CANCEL_EXTENDED_BOLUS") CANCEL_EXTENDED_BOLUS (R.string.uel_cancel_extended_bolus), + @SerializedName("CANCEL_TT") CANCEL_TT (R.string.uel_cancel_tt), + @SerializedName("CAREPORTAL") CAREPORTAL (R.string.uel_careportal), + @SerializedName("CALIBRATION") CALIBRATION (R.string.uel_calibration), + @SerializedName("INSULIN_CHANGE") INSULIN_CHANGE (R.string.uel_insulin_change), + @SerializedName("PRIME_BOLUS") PRIME_BOLUS (R.string.uel_prime_bolus), + @SerializedName("SITE_CHANGE") SITE_CHANGE (R.string.uel_site_change), + @SerializedName("TREATMENT") TREATMENT (R.string.uel_treatment), + @SerializedName("CAREPORTAL_NS_REFRESH") CAREPORTAL_NS_REFRESH (R.string.uel_careportal_ns_refresh), + @SerializedName("PROFILE_SWITCH_NS_REFRESH") PROFILE_SWITCH_NS_REFRESH (R.string.uel_profile_switch_ns_refresh), + @SerializedName("TREATMENTS_NS_REFRESH") TREATMENTS_NS_REFRESH (R.string.uel_treatments_ns_refresh), + @SerializedName("TT_NS_REFRESH") TT_NS_REFRESH (R.string.uel_tt_ns_refresh), + @SerializedName("AUTOMATION_REMOVED") AUTOMATION_REMOVED (R.string.uel_automation_removed), + @SerializedName("BG_REMOVED") BG_REMOVED (R.string.uel_bg_removed), + @SerializedName("CAREPORTAL_REMOVED") CAREPORTAL_REMOVED (R.string.uel_careportal_removed), + @SerializedName("EXTENDED_BOLUS_REMOVED") EXTENDED_BOLUS_REMOVED (R.string.uel_extended_bolus_removed), + @SerializedName("FOOD_REMOVED") FOOD_REMOVED (R.string.uel_food_removed), + @SerializedName("PROFILE_REMOVED") PROFILE_REMOVED (R.string.uel_profile_removed), + @SerializedName("PROFILE_SWITCH_REMOVED") PROFILE_SWITCH_REMOVED (R.string.uel_profile_switch_removed), + @SerializedName("RESTART_EVENTS_REMOVED") RESTART_EVENTS_REMOVED (R.string.uel_restart_events_removed), + @SerializedName("TREATMENT_REMOVED") TREATMENT_REMOVED (R.string.uel_treatment_removed), + @SerializedName("TT_REMOVED") TT_REMOVED (R.string.uel_tt_removed), + @SerializedName("NS_PAUSED") NS_PAUSED (R.string.uel_ns_paused), + @SerializedName("NS_QUEUE_CLEARED") NS_QUEUE_CLEARED (R.string.uel_ns_queue_cleared), + @SerializedName("NS_SETTINGS_COPIED") NS_SETTINGS_COPIED (R.string.uel_ns_settings_copied), + @SerializedName("ERROR_DIALOG_OK") ERROR_DIALOG_OK (R.string.uel_error_dialog_ok), + @SerializedName("ERROR_DIALOG_MUTE") ERROR_DIALOG_MUTE (R.string.uel_error_dialog_mute), + @SerializedName("ERROR_DIALOG_MUTE_5MIN") ERROR_DIALOG_MUTE_5MIN (R.string.uel_error_dialog_mute_5min), + @SerializedName("OBJECTIVE_STARTED") OBJECTIVE_STARTED (R.string.uel_objective_started), + @SerializedName("OBJECTIVE_UNSTARTED") OBJECTIVE_UNSTARTED (R.string.uel_objective_unstarted), + @SerializedName("OBJECTIVES_SKIPPED") OBJECTIVES_SKIPPED (R.string.uel_objectives_skipped), + @SerializedName("STAT_RESET") STAT_RESET (R.string.uel_stat_reset), + @SerializedName("DELETE_LOGS") DELETE_LOGS (R.string.uel_delete_logs), + @SerializedName("DELETE_FUTURE_TREATMENTS") DELETE_FUTURE_TREATMENTS (R.string.uel_delete_future_treatments), + @SerializedName("EXPORT_SETTINGS") EXPORT_SETTINGS (R.string.uel_export_settings), + @SerializedName("IMPORT_SETTINGS") IMPORT_SETTINGS (R.string.uel_import_settings), + @SerializedName("RESET_DATABASES") RESET_DATABASES (R.string.uel_reset_databases), + @SerializedName("EXPORT_DATABASES") EXPORT_DATABASES (R.string.uel_export_databases), + @SerializedName("IMPORT_DATABASES") IMPORT_DATABASES (R.string.uel_import_databases), + @SerializedName("OTP_EXPORT") OTP_EXPORT (R.string.uel_otp_export), + @SerializedName("OTP_RESET") OTP_RESET (R.string.uel_otp_reset), + @SerializedName("SMS_BASAL") SMS_BASAL (R.string.uel_sms_basal), + @SerializedName("SMS_BOLUS") SMS_BOLUS (R.string.uel_sms_bolus), + @SerializedName("SMS_CAL") SMS_CAL (R.string.uel_sms_cal), + @SerializedName("SMS_CARBS") SMS_CARBS (R.string.uel_sms_carbs), + @SerializedName("SMS_EXTENDED_BOLUS") SMS_EXTENDED_BOLUS (R.string.uel_sms_extended_bolus), + @SerializedName("SMS_LOOP_DISABLED") SMS_LOOP_DISABLED (R.string.uel_sms_loop_disabled), + @SerializedName("SMS_LOOP_ENABLED") SMS_LOOP_ENABLED (R.string.uel_sms_loop_enabled), + @SerializedName("SMS_LOOP_RESUME") SMS_LOOP_RESUME (R.string.uel_sms_loop_resume), + @SerializedName("SMS_LOOP_SUSPEND") SMS_LOOP_SUSPEND (R.string.uel_sms_loop_suspend), + @SerializedName("SMS_PROFILE") SMS_PROFILE (R.string.uel_sms_profile), + @SerializedName("SMS_PUMP_CONNECT") SMS_PUMP_CONNECT (R.string.uel_sms_pump_connect), + @SerializedName("SMS_PUMP_DISCONNECT") SMS_PUMP_DISCONNECT (R.string.uel_sms_pump_disconnect), + @SerializedName("SMS_SMS") SMS_SMS (R.string.uel_sms_sms), + @SerializedName("SMS_TT") SMS_TT (R.string.uel_sms_tt), - TT, - TT_ACTIVITY, - TT_EATING_SOON, - TT_HYPO, - - NEW_PROFILE, - CLONE_PROFILE, - STORE_PROFILE, - PROFILE_SWITCH, - PROFILE_SWITCH_CLONED, - - CLOSED_LOOP_MODE, - LGS_LOOP_MODE, - OPEN_LOOP_MODE, - LOOP_DISABLED, - LOOP_ENABLED, - RECONNECT, - DISCONNECT_15M, - DISCONNECT_30M, - DISCONNECT_1H, - DISCONNECT_2H, - DISCONNECT_3H, - RESUME, - SUSPEND_1H, - SUSPEND_2H, - SUSPEND_3H, - SUSPEND_10H, - - HW_PUMP_ALLOWED, - CLEAR_PAIRING_KEYS, - ACCEPTS_TEMP_BASAL, - CANCEL_TEMP_BASAL, - CANCEL_EXTENDED_BOLUS, - CANCEL_TT, - - CAREPORTAL, - CALIBRATION, - INSULIN_CHANGE, - PRIME_BOLUS, - SITE_CHANGE, - - TREATMENT, - CAREPORTAL_NS_REFRESH, - PROFILE_SWITCH_NS_REFRESH, - TREATMENTS_NS_REFRESH, - TT_NS_REFRESH, - - AUTOMATION_REMOVED, - BG_REMOVED, - CAREPORTAL_REMOVED, - EXTENDED_BOLUS_REMOVED, - FOOD_REMOVED, - PROFILE_REMOVED, - PROFILE_SWITCH_REMOVED, - RESTART_EVENTS_REMOVED, - TREATMENT_REMOVED, - TT_REMOVED, - - NS_PAUSED, - NS_QUEUE_CLEARED, - NS_SETTINGS_COPIED, - - ERROR_DIALOG_OK, - ERROR_DIALOG_MUTE , - ERROR_DIALOG_MUTE_5MIN, - - OBJECTIVE_STARTED, - OBJECTIVE_UNSTARTED, - OBJECTIVES_SKIPPED, - - STAT_RESET, - - DELETE_LOGS, - DELETE_FUTURE_TREATMENTS, - EXPORT_SETTINGS, - IMPORT_SETTINGS, - RESET_DATABASES, - EXPORT_DATABASES, - 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 } } \ No newline at end of file From b4f1996717d86a8fe8dc356d34ae78a71f7dafc0 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 21 Feb 2021 20:49:34 +0100 Subject: [PATCH 07/66] Add extension --- .../fragments/TreatmentsUserEntryFragment.kt | 3 +- .../utils/extensions/UserEntryStrings.kt | 104 ++++++++++ .../androidaps/database/entities/UserEntry.kt | 189 +++++++++--------- 3 files changed, 200 insertions(+), 96 deletions(-) create mode 100644 core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryStrings.kt 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 998be127d0..86aa5e45ab 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 @@ -13,6 +13,7 @@ import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.databinding.TreatmentsUserEntryFragmentBinding import info.nightscout.androidaps.databinding.TreatmentsUserEntryItemBinding import info.nightscout.androidaps.utils.DateUtil +import info.nightscout.androidaps.utils.extensions.stringId import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.rx.AapsSchedulers import io.reactivex.disposables.CompositeDisposable @@ -65,7 +66,7 @@ class TreatmentsUserEntryFragment : DaggerFragment() { override fun onBindViewHolder(holder: UserEntryViewHolder, position: Int) { val current = entries[position] holder.binding.date.text = dateUtil.dateAndTimeAndSecondsString(current.timestamp) - holder.binding.action.text = resourceHelper.gs(current.action.stringId) + holder.binding.action.text = resourceHelper.gs(current.action.stringId()) if (current.s != "") holder.binding.s.text = current.s else holder.binding.s.visibility = View.GONE if (current.d1 != 0.0) holder.binding.d1.text = current.d1.toString() else holder.binding.d1.visibility = View.GONE if (current.d2 != 0.0) holder.binding.d2.text = current.d2.toString() else holder.binding.d2.visibility = View.GONE diff --git a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryStrings.kt b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryStrings.kt new file mode 100644 index 0000000000..7d53305be6 --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryStrings.kt @@ -0,0 +1,104 @@ +package info.nightscout.androidaps.utils.extensions + +import info.nightscout.androidaps.core.R +import info.nightscout.androidaps.database.entities.UserEntry + +fun UserEntry.Action.stringId(): Int { + return when { + this == UserEntry.Action.BOLUS -> R.string.uel_bolus + this == UserEntry.Action.BOLUS_WIZARD -> R.string.uel_bolus_wizard + this == UserEntry.Action.BOLUS_ADVISOR -> R.string.uel_bolus_advisor + this == UserEntry.Action.BOLUS_RECORD -> R.string.uel_bolus_record + this == UserEntry.Action.EXTENDED_BOLUS -> R.string.uel_extended_bolus + this == UserEntry.Action.SUPERBOLUS_TBR -> R.string.uel_superbolus_tbr + this == UserEntry.Action.CARBS -> R.string.uel_carbs + this == UserEntry.Action.EXTENDED_CARBS -> R.string.uel_extended_carbs + this == UserEntry.Action.TEMP_BASAL -> R.string.uel_temp_basal + this == UserEntry.Action.TT -> R.string.uel_tt + this == UserEntry.Action.TT_ACTIVITY -> R.string.uel_tt_activity + this == UserEntry.Action.TT_EATING_SOON -> R.string.uel_tt_eating_soon + this == UserEntry.Action.TT_HYPO -> R.string.uel_tt_hypo + this == UserEntry.Action.NEW_PROFILE -> R.string.uel_new_profile + this == UserEntry.Action.CLONE_PROFILE -> R.string.uel_clone_profile + this == UserEntry.Action.STORE_PROFILE -> R.string.uel_store_profile + this == UserEntry.Action.PROFILE_SWITCH -> R.string.uel_profile_switch + this == UserEntry.Action.PROFILE_SWITCH_CLONED -> R.string.uel_profile_switch_cloned + this == UserEntry.Action.CLOSED_LOOP_MODE -> R.string.uel_closed_loop_mode + this == UserEntry.Action.LGS_LOOP_MODE -> R.string.uel_lgs_loop_mode + this == UserEntry.Action.OPEN_LOOP_MODE -> R.string.uel_open_loop_mode + this == UserEntry.Action.LOOP_DISABLED -> R.string.uel_loop_disabled + this == UserEntry.Action.LOOP_ENABLED -> R.string.uel_loop_enabled + this == UserEntry.Action.RECONNECT -> R.string.uel_reconnect + this == UserEntry.Action.DISCONNECT_15M -> R.string.uel_disconnect_15m + this == UserEntry.Action.DISCONNECT_30M -> R.string.uel_disconnect_30m + this == UserEntry.Action.DISCONNECT_1H -> R.string.uel_disconnect_1h + this == UserEntry.Action.DISCONNECT_2H -> R.string.uel_disconnect_2h + this == UserEntry.Action.DISCONNECT_3H -> R.string.uel_disconnect_3h + this == UserEntry.Action.RESUME -> R.string.uel_resume + this == UserEntry.Action.SUSPEND_1H -> R.string.uel_suspend_1h + this == UserEntry.Action.SUSPEND_2H -> R.string.uel_suspend_2h + this == UserEntry.Action.SUSPEND_3H -> R.string.uel_suspend_3h + this == UserEntry.Action.SUSPEND_10H -> R.string.uel_suspend_10h + this == UserEntry.Action.HW_PUMP_ALLOWED -> R.string.uel_hw_pump_allowed + this == UserEntry.Action.CLEAR_PAIRING_KEYS -> R.string.uel_clear_pairing_keys + this == UserEntry.Action.ACCEPTS_TEMP_BASAL -> R.string.uel_accepts_temp_basal + this == UserEntry.Action.CANCEL_TEMP_BASAL -> R.string.uel_cancel_temp_basal + this == UserEntry.Action.CANCEL_EXTENDED_BOLUS -> R.string.uel_cancel_extended_bolus + this == UserEntry.Action.CANCEL_TT -> R.string.uel_cancel_tt + this == UserEntry.Action.CAREPORTAL -> R.string.uel_careportal + this == UserEntry.Action.CALIBRATION -> R.string.uel_calibration + this == UserEntry.Action.INSULIN_CHANGE -> R.string.uel_insulin_change + this == UserEntry.Action.PRIME_BOLUS -> R.string.uel_prime_bolus + this == UserEntry.Action.SITE_CHANGE -> R.string.uel_site_change + this == UserEntry.Action.TREATMENT -> R.string.uel_treatment + this == UserEntry.Action.CAREPORTAL_NS_REFRESH -> R.string.uel_careportal_ns_refresh + this == UserEntry.Action.PROFILE_SWITCH_NS_REFRESH -> R.string.uel_profile_switch_ns_refresh + this == UserEntry.Action.TREATMENTS_NS_REFRESH -> R.string.uel_treatments_ns_refresh + this == UserEntry.Action.TT_NS_REFRESH -> R.string.uel_tt_ns_refresh + this == UserEntry.Action.AUTOMATION_REMOVED -> R.string.uel_automation_removed + this == UserEntry.Action.BG_REMOVED -> R.string.uel_bg_removed + this == UserEntry.Action.CAREPORTAL_REMOVED -> R.string.uel_careportal_removed + this == UserEntry.Action.EXTENDED_BOLUS_REMOVED -> R.string.uel_extended_bolus_removed + this == UserEntry.Action.FOOD_REMOVED -> R.string.uel_food_removed + this == UserEntry.Action.PROFILE_REMOVED -> R.string.uel_profile_removed + this == UserEntry.Action.PROFILE_SWITCH_REMOVED -> R.string.uel_profile_switch_removed + this == UserEntry.Action.RESTART_EVENTS_REMOVED -> R.string.uel_restart_events_removed + this == UserEntry.Action.TREATMENT_REMOVED -> R.string.uel_treatment_removed + this == UserEntry.Action.TT_REMOVED -> R.string.uel_tt_removed + this == UserEntry.Action.NS_PAUSED -> R.string.uel_ns_paused + this == UserEntry.Action.NS_QUEUE_CLEARED -> R.string.uel_ns_queue_cleared + this == UserEntry.Action.NS_SETTINGS_COPIED -> R.string.uel_ns_settings_copied + this == UserEntry.Action.ERROR_DIALOG_OK -> R.string.uel_error_dialog_ok + this == UserEntry.Action.ERROR_DIALOG_MUTE -> R.string.uel_error_dialog_mute + this == UserEntry.Action.ERROR_DIALOG_MUTE_5MIN -> R.string.uel_error_dialog_mute_5min + this == UserEntry.Action.OBJECTIVE_STARTED -> R.string.uel_objective_started + this == UserEntry.Action.OBJECTIVE_UNSTARTED -> R.string.uel_objective_unstarted + this == UserEntry.Action.OBJECTIVES_SKIPPED -> R.string.uel_objectives_skipped + this == UserEntry.Action.STAT_RESET -> R.string.uel_stat_reset + this == UserEntry.Action.DELETE_LOGS -> R.string.uel_delete_logs + this == UserEntry.Action.DELETE_FUTURE_TREATMENTS -> R.string.uel_delete_future_treatments + this == UserEntry.Action.EXPORT_SETTINGS -> R.string.uel_export_settings + this == UserEntry.Action.IMPORT_SETTINGS -> R.string.uel_import_settings + this == UserEntry.Action.RESET_DATABASES -> R.string.uel_reset_databases + this == UserEntry.Action.EXPORT_DATABASES -> R.string.uel_export_databases + this == UserEntry.Action.IMPORT_DATABASES -> R.string.uel_import_databases + this == UserEntry.Action.OTP_EXPORT -> R.string.uel_otp_export + this == UserEntry.Action.OTP_RESET -> R.string.uel_otp_reset + this == UserEntry.Action.SMS_BASAL -> R.string.uel_sms_basal + this == UserEntry.Action.SMS_BOLUS -> R.string.uel_sms_bolus + this == UserEntry.Action.SMS_CAL -> R.string.uel_sms_cal + this == UserEntry.Action.SMS_CARBS -> R.string.uel_sms_carbs + this == UserEntry.Action.SMS_EXTENDED_BOLUS -> R.string.uel_sms_extended_bolus + this == UserEntry.Action.SMS_LOOP_DISABLED -> R.string.uel_sms_loop_disabled + this == UserEntry.Action.SMS_LOOP_ENABLED -> R.string.uel_sms_loop_enabled + this == UserEntry.Action.SMS_LOOP_RESUME -> R.string.uel_sms_loop_resume + this == UserEntry.Action.SMS_LOOP_SUSPEND -> R.string.uel_sms_loop_suspend + this == UserEntry.Action.SMS_PROFILE -> R.string.uel_sms_profile + this == UserEntry.Action.SMS_PUMP_CONNECT -> R.string.uel_sms_pump_connect + this == UserEntry.Action.SMS_PUMP_DISCONNECT -> R.string.uel_sms_pump_disconnect + this == UserEntry.Action.SMS_SMS -> R.string.uel_sms_sms + this == UserEntry.Action.SMS_TT -> R.string.uel_sms_tt + else -> R.string.uel_sms_tt + + } +} \ No newline at end of file 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 0f1f66c574..ecc4e98c52 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 @@ -22,100 +22,99 @@ data class UserEntry( var i1: Int, var i2: Int ) : DBEntry, DBEntryWithTime { - enum class Action (val stringId:Int) { - @SerializedName("BOLUS") BOLUS (R.string.uel_bolus), - @SerializedName("BOLUS_WIZARD") BOLUS_WIZARD (R.string.uel_bolus_wizard), - @SerializedName("BOLUS_ADVISOR") BOLUS_ADVISOR (R.string.uel_bolus_advisor), - @SerializedName("BOLUS_RECORD") BOLUS_RECORD (R.string.uel_bolus_record), - @SerializedName("EXTENDED_BOLUS") EXTENDED_BOLUS (R.string.uel_extended_bolus), - @SerializedName("SUPERBOLUS_TBR") SUPERBOLUS_TBR (R.string.uel_superbolus_tbr), - @SerializedName("CARBS") CARBS (R.string.uel_carbs), - @SerializedName("EXTENDED_CARBS") EXTENDED_CARBS (R.string.uel_extended_carbs), - @SerializedName("TEMP_BASAL") TEMP_BASAL (R.string.uel_temp_basal), - @SerializedName("TT") TT (R.string.uel_tt), - @SerializedName("TT_ACTIVITY") TT_ACTIVITY (R.string.uel_tt_activity), - @SerializedName("TT_EATING_SOON") TT_EATING_SOON (R.string.uel_tt_eating_soon), - @SerializedName("TT_HYPO") TT_HYPO (R.string.uel_tt_hypo), - @SerializedName("NEW_PROFILE") NEW_PROFILE (R.string.uel_new_profile), - @SerializedName("CLONE_PROFILE") CLONE_PROFILE (R.string.uel_clone_profile), - @SerializedName("STORE_PROFILE") STORE_PROFILE (R.string.uel_store_profile), - @SerializedName("PROFILE_SWITCH") PROFILE_SWITCH (R.string.uel_profile_switch), - @SerializedName("PROFILE_SWITCH_CLONED") PROFILE_SWITCH_CLONED (R.string.uel_profile_switch_cloned), - @SerializedName("CLOSED_LOOP_MODE") CLOSED_LOOP_MODE (R.string.uel_closed_loop_mode), - @SerializedName("LGS_LOOP_MODE") LGS_LOOP_MODE (R.string.uel_lgs_loop_mode), - @SerializedName("OPEN_LOOP_MODE") OPEN_LOOP_MODE (R.string.uel_open_loop_mode), - @SerializedName("LOOP_DISABLED") LOOP_DISABLED (R.string.uel_loop_disabled), - @SerializedName("LOOP_ENABLED") LOOP_ENABLED (R.string.uel_loop_enabled), - @SerializedName("RECONNECT") RECONNECT (R.string.uel_reconnect), - @SerializedName("DISCONNECT_15M") DISCONNECT_15M (R.string.uel_disconnect_15m), - @SerializedName("DISCONNECT_30M") DISCONNECT_30M (R.string.uel_disconnect_30m), - @SerializedName("DISCONNECT_1H") DISCONNECT_1H (R.string.uel_disconnect_1h), - @SerializedName("DISCONNECT_2H") DISCONNECT_2H (R.string.uel_disconnect_2h), - @SerializedName("DISCONNECT_3H") DISCONNECT_3H (R.string.uel_disconnect_3h), - @SerializedName("RESUME") RESUME (R.string.uel_resume), - @SerializedName("SUSPEND_1H") SUSPEND_1H (R.string.uel_suspend_1h), - @SerializedName("SUSPEND_2H") SUSPEND_2H (R.string.uel_suspend_2h), - @SerializedName("SUSPEND_3H") SUSPEND_3H (R.string.uel_suspend_3h), - @SerializedName("SUSPEND_10H") SUSPEND_10H (R.string.uel_suspend_10h), - @SerializedName("HW_PUMP_ALLOWED") HW_PUMP_ALLOWED (R.string.uel_hw_pump_allowed), - @SerializedName("CLEAR_PAIRING_KEYS") CLEAR_PAIRING_KEYS (R.string.uel_clear_pairing_keys), - @SerializedName("ACCEPTS_TEMP_BASAL") ACCEPTS_TEMP_BASAL (R.string.uel_accepts_temp_basal), - @SerializedName("CANCEL_TEMP_BASAL") CANCEL_TEMP_BASAL (R.string.uel_cancel_temp_basal), - @SerializedName("CANCEL_EXTENDED_BOLUS") CANCEL_EXTENDED_BOLUS (R.string.uel_cancel_extended_bolus), - @SerializedName("CANCEL_TT") CANCEL_TT (R.string.uel_cancel_tt), - @SerializedName("CAREPORTAL") CAREPORTAL (R.string.uel_careportal), - @SerializedName("CALIBRATION") CALIBRATION (R.string.uel_calibration), - @SerializedName("INSULIN_CHANGE") INSULIN_CHANGE (R.string.uel_insulin_change), - @SerializedName("PRIME_BOLUS") PRIME_BOLUS (R.string.uel_prime_bolus), - @SerializedName("SITE_CHANGE") SITE_CHANGE (R.string.uel_site_change), - @SerializedName("TREATMENT") TREATMENT (R.string.uel_treatment), - @SerializedName("CAREPORTAL_NS_REFRESH") CAREPORTAL_NS_REFRESH (R.string.uel_careportal_ns_refresh), - @SerializedName("PROFILE_SWITCH_NS_REFRESH") PROFILE_SWITCH_NS_REFRESH (R.string.uel_profile_switch_ns_refresh), - @SerializedName("TREATMENTS_NS_REFRESH") TREATMENTS_NS_REFRESH (R.string.uel_treatments_ns_refresh), - @SerializedName("TT_NS_REFRESH") TT_NS_REFRESH (R.string.uel_tt_ns_refresh), - @SerializedName("AUTOMATION_REMOVED") AUTOMATION_REMOVED (R.string.uel_automation_removed), - @SerializedName("BG_REMOVED") BG_REMOVED (R.string.uel_bg_removed), - @SerializedName("CAREPORTAL_REMOVED") CAREPORTAL_REMOVED (R.string.uel_careportal_removed), - @SerializedName("EXTENDED_BOLUS_REMOVED") EXTENDED_BOLUS_REMOVED (R.string.uel_extended_bolus_removed), - @SerializedName("FOOD_REMOVED") FOOD_REMOVED (R.string.uel_food_removed), - @SerializedName("PROFILE_REMOVED") PROFILE_REMOVED (R.string.uel_profile_removed), - @SerializedName("PROFILE_SWITCH_REMOVED") PROFILE_SWITCH_REMOVED (R.string.uel_profile_switch_removed), - @SerializedName("RESTART_EVENTS_REMOVED") RESTART_EVENTS_REMOVED (R.string.uel_restart_events_removed), - @SerializedName("TREATMENT_REMOVED") TREATMENT_REMOVED (R.string.uel_treatment_removed), - @SerializedName("TT_REMOVED") TT_REMOVED (R.string.uel_tt_removed), - @SerializedName("NS_PAUSED") NS_PAUSED (R.string.uel_ns_paused), - @SerializedName("NS_QUEUE_CLEARED") NS_QUEUE_CLEARED (R.string.uel_ns_queue_cleared), - @SerializedName("NS_SETTINGS_COPIED") NS_SETTINGS_COPIED (R.string.uel_ns_settings_copied), - @SerializedName("ERROR_DIALOG_OK") ERROR_DIALOG_OK (R.string.uel_error_dialog_ok), - @SerializedName("ERROR_DIALOG_MUTE") ERROR_DIALOG_MUTE (R.string.uel_error_dialog_mute), - @SerializedName("ERROR_DIALOG_MUTE_5MIN") ERROR_DIALOG_MUTE_5MIN (R.string.uel_error_dialog_mute_5min), - @SerializedName("OBJECTIVE_STARTED") OBJECTIVE_STARTED (R.string.uel_objective_started), - @SerializedName("OBJECTIVE_UNSTARTED") OBJECTIVE_UNSTARTED (R.string.uel_objective_unstarted), - @SerializedName("OBJECTIVES_SKIPPED") OBJECTIVES_SKIPPED (R.string.uel_objectives_skipped), - @SerializedName("STAT_RESET") STAT_RESET (R.string.uel_stat_reset), - @SerializedName("DELETE_LOGS") DELETE_LOGS (R.string.uel_delete_logs), - @SerializedName("DELETE_FUTURE_TREATMENTS") DELETE_FUTURE_TREATMENTS (R.string.uel_delete_future_treatments), - @SerializedName("EXPORT_SETTINGS") EXPORT_SETTINGS (R.string.uel_export_settings), - @SerializedName("IMPORT_SETTINGS") IMPORT_SETTINGS (R.string.uel_import_settings), - @SerializedName("RESET_DATABASES") RESET_DATABASES (R.string.uel_reset_databases), - @SerializedName("EXPORT_DATABASES") EXPORT_DATABASES (R.string.uel_export_databases), - @SerializedName("IMPORT_DATABASES") IMPORT_DATABASES (R.string.uel_import_databases), - @SerializedName("OTP_EXPORT") OTP_EXPORT (R.string.uel_otp_export), - @SerializedName("OTP_RESET") OTP_RESET (R.string.uel_otp_reset), - @SerializedName("SMS_BASAL") SMS_BASAL (R.string.uel_sms_basal), - @SerializedName("SMS_BOLUS") SMS_BOLUS (R.string.uel_sms_bolus), - @SerializedName("SMS_CAL") SMS_CAL (R.string.uel_sms_cal), - @SerializedName("SMS_CARBS") SMS_CARBS (R.string.uel_sms_carbs), - @SerializedName("SMS_EXTENDED_BOLUS") SMS_EXTENDED_BOLUS (R.string.uel_sms_extended_bolus), - @SerializedName("SMS_LOOP_DISABLED") SMS_LOOP_DISABLED (R.string.uel_sms_loop_disabled), - @SerializedName("SMS_LOOP_ENABLED") SMS_LOOP_ENABLED (R.string.uel_sms_loop_enabled), - @SerializedName("SMS_LOOP_RESUME") SMS_LOOP_RESUME (R.string.uel_sms_loop_resume), - @SerializedName("SMS_LOOP_SUSPEND") SMS_LOOP_SUSPEND (R.string.uel_sms_loop_suspend), - @SerializedName("SMS_PROFILE") SMS_PROFILE (R.string.uel_sms_profile), - @SerializedName("SMS_PUMP_CONNECT") SMS_PUMP_CONNECT (R.string.uel_sms_pump_connect), - @SerializedName("SMS_PUMP_DISCONNECT") SMS_PUMP_DISCONNECT (R.string.uel_sms_pump_disconnect), - @SerializedName("SMS_SMS") SMS_SMS (R.string.uel_sms_sms), - @SerializedName("SMS_TT") SMS_TT (R.string.uel_sms_tt), - + enum class Action () { + @SerializedName("BOLUS") BOLUS, + @SerializedName("BOLUS_WIZARD") BOLUS_WIZARD, + @SerializedName("BOLUS_ADVISOR") BOLUS_ADVISOR, + @SerializedName("BOLUS_RECORD") BOLUS_RECORD, + @SerializedName("EXTENDED_BOLUS") EXTENDED_BOLUS, + @SerializedName("SUPERBOLUS_TBR") SUPERBOLUS_TBR, + @SerializedName("CARBS") CARBS, + @SerializedName("EXTENDED_CARBS") EXTENDED_CARBS, + @SerializedName("TEMP_BASAL") TEMP_BASAL, + @SerializedName("TT") TT, + @SerializedName("TT_ACTIVITY") TT_ACTIVITY, + @SerializedName("TT_EATING_SOON") TT_EATING_SOON, + @SerializedName("TT_HYPO") TT_HYPO, + @SerializedName("NEW_PROFILE") NEW_PROFILE, + @SerializedName("CLONE_PROFILE") CLONE_PROFILE, + @SerializedName("STORE_PROFILE") STORE_PROFILE, + @SerializedName("PROFILE_SWITCH") PROFILE_SWITCH, + @SerializedName("PROFILE_SWITCH_CLONED") PROFILE_SWITCH_CLONED, + @SerializedName("CLOSED_LOOP_MODE") CLOSED_LOOP_MODE, + @SerializedName("LGS_LOOP_MODE") LGS_LOOP_MODE, + @SerializedName("OPEN_LOOP_MODE") OPEN_LOOP_MODE, + @SerializedName("LOOP_DISABLED") LOOP_DISABLED, + @SerializedName("LOOP_ENABLED") LOOP_ENABLED, + @SerializedName("RECONNECT") RECONNECT, + @SerializedName("DISCONNECT_15M") DISCONNECT_15M, + @SerializedName("DISCONNECT_30M") DISCONNECT_30M, + @SerializedName("DISCONNECT_1H") DISCONNECT_1H, + @SerializedName("DISCONNECT_2H") DISCONNECT_2H, + @SerializedName("DISCONNECT_3H") DISCONNECT_3H, + @SerializedName("RESUME") RESUME, + @SerializedName("SUSPEND_1H") SUSPEND_1H, + @SerializedName("SUSPEND_2H") SUSPEND_2H, + @SerializedName("SUSPEND_3H") SUSPEND_3H, + @SerializedName("SUSPEND_10H") SUSPEND_10H, + @SerializedName("HW_PUMP_ALLOWED") HW_PUMP_ALLOWED, + @SerializedName("CLEAR_PAIRING_KEYS") CLEAR_PAIRING_KEYS, + @SerializedName("ACCEPTS_TEMP_BASAL") ACCEPTS_TEMP_BASAL, + @SerializedName("CANCEL_TEMP_BASAL") CANCEL_TEMP_BASAL, + @SerializedName("CANCEL_EXTENDED_BOLUS") CANCEL_EXTENDED_BOLUS, + @SerializedName("CANCEL_TT") CANCEL_TT, + @SerializedName("CAREPORTAL") CAREPORTAL, + @SerializedName("CALIBRATION") CALIBRATION, + @SerializedName("INSULIN_CHANGE") INSULIN_CHANGE, + @SerializedName("PRIME_BOLUS") PRIME_BOLUS, + @SerializedName("SITE_CHANGE") SITE_CHANGE, + @SerializedName("TREATMENT") TREATMENT, + @SerializedName("CAREPORTAL_NS_REFRESH") CAREPORTAL_NS_REFRESH, + @SerializedName("PROFILE_SWITCH_NS_REFRESH") PROFILE_SWITCH_NS_REFRESH, + @SerializedName("TREATMENTS_NS_REFRESH") TREATMENTS_NS_REFRESH, + @SerializedName("TT_NS_REFRESH") TT_NS_REFRESH, + @SerializedName("AUTOMATION_REMOVED") AUTOMATION_REMOVED, + @SerializedName("BG_REMOVED") BG_REMOVED, + @SerializedName("CAREPORTAL_REMOVED") CAREPORTAL_REMOVED, + @SerializedName("EXTENDED_BOLUS_REMOVED") EXTENDED_BOLUS_REMOVED, + @SerializedName("FOOD_REMOVED") FOOD_REMOVED, + @SerializedName("PROFILE_REMOVED") PROFILE_REMOVED, + @SerializedName("PROFILE_SWITCH_REMOVED") PROFILE_SWITCH_REMOVED, + @SerializedName("RESTART_EVENTS_REMOVED") RESTART_EVENTS_REMOVED, + @SerializedName("TREATMENT_REMOVED") TREATMENT_REMOVED, + @SerializedName("TT_REMOVED") TT_REMOVED, + @SerializedName("NS_PAUSED") NS_PAUSED, + @SerializedName("NS_QUEUE_CLEARED") NS_QUEUE_CLEARED, + @SerializedName("NS_SETTINGS_COPIED") NS_SETTINGS_COPIED, + @SerializedName("ERROR_DIALOG_OK") ERROR_DIALOG_OK, + @SerializedName("ERROR_DIALOG_MUTE") ERROR_DIALOG_MUTE, + @SerializedName("ERROR_DIALOG_MUTE_5MIN") ERROR_DIALOG_MUTE_5MIN, + @SerializedName("OBJECTIVE_STARTED") OBJECTIVE_STARTED, + @SerializedName("OBJECTIVE_UNSTARTED") OBJECTIVE_UNSTARTED, + @SerializedName("OBJECTIVES_SKIPPED") OBJECTIVES_SKIPPED, + @SerializedName("STAT_RESET") STAT_RESET, + @SerializedName("DELETE_LOGS") DELETE_LOGS, + @SerializedName("DELETE_FUTURE_TREATMENTS") DELETE_FUTURE_TREATMENTS, + @SerializedName("EXPORT_SETTINGS") EXPORT_SETTINGS, + @SerializedName("IMPORT_SETTINGS") IMPORT_SETTINGS, + @SerializedName("RESET_DATABASES") RESET_DATABASES, + @SerializedName("EXPORT_DATABASES") EXPORT_DATABASES, + @SerializedName("IMPORT_DATABASES") IMPORT_DATABASES, + @SerializedName("OTP_EXPORT") OTP_EXPORT, + @SerializedName("OTP_RESET") OTP_RESET, + @SerializedName("SMS_BASAL") SMS_BASAL, + @SerializedName("SMS_BOLUS") SMS_BOLUS, + @SerializedName("SMS_CAL") SMS_CAL, + @SerializedName("SMS_CARBS") SMS_CARBS, + @SerializedName("SMS_EXTENDED_BOLUS") SMS_EXTENDED_BOLUS, + @SerializedName("SMS_LOOP_DISABLED") SMS_LOOP_DISABLED, + @SerializedName("SMS_LOOP_ENABLED") SMS_LOOP_ENABLED, + @SerializedName("SMS_LOOP_RESUME") SMS_LOOP_RESUME, + @SerializedName("SMS_LOOP_SUSPEND") SMS_LOOP_SUSPEND, + @SerializedName("SMS_PROFILE") SMS_PROFILE, + @SerializedName("SMS_PUMP_CONNECT") SMS_PUMP_CONNECT, + @SerializedName("SMS_PUMP_DISCONNECT") SMS_PUMP_DISCONNECT, + @SerializedName("SMS_SMS") SMS_SMS, + @SerializedName("SMS_TT") SMS_TT } } \ No newline at end of file From dec7232d426c1245818200ad95310fa480c707df Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 21 Feb 2021 22:46:43 +0100 Subject: [PATCH 08/66] Add Converter, companion object and unknow string --- .../androidaps/utils/extensions/UserEntryStrings.kt | 3 +-- core/src/main/res/values/strings.xml | 1 + .../info/nightscout/androidaps/database/Converters.kt | 6 ++++++ .../nightscout/androidaps/database/entities/UserEntry.kt | 8 +++++++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryStrings.kt b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryStrings.kt index 7d53305be6..8da2ef3a3d 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryStrings.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryStrings.kt @@ -98,7 +98,6 @@ fun UserEntry.Action.stringId(): Int { this == UserEntry.Action.SMS_PUMP_DISCONNECT -> R.string.uel_sms_pump_disconnect this == UserEntry.Action.SMS_SMS -> R.string.uel_sms_sms this == UserEntry.Action.SMS_TT -> R.string.uel_sms_tt - else -> R.string.uel_sms_tt - + else -> R.string.uel_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 c53af0a267..21c17997ba 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -419,6 +419,7 @@ SMS PUMP DISCONNECT SMS SMS SMS TT + UNKNOWN %1$d day diff --git a/database/src/main/java/info/nightscout/androidaps/database/Converters.kt b/database/src/main/java/info/nightscout/androidaps/database/Converters.kt index cdac1563d5..5c054bd8be 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/Converters.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/Converters.kt @@ -10,6 +10,12 @@ import org.json.JSONObject class Converters { + @TypeConverter + fun fromAction(action: UserEntry.Action?) = action?.name + + @TypeConverter + fun toAction(action: String?) = action?.let { UserEntry.Action.valueOf(it) } + @TypeConverter fun fromBolusType(bolusType: Bolus.Type?) = bolusType?.name 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 ecc4e98c52..2ee5f03c7d 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 @@ -115,6 +115,12 @@ data class UserEntry( @SerializedName("SMS_PUMP_CONNECT") SMS_PUMP_CONNECT, @SerializedName("SMS_PUMP_DISCONNECT") SMS_PUMP_DISCONNECT, @SerializedName("SMS_SMS") SMS_SMS, - @SerializedName("SMS_TT") SMS_TT + @SerializedName("SMS_TT") SMS_TT, + @SerializedName("UNKNOWN") UNKNOWN + ; + + companion object { + fun fromString(source: String?) = UserEntry.Action.values().firstOrNull { it.name == source } ?: UserEntry.Action.UNKNOWN + } } } \ No newline at end of file From 666e0a34aafc23db1711f8e9203709017e757312 Mon Sep 17 00:00:00 2001 From: Philoul Date: Mon, 22 Feb 2021 14:56:29 +0100 Subject: [PATCH 09/66] Fix Convertor Crash (with "existing entries in database that doesn't exist as enum new keys") --- .../main/java/info/nightscout/androidaps/database/Converters.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/src/main/java/info/nightscout/androidaps/database/Converters.kt b/database/src/main/java/info/nightscout/androidaps/database/Converters.kt index 5c054bd8be..29bd3db50c 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/Converters.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/Converters.kt @@ -14,7 +14,7 @@ class Converters { fun fromAction(action: UserEntry.Action?) = action?.name @TypeConverter - fun toAction(action: String?) = action?.let { UserEntry.Action.valueOf(it) } + fun toAction(action: String?) = action?.let { UserEntry.Action.fromString(it) } @TypeConverter fun fromBolusType(bolusType: Bolus.Type?) = bolusType?.name From ca8ad6ca9e7383b326a90a897fcc4c020be4dd0c Mon Sep 17 00:00:00 2001 From: Philoul Date: Mon, 22 Feb 2021 18:43:37 +0100 Subject: [PATCH 10/66] Fix TT UserEntries from TT Dialog Always entered as TT even if TT EatingSoon, TT Cancel ... --- .../nightscout/androidaps/dialogs/TempTargetDialog.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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 a111a95e64..469be1e83c 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt @@ -149,7 +149,7 @@ class TempTargetDialog : DialogFragmentWithDate() { override fun submit(): Boolean { if (_binding == null) return false val actions: LinkedList = LinkedList() - val reason = binding.reason.selectedItem?.toString() ?: return false + var reason = binding.reason.selectedItem?.toString() ?: return false val unitResId = if (profileFunction.getUnits() == Constants.MGDL) R.string.mgdl else R.string.mmol val target = binding.temptarget.value val duration = binding.duration.value.toInt() @@ -159,13 +159,20 @@ class TempTargetDialog : DialogFragmentWithDate() { actions.add(resourceHelper.gs(R.string.duration) + ": " + resourceHelper.gs(R.string.format_mins, duration)) } else { actions.add(resourceHelper.gs(R.string.stoptemptarget)) + reason = resourceHelper.gs(R.string.stoptemptarget) } if (eventTimeChanged) actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime)) activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { - uel.log(UserEntry.Action.TT, d1 = target, i1 = duration) + when(reason) { + resourceHelper.gs(R.string.eatingsoon) -> uel.log(UserEntry.Action.TT_EATING_SOON, d1 = target, i1 = duration) + resourceHelper.gs(R.string.activity) -> uel.log(UserEntry.Action.TT_ACTIVITY, d1 = target, i1 = duration) + resourceHelper.gs(R.string.hypo) -> uel.log(UserEntry.Action.TT_HYPO, d1 = target, i1 = duration) + resourceHelper.gs(R.string.manual) -> uel.log(UserEntry.Action.TT, d1 = target, i1 = duration) + resourceHelper.gs(R.string.stoptemptarget) -> uel.log(UserEntry.Action.CANCEL_TT) + } if (target == 0.0 || duration == 0) { val tempTarget = TempTarget() .date(eventTime) From 51add9a4fd4d1d3d34d0eb64ec95ffaccb3f683f Mon Sep 17 00:00:00 2001 From: Philoul Date: Tue, 23 Feb 2021 10:16:11 +0100 Subject: [PATCH 11/66] Fix TT Dialog Cancel if duration Force Cancel when Cancel button pressed (even if a duration exists in field when button is pressed) --- .../info/nightscout/androidaps/dialogs/TempTargetDialog.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 469be1e83c..f3322574b0 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt @@ -126,18 +126,19 @@ class TempTargetDialog : DialogFragmentWithDate() { binding.duration.value = defaultValueHelper.determineEatingSoonTTDuration().toDouble() binding.reason.setSelection(reasonList.indexOf(resourceHelper.gs(R.string.eatingsoon))) } - R.id.activity -> { binding.temptarget.value = defaultValueHelper.determineActivityTT() binding.duration.value = defaultValueHelper.determineActivityTTDuration().toDouble() binding.reason.setSelection(reasonList.indexOf(resourceHelper.gs(R.string.activity))) } - R.id.hypo -> { binding.temptarget.value = defaultValueHelper.determineHypoTT() binding.duration.value = defaultValueHelper.determineHypoTTDuration().toDouble() binding.reason.setSelection(reasonList.indexOf(resourceHelper.gs(R.string.hypo))) } + R.id.cancel -> { + binding.duration.value = 0.0 + } } } From 274cac8ff9967f8278b088d530dd21f5b0a3892d Mon Sep 17 00:00:00 2001 From: Philoul Date: Thu, 25 Feb 2021 12:28:36 +0100 Subject: [PATCH 12/66] First draft with bug --- .../androidaps/dialogs/CalibrationDialog.kt | 4 ++- .../androidaps/logging/UserEntryLogger.kt | 7 ++-- .../utils/extensions/UnitsStrings.kt | 36 +++++++++++++++++++ core/src/main/res/values/strings.xml | 2 ++ .../androidaps/database/Converters.kt | 17 +++++++++ .../androidaps/database/DatabaseModule.kt | 6 ++++ .../androidaps/database/entities/UserEntry.kt | 30 +++++++++++++--- .../transactions/UserEntryTransaction.kt | 11 +++--- 8 files changed, 100 insertions(+), 13 deletions(-) create mode 100644 core/src/main/java/info/nightscout/androidaps/utils/extensions/UnitsStrings.kt 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 5e2b29dd03..4c129c301c 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt @@ -10,10 +10,12 @@ import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.database.entities.UserEntry +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.utils.extensions.fromStringKey import info.nightscout.androidaps.utils.HtmlHelper import info.nightscout.androidaps.utils.XdripCalibrations import info.nightscout.androidaps.utils.alertDialogs.OKDialog @@ -78,7 +80,7 @@ class CalibrationDialog : DialogFragmentWithDate() { if (bg > 0) { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_calibration), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { - uel.log(UserEntry.Action.CALIBRATION, d1 = bg) + uel.log(Action.CALIBRATION, d1 = ValueWithUnit(bg, if (units == Constants.MMOL) Units.Mg_Dl else Units.Mmol_L)) xdripCalibrations.sendIntent(bg) }) } diff --git a/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt b/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt index f2270ac57d..eb2dae411b 100644 --- a/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt +++ b/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt @@ -2,6 +2,7 @@ package info.nightscout.androidaps.logging import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.database.transactions.UserEntryTransaction import info.nightscout.androidaps.utils.rx.AapsSchedulers import io.reactivex.disposables.CompositeDisposable @@ -19,7 +20,7 @@ class UserEntryLogger @Inject constructor( private val compositeDisposable = CompositeDisposable() - fun log(action: UserEntry.Action, s: String = "", d1: Double = 0.0, d2: Double = 0.0, i1: Int = 0, i2: Int = 0) { + fun log(action: UserEntry.Action, s: String = "", d1: ValueWithUnit = ValueWithUnit(0.0,Units.None), d2: ValueWithUnit = ValueWithUnit(0.0,Units.None), i1: ValueWithUnit = ValueWithUnit(0,Units.None), i2: ValueWithUnit = ValueWithUnit(0,Units.None)) { compositeDisposable += repository.runTransaction(UserEntryTransaction( action = action, s = s, @@ -31,8 +32,8 @@ class UserEntryLogger @Inject constructor( .subscribeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io) .subscribeBy( - onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $s ${if (d1 == 0.0) d1 else ""} ${if (d2 == 0.0) d2 else ""} ${if (i1 == 0) i1 else ""} ${if (i2 == 0) i2 else ""}") }, - onComplete = { aapsLogger.debug("USER ENTRY: $action $s ${if (d1 == 0.0) d1 else ""} ${if (d2 == 0.0) d2 else ""} ${if (i1 == 0) i1 else ""} ${if (i2 == 0) i2 else ""}") } + onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $s ${if (d1.dValue != 0.0) d1 else ""} ${if (d2.dValue != 0.0) d2 else ""} ${if (i1.iValue != 0) i1 else ""} ${if (i2.iValue != 0) i2 else ""}") }, + onComplete = { aapsLogger.debug("USER ENTRY: $action $s ${if (d1.dValue != 0.0) d1 else ""} ${if (d2.dValue != 0.0) d2 else ""} ${if (i1.iValue != 0) i1 else ""} ${if (i2.iValue != 0) i2 else ""}") } ) } } \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UnitsStrings.kt b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UnitsStrings.kt new file mode 100644 index 0000000000..7d7d306044 --- /dev/null +++ b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UnitsStrings.kt @@ -0,0 +1,36 @@ +package info.nightscout.androidaps.utils.extensions + +import info.nightscout.androidaps.Constants +import info.nightscout.androidaps.core.R +import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.utils.resources.ResourceHelper + +fun UserEntry.Units.stringId(): Int { + return when { + this == UserEntry.Units.Mg_Dl -> R.string.mgdl + this == UserEntry.Units.Mmol_L -> R.string.mmol + this == UserEntry.Units.U -> R.string.insulin_unit_shortname + this == UserEntry.Units.U_H -> R.string.profile_ins_units_per_hour + this == UserEntry.Units.G -> R.string.shortgram + this == UserEntry.Units.M -> R.string.shortminute + this == UserEntry.Units.H -> R.string.shorthour + this == UserEntry.Units.Percent -> R.string.percent + else -> 0 + } +} + +fun UserEntry.Units.stringkey(): String { + return when { + this == UserEntry.Units.Mg_Dl -> Constants.MGDL + this == UserEntry.Units.Mmol_L -> Constants.MMOL + this == UserEntry.Units.U -> UserEntry.Units.U.name + this == UserEntry.Units.U_H -> UserEntry.Units.U_H.name + this == UserEntry.Units.G -> UserEntry.Units.G.name + this == UserEntry.Units.M -> UserEntry.Units.M.name + this == UserEntry.Units.H -> UserEntry.Units.H.name + this == UserEntry.Units.Percent -> "%" + else -> "" + } +} + +fun UserEntry.Units.Companion(source: String?) = UserEntry.Units.values().firstOrNull { it.stringkey() == source } ?: UserEntry.Units.None \ 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 21c17997ba..04b3dc9e6e 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -92,6 +92,8 @@ Event type mg/dl mmol/l + g + %% Advanced Settings Bluetooth BT Watchdog diff --git a/database/src/main/java/info/nightscout/androidaps/database/Converters.kt b/database/src/main/java/info/nightscout/androidaps/database/Converters.kt index 29bd3db50c..5cfb99a71c 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/Converters.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/Converters.kt @@ -16,6 +16,23 @@ class Converters { @TypeConverter fun toAction(action: String?) = action?.let { UserEntry.Action.fromString(it) } + @TypeConverter + fun fromValueWithUnit(valueWithUnit: UserEntry.ValueWithUnit?): String? { + if (valueWithUnit == null) return null + val jsonObject = JSONObject() + jsonObject.put("dValue", valueWithUnit.dValue) + jsonObject.put("iValue", valueWithUnit.iValue) + jsonObject.put("unit", valueWithUnit.unit.name) + return jsonObject.toString() + } + + @TypeConverter + fun toValueWithUnit(jsonString: String?): UserEntry.ValueWithUnit? { + if (jsonString == null) return null + val jsonObject = JSONObject(jsonString) + return UserEntry.ValueWithUnit(jsonObject.getDouble("dValue"), jsonObject.getInt("iValue"),UserEntry.Units.fromString(jsonObject.getString("unit")) ) + } + @TypeConverter fun fromBolusType(bolusType: Bolus.Type?) = bolusType?.name diff --git a/database/src/main/java/info/nightscout/androidaps/database/DatabaseModule.kt b/database/src/main/java/info/nightscout/androidaps/database/DatabaseModule.kt index b36e16ff5d..32dbba2511 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/DatabaseModule.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/DatabaseModule.kt @@ -33,4 +33,10 @@ open class DatabaseModule { database.execSQL("CREATE TABLE IF NOT EXISTS userEntry (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `action` TEXT NOT NULL, `s` TEXT NOT NULL, `d1` REAL NOT NULL, `d2` REAL NOT NULL, `i1` INTEGER NOT NULL, `i2` INTEGER NOT NULL)") } } + + private val migration3to4 = object : Migration(3, 4) { + override fun migrate(database: SupportSQLiteDatabase) { + database.execSQL("CREATE TABLE IF NOT EXISTS userEntry (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `action` TEXT NOT NULL, `s` TEXT NOT NULL, `d1` TEXT NOT NULL, `d2` TEXT NOT NULL, `i1` TEXT NOT NULL, `i2` TEXT NOT NULL)") + } + } } \ No newline at end of file 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 2ee5f03c7d..84c2649b05 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 @@ -17,10 +17,10 @@ data class UserEntry( override var utcOffset: Long = TimeZone.getDefault().getOffset(timestamp).toLong(), var action: Action, var s: String, - var d1: Double, - var d2: Double, - var i1: Int, - var i2: Int + var d1: ValueWithUnit, + var d2: ValueWithUnit, + var i1: ValueWithUnit, + var i2: ValueWithUnit ) : DBEntry, DBEntryWithTime { enum class Action () { @SerializedName("BOLUS") BOLUS, @@ -123,4 +123,26 @@ data class UserEntry( fun fromString(source: String?) = UserEntry.Action.values().firstOrNull { it.name == source } ?: UserEntry.Action.UNKNOWN } } + data class ValueWithUnit (val dValue: Double, val iValue: Int, val unit: Units) { + constructor(value:Int, unit:Units) : this(0.0, value, unit) + constructor(value:Double, unit:Units) : this(value,0, unit) + + + } + enum class Units { + @SerializedName("None") None, + @SerializedName("Mg_Dl") Mg_Dl, + @SerializedName("Mmol_L") Mmol_L, + @SerializedName("U") U, + @SerializedName("U_H") U_H, + @SerializedName("G") G, + @SerializedName("M") M, + @SerializedName("H") H, + @SerializedName("Percent") Percent + ; + + companion object { + fun fromString(unit: String?) = UserEntry.Units.values().firstOrNull { it.name == unit } ?: UserEntry.Units.None + } + } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UserEntryTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UserEntryTransaction.kt index c4d4ce2755..0b633d013b 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UserEntryTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UserEntryTransaction.kt @@ -1,14 +1,15 @@ package info.nightscout.androidaps.database.transactions import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* class UserEntryTransaction( - val action: UserEntry.Action, + val action: Action, val s: String = "", - val d1: Double = 0.0, - val d2: Double = 0.0, - val i1: Int = 0, - val i2: Int = 0, + val d1: ValueWithUnit = ValueWithUnit(0.0, Units.None), + val d2: ValueWithUnit = ValueWithUnit(0.0, Units.None), + val i1: ValueWithUnit = ValueWithUnit(0, Units.None), + val i2: ValueWithUnit = ValueWithUnit(0, Units.None) ) : Transaction() { override fun run() { From 95e32c34060c7b25aa190339230867d15a00b73f Mon Sep 17 00:00:00 2001 From: Philoul Date: Sat, 27 Feb 2021 15:45:47 +0100 Subject: [PATCH 13/66] Exemple with CalibrationDialog and CarbsDialog.kt Good Direction ? --- .../androidaps/dialogs/CalibrationDialog.kt | 4 +- .../androidaps/dialogs/CarbsDialog.kt | 12 ++-- .../androidaps/logging/UserEntryLogger.kt | 58 ++++++++++++++++--- .../androidaps/database/Converters.kt | 31 +++++++++- .../androidaps/database/entities/UserEntry.kt | 15 ++--- .../transactions/UserEntryTransaction.kt | 13 +---- 6 files changed, 96 insertions(+), 37 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 4c129c301c..b6285863be 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt @@ -9,13 +9,11 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile -import info.nightscout.androidaps.database.entities.UserEntry 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.utils.extensions.fromStringKey import info.nightscout.androidaps.utils.HtmlHelper import info.nightscout.androidaps.utils.XdripCalibrations import info.nightscout.androidaps.utils.alertDialogs.OKDialog @@ -80,7 +78,7 @@ class CalibrationDialog : DialogFragmentWithDate() { if (bg > 0) { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_calibration), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { - uel.log(Action.CALIBRATION, d1 = ValueWithUnit(bg, if (units == Constants.MMOL) Units.Mg_Dl else Units.Mmol_L)) + uel.log(Action.CALIBRATION, ValueWithUnit(bg, if (units == Constants.MMOL) Units.Mmol_L else Units.Mg_Dl)) xdripCalibrations.sendIntent(bg) }) } 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 f8a334f7b0..82f39b363a 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt @@ -11,7 +11,7 @@ import info.nightscout.androidaps.Constants import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.databinding.DialogCarbsBinding import info.nightscout.androidaps.db.CareportalEvent import info.nightscout.androidaps.db.Source @@ -213,7 +213,7 @@ class CarbsDialog : DialogFragmentWithDate() { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.carbs), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { when { activitySelected -> { - uel.log(UserEntry.Action.TT_ACTIVITY, d1 = activityTT, i1 = activityTTDuration) + uel.log(Action.TT_ACTIVITY, ValueWithUnit(activityTT, if (units == Constants.MMOL) Units.Mmol_L else Units.Mg_Dl) , ValueWithUnit(activityTTDuration, Units.M)) val tempTarget = TempTarget() .date(System.currentTimeMillis()) .duration(activityTTDuration) @@ -225,7 +225,7 @@ class CarbsDialog : DialogFragmentWithDate() { } eatingSoonSelected -> { - uel.log(UserEntry.Action.TT_EATING_SOON, d1 = eatingSoonTT, i1 = eatingSoonTTDuration) + uel.log(Action.TT_EATING_SOON, ValueWithUnit(eatingSoonTT, if (units == Constants.MMOL) Units.Mmol_L else Units.Mg_Dl) , ValueWithUnit(eatingSoonTTDuration, Units.M)) val tempTarget = TempTarget() .date(System.currentTimeMillis()) .duration(eatingSoonTTDuration) @@ -237,7 +237,7 @@ class CarbsDialog : DialogFragmentWithDate() { } hypoSelected -> { - uel.log(UserEntry.Action.TT_HYPO, d1 = hypoTT, i1 = hypoTTDuration) + uel.log(Action.TT_HYPO, ValueWithUnit(hypoTT, if (units == Constants.MMOL) Units.Mmol_L else Units.Mg_Dl) , ValueWithUnit(hypoTTDuration, Units.M)) val tempTarget = TempTarget() .date(System.currentTimeMillis()) .duration(hypoTTDuration) @@ -250,10 +250,10 @@ class CarbsDialog : DialogFragmentWithDate() { } if (carbsAfterConstraints > 0) { if (duration == 0) { - uel.log(UserEntry.Action.CARBS, d1 = carbsAfterConstraints.toDouble(), i1 = timeOffset) + uel.log(Action.CARBS, ValueWithUnit(carbsAfterConstraints.toDouble(), Units.G), ValueWithUnit(timeOffset, Units.M)) carbsGenerator.createCarb(carbsAfterConstraints, time, CareportalEvent.CARBCORRECTION, notes) } else { - uel.log(UserEntry.Action.CARBS, d1 = carbsAfterConstraints.toDouble(), i1 = timeOffset, i2 = duration) + uel.log(Action.CARBS, ValueWithUnit(carbsAfterConstraints.toDouble(), Units.G), ValueWithUnit(timeOffset,Units.M), ValueWithUnit(duration, Units.H)) carbsGenerator.generateCarbs(carbsAfterConstraints, time, duration, notes) nsUpload.uploadEvent(CareportalEvent.NOTE, DateUtil.now() - 2000, resourceHelper.gs(R.string.generated_ecarbs_note, carbsAfterConstraints, duration, timeOffset)) } diff --git a/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt b/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt index eb2dae411b..beefb07d00 100644 --- a/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt +++ b/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt @@ -1,7 +1,7 @@ package info.nightscout.androidaps.logging +import info.nightscout.androidaps.Constants import info.nightscout.androidaps.database.AppRepository -import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.database.transactions.UserEntryTransaction import info.nightscout.androidaps.utils.rx.AapsSchedulers @@ -20,20 +20,62 @@ class UserEntryLogger @Inject constructor( private val compositeDisposable = CompositeDisposable() - fun log(action: UserEntry.Action, s: String = "", d1: ValueWithUnit = ValueWithUnit(0.0,Units.None), d2: ValueWithUnit = ValueWithUnit(0.0,Units.None), i1: ValueWithUnit = ValueWithUnit(0,Units.None), i2: ValueWithUnit = ValueWithUnit(0,Units.None)) { + fun log(action: Action, s: String, vararg listvalues: ValueWithUnit) { + val values = mutableListOf() + for (v in listvalues){ + var vConverted = v + // Convertion to always store all values in the same units in database + when(v.unit) { + Units.Mmol_L -> { vConverted = ValueWithUnit(v.dValue * Constants.MMOLL_TO_MGDL, Units.Mg_Dl)} + } + values.add(vConverted) + } compositeDisposable += repository.runTransaction(UserEntryTransaction( action = action, s = s, - d1 = d1, - d2 = d2, - i1 = i1, - i2 = i2 + values = values )) .subscribeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io) .subscribeBy( - onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $s ${if (d1.dValue != 0.0) d1 else ""} ${if (d2.dValue != 0.0) d2 else ""} ${if (i1.iValue != 0) i1 else ""} ${if (i2.iValue != 0) i2 else ""}") }, - onComplete = { aapsLogger.debug("USER ENTRY: $action $s ${if (d1.dValue != 0.0) d1 else ""} ${if (d2.dValue != 0.0) d2 else ""} ${if (i1.iValue != 0) i1 else ""} ${if (i2.iValue != 0) i2 else ""}") } + //onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $s ${if (d1.dValue != 0.0) d1 else ""} ${if (d2.dValue != 0.0) d2 else ""} ${if (i1.iValue != 0) i1 else ""} ${if (i2.iValue != 0) i2 else ""}") }, + //onComplete = { aapsLogger.debug("USER ENTRY: $action $s ${if (d1.dValue != 0.0) d1 else ""} ${if (d2.dValue != 0.0) d2 else ""} ${if (i1.iValue != 0) i1 else ""} ${if (i2.iValue != 0) i2 else ""}") } + ) + } + + fun log(action: Action, vararg listvalues: ValueWithUnit) { + val values = mutableListOf() + for (v in listvalues){ + var vConverted = v + // Convertion to always store all values in the same units in database + when(v.unit) { + Units.Mmol_L -> { vConverted = ValueWithUnit(v.dValue * Constants.MMOLL_TO_MGDL, Units.Mg_Dl)} + } + values.add(vConverted) + } + compositeDisposable += repository.runTransaction(UserEntryTransaction( + action = action, + s = "", + values = values + )) + .subscribeOn(aapsSchedulers.io) + .observeOn(aapsSchedulers.io) + .subscribeBy( + //onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $s ${if (d1.dValue != 0.0) d1 else ""} ${if (d2.dValue != 0.0) d2 else ""} ${if (i1.iValue != 0) i1 else ""} ${if (i2.iValue != 0) i2 else ""}") }, + //onComplete = { aapsLogger.debug("USER ENTRY: $action $s ${if (d1.dValue != 0.0) d1 else ""} ${if (d2.dValue != 0.0) d2 else ""} ${if (i1.iValue != 0) i1 else ""} ${if (i2.iValue != 0) i2 else ""}") } + ) + } + + fun log(action: Action) { + compositeDisposable += repository.runTransaction(UserEntryTransaction( + action = action, + s = "" + )) + .subscribeOn(aapsSchedulers.io) + .observeOn(aapsSchedulers.io) + .subscribeBy( + onError = { aapsLogger.debug("ERRORED USER ENTRY: $action") }, + onComplete = { aapsLogger.debug("USER ENTRY: $action") } ) } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/Converters.kt b/database/src/main/java/info/nightscout/androidaps/database/Converters.kt index 5cfb99a71c..eb23f19449 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/Converters.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/Converters.kt @@ -20,8 +20,10 @@ class Converters { fun fromValueWithUnit(valueWithUnit: UserEntry.ValueWithUnit?): String? { if (valueWithUnit == null) return null val jsonObject = JSONObject() + jsonObject.put("sValue", valueWithUnit.sValue) jsonObject.put("dValue", valueWithUnit.dValue) jsonObject.put("iValue", valueWithUnit.iValue) + jsonObject.put("lValue", valueWithUnit.lValue) jsonObject.put("unit", valueWithUnit.unit.name) return jsonObject.toString() } @@ -30,7 +32,34 @@ class Converters { fun toValueWithUnit(jsonString: String?): UserEntry.ValueWithUnit? { if (jsonString == null) return null val jsonObject = JSONObject(jsonString) - return UserEntry.ValueWithUnit(jsonObject.getDouble("dValue"), jsonObject.getInt("iValue"),UserEntry.Units.fromString(jsonObject.getString("unit")) ) + return UserEntry.ValueWithUnit(jsonObject.getString("sValue"), jsonObject.getDouble("dValue"), jsonObject.getInt("iValue"), jsonObject.getLong("lValue"), UserEntry.Units.fromString(jsonObject.getString("unit")) ) + } + + @TypeConverter + fun fromMutableListOfValueWithUnit(values: MutableList?): String? { + if (values == null) return null + val jsonArray = JSONArray() + values.forEach { + val jsonObject = JSONObject() + jsonObject.put("dValue", it.dValue) + jsonObject.put("iValue", it.iValue) + jsonObject.put("lValue", it.lValue) + jsonObject.put("unit", it.unit.name) + jsonArray.put(jsonObject) + } + return jsonArray.toString() + } + + @TypeConverter + fun toMutableListOfValueWithUnit(jsonString: String?): List? { + if (jsonString == null) return null + val jsonArray = JSONArray(jsonString) + val list = mutableListOf() + for (i in 0 until jsonArray.length()) { + val jsonObject = jsonArray.getJSONObject(i) + list.add(Block(jsonObject.getLong("duration"), jsonObject.getDouble("amount"))) + } + return list } @TypeConverter 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 84c2649b05..dd9dd003f0 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 @@ -17,10 +17,7 @@ data class UserEntry( override var utcOffset: Long = TimeZone.getDefault().getOffset(timestamp).toLong(), var action: Action, var s: String, - var d1: ValueWithUnit, - var d2: ValueWithUnit, - var i1: ValueWithUnit, - var i2: ValueWithUnit + var values: MutableList ) : DBEntry, DBEntryWithTime { enum class Action () { @SerializedName("BOLUS") BOLUS, @@ -123,16 +120,16 @@ data class UserEntry( fun fromString(source: String?) = UserEntry.Action.values().firstOrNull { it.name == source } ?: UserEntry.Action.UNKNOWN } } - data class ValueWithUnit (val dValue: Double, val iValue: Int, val unit: Units) { - constructor(value:Int, unit:Units) : this(0.0, value, unit) - constructor(value:Double, unit:Units) : this(value,0, unit) - - + data class ValueWithUnit (val dValue: Double, val iValue: Int, val lValue: Long, val unit: Units) { + constructor(dvalue:Double, unit:Units) : this(dvalue,0, 0, unit) + constructor(ivalue:Int, unit:Units) : this(0.0, ivalue, 0, unit) + constructor(lvalue:Long, unit:Units) : this(0.0,0, lvalue, unit) } enum class Units { @SerializedName("None") None, @SerializedName("Mg_Dl") Mg_Dl, @SerializedName("Mmol_L") Mmol_L, + @SerializedName("Timestamp") Timestamp, @SerializedName("U") U, @SerializedName("U_H") U_H, @SerializedName("G") G, diff --git a/database/src/main/java/info/nightscout/androidaps/database/transactions/UserEntryTransaction.kt b/database/src/main/java/info/nightscout/androidaps/database/transactions/UserEntryTransaction.kt index 0b633d013b..3537f2bd83 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/transactions/UserEntryTransaction.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/transactions/UserEntryTransaction.kt @@ -5,23 +5,16 @@ import info.nightscout.androidaps.database.entities.UserEntry.* class UserEntryTransaction( val action: Action, - val s: String = "", - val d1: ValueWithUnit = ValueWithUnit(0.0, Units.None), - val d2: ValueWithUnit = ValueWithUnit(0.0, Units.None), - val i1: ValueWithUnit = ValueWithUnit(0, Units.None), - val i2: ValueWithUnit = ValueWithUnit(0, Units.None) + val s: String, + val values: MutableList = mutableListOf() ) : Transaction() { override fun run() { - database.userEntryDao.insert(UserEntry( timestamp = System.currentTimeMillis(), action = action, s = s, - d1 = d1, - d2 = d2, - i1 = i1, - i2 = i2 + values = values )) } } \ No newline at end of file From 8798be0c3465bebed108a555c627f8cc933f9fe2 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 28 Feb 2021 15:54:37 +0100 Subject: [PATCH 14/66] Update uel.log entries, Increase database version 3=>4, update migration3to4 --- .../androidaps/activities/StatsActivity.kt | 4 +- .../androidaps/dialogs/CalibrationDialog.kt | 2 +- .../androidaps/dialogs/CarbsDialog.kt | 6 +- .../androidaps/dialogs/CareDialog.kt | 4 +- .../androidaps/dialogs/ExtendedBolusDialog.kt | 4 +- .../androidaps/dialogs/FillDialog.kt | 8 +- .../androidaps/dialogs/InsulinDialog.kt | 8 +- .../androidaps/dialogs/LoopDialog.kt | 32 +- .../androidaps/dialogs/ProfileSwitchDialog.kt | 4 +- .../androidaps/dialogs/TempBasalDialog.kt | 6 +- .../androidaps/dialogs/TempTargetDialog.kt | 13 +- .../androidaps/dialogs/TreatmentDialog.kt | 4 +- .../configBuilder/ConfigBuilderPlugin.kt | 4 +- .../objectives/ObjectivesFragment.kt | 4 +- .../objectives/ObjectivesPlugin.kt | 4 +- .../general/actions/ActionsFragment.kt | 6 +- .../general/automation/AutomationFragment.kt | 6 +- .../plugins/general/food/FoodFragment.kt | 4 +- .../general/maintenance/ImportExportPrefs.kt | 4 +- .../maintenance/MaintenanceFragment.kt | 10 +- .../general/nsclient/NSClientFragment.java | 5 +- .../general/nsclient/data/NSSettingsStatus.kt | 4 +- .../general/overview/OverviewFragment.kt | 4 +- .../smsCommunicator/SmsCommunicatorPlugin.kt | 66 +- .../activities/SmsCommunicatorOtpActivity.kt | 6 +- .../profile/local/LocalProfileFragment.kt | 8 +- .../profile/local/LocalProfilePlugin.kt | 4 +- .../plugins/profile/ns/NSProfileFragment.kt | 4 +- .../plugins/source/BGSourceFragment.kt | 4 +- .../fragments/TreatmentsBolusFragment.kt | 8 +- .../fragments/TreatmentsCareportalFragment.kt | 8 +- .../TreatmentsExtendedBolusesFragment.kt | 4 +- .../TreatmentsProfileSwitchFragment.kt | 8 +- .../fragments/TreatmentsTempTargetFragment.kt | 6 +- .../TreatmentsTemporaryBasalsFragment.kt | 4 +- .../fragments/TreatmentsUserEntryFragment.kt | 3 + .../androidaps/utils/wizard/BolusWizard.kt | 8 +- .../info/nightscout/androidaps/Constants.java | 5 +- .../androidaps/dialogs/ErrorDialog.kt | 8 +- .../androidaps/logging/UserEntryLogger.kt | 26 +- .../utils/extensions/UnitsStrings.kt | 2 +- core/src/main/res/values/strings.xml | 2 +- .../androidaps/dana/DanaFragment.kt | 4 +- .../4.json | 2739 +++++++++++++++++ .../androidaps/database/AppDatabase.kt | 2 +- .../androidaps/database/Converters.kt | 37 +- .../androidaps/database/DatabaseModule.kt | 4 +- .../androidaps/database/entities/UserEntry.kt | 30 +- 48 files changed, 2944 insertions(+), 206 deletions(-) create mode 100644 database/schemas/info.nightscout.androidaps.database.AppDatabase/4.json diff --git a/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt index 647c449f1a..896506b93f 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/StatsActivity.kt @@ -2,7 +2,7 @@ package info.nightscout.androidaps.activities import android.os.Bundle import info.nightscout.androidaps.R -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.databinding.ActivityStatsBinding import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.utils.ActivityMonitor @@ -32,7 +32,7 @@ class StatsActivity : NoSplashAppCompatActivity() { binding.ok.setOnClickListener { finish() } binding.reset.setOnClickListener { OKDialog.showConfirmation(this, resourceHelper.gs(R.string.doyouwantresetstats)) { - uel.log(UserEntry.Action.STAT_RESET) + uel.log(Action.STAT_RESET) activityMonitor.reset() recreate() } 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 b6285863be..68420e62d2 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt @@ -78,7 +78,7 @@ class CalibrationDialog : DialogFragmentWithDate() { if (bg > 0) { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_calibration), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { - uel.log(Action.CALIBRATION, ValueWithUnit(bg, if (units == Constants.MMOL) Units.Mmol_L else Units.Mg_Dl)) + uel.log(Action.CALIBRATION, ValueWithUnit(bg, units)) xdripCalibrations.sendIntent(bg) }) } 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 82f39b363a..b6893165f0 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt @@ -213,7 +213,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, if (units == Constants.MMOL) Units.Mmol_L else Units.Mg_Dl) , ValueWithUnit(activityTTDuration, Units.M)) + uel.log(Action.TT_ACTIVITY, ValueWithUnit(activityTT, units) , ValueWithUnit(activityTTDuration, Units.M)) val tempTarget = TempTarget() .date(System.currentTimeMillis()) .duration(activityTTDuration) @@ -225,7 +225,7 @@ class CarbsDialog : DialogFragmentWithDate() { } eatingSoonSelected -> { - uel.log(Action.TT_EATING_SOON, ValueWithUnit(eatingSoonTT, if (units == Constants.MMOL) Units.Mmol_L else Units.Mg_Dl) , ValueWithUnit(eatingSoonTTDuration, Units.M)) + uel.log(Action.TT_EATING_SOON, ValueWithUnit(eatingSoonTT, units) , ValueWithUnit(eatingSoonTTDuration, Units.M)) val tempTarget = TempTarget() .date(System.currentTimeMillis()) .duration(eatingSoonTTDuration) @@ -237,7 +237,7 @@ class CarbsDialog : DialogFragmentWithDate() { } hypoSelected -> { - uel.log(Action.TT_HYPO, ValueWithUnit(hypoTT, if (units == Constants.MMOL) Units.Mmol_L else Units.Mg_Dl) , ValueWithUnit(hypoTTDuration, Units.M)) + uel.log(Action.TT_HYPO, ValueWithUnit(hypoTT, units) , ValueWithUnit(hypoTTDuration, Units.M)) val tempTarget = TempTarget() .date(System.currentTimeMillis()) .duration(hypoTTDuration) 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 1941500fdf..cbb30d1b0a 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt @@ -13,7 +13,7 @@ import info.nightscout.androidaps.Constants import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.databinding.DialogCareBinding import info.nightscout.androidaps.db.CareportalEvent import info.nightscout.androidaps.db.Source @@ -223,7 +223,7 @@ class CareDialog : DialogFragmentWithDate() { EventType.ANNOUNCEMENT -> CareportalEvent.ANNOUNCEMENT } careportalEvent.json = json.toString() - uel.log(UserEntry.Action.CAREPORTAL, careportalEvent.eventType) + uel.log(Action.CAREPORTAL, ValueWithUnit(careportalEvent.eventType, Units.CPEvent)) MainApp.getDbHelper().createOrUpdate(careportalEvent) nsUpload.uploadCareportalEntryToNS(json) }, null) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/ExtendedBolusDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/ExtendedBolusDialog.kt index 2bf7700f95..34b9b8f307 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/ExtendedBolusDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/ExtendedBolusDialog.kt @@ -8,7 +8,7 @@ import android.view.ViewGroup import com.google.common.base.Joiner import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.ErrorHelperActivity -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.databinding.DialogExtendedbolusBinding import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider @@ -88,7 +88,7 @@ class ExtendedBolusDialog : DialogFragmentWithDate() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.extended_bolus), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { - uel.log(UserEntry.Action.EXTENDED_BOLUS, d1 = insulinAfterConstraint, i1 = durationInMinutes) + uel.log(Action.EXTENDED_BOLUS, ValueWithUnit(insulinAfterConstraint, Units.U), ValueWithUnit(durationInMinutes, Units.M)) commandQueue.extendedBolus(insulinAfterConstraint, durationInMinutes, object : Callback() { override fun run() { if (!result.success) { 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 aebf1f439d..0af112aa29 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt @@ -9,7 +9,7 @@ import com.google.common.base.Joiner import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.data.DetailedBolusInfo -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.databinding.DialogFillBinding import info.nightscout.androidaps.db.CareportalEvent import info.nightscout.androidaps.db.Source @@ -128,16 +128,16 @@ class FillDialog : DialogFragmentWithDate() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.primefill), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { if (insulinAfterConstraints > 0) { - uel.log(UserEntry.Action.PRIME_BOLUS, d1 = insulinAfterConstraints) + uel.log(Action.PRIME_BOLUS, ValueWithUnit(insulinAfterConstraints, Units.U)) requestPrimeBolus(insulinAfterConstraints, notes) } if (siteChange) { - uel.log(UserEntry.Action.SITE_CHANGE) + uel.log(Action.SITE_CHANGE) nsUpload.generateCareportalEvent(CareportalEvent.SITECHANGE, eventTime, notes) } if (insulinChange) { // add a second for case of both checked - uel.log(UserEntry.Action.INSULIN_CHANGE) + uel.log(Action.INSULIN_CHANGE) nsUpload.generateCareportalEvent(CareportalEvent.INSULINCHANGE, eventTime + 1000, notes) } }, null) 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 adcf1e74a0..f6cc1e1428 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt @@ -15,7 +15,7 @@ import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.data.DetailedBolusInfo import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.database.AppRepository -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.databinding.DialogInsulinBinding import info.nightscout.androidaps.db.CareportalEvent import info.nightscout.androidaps.db.Source @@ -179,7 +179,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(UserEntry.Action.TT_EATING_SOON, d1 = eatingSoonTT, i1 = eatingSoonTTDuration) + uel.log(Action.TT_EATING_SOON, ValueWithUnit(eatingSoonTT, units), ValueWithUnit(eatingSoonTTDuration, Units.M)) val tempTarget = TempTarget() .date(System.currentTimeMillis()) .duration(eatingSoonTTDuration) @@ -197,11 +197,11 @@ class InsulinDialog : DialogFragmentWithDate() { detailedBolusInfo.source = Source.USER detailedBolusInfo.notes = notes if (recordOnlyChecked) { - uel.log(UserEntry.Action.BOLUS_RECORD, d1 = insulinAfterConstraints, i1 = timeOffset) + uel.log(Action.BOLUS_RECORD, ValueWithUnit(insulinAfterConstraints, Units.U), ValueWithUnit(timeOffset, Units.M)) detailedBolusInfo.date = time activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false) } else { - uel.log(UserEntry.Action.BOLUS, d1 = insulinAfterConstraints) + uel.log(Action.BOLUS, ValueWithUnit(insulinAfterConstraints, Units.U)) detailedBolusInfo.date = DateUtil.now() commandQueue.bolus(detailedBolusInfo, object : Callback() { override fun run() { 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 e201a7f1bb..77be1a538f 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt @@ -12,7 +12,7 @@ import androidx.fragment.app.FragmentManager import dagger.android.support.DaggerDialogFragment import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.ErrorHelperActivity -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.databinding.DialogLoopBinding import info.nightscout.androidaps.events.EventPreferenceChange import info.nightscout.androidaps.events.EventRefreshOverview @@ -239,28 +239,28 @@ class LoopDialog : DaggerDialogFragment() { val profile = profileFunction.getProfile() ?: return true when (v.id) { R.id.overview_closeloop -> { - uel.log(UserEntry.Action.CLOSED_LOOP_MODE) + uel.log(Action.CLOSED_LOOP_MODE) sp.putString(R.string.key_aps_mode, "closed") rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.closedloop))) return true } R.id.overview_lgsloop -> { - uel.log(UserEntry.Action.LGS_LOOP_MODE) + uel.log(Action.LGS_LOOP_MODE) sp.putString(R.string.key_aps_mode, "lgs") rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend))) return true } R.id.overview_openloop -> { - uel.log(UserEntry.Action.OPEN_LOOP_MODE) + uel.log(Action.OPEN_LOOP_MODE) sp.putString(R.string.key_aps_mode, "open") rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend))) return true } R.id.overview_disable -> { - uel.log(UserEntry.Action.LOOP_DISABLED) + uel.log(Action.LOOP_DISABLED) loopPlugin.setPluginEnabled(PluginType.LOOP, false) loopPlugin.setFragmentVisible(PluginType.LOOP, false) configBuilderPlugin.storeSettings("DisablingLoop") @@ -277,7 +277,7 @@ class LoopDialog : DaggerDialogFragment() { } R.id.overview_enable -> { - uel.log(UserEntry.Action.LOOP_ENABLED) + uel.log(Action.LOOP_ENABLED) loopPlugin.setPluginEnabled(PluginType.LOOP, true) loopPlugin.setFragmentVisible(PluginType.LOOP, true) configBuilderPlugin.storeSettings("EnablingLoop") @@ -287,7 +287,7 @@ class LoopDialog : DaggerDialogFragment() { } R.id.overview_resume, R.id.overview_reconnect -> { - uel.log(if (v.id==R.id.overview_resume) UserEntry.Action.RESUME else UserEntry.Action.RECONNECT ) + uel.log(if (v.id==R.id.overview_resume) Action.RESUME else Action.RECONNECT ) loopPlugin.suspendTo(0L) rxBus.send(EventRefreshOverview("suspendmenu")) commandQueue.cancelTempBasal(true, object : Callback() { @@ -303,49 +303,49 @@ class LoopDialog : DaggerDialogFragment() { } R.id.overview_suspend_1h -> { - uel.log(UserEntry.Action.SUSPEND_1H) + uel.log(Action.SUSPEND_1H) loopPlugin.suspendLoop(60) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_suspend_2h -> { - uel.log(UserEntry.Action.SUSPEND_2H) + uel.log(Action.SUSPEND_2H) loopPlugin.suspendLoop(120) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_suspend_3h -> { - uel.log(UserEntry.Action.SUSPEND_3H) + uel.log(Action.SUSPEND_3H) loopPlugin.suspendLoop(180) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_suspend_10h -> { - uel.log(UserEntry.Action.SUSPEND_10H) + uel.log(Action.SUSPEND_10H) loopPlugin.suspendLoop(600) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_disconnect_15m -> { - uel.log(UserEntry.Action.DISCONNECT_15M) + uel.log(Action.DISCONNECT_15M) loopPlugin.disconnectPump(15, profile) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_disconnect_30m -> { - uel.log(UserEntry.Action.DISCONNECT_30M) + uel.log(Action.DISCONNECT_30M) loopPlugin.disconnectPump(30, profile) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_disconnect_1h -> { - uel.log(UserEntry.Action.DISCONNECT_1H) + uel.log(Action.DISCONNECT_1H) 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(UserEntry.Action.DISCONNECT_2H) + uel.log(Action.DISCONNECT_2H) loopPlugin.disconnectPump(120, profile) rxBus.send(EventRefreshOverview("suspendmenu")) return true } R.id.overview_disconnect_3h -> { - uel.log(UserEntry.Action.DISCONNECT_3H) + uel.log(Action.DISCONNECT_3H) loopPlugin.disconnectPump(180, profile) rxBus.send(EventRefreshOverview("suspendmenu")) return true diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt index b834c17af3..cdfed0ae58 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt @@ -8,7 +8,7 @@ import android.widget.ArrayAdapter import com.google.common.base.Joiner import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.databinding.DialogProfileswitchBinding import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.ProfileFunction @@ -125,7 +125,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { - uel.log(UserEntry.Action.PROFILE_SWITCH, d1 = percent.toDouble(), i1 = timeShift, i2 = duration) + uel.log(Action.PROFILE_SWITCH, ValueWithUnit(percent, Units.Percent), ValueWithUnit(timeShift, Units.H), ValueWithUnit(duration, Units.M)) treatmentsPlugin.doProfileSwitch(profileStore, profile, duration, percent, timeShift, eventTime) }) } diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt index 78038f22f4..01c9aa8d2a 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt @@ -8,7 +8,7 @@ import android.view.ViewGroup import com.google.common.base.Joiner import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.ErrorHelperActivity -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.databinding.DialogTempbasalBinding import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider @@ -126,10 +126,10 @@ class TempBasalDialog : DialogFragmentWithDate() { } } if (isPercentPump) { - uel.log(UserEntry.Action.TEMP_BASAL, d1 = percent.toDouble(), i1 = durationInMinutes) + uel.log(Action.TEMP_BASAL, ValueWithUnit(percent, Units.Percent), ValueWithUnit(durationInMinutes, Units.M)) commandQueue.tempBasalPercent(percent, durationInMinutes, true, profile, callback) } else { - uel.log(UserEntry.Action.TEMP_BASAL, d1 = absolute, i1 = durationInMinutes) + uel.log(Action.TEMP_BASAL, ValueWithUnit(absolute, Units.U), ValueWithUnit(durationInMinutes, Units.M)) commandQueue.tempBasalAbsolute(absolute, durationInMinutes, true, profile, callback) } }) 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 f3322574b0..c7e364ae96 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt @@ -10,7 +10,7 @@ import com.google.common.collect.Lists import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.databinding.DialogTemptargetBinding import info.nightscout.androidaps.db.Source import info.nightscout.androidaps.db.TempTarget @@ -167,12 +167,13 @@ class TempTargetDialog : DialogFragmentWithDate() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { + val units = profileFunction.getUnits() when(reason) { - resourceHelper.gs(R.string.eatingsoon) -> uel.log(UserEntry.Action.TT_EATING_SOON, d1 = target, i1 = duration) - resourceHelper.gs(R.string.activity) -> uel.log(UserEntry.Action.TT_ACTIVITY, d1 = target, i1 = duration) - resourceHelper.gs(R.string.hypo) -> uel.log(UserEntry.Action.TT_HYPO, d1 = target, i1 = duration) - resourceHelper.gs(R.string.manual) -> uel.log(UserEntry.Action.TT, d1 = target, i1 = duration) - resourceHelper.gs(R.string.stoptemptarget) -> uel.log(UserEntry.Action.CANCEL_TT) + resourceHelper.gs(R.string.eatingsoon) -> uel.log(Action.TT_EATING_SOON, ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) + resourceHelper.gs(R.string.activity) -> uel.log(Action.TT_ACTIVITY, ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) + resourceHelper.gs(R.string.hypo) -> uel.log(Action.TT_HYPO, ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) + resourceHelper.gs(R.string.manual) -> uel.log(Action.TT, ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) + resourceHelper.gs(R.string.stoptemptarget) -> uel.log(Action.CANCEL_TT) } if (target == 0.0 || duration == 0) { val tempTarget = TempTarget() 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 8be73db915..eae7f6950c 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt @@ -12,7 +12,7 @@ import info.nightscout.androidaps.Config import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.data.DetailedBolusInfo -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.databinding.DialogTreatmentBinding import info.nightscout.androidaps.db.CareportalEvent import info.nightscout.androidaps.db.Source @@ -130,7 +130,7 @@ class TreatmentDialog : DialogFragmentWithDate() { if (insulinAfterConstraints > 0 || carbsAfterConstraints > 0) { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_treatment_label), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { - uel.log(UserEntry.Action.TREATMENT, d1 = insulin, i1 = carbs) + uel.log(Action.TREATMENT, ValueWithUnit(insulin, Units.U), ValueWithUnit(carbs, Units.G)) val detailedBolusInfo = DetailedBolusInfo() if (insulinAfterConstraints == 0.0) detailedBolusInfo.eventType = CareportalEvent.CARBCORRECTION if (carbsAfterConstraints == 0) detailedBolusInfo.eventType = CareportalEvent.CORRECTIONBOLUS 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 8bd3025b1c..d2065c238c 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 @@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.configBuilder import androidx.fragment.app.FragmentActivity import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.events.EventAppInitialized import info.nightscout.androidaps.events.EventConfigBuilderChange import info.nightscout.androidaps.events.EventRebuildTabs @@ -143,7 +143,7 @@ class ConfigBuilderPlugin @Inject constructor( OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.allow_hardware_pump_text), Runnable { performPluginSwitch(changedPlugin, newState, type) sp.putBoolean("allow_hardware_pump", true) - uel.log(UserEntry.Action.HW_PUMP_ALLOWED) + uel.log(Action.HW_PUMP_ALLOWED) aapsLogger.debug(LTag.PUMP, "First time HW pump allowed!") }, Runnable { rxBus.send(EventConfigBuilderUpdateGui()) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt index 769d1d033d..22fcb7052f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt @@ -17,7 +17,7 @@ import androidx.recyclerview.widget.LinearSmoothScroller import androidx.recyclerview.widget.RecyclerView import dagger.android.support.DaggerFragment import info.nightscout.androidaps.R -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.databinding.ObjectivesFragmentBinding import info.nightscout.androidaps.databinding.ObjectivesItemBinding import info.nightscout.androidaps.dialogs.NtpProgressDialog @@ -308,7 +308,7 @@ class ObjectivesFragment : DaggerFragment() { holder.binding.unstart.setOnClickListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.objectives), resourceHelper.gs(R.string.doyouwantresetstart), Runnable { - uel.log(UserEntry.Action.OBJECTIVE_UNSTARTED, i1 = position + 1) + uel.log(Action.OBJECTIVE_UNSTARTED, ValueWithUnit(position + 1, Units.None)) objective.startedOn = 0 scrollToCurrentObjective() rxBus.send(EventObjectivesUpdateGui()) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt index b4a5144e2e..93090c7533 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt @@ -7,7 +7,7 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.BuildConfig import info.nightscout.androidaps.Config import info.nightscout.androidaps.R -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.interfaces.* import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.UserEntryLogger @@ -143,7 +143,7 @@ class ObjectivesPlugin @Inject constructor( sp.putLong("Objectives_" + "auto" + "_accomplished", DateUtil.now()) setupObjectives() OKDialog.show(activity, resourceHelper.gs(R.string.objectives), resourceHelper.gs(R.string.codeaccepted)) - uel.log(UserEntry.Action.OBJECTIVES_SKIPPED) + uel.log(Action.OBJECTIVES_SKIPPED) } else { OKDialog.show(activity, resourceHelper.gs(R.string.objectives), resourceHelper.gs(R.string.codeinvalid)) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt index 2ee007e225..b33a90e935 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt @@ -16,7 +16,7 @@ import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.activities.TDDStatsActivity -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.dialogs.* import info.nightscout.androidaps.events.* import info.nightscout.androidaps.historyBrowser.HistoryBrowseActivity @@ -155,7 +155,7 @@ class ActionsFragment : DaggerFragment() { } extendedBolusCancel?.setOnClickListener { if (activePlugin.activeTreatments.isInHistoryExtendedBoluslInProgress) { - uel.log(UserEntry.Action.CANCEL_EXTENDED_BOLUS) + uel.log(Action.CANCEL_EXTENDED_BOLUS) commandQueue.cancelExtended(object : Callback() { override fun run() { if (!result.success) { @@ -170,7 +170,7 @@ class ActionsFragment : DaggerFragment() { } cancelTempBasal?.setOnClickListener { if (activePlugin.activeTreatments.isTempBasalInProgress) { - uel.log(UserEntry.Action.CANCEL_TEMP_BASAL) + uel.log(Action.CANCEL_TEMP_BASAL) commandQueue.cancelTempBasal(true, object : Callback() { override fun run() { if (!result.success) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt index cdcb5e317f..65c757e2a6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt @@ -18,7 +18,7 @@ import androidx.recyclerview.widget.RecyclerView import dagger.android.HasAndroidInjector import dagger.android.support.DaggerFragment import info.nightscout.androidaps.R -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.databinding.AutomationEventItemBinding import info.nightscout.androidaps.databinding.AutomationFragmentBinding import info.nightscout.androidaps.logging.UserEntryLogger @@ -217,7 +217,7 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener { holder.binding.iconTrash.setOnClickListener { OKDialog.showConfirmation(requireContext(), resourceHelper.gs(R.string.removerecord) + " " + automationPlugin.at(position).title, { - uel.log(UserEntry.Action.AUTOMATION_REMOVED, automationPlugin.at(position).title) + uel.log(Action.AUTOMATION_REMOVED, automationPlugin.at(position).title) automationPlugin.removeAt(position) notifyItemRemoved(position) }, { @@ -240,7 +240,7 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord) + " " + automationPlugin.at(position).title, Runnable { - uel.log(UserEntry.Action.AUTOMATION_REMOVED, automationPlugin.at(position).title) + uel.log(Action.AUTOMATION_REMOVED, automationPlugin.at(position).title) automationPlugin.removeAt(position) notifyItemRemoved(position) rxBus.send(EventAutomationDataChanged()) 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 1624022ca0..f9ce2e17bb 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 @@ -15,7 +15,7 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import dagger.android.support.DaggerFragment import info.nightscout.androidaps.R -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.databinding.FoodFragmentBinding import info.nightscout.androidaps.databinding.FoodItemBinding import info.nightscout.androidaps.events.EventFoodDatabaseChanged @@ -217,7 +217,7 @@ class FoodFragment : DaggerFragment() { val food = v.tag as Food activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.confirmation), resourceHelper.gs(R.string.removerecord) + "\n" + food.name, DialogInterface.OnClickListener { _: DialogInterface?, _: Int -> - uel.log(UserEntry.Action.FOOD_REMOVED, food.name) + uel.log(Action.FOOD_REMOVED, food.name) if (food._id != null && food._id != "") { nsUpload.removeFoodFromNS(food._id) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt index 538f0dc166..c02f85658c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt @@ -15,7 +15,7 @@ import info.nightscout.androidaps.BuildConfig import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.DaggerAppCompatActivityWithResult import info.nightscout.androidaps.activities.PreferencesActivity -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.events.EventAppExit import info.nightscout.androidaps.interfaces.ConfigInterface import info.nightscout.androidaps.interfaces.ImportExportPrefsInterface @@ -345,7 +345,7 @@ class ImportExportPrefs @Inject constructor( private fun restartAppAfterImport(context: Context) { sp.putBoolean(R.string.key_setupwizard_processed, true) OKDialog.show(context, resourceHelper.gs(R.string.setting_imported), resourceHelper.gs(R.string.restartingapp), Runnable { - uel.log(UserEntry.Action.IMPORT_SETTINGS) + uel.log(Action.IMPORT_SETTINGS) log.debug(LTag.CORE, "Exiting") rxBus.send(EventAppExit()) if (context is AppCompatActivity) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenanceFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenanceFragment.kt index b1af7acdcf..2050c57fcd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenanceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenanceFragment.kt @@ -9,7 +9,7 @@ import dagger.android.support.DaggerFragment import info.nightscout.androidaps.MainApp 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.* import info.nightscout.androidaps.databinding.MaintenanceFragmentBinding import info.nightscout.androidaps.events.EventNewBG import info.nightscout.androidaps.interfaces.ImportExportPrefsInterface @@ -57,13 +57,13 @@ class MaintenanceFragment : DaggerFragment() { super.onViewCreated(view, savedInstanceState) binding.logSend.setOnClickListener { maintenancePlugin.sendLogs() } binding.logDelete.setOnClickListener { - uel.log(UserEntry.Action.DELETE_LOGS) + uel.log(Action.DELETE_LOGS) maintenancePlugin.deleteLogs() } binding.navResetdb.setOnClickListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.maintenance), resourceHelper.gs(R.string.reset_db_confirm), Runnable { - uel.log(UserEntry.Action.RESET_DATABASES) + uel.log(Action.RESET_DATABASES) compositeDisposable.add( fromAction { MainApp.getDbHelper().resetDatabases() @@ -84,14 +84,14 @@ class MaintenanceFragment : DaggerFragment() { } } binding.navExport.setOnClickListener { - uel.log(UserEntry.Action.EXPORT_SETTINGS) + uel.log(Action.EXPORT_SETTINGS) // start activity for checking permissions... importExportPrefs.verifyStoragePermissions(this) { importExportPrefs.exportSharedPreferences(this) } } binding.navImport.setOnClickListener { - uel.log(UserEntry.Action.IMPORT_SETTINGS) + uel.log(Action.IMPORT_SETTINGS) // start activity for checking permissions... importExportPrefs.verifyStoragePermissions(this) { importExportPrefs.importSharedPreferences(this) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientFragment.java index 2bf19b771d..c9046f24ba 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientFragment.java @@ -17,6 +17,7 @@ import javax.inject.Inject; import dagger.android.support.DaggerFragment; import info.nightscout.androidaps.R; import info.nightscout.androidaps.database.entities.UserEntry; +import info.nightscout.androidaps.database.entities.UserEntry.*; import info.nightscout.androidaps.logging.UserEntryLogger; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientNewLog; @@ -124,7 +125,7 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList break; case R.id.nsclientinternal_clearqueue: OKDialog.showConfirmation(getContext(), resourceHelper.gs(R.string.nsclientinternal), resourceHelper.gs(R.string.clearqueueconfirm), () -> { - uel.log(UserEntry.Action.NS_QUEUE_CLEARED, "", 0.0, 0.0, 0, 0); + uel.log(Action.NS_QUEUE_CLEARED, new ValueWithUnit(0, Units.None)); uploadQueue.clearQueue(); updateGui(); fabricPrivacy.logCustom("NSClientClearQueue"); @@ -140,7 +141,7 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { switch (buttonView.getId()) { case R.id.nsclientinternal_paused: - uel.log(UserEntry.Action.NS_PAUSED, "", 0.0, 0.0, isChecked ? 1 : 0, 0); + uel.log(Action.NS_PAUSED, new ValueWithUnit(isChecked ? 1 : 0, Units.None)); nsClientPlugin.pause(isChecked); updateGui(); fabricPrivacy.logCustom("NSClientPause"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSSettingsStatus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSSettingsStatus.kt index ca2283e545..70d55c2dcc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSSettingsStatus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/data/NSSettingsStatus.kt @@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.nsclient.data import android.content.Context import info.nightscout.androidaps.Config import info.nightscout.androidaps.R -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.UserEntryLogger @@ -236,7 +236,7 @@ class NSSettingsStatus @Inject constructor( getExtendedWarnValue("sage", "urgent")?.let { sp.putDouble(R.string.key_statuslights_sage_critical, it) } getExtendedWarnValue("bage", "warn")?.let { sp.putDouble(R.string.key_statuslights_bage_warning, it) } getExtendedWarnValue("bage", "urgent")?.let { sp.putDouble(R.string.key_statuslights_bage_critical, it) } - uel.log(UserEntry.Action.NS_SETTINGS_COPIED) + uel.log(Action.NS_SETTINGS_COPIED) } if (context != null) OKDialog.showConfirmation(context, resourceHelper.gs(R.string.statuslights), resourceHelper.gs(R.string.copyexistingvalues), action) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt index d33c3df7ed..41bef96ad5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt @@ -28,7 +28,7 @@ import info.nightscout.androidaps.Config import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.databinding.OverviewFragmentBinding import info.nightscout.androidaps.dialogs.* import info.nightscout.androidaps.events.* @@ -343,7 +343,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.tempbasal_label), lastRun.constraintsProcessed?.toSpanned() ?: "".toSpanned(), { - uel.log(UserEntry.Action.ACCEPTS_TEMP_BASAL) + uel.log(Action.ACCEPTS_TEMP_BASAL) binding.buttonsLayout.acceptTempButton.visibility = View.GONE (context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).cancel(Constants.notificationID) rxBus.send(EventWearDoAction("cancelChangeRequest")) 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 fe4b616bb4..4d81704584 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 @@ -15,7 +15,7 @@ import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.data.DetailedBolusInfo import info.nightscout.androidaps.data.Profile -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.db.Source import info.nightscout.androidaps.db.TempTarget import info.nightscout.androidaps.events.EventPreferenceChange @@ -338,7 +338,7 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - uel.log(UserEntry.Action.SMS_LOOP_DISABLED) + uel.log(Action.SMS_LOOP_DISABLED) loopPlugin.setPluginEnabled(PluginType.LOOP, false) commandQueue.cancelTempBasal(true, object : Callback() { override fun run() { @@ -362,7 +362,7 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - uel.log(UserEntry.Action.SMS_LOOP_ENABLED) + uel.log(Action.SMS_LOOP_ENABLED) loopPlugin.setPluginEnabled(PluginType.LOOP, true) sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_loophasbeenenabled))) rxBus.send(EventRefreshOverview("SMS_LOOP_START")) @@ -389,7 +389,7 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - uel.log(UserEntry.Action.SMS_LOOP_RESUME) + uel.log(Action.SMS_LOOP_RESUME) loopPlugin.suspendTo(0L) rxBus.send(EventRefreshOverview("SMS_LOOP_RESUME")) commandQueue.cancelTempBasal(true, object : Callback() { @@ -422,7 +422,7 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(duration) { override fun run() { - uel.log(UserEntry.Action.SMS_LOOP_SUSPEND) + uel.log(Action.SMS_LOOP_SUSPEND) commandQueue.cancelTempBasal(true, object : Callback() { override fun run() { if (result.success) { @@ -506,7 +506,7 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - uel.log(UserEntry.Action.SMS_PUMP_CONNECT) + uel.log(Action.SMS_PUMP_CONNECT) commandQueue.cancelTempBasal(true, object : Callback() { override fun run() { if (!result.success) { @@ -535,7 +535,7 @@ class SmsCommunicatorPlugin @Inject constructor( receivedSms.processed = true messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() { override fun run() { - uel.log(UserEntry.Action.SMS_PUMP_DISCONNECT) + uel.log(Action.SMS_PUMP_DISCONNECT) val profile = profileFunction.getProfile() loopPlugin.disconnectPump(duration, profile) rxBus.send(EventRefreshOverview("SMS_PUMP_DISCONNECT")) @@ -592,7 +592,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(UserEntry.Action.SMS_PROFILE, replyText) + uel.log(Action.SMS_PROFILE, ValueWithUnit(R.string.profileswitchcreated, Units.R_String)) } }) } @@ -614,12 +614,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(UserEntry.Action.SMS_BASAL, replyText) + uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), 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(UserEntry.Action.SMS_BASAL, replyText) + uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalcancelfailed, Units.R_String)) } } }) @@ -647,12 +647,15 @@ class SmsCommunicatorPlugin @Inject constructor( var replyText = if (result.isPercent) String.format(resourceHelper.gs(R.string.smscommunicator_tempbasalset_percent), result.percent, result.duration) else String.format(resourceHelper.gs(R.string.smscommunicator_tempbasalset), result.absolute, result.duration) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log(UserEntry.Action.SMS_BASAL, replyText) + if (result.isPercent) + uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalset_percent, Units.R_String), 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, Units.R_String), 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(UserEntry.Action.SMS_BASAL, replyText) + uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalfailed, Units.R_String)) } } }) @@ -682,12 +685,15 @@ class SmsCommunicatorPlugin @Inject constructor( else String.format(resourceHelper.gs(R.string.smscommunicator_tempbasalset), result.absolute, result.duration) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log(UserEntry.Action.SMS_BASAL, replyText) + if (result.isPercent) + uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalset_percent, Units.R_String), 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, Units.R_String), 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(UserEntry.Action.SMS_BASAL, replyText) + uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalfailed, Units.R_String)) } } }) @@ -714,7 +720,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(UserEntry.Action.SMS_EXTENDED_BOLUS, replyText) + uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true),ValueWithUnit(R.string.smscommunicator_extendedcanceled, Units.R_String)) } } }) @@ -740,12 +746,15 @@ class SmsCommunicatorPlugin @Inject constructor( if (config.APS) replyText += "\n" + resourceHelper.gs(R.string.loopsuspended) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log(UserEntry.Action.SMS_EXTENDED_BOLUS, replyText) + if (config.APS) + uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_extendedset, Units.R_String), ValueWithUnit(aDouble, 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, Units.R_String), ValueWithUnit(aDouble, 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(UserEntry.Action.SMS_EXTENDED_BOLUS, replyText) + uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true),ValueWithUnit(R.string.smscommunicator_extendedfailed, Units.R_String)) } } }) @@ -814,12 +823,12 @@ class SmsCommunicatorPlugin @Inject constructor( } } sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log(UserEntry.Action.SMS_BOLUS, replyText) + uel.log(Action.SMS_BOLUS, replyText) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_bolusfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log(UserEntry.Action.SMS_BOLUS, replyText) + uel.log(Action.SMS_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_bolusfailed, Units.R_String)) } } }) @@ -859,12 +868,12 @@ class SmsCommunicatorPlugin @Inject constructor( var replyText = String.format(resourceHelper.gs(R.string.smscommunicator_carbsset), anInteger) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log(UserEntry.Action.SMS_CARBS, replyText) + uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_carbsset, Units.R_String), ValueWithUnit(anInteger,Units.G)) } else { - var replyText = resourceHelper.gs(R.string.smscommunicator_carbsfailed) + var replyText = resourceHelper.gs(R.string.smscommunicator_carbsfailed, anInteger) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMS(Sms(receivedSms.phoneNumber, replyText)) - uel.log(UserEntry.Action.SMS_CARBS, replyText) + uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_carbsfailed, Units.R_String), ValueWithUnit(anInteger,Units.G)) } } }) @@ -873,7 +882,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(UserEntry.Action.SMS_CARBS, replyText) + uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_carbsset, Units.R_String), ValueWithUnit(anInteger,Units.G)) } } }) @@ -938,7 +947,7 @@ class SmsCommunicatorPlugin @Inject constructor( val ttString = if (units == Constants.MMOL) DecimalFormatter.to1Decimal(tt) else DecimalFormatter.to0Decimal(tt) val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_tt_set), ttString, ttDuration) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log(UserEntry.Action.SMS_TT, replyText) + uel.log(Action.SMS_TT, ValueWithUnit(R.string.smscommunicator_tt_set, Units.R_String), ValueWithUnit(tt, units), ValueWithUnit(ttDuration, Units.M)) } }) } else if (isStop) { @@ -956,7 +965,7 @@ class SmsCommunicatorPlugin @Inject constructor( activePlugin.activeTreatments.addToHistoryTempTarget(tempTarget) val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_tt_canceled)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log(UserEntry.Action.SMS_TT, reply) + uel.log(Action.SMS_TT, ValueWithUnit(R.string.smscommunicator_tt_canceled, Units.R_String)) } }) } else @@ -975,7 +984,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(UserEntry.Action.SMS_SMS, replyText) + uel.log(Action.SMS_SMS, ValueWithUnit(R.string.smscommunicator_stoppedsms, Units.R_String)) } }) } else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat))) @@ -993,7 +1002,10 @@ class SmsCommunicatorPlugin @Inject constructor( val replyText = if (result) resourceHelper.gs(R.string.smscommunicator_calibrationsent) else resourceHelper.gs(R.string.smscommunicator_calibrationfailed) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log(UserEntry.Action.SMS_CAL, replyText) + if (result) + uel.log(Action.SMS_CAL, ValueWithUnit(R.string.smscommunicator_calibrationsent, Units.R_String)) + else + uel.log(Action.SMS_CAL, ValueWithUnit(R.string.smscommunicator_calibrationfailed, Units.R_String)) } }) } else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat))) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt index e5ef8e1416..848dc05faf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt @@ -14,7 +14,7 @@ import com.google.common.primitives.Ints.min import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.NoSplashAppCompatActivity -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.databinding.ActivitySmscommunicatorOtpBinding import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper @@ -73,7 +73,7 @@ class SmsCommunicatorOtpActivity : NoSplashAppCompatActivity() { resourceHelper.gs(R.string.smscommunicator_otp_reset_title), resourceHelper.gs(R.string.smscommunicator_otp_reset_prompt), Runnable { - uel.log(UserEntry.Action.OTP_RESET) + uel.log(Action.OTP_RESET) otp.ensureKey(true) updateGui() ToastUtils.Long.infoToast(this, resourceHelper.gs(R.string.smscommunicator_otp_reset_successful)) @@ -89,7 +89,7 @@ class SmsCommunicatorOtpActivity : NoSplashAppCompatActivity() { val clip = ClipData.newPlainText("OTP Secret", otp.provisioningSecret()) clipboard.primaryClip = clip ToastUtils.Long.infoToast(this, resourceHelper.gs(R.string.smscommunicator_otp_export_successful)) - uel.log(UserEntry.Action.OTP_EXPORT) + uel.log(Action.OTP_EXPORT) }) true diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt index cc7087ff43..9871225e75 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt @@ -12,7 +12,7 @@ import dagger.android.support.DaggerFragment import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.databinding.LocalprofileFragmentBinding import info.nightscout.androidaps.dialogs.ProfileSwitchDialog import info.nightscout.androidaps.interfaces.ActivePluginProvider @@ -163,7 +163,7 @@ class LocalProfileFragment : DaggerFragment() { if (localProfilePlugin.isEdited) { activity?.let { OKDialog.show(it, "", resourceHelper.gs(R.string.saveorresetchangesfirst)) } } else { - uel.log(UserEntry.Action.NEW_PROFILE) + uel.log(Action.NEW_PROFILE) localProfilePlugin.addNewProfile() build() } @@ -173,7 +173,7 @@ class LocalProfileFragment : DaggerFragment() { if (localProfilePlugin.isEdited) { activity?.let { OKDialog.show(it, "", resourceHelper.gs(R.string.saveorresetchangesfirst)) } } else { - uel.log(UserEntry.Action.CLONE_PROFILE, localProfilePlugin.currentProfile()?.name ?: "") + uel.log(Action.CLONE_PROFILE, localProfilePlugin.currentProfile()?.name ?: "") localProfilePlugin.cloneProfile() build() } @@ -182,7 +182,7 @@ class LocalProfileFragment : DaggerFragment() { binding.profileRemove.setOnClickListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.deletecurrentprofile), { - uel.log(UserEntry.Action.PROFILE_REMOVED, localProfilePlugin.currentProfile()?.name ?: "") + uel.log(Action.PROFILE_REMOVED, localProfilePlugin.currentProfile()?.name ?: "") localProfilePlugin.removeCurrentProfile() build() }, null) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt index 5bbeda0a9f..8da1e6b188 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt @@ -5,7 +5,7 @@ import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Profile -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.events.EventProfileStoreChanged import info.nightscout.androidaps.interfaces.* import info.nightscout.androidaps.logging.AAPSLogger @@ -116,7 +116,7 @@ class LocalProfilePlugin @Inject constructor( createAndStoreConvertedProfile() isEdited = false aapsLogger.debug(LTag.PROFILE, "Storing settings: " + rawProfile?.data.toString()) - uel.log(UserEntry.Action.STORE_PROFILE) + uel.log(Action.STORE_PROFILE) rxBus.send(EventProfileStoreChanged()) var namesOK = true profiles.forEach { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfileFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfileFragment.kt index 48ca291497..050d6346e3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfileFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfileFragment.kt @@ -8,7 +8,7 @@ import android.widget.AdapterView import android.widget.ArrayAdapter import dagger.android.support.DaggerFragment import info.nightscout.androidaps.R -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.databinding.NsprofileFragmentBinding import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.logging.UserEntryLogger @@ -62,7 +62,7 @@ class NSProfileFragment : DaggerFragment() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.nsprofile), resourceHelper.gs(R.string.activate_profile) + ": " + name + " ?", Runnable { - uel.log(UserEntry.Action.PROFILE_SWITCH, name, i1 = 100) + uel.log(Action.PROFILE_SWITCH, name, ValueWithUnit(100.toInt(), Units.Percent)) treatmentsPlugin.doProfileSwitch(store, name, 0, 100, 0, DateUtil.now()) }) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt index 81e96e5df6..6a9b803f8f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt @@ -11,7 +11,7 @@ import dagger.android.support.DaggerFragment import info.nightscout.androidaps.R import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.entities.GlucoseValue -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.database.transactions.InvalidateGlucoseValueTransaction import info.nightscout.androidaps.databinding.BgsourceFragmentBinding import info.nightscout.androidaps.databinding.BgsourceItemBinding @@ -129,7 +129,7 @@ class BGSourceFragment : DaggerFragment() { activity?.let { activity -> val text = dateUtil.dateAndTimeString(glucoseValue.timestamp) + "\n" + glucoseValue.valueToUnitsString(profileFunction.getUnits()) OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable { - uel.log(UserEntry.Action.BG_REMOVED, dateUtil.dateAndTimeString(glucoseValue.timestamp)) + uel.log(Action.BG_REMOVED, ValueWithUnit(glucoseValue.timestamp, Units.Timestamp)) disposable += repository.runTransaction(InvalidateGlucoseValueTransaction(glucoseValue.id)).subscribe() }) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt index 362a1783dd..e2d5941059 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt @@ -9,7 +9,7 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import dagger.android.support.DaggerFragment import info.nightscout.androidaps.R -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.databinding.TreatmentsBolusFragmentBinding import info.nightscout.androidaps.databinding.TreatmentsBolusItemBinding import info.nightscout.androidaps.db.Source @@ -69,7 +69,7 @@ class TreatmentsBolusFragment : DaggerFragment() { binding.refreshFromNightscout.setOnClickListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.refresheventsfromnightscout) + "?") { - uel.log(UserEntry.Action.TREATMENTS_NS_REFRESH) + uel.log(Action.TREATMENTS_NS_REFRESH) treatmentsPlugin.service.resetTreatments() rxBus.send(EventNSClientRestart()) } @@ -78,7 +78,7 @@ class TreatmentsBolusFragment : DaggerFragment() { binding.deleteFutureTreatments.setOnClickListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_treatment_label), resourceHelper.gs(R.string.deletefuturetreatments) + "?", Runnable { - uel.log(UserEntry.Action.DELETE_FUTURE_TREATMENTS) + uel.log(Action.DELETE_FUTURE_TREATMENTS) val futureTreatments = treatmentsPlugin.service.getTreatmentDataFromTime(DateUtil.now() + 1000, true) for (treatment in futureTreatments) { if (NSUpload.isIdValid(treatment._id)) @@ -175,7 +175,7 @@ class TreatmentsBolusFragment : DaggerFragment() { resourceHelper.gs(R.string.carbs) + ": " + resourceHelper.gs(R.string.format_carbs, treatment.carbs.toInt()) + "\n" + resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(treatment.date) OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable { - uel.log(UserEntry.Action.TREATMENT_REMOVED, text) + uel.log(Action.TREATMENT_REMOVED, ValueWithUnit(treatment.date, Units.Timestamp), ValueWithUnit(treatment.insulin, Units.U), ValueWithUnit(treatment.carbs.toInt(), Units.G)) if (treatment.source == Source.PUMP) { treatment.isValid = false treatmentsPlugin.service.update(treatment) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsCareportalFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsCareportalFragment.kt index 8e1d69a099..6b87a963d8 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 @@ -10,7 +10,7 @@ import androidx.recyclerview.widget.RecyclerView import dagger.android.support.DaggerFragment import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.databinding.TreatmentsCareportalFragmentBinding import info.nightscout.androidaps.databinding.TreatmentsCareportalItemBinding import info.nightscout.androidaps.db.CareportalEvent @@ -65,7 +65,7 @@ class TreatmentsCareportalFragment : DaggerFragment() { binding.refreshFromNightscout.setOnClickListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal), resourceHelper.gs(R.string.refresheventsfromnightscout) + " ?", Runnable { - uel.log(UserEntry.Action.CAREPORTAL_NS_REFRESH) + uel.log(Action.CAREPORTAL_NS_REFRESH) MainApp.getDbHelper().resetCareportalEvents() rxBus.send(EventNSClientRestart()) }) @@ -74,7 +74,7 @@ class TreatmentsCareportalFragment : DaggerFragment() { binding.removeAndroidapsStartedEvents.setOnClickListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal), resourceHelper.gs(R.string.careportal_removestartedevents), Runnable { - uel.log(UserEntry.Action.RESTART_EVENTS_REMOVED) + uel.log(Action.RESTART_EVENTS_REMOVED) val events = MainApp.getDbHelper().getCareportalEvents(false) for (i in events.indices) { val careportalEvent = events[i] @@ -155,7 +155,7 @@ class TreatmentsCareportalFragment : DaggerFragment() { resourceHelper.gs(R.string.careportal_newnstreatment_notes_label) + ": " + careportalEvent.notes + "\n" + resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(careportalEvent.date) OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable { - uel.log(UserEntry.Action.CAREPORTAL_REMOVED, text) + uel.log(Action.CAREPORTAL_REMOVED, careportalEvent.notes, ValueWithUnit(careportalEvent.eventType, Units.CPEvent), ValueWithUnit(careportalEvent.date, Units.Timestamp)) if (NSUpload.isIdValid(careportalEvent._id)) nsUpload.removeCareportalEntryFromNS(careportalEvent._id) else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt index 3e5f1b5bef..34447354d3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt @@ -13,7 +13,7 @@ import dagger.android.support.DaggerFragment import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Intervals -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.databinding.TreatmentsExtendedbolusFragmentBinding import info.nightscout.androidaps.databinding.TreatmentsExtendedbolusItemBinding import info.nightscout.androidaps.db.ExtendedBolus @@ -122,7 +122,7 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() { ${resourceHelper.gs(R.string.extended_bolus)} ${resourceHelper.gs(R.string.date)}: ${dateUtil.dateAndTimeString(extendedBolus.date)} """.trimIndent(), { _: DialogInterface, _: Int -> - uel.log(UserEntry.Action.EXTENDED_BOLUS_REMOVED) + uel.log(Action.EXTENDED_BOLUS_REMOVED) val id = extendedBolus._id if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id) else uploadQueue.removeID("dbAdd", id) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt index 7af0e5debc..9a204467d6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt @@ -10,7 +10,7 @@ import androidx.recyclerview.widget.RecyclerView import dagger.android.support.DaggerFragment import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.databinding.TreatmentsProfileswitchFragmentBinding import info.nightscout.androidaps.databinding.TreatmentsProfileswitchItemBinding import info.nightscout.androidaps.db.ProfileSwitch @@ -70,7 +70,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() { binding.refreshFromNightscout.setOnClickListener { activity?.let { activity -> - uel.log(UserEntry.Action.PROFILE_SWITCH_NS_REFRESH) + uel.log(Action.PROFILE_SWITCH_NS_REFRESH) OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.refresheventsfromnightscout) + "?") { MainApp.getDbHelper().resetProfileSwitch() rxBus.send(EventNSClientRestart()) @@ -147,7 +147,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), resourceHelper.gs(R.string.careportal_profileswitch) + ": " + profileSwitch.profileName + "\n" + resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(profileSwitch.date), Runnable { - uel.log(UserEntry.Action.PROFILE_SWITCH_REMOVED, profileSwitch.profileName + " " + dateUtil.dateAndTimeString(profileSwitch.date)) + uel.log(Action.PROFILE_SWITCH_REMOVED, profileSwitch.profileName, ValueWithUnit(profileSwitch.date, Units.Timestamp)) val id = profileSwitch._id if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id) else uploadQueue.removeID("dbAdd", id) @@ -160,7 +160,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() { val profileSwitch = it.tag as ProfileSwitch OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), resourceHelper.gs(R.string.copytolocalprofile) + "\n" + profileSwitch.customizedName + "\n" + dateUtil.dateAndTimeString(profileSwitch.date), Runnable { profileSwitch.profileObject?.let { - uel.log(UserEntry.Action.PROFILE_SWITCH_CLONED, profileSwitch.profileName + " " + dateUtil.dateAndTimeString(profileSwitch.date)) + uel.log(Action.PROFILE_SWITCH_CLONED, profileSwitch.profileName, ValueWithUnit(profileSwitch.date, Units.Timestamp)) val nonCustomized = it.convertToNonCustomizedProfile() if (nonCustomized.isValid(resourceHelper.gs(R.string.careportal_profileswitch, false))) { localProfilePlugin.addProfile(localProfilePlugin.copyFrom(nonCustomized, profileSwitch.customizedName + " " + dateUtil.dateAndTimeString(profileSwitch.date).replace(".", "_"))) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt index f72e042988..56e752b1ab 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt @@ -13,7 +13,7 @@ import dagger.android.support.DaggerFragment import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Intervals -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.databinding.TreatmentsTemptargetFragmentBinding import info.nightscout.androidaps.databinding.TreatmentsTemptargetItemBinding import info.nightscout.androidaps.db.Source @@ -70,7 +70,7 @@ class TreatmentsTempTargetFragment : DaggerFragment() { binding.refreshFromNightscout.setOnClickListener { context?.let { context -> OKDialog.showConfirmation(context, resourceHelper.gs(R.string.refresheventsfromnightscout) + " ?", { - uel.log(UserEntry.Action.TT_NS_REFRESH) + uel.log(Action.TT_NS_REFRESH) MainApp.getDbHelper().resetTempTargets() rxBus.send(EventNSClientRestart()) }) @@ -162,7 +162,7 @@ class TreatmentsTempTargetFragment : DaggerFragment() { ${dateUtil.dateAndTimeString(tempTarget.date)} """.trimIndent(), { _: DialogInterface?, _: Int -> - uel.log(UserEntry.Action.TT_REMOVED, tempTarget.friendlyDescription(profileFunction.getUnits(), resourceHelper)) + uel.log(Action.TT_REMOVED, ValueWithUnit(tempTarget.reason, Units.TT_Reason), ValueWithUnit(tempTarget.date, Units.Timestamp), ValueWithUnit(tempTarget.low, Units.Mg_Dl), ValueWithUnit(tempTarget.high, Units.Mg_Dl), ValueWithUnit(tempTarget.durationInMinutes, Units.M)) val id = tempTarget._id if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id) else uploadQueue.removeID("dbAdd", id) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt index 8fb6e08998..446cd3605f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt @@ -12,7 +12,7 @@ import dagger.android.support.DaggerFragment import info.nightscout.androidaps.R import info.nightscout.androidaps.data.Intervals import info.nightscout.androidaps.data.IobTotal -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.databinding.TreatmentsTempbasalsFragmentBinding import info.nightscout.androidaps.databinding.TreatmentsTempbasalsItemBinding import info.nightscout.androidaps.db.Source @@ -164,7 +164,7 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() { ${resourceHelper.gs(R.string.date)}: ${dateUtil.dateAndTimeString(tempBasal.date)} """.trimIndent(), { _: DialogInterface?, _: Int -> - uel.log(UserEntry.Action.TT_REMOVED, dateUtil.dateAndTimeString(tempBasal.date)) + uel.log(Action.TT_REMOVED, ValueWithUnit(tempBasal.date, Units.Timestamp)) activePlugin.activeTreatments.removeTempBasal(tempBasal) }, null) } 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 86aa5e45ab..419e63f745 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 @@ -68,10 +68,13 @@ class TreatmentsUserEntryFragment : DaggerFragment() { holder.binding.date.text = dateUtil.dateAndTimeAndSecondsString(current.timestamp) holder.binding.action.text = resourceHelper.gs(current.action.stringId()) if (current.s != "") holder.binding.s.text = current.s else holder.binding.s.visibility = View.GONE + /* if (current.d1 != 0.0) holder.binding.d1.text = current.d1.toString() else holder.binding.d1.visibility = View.GONE if (current.d2 != 0.0) holder.binding.d2.text = current.d2.toString() else holder.binding.d2.visibility = View.GONE if (current.i1 != 0) holder.binding.i1.text = current.i1.toString() else holder.binding.i1.visibility = View.GONE if (current.i2 != 0) holder.binding.i2.text = current.i2.toString() else holder.binding.i2.visibility = View.GONE + + */ } inner class UserEntryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { diff --git a/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt b/app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt index ce3e3b6f1d..1b283c5793 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 @@ -10,7 +10,7 @@ import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.data.DetailedBolusInfo import info.nightscout.androidaps.data.Profile -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.db.CareportalEvent import info.nightscout.androidaps.db.Source import info.nightscout.androidaps.db.TempTarget @@ -347,7 +347,7 @@ class BolusWizard @Inject constructor( boluscalc = nsJSON() source = Source.USER notes = this@BolusWizard.notes - uel.log(UserEntry.Action.BOLUS_ADVISOR, d1 = insulinAfterConstraints) + uel.log(Action.BOLUS_ADVISOR, ValueWithUnit(insulinAfterConstraints, Units.U)) if (insulin > 0) { commandQueue.bolus(this, object : Callback() { override fun run() { @@ -370,7 +370,7 @@ class BolusWizard @Inject constructor( OKDialog.showConfirmation(ctx, resourceHelper.gs(R.string.boluswizard), confirmMessage, { if (insulinAfterConstraints > 0 || carbs > 0) { if (useSuperBolus) { - uel.log(UserEntry.Action.SUPERBOLUS_TBR) + uel.log(Action.SUPERBOLUS_TBR) if (loopPlugin.isEnabled(PluginType.LOOP)) { loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000) rxBus.send(EventRefreshOverview("WizardDialog")) @@ -411,7 +411,7 @@ class BolusWizard @Inject constructor( boluscalc = nsJSON() source = Source.USER notes = this@BolusWizard.notes - uel.log(UserEntry.Action.BOLUS_WIZARD, "", insulinAfterConstraints, carbs) + uel.log(Action.BOLUS_WIZARD, notes, ValueWithUnit(insulinAfterConstraints, Units.U), ValueWithUnit(this@BolusWizard.carbs, Units.G), ValueWithUnit(carbTime, Units.M)) if (insulin > 0 || pump.pumpDescription.storesCarbInfo) { commandQueue.bolus(this, object : Callback() { override fun run() { diff --git a/core/src/main/java/info/nightscout/androidaps/Constants.java b/core/src/main/java/info/nightscout/androidaps/Constants.java index b0daa4fe78..81c201aed2 100644 --- a/core/src/main/java/info/nightscout/androidaps/Constants.java +++ b/core/src/main/java/info/nightscout/androidaps/Constants.java @@ -1,13 +1,14 @@ package info.nightscout.androidaps; import info.nightscout.androidaps.utils.T; +import info.nightscout.androidaps.database.entities.UserEntry.*; /** * Created by mike on 07.06.2016. */ public class Constants { - public static final String MGDL = "mg/dl"; // This is Nightscout's representation - public static final String MMOL = "mmol"; + public static final String MGDL = Units.Mg_Dl.name(); // This is Nightscout's representation + public static final String MMOL = Units.Mmol_L.name(); public static final double MMOLL_TO_MGDL = 18; // 18.0182; public static final double MGDL_TO_MMOLL = 1 / MMOLL_TO_MGDL; diff --git a/core/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt b/core/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt index 91ce1f5a19..9e5a88f08a 100644 --- a/core/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt +++ b/core/src/main/java/info/nightscout/androidaps/dialogs/ErrorDialog.kt @@ -11,7 +11,7 @@ import dagger.android.support.DaggerDialogFragment import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.core.R import info.nightscout.androidaps.core.databinding.DialogErrorBinding -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.services.AlarmSoundServiceHelper @@ -59,15 +59,15 @@ class ErrorDialog : DaggerDialogFragment() { binding.title.text = title binding.ok.setOnClickListener { - uel.log(UserEntry.Action.ERROR_DIALOG_OK) + uel.log(Action.ERROR_DIALOG_OK) dismiss() } binding.mute.setOnClickListener { - uel.log(UserEntry.Action.ERROR_DIALOG_MUTE) + uel.log(Action.ERROR_DIALOG_MUTE) stopAlarm() } binding.mute5min.setOnClickListener { - uel.log(UserEntry.Action.ERROR_DIALOG_MUTE_5MIN) + uel.log(Action.ERROR_DIALOG_MUTE_5MIN) stopAlarm() loopHandler.postDelayed(this::startAlarm, T.mins(5).msecs()) } diff --git a/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt b/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt index beefb07d00..1cc1895c48 100644 --- a/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt +++ b/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt @@ -23,12 +23,7 @@ class UserEntryLogger @Inject constructor( fun log(action: Action, s: String, vararg listvalues: ValueWithUnit) { val values = mutableListOf() for (v in listvalues){ - var vConverted = v - // Convertion to always store all values in the same units in database - when(v.unit) { - Units.Mmol_L -> { vConverted = ValueWithUnit(v.dValue * Constants.MMOLL_TO_MGDL, Units.Mg_Dl)} - } - values.add(vConverted) + values.add(v) } compositeDisposable += repository.runTransaction(UserEntryTransaction( action = action, @@ -38,20 +33,15 @@ class UserEntryLogger @Inject constructor( .subscribeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io) .subscribeBy( - //onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $s ${if (d1.dValue != 0.0) d1 else ""} ${if (d2.dValue != 0.0) d2 else ""} ${if (i1.iValue != 0) i1 else ""} ${if (i2.iValue != 0) i2 else ""}") }, - //onComplete = { aapsLogger.debug("USER ENTRY: $action $s ${if (d1.dValue != 0.0) d1 else ""} ${if (d2.dValue != 0.0) d2 else ""} ${if (i1.iValue != 0) i1 else ""} ${if (i2.iValue != 0) i2 else ""}") } + onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $s $values") }, + onComplete = { aapsLogger.debug("USER ENTRY: $action $s $values") } ) } fun log(action: Action, vararg listvalues: ValueWithUnit) { val values = mutableListOf() for (v in listvalues){ - var vConverted = v - // Convertion to always store all values in the same units in database - when(v.unit) { - Units.Mmol_L -> { vConverted = ValueWithUnit(v.dValue * Constants.MMOLL_TO_MGDL, Units.Mg_Dl)} - } - values.add(vConverted) + values.add(v) } compositeDisposable += repository.runTransaction(UserEntryTransaction( action = action, @@ -61,15 +51,15 @@ class UserEntryLogger @Inject constructor( .subscribeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io) .subscribeBy( - //onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $s ${if (d1.dValue != 0.0) d1 else ""} ${if (d2.dValue != 0.0) d2 else ""} ${if (i1.iValue != 0) i1 else ""} ${if (i2.iValue != 0) i2 else ""}") }, - //onComplete = { aapsLogger.debug("USER ENTRY: $action $s ${if (d1.dValue != 0.0) d1 else ""} ${if (d2.dValue != 0.0) d2 else ""} ${if (i1.iValue != 0) i1 else ""} ${if (i2.iValue != 0) i2 else ""}") } + onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $values") }, + onComplete = { aapsLogger.debug("USER ENTRY: $action $values") } ) } - fun log(action: Action) { + fun log(action: Action, s: String = "") { compositeDisposable += repository.runTransaction(UserEntryTransaction( action = action, - s = "" + s = s )) .subscribeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io) diff --git a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UnitsStrings.kt b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UnitsStrings.kt index 7d7d306044..08e0afa1bc 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UnitsStrings.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UnitsStrings.kt @@ -14,7 +14,7 @@ fun UserEntry.Units.stringId(): Int { this == UserEntry.Units.G -> R.string.shortgram this == UserEntry.Units.M -> R.string.shortminute this == UserEntry.Units.H -> R.string.shorthour - this == UserEntry.Units.Percent -> R.string.percent + this == UserEntry.Units.Percent -> R.string.shortpercent else -> 0 } } diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 04b3dc9e6e..d6ef6df036 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -93,7 +93,7 @@ mg/dl mmol/l g - %% + %% Advanced Settings Bluetooth BT Watchdog diff --git a/dana/src/main/java/info/nightscout/androidaps/dana/DanaFragment.kt b/dana/src/main/java/info/nightscout/androidaps/dana/DanaFragment.kt index fc5ca3db9f..b0100f93c3 100644 --- a/dana/src/main/java/info/nightscout/androidaps/dana/DanaFragment.kt +++ b/dana/src/main/java/info/nightscout/androidaps/dana/DanaFragment.kt @@ -10,7 +10,7 @@ import android.view.ViewGroup import dagger.android.support.DaggerFragment import info.nightscout.androidaps.activities.TDDStatsActivity import info.nightscout.androidaps.dana.databinding.DanarFragmentBinding -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.dialogs.ProfileViewerDialog import info.nightscout.androidaps.events.EventExtendedBolusChange import info.nightscout.androidaps.events.EventInitializationChanged @@ -109,7 +109,7 @@ class DanaFragment : DaggerFragment() { binding.btconnection.setOnLongClickListener { activity?.let { OKDialog.showConfirmation(it, resourceHelper.gs(R.string.resetpairing)) { - uel.log(UserEntry.Action.CLEAR_PAIRING_KEYS) + uel.log(Action.CLEAR_PAIRING_KEYS) (activePlugin.activePump as DanaPumpInterface).clearPairing() } } diff --git a/database/schemas/info.nightscout.androidaps.database.AppDatabase/4.json b/database/schemas/info.nightscout.androidaps.database.AppDatabase/4.json new file mode 100644 index 0000000000..cdfcf79810 --- /dev/null +++ b/database/schemas/info.nightscout.androidaps.database.AppDatabase/4.json @@ -0,0 +1,2739 @@ +{ + "formatVersion": 1, + "database": { + "version": 4, + "identityHash": "9e6e8a398493c289fd1db6f1aa5155db", + "entities": [ + { + "tableName": "apsResults", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `version` INTEGER NOT NULL, `dateCreated` INTEGER NOT NULL, `isValid` INTEGER NOT NULL, `referenceId` INTEGER, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `algorithm` TEXT NOT NULL, `glucoseStatusJson` TEXT NOT NULL, `currentTempJson` TEXT NOT NULL, `iobDataJson` TEXT NOT NULL, `profileJson` TEXT NOT NULL, `autosensDataJson` TEXT, `mealDataJson` TEXT NOT NULL, `isMicroBolusAllowed` INTEGER, `resultJson` TEXT NOT NULL, `nightscoutSystemId` TEXT, `nightscoutId` TEXT, `pumpType` TEXT, `pumpSerial` TEXT, `pumpId` INTEGER, `startId` INTEGER, `endId` INTEGER, FOREIGN KEY(`referenceId`) REFERENCES `apsResults`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "version", + "columnName": "version", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "dateCreated", + "columnName": "dateCreated", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isValid", + "columnName": "isValid", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "referenceId", + "columnName": "referenceId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "timestamp", + "columnName": "timestamp", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "utcOffset", + "columnName": "utcOffset", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "algorithm", + "columnName": "algorithm", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "glucoseStatusJson", + "columnName": "glucoseStatusJson", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "currentTempJson", + "columnName": "currentTempJson", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "iobDataJson", + "columnName": "iobDataJson", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "profileJson", + "columnName": "profileJson", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "autosensDataJson", + "columnName": "autosensDataJson", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "mealDataJson", + "columnName": "mealDataJson", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "isMicroBolusAllowed", + "columnName": "isMicroBolusAllowed", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "resultJson", + "columnName": "resultJson", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutSystemId", + "columnName": "nightscoutSystemId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutId", + "columnName": "nightscoutId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpType", + "columnName": "pumpType", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpSerial", + "columnName": "pumpSerial", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpId", + "columnName": "pumpId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.startId", + "columnName": "startId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.endId", + "columnName": "endId", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_apsResults_referenceId", + "unique": false, + "columnNames": [ + "referenceId" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_apsResults_referenceId` ON `${TABLE_NAME}` (`referenceId`)" + }, + { + "name": "index_apsResults_timestamp", + "unique": false, + "columnNames": [ + "timestamp" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_apsResults_timestamp` ON `${TABLE_NAME}` (`timestamp`)" + } + ], + "foreignKeys": [ + { + "table": "apsResults", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "referenceId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "boluses", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `version` INTEGER NOT NULL, `dateCreated` INTEGER NOT NULL, `isValid` INTEGER NOT NULL, `referenceId` INTEGER, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `amount` REAL NOT NULL, `type` TEXT NOT NULL, `isBasalInsulin` INTEGER NOT NULL, `nightscoutSystemId` TEXT, `nightscoutId` TEXT, `pumpType` TEXT, `pumpSerial` TEXT, `pumpId` INTEGER, `startId` INTEGER, `endId` INTEGER, `insulinLabel` TEXT, `insulinEndTime` INTEGER, `peak` INTEGER, FOREIGN KEY(`referenceId`) REFERENCES `boluses`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "version", + "columnName": "version", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "dateCreated", + "columnName": "dateCreated", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isValid", + "columnName": "isValid", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "referenceId", + "columnName": "referenceId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "timestamp", + "columnName": "timestamp", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "utcOffset", + "columnName": "utcOffset", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "amount", + "columnName": "amount", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "isBasalInsulin", + "columnName": "isBasalInsulin", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutSystemId", + "columnName": "nightscoutSystemId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutId", + "columnName": "nightscoutId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpType", + "columnName": "pumpType", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpSerial", + "columnName": "pumpSerial", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpId", + "columnName": "pumpId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.startId", + "columnName": "startId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.endId", + "columnName": "endId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "insulinConfiguration.insulinLabel", + "columnName": "insulinLabel", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "insulinConfiguration.insulinEndTime", + "columnName": "insulinEndTime", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "insulinConfiguration.peak", + "columnName": "peak", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_boluses_referenceId", + "unique": false, + "columnNames": [ + "referenceId" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_boluses_referenceId` ON `${TABLE_NAME}` (`referenceId`)" + }, + { + "name": "index_boluses_timestamp", + "unique": false, + "columnNames": [ + "timestamp" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_boluses_timestamp` ON `${TABLE_NAME}` (`timestamp`)" + } + ], + "foreignKeys": [ + { + "table": "boluses", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "referenceId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "bolusCalculatorResults", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `version` INTEGER NOT NULL, `dateCreated` INTEGER NOT NULL, `isValid` INTEGER NOT NULL, `referenceId` INTEGER, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `targetBGLow` REAL NOT NULL, `targetBGHigh` REAL NOT NULL, `isf` REAL NOT NULL, `ic` REAL NOT NULL, `bolusIOB` REAL NOT NULL, `wasBolusIOBUsed` INTEGER NOT NULL, `basalIOB` REAL NOT NULL, `wasBasalIOBUsed` INTEGER NOT NULL, `glucoseValue` REAL NOT NULL, `wasGlucoseUsed` INTEGER NOT NULL, `glucoseDifference` REAL NOT NULL, `glucoseInsulin` REAL NOT NULL, `glucoseTrend` REAL NOT NULL, `wasTrendUsed` INTEGER NOT NULL, `trendInsulin` REAL NOT NULL, `cob` REAL NOT NULL, `wasCOBUsed` INTEGER NOT NULL, `cobInsulin` REAL NOT NULL, `carbs` REAL NOT NULL, `wereCarbsUsed` INTEGER NOT NULL, `carbsInsulin` REAL NOT NULL, `otherCorrection` REAL NOT NULL, `wasSuperbolusUsed` INTEGER NOT NULL, `superbolusInsulin` REAL NOT NULL, `wasTempTargetUsed` INTEGER NOT NULL, `totalInsulin` REAL NOT NULL, `nightscoutSystemId` TEXT, `nightscoutId` TEXT, `pumpType` TEXT, `pumpSerial` TEXT, `pumpId` INTEGER, `startId` INTEGER, `endId` INTEGER, FOREIGN KEY(`referenceId`) REFERENCES `bolusCalculatorResults`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "version", + "columnName": "version", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "dateCreated", + "columnName": "dateCreated", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isValid", + "columnName": "isValid", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "referenceId", + "columnName": "referenceId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "timestamp", + "columnName": "timestamp", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "utcOffset", + "columnName": "utcOffset", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "targetBGLow", + "columnName": "targetBGLow", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "targetBGHigh", + "columnName": "targetBGHigh", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "isf", + "columnName": "isf", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "ic", + "columnName": "ic", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "bolusIOB", + "columnName": "bolusIOB", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "wasBolusIOBUsed", + "columnName": "wasBolusIOBUsed", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "basalIOB", + "columnName": "basalIOB", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "wasBasalIOBUsed", + "columnName": "wasBasalIOBUsed", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "glucoseValue", + "columnName": "glucoseValue", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "wasGlucoseUsed", + "columnName": "wasGlucoseUsed", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "glucoseDifference", + "columnName": "glucoseDifference", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "glucoseInsulin", + "columnName": "glucoseInsulin", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "glucoseTrend", + "columnName": "glucoseTrend", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "wasTrendUsed", + "columnName": "wasTrendUsed", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "trendInsulin", + "columnName": "trendInsulin", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "cob", + "columnName": "cob", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "wasCOBUsed", + "columnName": "wasCOBUsed", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "cobInsulin", + "columnName": "cobInsulin", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "carbs", + "columnName": "carbs", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "wereCarbsUsed", + "columnName": "wereCarbsUsed", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "carbsInsulin", + "columnName": "carbsInsulin", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "otherCorrection", + "columnName": "otherCorrection", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "wasSuperbolusUsed", + "columnName": "wasSuperbolusUsed", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "superbolusInsulin", + "columnName": "superbolusInsulin", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "wasTempTargetUsed", + "columnName": "wasTempTargetUsed", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "totalInsulin", + "columnName": "totalInsulin", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutSystemId", + "columnName": "nightscoutSystemId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutId", + "columnName": "nightscoutId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpType", + "columnName": "pumpType", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpSerial", + "columnName": "pumpSerial", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpId", + "columnName": "pumpId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.startId", + "columnName": "startId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.endId", + "columnName": "endId", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_bolusCalculatorResults_referenceId", + "unique": false, + "columnNames": [ + "referenceId" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_bolusCalculatorResults_referenceId` ON `${TABLE_NAME}` (`referenceId`)" + }, + { + "name": "index_bolusCalculatorResults_timestamp", + "unique": false, + "columnNames": [ + "timestamp" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_bolusCalculatorResults_timestamp` ON `${TABLE_NAME}` (`timestamp`)" + } + ], + "foreignKeys": [ + { + "table": "bolusCalculatorResults", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "referenceId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "carbs", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `version` INTEGER NOT NULL, `dateCreated` INTEGER NOT NULL, `isValid` INTEGER NOT NULL, `referenceId` INTEGER, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `duration` INTEGER NOT NULL, `amount` REAL NOT NULL, `nightscoutSystemId` TEXT, `nightscoutId` TEXT, `pumpType` TEXT, `pumpSerial` TEXT, `pumpId` INTEGER, `startId` INTEGER, `endId` INTEGER, FOREIGN KEY(`referenceId`) REFERENCES `carbs`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "version", + "columnName": "version", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "dateCreated", + "columnName": "dateCreated", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isValid", + "columnName": "isValid", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "referenceId", + "columnName": "referenceId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "timestamp", + "columnName": "timestamp", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "utcOffset", + "columnName": "utcOffset", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "duration", + "columnName": "duration", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "amount", + "columnName": "amount", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutSystemId", + "columnName": "nightscoutSystemId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutId", + "columnName": "nightscoutId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpType", + "columnName": "pumpType", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpSerial", + "columnName": "pumpSerial", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpId", + "columnName": "pumpId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.startId", + "columnName": "startId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.endId", + "columnName": "endId", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_carbs_referenceId", + "unique": false, + "columnNames": [ + "referenceId" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_carbs_referenceId` ON `${TABLE_NAME}` (`referenceId`)" + }, + { + "name": "index_carbs_timestamp", + "unique": false, + "columnNames": [ + "timestamp" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_carbs_timestamp` ON `${TABLE_NAME}` (`timestamp`)" + } + ], + "foreignKeys": [ + { + "table": "carbs", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "referenceId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "effectiveProfileSwitches", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `version` INTEGER NOT NULL, `dateCreated` INTEGER NOT NULL, `isValid` INTEGER NOT NULL, `referenceId` INTEGER, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `duration` INTEGER NOT NULL, `basalBlocks` TEXT NOT NULL, `nightscoutSystemId` TEXT, `nightscoutId` TEXT, `pumpType` TEXT, `pumpSerial` TEXT, `pumpId` INTEGER, `startId` INTEGER, `endId` INTEGER, FOREIGN KEY(`referenceId`) REFERENCES `effectiveProfileSwitches`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "version", + "columnName": "version", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "dateCreated", + "columnName": "dateCreated", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isValid", + "columnName": "isValid", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "referenceId", + "columnName": "referenceId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "timestamp", + "columnName": "timestamp", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "utcOffset", + "columnName": "utcOffset", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "duration", + "columnName": "duration", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "basalBlocks", + "columnName": "basalBlocks", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutSystemId", + "columnName": "nightscoutSystemId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutId", + "columnName": "nightscoutId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpType", + "columnName": "pumpType", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpSerial", + "columnName": "pumpSerial", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpId", + "columnName": "pumpId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.startId", + "columnName": "startId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.endId", + "columnName": "endId", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_effectiveProfileSwitches_referenceId", + "unique": false, + "columnNames": [ + "referenceId" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_effectiveProfileSwitches_referenceId` ON `${TABLE_NAME}` (`referenceId`)" + }, + { + "name": "index_effectiveProfileSwitches_timestamp", + "unique": false, + "columnNames": [ + "timestamp" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_effectiveProfileSwitches_timestamp` ON `${TABLE_NAME}` (`timestamp`)" + } + ], + "foreignKeys": [ + { + "table": "effectiveProfileSwitches", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "referenceId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "extendedBoluses", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `version` INTEGER NOT NULL, `dateCreated` INTEGER NOT NULL, `isValid` INTEGER NOT NULL, `referenceId` INTEGER, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `duration` INTEGER NOT NULL, `amount` REAL NOT NULL, `isEmulatingTempBasal` INTEGER NOT NULL, `nightscoutSystemId` TEXT, `nightscoutId` TEXT, `pumpType` TEXT, `pumpSerial` TEXT, `pumpId` INTEGER, `startId` INTEGER, `endId` INTEGER, FOREIGN KEY(`referenceId`) REFERENCES `extendedBoluses`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "version", + "columnName": "version", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "dateCreated", + "columnName": "dateCreated", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isValid", + "columnName": "isValid", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "referenceId", + "columnName": "referenceId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "timestamp", + "columnName": "timestamp", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "utcOffset", + "columnName": "utcOffset", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "duration", + "columnName": "duration", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "amount", + "columnName": "amount", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "isEmulatingTempBasal", + "columnName": "isEmulatingTempBasal", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutSystemId", + "columnName": "nightscoutSystemId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutId", + "columnName": "nightscoutId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpType", + "columnName": "pumpType", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpSerial", + "columnName": "pumpSerial", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpId", + "columnName": "pumpId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.startId", + "columnName": "startId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.endId", + "columnName": "endId", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_extendedBoluses_referenceId", + "unique": false, + "columnNames": [ + "referenceId" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_extendedBoluses_referenceId` ON `${TABLE_NAME}` (`referenceId`)" + }, + { + "name": "index_extendedBoluses_timestamp", + "unique": false, + "columnNames": [ + "timestamp" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_extendedBoluses_timestamp` ON `${TABLE_NAME}` (`timestamp`)" + } + ], + "foreignKeys": [ + { + "table": "extendedBoluses", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "referenceId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "glucoseValues", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `version` INTEGER NOT NULL, `dateCreated` INTEGER NOT NULL, `isValid` INTEGER NOT NULL, `referenceId` INTEGER, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `raw` REAL, `value` REAL NOT NULL, `trendArrow` TEXT NOT NULL, `noise` REAL, `sourceSensor` TEXT NOT NULL, `nightscoutSystemId` TEXT, `nightscoutId` TEXT, `pumpType` TEXT, `pumpSerial` TEXT, `pumpId` INTEGER, `startId` INTEGER, `endId` INTEGER, FOREIGN KEY(`referenceId`) REFERENCES `glucoseValues`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "version", + "columnName": "version", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "dateCreated", + "columnName": "dateCreated", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isValid", + "columnName": "isValid", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "referenceId", + "columnName": "referenceId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "timestamp", + "columnName": "timestamp", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "utcOffset", + "columnName": "utcOffset", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "raw", + "columnName": "raw", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "value", + "columnName": "value", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "trendArrow", + "columnName": "trendArrow", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "noise", + "columnName": "noise", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "sourceSensor", + "columnName": "sourceSensor", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutSystemId", + "columnName": "nightscoutSystemId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutId", + "columnName": "nightscoutId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpType", + "columnName": "pumpType", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpSerial", + "columnName": "pumpSerial", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpId", + "columnName": "pumpId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.startId", + "columnName": "startId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.endId", + "columnName": "endId", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_glucoseValues_referenceId", + "unique": false, + "columnNames": [ + "referenceId" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_glucoseValues_referenceId` ON `${TABLE_NAME}` (`referenceId`)" + }, + { + "name": "index_glucoseValues_timestamp", + "unique": false, + "columnNames": [ + "timestamp" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_glucoseValues_timestamp` ON `${TABLE_NAME}` (`timestamp`)" + } + ], + "foreignKeys": [ + { + "table": "glucoseValues", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "referenceId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "profileSwitches", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `version` INTEGER NOT NULL, `dateCreated` INTEGER NOT NULL, `isValid` INTEGER NOT NULL, `referenceId` INTEGER, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `profileName` TEXT NOT NULL, `glucoseUnit` TEXT NOT NULL, `basalBlocks` TEXT NOT NULL, `isfBlocks` TEXT NOT NULL, `icBlocks` TEXT NOT NULL, `targetBlocks` TEXT NOT NULL, `timeshift` INTEGER NOT NULL, `percentage` INTEGER NOT NULL, `duration` INTEGER NOT NULL, `nightscoutSystemId` TEXT, `nightscoutId` TEXT, `pumpType` TEXT, `pumpSerial` TEXT, `pumpId` INTEGER, `startId` INTEGER, `endId` INTEGER, `insulinLabel` TEXT NOT NULL, `insulinEndTime` INTEGER NOT NULL, `peak` INTEGER NOT NULL, FOREIGN KEY(`referenceId`) REFERENCES `profileSwitches`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "version", + "columnName": "version", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "dateCreated", + "columnName": "dateCreated", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isValid", + "columnName": "isValid", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "referenceId", + "columnName": "referenceId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "timestamp", + "columnName": "timestamp", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "utcOffset", + "columnName": "utcOffset", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "profileName", + "columnName": "profileName", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "glucoseUnit", + "columnName": "glucoseUnit", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "basalBlocks", + "columnName": "basalBlocks", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "isfBlocks", + "columnName": "isfBlocks", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "icBlocks", + "columnName": "icBlocks", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "targetBlocks", + "columnName": "targetBlocks", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "timeshift", + "columnName": "timeshift", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "percentage", + "columnName": "percentage", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "duration", + "columnName": "duration", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutSystemId", + "columnName": "nightscoutSystemId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutId", + "columnName": "nightscoutId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpType", + "columnName": "pumpType", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpSerial", + "columnName": "pumpSerial", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpId", + "columnName": "pumpId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.startId", + "columnName": "startId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.endId", + "columnName": "endId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "insulinConfiguration.insulinLabel", + "columnName": "insulinLabel", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "insulinConfiguration.insulinEndTime", + "columnName": "insulinEndTime", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "insulinConfiguration.peak", + "columnName": "peak", + "affinity": "INTEGER", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_profileSwitches_referenceId", + "unique": false, + "columnNames": [ + "referenceId" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_profileSwitches_referenceId` ON `${TABLE_NAME}` (`referenceId`)" + }, + { + "name": "index_profileSwitches_timestamp", + "unique": false, + "columnNames": [ + "timestamp" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_profileSwitches_timestamp` ON `${TABLE_NAME}` (`timestamp`)" + } + ], + "foreignKeys": [ + { + "table": "profileSwitches", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "referenceId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "temporaryBasals", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `version` INTEGER NOT NULL, `dateCreated` INTEGER NOT NULL, `isValid` INTEGER NOT NULL, `referenceId` INTEGER, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `type` TEXT NOT NULL, `isAbsolute` INTEGER NOT NULL, `rate` REAL NOT NULL, `duration` INTEGER NOT NULL, `nightscoutSystemId` TEXT, `nightscoutId` TEXT, `pumpType` TEXT, `pumpSerial` TEXT, `pumpId` INTEGER, `startId` INTEGER, `endId` INTEGER, FOREIGN KEY(`referenceId`) REFERENCES `temporaryBasals`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "version", + "columnName": "version", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "dateCreated", + "columnName": "dateCreated", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isValid", + "columnName": "isValid", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "referenceId", + "columnName": "referenceId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "timestamp", + "columnName": "timestamp", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "utcOffset", + "columnName": "utcOffset", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "isAbsolute", + "columnName": "isAbsolute", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "rate", + "columnName": "rate", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "duration", + "columnName": "duration", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutSystemId", + "columnName": "nightscoutSystemId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutId", + "columnName": "nightscoutId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpType", + "columnName": "pumpType", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpSerial", + "columnName": "pumpSerial", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpId", + "columnName": "pumpId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.startId", + "columnName": "startId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.endId", + "columnName": "endId", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_temporaryBasals_referenceId", + "unique": false, + "columnNames": [ + "referenceId" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_temporaryBasals_referenceId` ON `${TABLE_NAME}` (`referenceId`)" + }, + { + "name": "index_temporaryBasals_timestamp", + "unique": false, + "columnNames": [ + "timestamp" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_temporaryBasals_timestamp` ON `${TABLE_NAME}` (`timestamp`)" + } + ], + "foreignKeys": [ + { + "table": "temporaryBasals", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "referenceId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "temporaryTargets", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `version` INTEGER NOT NULL, `dateCreated` INTEGER NOT NULL, `isValid` INTEGER NOT NULL, `referenceId` INTEGER, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `reason` TEXT NOT NULL, `highTarget` REAL NOT NULL, `lowTarget` REAL NOT NULL, `duration` INTEGER NOT NULL, `nightscoutSystemId` TEXT, `nightscoutId` TEXT, `pumpType` TEXT, `pumpSerial` TEXT, `pumpId` INTEGER, `startId` INTEGER, `endId` INTEGER, FOREIGN KEY(`referenceId`) REFERENCES `temporaryTargets`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "version", + "columnName": "version", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "dateCreated", + "columnName": "dateCreated", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isValid", + "columnName": "isValid", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "referenceId", + "columnName": "referenceId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "timestamp", + "columnName": "timestamp", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "utcOffset", + "columnName": "utcOffset", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "reason", + "columnName": "reason", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "highTarget", + "columnName": "highTarget", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "lowTarget", + "columnName": "lowTarget", + "affinity": "REAL", + "notNull": true + }, + { + "fieldPath": "duration", + "columnName": "duration", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutSystemId", + "columnName": "nightscoutSystemId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutId", + "columnName": "nightscoutId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpType", + "columnName": "pumpType", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpSerial", + "columnName": "pumpSerial", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpId", + "columnName": "pumpId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.startId", + "columnName": "startId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.endId", + "columnName": "endId", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_temporaryTargets_referenceId", + "unique": false, + "columnNames": [ + "referenceId" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_temporaryTargets_referenceId` ON `${TABLE_NAME}` (`referenceId`)" + }, + { + "name": "index_temporaryTargets_timestamp", + "unique": false, + "columnNames": [ + "timestamp" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_temporaryTargets_timestamp` ON `${TABLE_NAME}` (`timestamp`)" + } + ], + "foreignKeys": [ + { + "table": "temporaryTargets", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "referenceId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "therapyEvents", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `version` INTEGER NOT NULL, `dateCreated` INTEGER NOT NULL, `isValid` INTEGER NOT NULL, `referenceId` INTEGER, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `duration` INTEGER NOT NULL, `type` TEXT NOT NULL, `note` TEXT, `amount` REAL, `nightscoutSystemId` TEXT, `nightscoutId` TEXT, `pumpType` TEXT, `pumpSerial` TEXT, `pumpId` INTEGER, `startId` INTEGER, `endId` INTEGER, FOREIGN KEY(`referenceId`) REFERENCES `therapyEvents`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "version", + "columnName": "version", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "dateCreated", + "columnName": "dateCreated", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isValid", + "columnName": "isValid", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "referenceId", + "columnName": "referenceId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "timestamp", + "columnName": "timestamp", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "utcOffset", + "columnName": "utcOffset", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "duration", + "columnName": "duration", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "type", + "columnName": "type", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "note", + "columnName": "note", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "amount", + "columnName": "amount", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutSystemId", + "columnName": "nightscoutSystemId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutId", + "columnName": "nightscoutId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpType", + "columnName": "pumpType", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpSerial", + "columnName": "pumpSerial", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpId", + "columnName": "pumpId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.startId", + "columnName": "startId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.endId", + "columnName": "endId", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_therapyEvents_referenceId", + "unique": false, + "columnNames": [ + "referenceId" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_therapyEvents_referenceId` ON `${TABLE_NAME}` (`referenceId`)" + }, + { + "name": "index_therapyEvents_timestamp", + "unique": false, + "columnNames": [ + "timestamp" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_therapyEvents_timestamp` ON `${TABLE_NAME}` (`timestamp`)" + } + ], + "foreignKeys": [ + { + "table": "therapyEvents", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "referenceId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "totalDailyDoses", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `version` INTEGER NOT NULL, `dateCreated` INTEGER NOT NULL, `isValid` INTEGER NOT NULL, `referenceId` INTEGER, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `basalAmount` REAL, `bolusAmount` REAL, `totalAmount` REAL, `nightscoutSystemId` TEXT, `nightscoutId` TEXT, `pumpType` TEXT, `pumpSerial` TEXT, `pumpId` INTEGER, `startId` INTEGER, `endId` INTEGER, FOREIGN KEY(`referenceId`) REFERENCES `totalDailyDoses`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "version", + "columnName": "version", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "dateCreated", + "columnName": "dateCreated", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isValid", + "columnName": "isValid", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "referenceId", + "columnName": "referenceId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "timestamp", + "columnName": "timestamp", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "utcOffset", + "columnName": "utcOffset", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "basalAmount", + "columnName": "basalAmount", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "bolusAmount", + "columnName": "bolusAmount", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "totalAmount", + "columnName": "totalAmount", + "affinity": "REAL", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutSystemId", + "columnName": "nightscoutSystemId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutId", + "columnName": "nightscoutId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpType", + "columnName": "pumpType", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpSerial", + "columnName": "pumpSerial", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpId", + "columnName": "pumpId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.startId", + "columnName": "startId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.endId", + "columnName": "endId", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_totalDailyDoses_referenceId", + "unique": false, + "columnNames": [ + "referenceId" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_totalDailyDoses_referenceId` ON `${TABLE_NAME}` (`referenceId`)" + }, + { + "name": "index_totalDailyDoses_timestamp", + "unique": false, + "columnNames": [ + "timestamp" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_totalDailyDoses_timestamp` ON `${TABLE_NAME}` (`timestamp`)" + } + ], + "foreignKeys": [ + { + "table": "totalDailyDoses", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "referenceId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "apsResultLinks", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `version` INTEGER NOT NULL, `dateCreated` INTEGER NOT NULL, `isValid` INTEGER NOT NULL, `referenceId` INTEGER, `apsResultId` INTEGER NOT NULL, `smbId` INTEGER, `tbrId` INTEGER, `nightscoutSystemId` TEXT, `nightscoutId` TEXT, `pumpType` TEXT, `pumpSerial` TEXT, `pumpId` INTEGER, `startId` INTEGER, `endId` INTEGER, FOREIGN KEY(`apsResultId`) REFERENCES `apsResults`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION , FOREIGN KEY(`smbId`) REFERENCES `boluses`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION , FOREIGN KEY(`tbrId`) REFERENCES `temporaryBasals`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION , FOREIGN KEY(`referenceId`) REFERENCES `apsResultLinks`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "version", + "columnName": "version", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "dateCreated", + "columnName": "dateCreated", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isValid", + "columnName": "isValid", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "referenceId", + "columnName": "referenceId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "apsResultId", + "columnName": "apsResultId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "smbId", + "columnName": "smbId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "tbrId", + "columnName": "tbrId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutSystemId", + "columnName": "nightscoutSystemId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutId", + "columnName": "nightscoutId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpType", + "columnName": "pumpType", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpSerial", + "columnName": "pumpSerial", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpId", + "columnName": "pumpId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.startId", + "columnName": "startId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.endId", + "columnName": "endId", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_apsResultLinks_referenceId", + "unique": false, + "columnNames": [ + "referenceId" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_apsResultLinks_referenceId` ON `${TABLE_NAME}` (`referenceId`)" + }, + { + "name": "index_apsResultLinks_apsResultId", + "unique": false, + "columnNames": [ + "apsResultId" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_apsResultLinks_apsResultId` ON `${TABLE_NAME}` (`apsResultId`)" + }, + { + "name": "index_apsResultLinks_smbId", + "unique": false, + "columnNames": [ + "smbId" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_apsResultLinks_smbId` ON `${TABLE_NAME}` (`smbId`)" + }, + { + "name": "index_apsResultLinks_tbrId", + "unique": false, + "columnNames": [ + "tbrId" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_apsResultLinks_tbrId` ON `${TABLE_NAME}` (`tbrId`)" + } + ], + "foreignKeys": [ + { + "table": "apsResults", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "apsResultId" + ], + "referencedColumns": [ + "id" + ] + }, + { + "table": "boluses", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "smbId" + ], + "referencedColumns": [ + "id" + ] + }, + { + "table": "temporaryBasals", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "tbrId" + ], + "referencedColumns": [ + "id" + ] + }, + { + "table": "apsResultLinks", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "referenceId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "mealLinks", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `version` INTEGER NOT NULL, `dateCreated` INTEGER NOT NULL, `isValid` INTEGER NOT NULL, `referenceId` INTEGER, `bolusId` INTEGER, `carbsId` INTEGER, `bolusCalcResultId` INTEGER, `superbolusTempBasalId` INTEGER, `noteId` INTEGER, `nightscoutSystemId` TEXT, `nightscoutId` TEXT, `pumpType` TEXT, `pumpSerial` TEXT, `pumpId` INTEGER, `startId` INTEGER, `endId` INTEGER, FOREIGN KEY(`bolusId`) REFERENCES `boluses`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION , FOREIGN KEY(`carbsId`) REFERENCES `carbs`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION , FOREIGN KEY(`bolusCalcResultId`) REFERENCES `bolusCalculatorResults`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION , FOREIGN KEY(`superbolusTempBasalId`) REFERENCES `temporaryBasals`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION , FOREIGN KEY(`noteId`) REFERENCES `therapyEvents`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION , FOREIGN KEY(`referenceId`) REFERENCES `mealLinks`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "version", + "columnName": "version", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "dateCreated", + "columnName": "dateCreated", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isValid", + "columnName": "isValid", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "referenceId", + "columnName": "referenceId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "bolusId", + "columnName": "bolusId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "carbsId", + "columnName": "carbsId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "bolusCalcResultId", + "columnName": "bolusCalcResultId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "superbolusTempBasalId", + "columnName": "superbolusTempBasalId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "noteId", + "columnName": "noteId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutSystemId", + "columnName": "nightscoutSystemId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutId", + "columnName": "nightscoutId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpType", + "columnName": "pumpType", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpSerial", + "columnName": "pumpSerial", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpId", + "columnName": "pumpId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.startId", + "columnName": "startId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.endId", + "columnName": "endId", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_mealLinks_referenceId", + "unique": false, + "columnNames": [ + "referenceId" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_mealLinks_referenceId` ON `${TABLE_NAME}` (`referenceId`)" + }, + { + "name": "index_mealLinks_bolusId", + "unique": false, + "columnNames": [ + "bolusId" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_mealLinks_bolusId` ON `${TABLE_NAME}` (`bolusId`)" + }, + { + "name": "index_mealLinks_carbsId", + "unique": false, + "columnNames": [ + "carbsId" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_mealLinks_carbsId` ON `${TABLE_NAME}` (`carbsId`)" + }, + { + "name": "index_mealLinks_bolusCalcResultId", + "unique": false, + "columnNames": [ + "bolusCalcResultId" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_mealLinks_bolusCalcResultId` ON `${TABLE_NAME}` (`bolusCalcResultId`)" + }, + { + "name": "index_mealLinks_superbolusTempBasalId", + "unique": false, + "columnNames": [ + "superbolusTempBasalId" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_mealLinks_superbolusTempBasalId` ON `${TABLE_NAME}` (`superbolusTempBasalId`)" + }, + { + "name": "index_mealLinks_noteId", + "unique": false, + "columnNames": [ + "noteId" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_mealLinks_noteId` ON `${TABLE_NAME}` (`noteId`)" + } + ], + "foreignKeys": [ + { + "table": "boluses", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "bolusId" + ], + "referencedColumns": [ + "id" + ] + }, + { + "table": "carbs", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "carbsId" + ], + "referencedColumns": [ + "id" + ] + }, + { + "table": "bolusCalculatorResults", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "bolusCalcResultId" + ], + "referencedColumns": [ + "id" + ] + }, + { + "table": "temporaryBasals", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "superbolusTempBasalId" + ], + "referencedColumns": [ + "id" + ] + }, + { + "table": "therapyEvents", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "noteId" + ], + "referencedColumns": [ + "id" + ] + }, + { + "table": "mealLinks", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "referenceId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "multiwaveBolusLinks", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `version` INTEGER NOT NULL, `dateCreated` INTEGER NOT NULL, `isValid` INTEGER NOT NULL, `referenceId` INTEGER, `bolusId` INTEGER NOT NULL, `extendedBolusId` INTEGER NOT NULL, `nightscoutSystemId` TEXT, `nightscoutId` TEXT, `pumpType` TEXT, `pumpSerial` TEXT, `pumpId` INTEGER, `startId` INTEGER, `endId` INTEGER, FOREIGN KEY(`bolusId`) REFERENCES `boluses`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION , FOREIGN KEY(`extendedBolusId`) REFERENCES `extendedBoluses`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION , FOREIGN KEY(`referenceId`) REFERENCES `multiwaveBolusLinks`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "version", + "columnName": "version", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "dateCreated", + "columnName": "dateCreated", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isValid", + "columnName": "isValid", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "referenceId", + "columnName": "referenceId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "bolusId", + "columnName": "bolusId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "extendedBolusId", + "columnName": "extendedBolusId", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutSystemId", + "columnName": "nightscoutSystemId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.nightscoutId", + "columnName": "nightscoutId", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpType", + "columnName": "pumpType", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpSerial", + "columnName": "pumpSerial", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.pumpId", + "columnName": "pumpId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.startId", + "columnName": "startId", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "interfaceIDs_backing.endId", + "columnName": "endId", + "affinity": "INTEGER", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_multiwaveBolusLinks_referenceId", + "unique": false, + "columnNames": [ + "referenceId" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_multiwaveBolusLinks_referenceId` ON `${TABLE_NAME}` (`referenceId`)" + }, + { + "name": "index_multiwaveBolusLinks_bolusId", + "unique": false, + "columnNames": [ + "bolusId" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_multiwaveBolusLinks_bolusId` ON `${TABLE_NAME}` (`bolusId`)" + }, + { + "name": "index_multiwaveBolusLinks_extendedBolusId", + "unique": false, + "columnNames": [ + "extendedBolusId" + ], + "createSql": "CREATE INDEX IF NOT EXISTS `index_multiwaveBolusLinks_extendedBolusId` ON `${TABLE_NAME}` (`extendedBolusId`)" + } + ], + "foreignKeys": [ + { + "table": "boluses", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "bolusId" + ], + "referencedColumns": [ + "id" + ] + }, + { + "table": "extendedBoluses", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "extendedBolusId" + ], + "referencedColumns": [ + "id" + ] + }, + { + "table": "multiwaveBolusLinks", + "onDelete": "NO ACTION", + "onUpdate": "NO ACTION", + "columns": [ + "referenceId" + ], + "referencedColumns": [ + "id" + ] + } + ] + }, + { + "tableName": "preferenceChanges", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `key` TEXT NOT NULL, `value` TEXT)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "timestamp", + "columnName": "timestamp", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "utcOffset", + "columnName": "utcOffset", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "key", + "columnName": "key", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "value", + "columnName": "value", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "versionChanges", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `versionCode` INTEGER NOT NULL, `versionName` TEXT NOT NULL, `gitRemote` TEXT, `commitHash` TEXT)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "timestamp", + "columnName": "timestamp", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "utcOffset", + "columnName": "utcOffset", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "versionCode", + "columnName": "versionCode", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "versionName", + "columnName": "versionName", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "gitRemote", + "columnName": "gitRemote", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "commitHash", + "columnName": "commitHash", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "userEntry", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `action` TEXT NOT NULL, `s` TEXT NOT NULL, `values` TEXT NOT NULL)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "timestamp", + "columnName": "timestamp", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "utcOffset", + "columnName": "utcOffset", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "action", + "columnName": "action", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "s", + "columnName": "s", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "values", + "columnName": "values", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "id" + ], + "autoGenerate": true + }, + "indices": [], + "foreignKeys": [] + } + ], + "views": [], + "setupQueries": [ + "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '9e6e8a398493c289fd1db6f1aa5155db')" + ] + } +} \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/AppDatabase.kt b/database/src/main/java/info/nightscout/androidaps/database/AppDatabase.kt index f2cf4c1f7e..708bc6a293 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/AppDatabase.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/AppDatabase.kt @@ -6,7 +6,7 @@ import androidx.room.TypeConverters import info.nightscout.androidaps.database.daos.* import info.nightscout.androidaps.database.entities.* -const val DATABASE_VERSION = 3 +const val DATABASE_VERSION = 4 @Database(version = DATABASE_VERSION, entities = [APSResult::class, Bolus::class, BolusCalculatorResult::class, Carbs::class, diff --git a/database/src/main/java/info/nightscout/androidaps/database/Converters.kt b/database/src/main/java/info/nightscout/androidaps/database/Converters.kt index eb23f19449..04d5cb9901 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/Converters.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/Converters.kt @@ -5,6 +5,7 @@ import info.nightscout.androidaps.database.data.Block import info.nightscout.androidaps.database.data.TargetBlock import info.nightscout.androidaps.database.embedments.InterfaceIDs import info.nightscout.androidaps.database.entities.* +import info.nightscout.androidaps.database.entities.UserEntry.* import org.json.JSONArray import org.json.JSONObject @@ -16,48 +17,32 @@ class Converters { @TypeConverter fun toAction(action: String?) = action?.let { UserEntry.Action.fromString(it) } - @TypeConverter - fun fromValueWithUnit(valueWithUnit: UserEntry.ValueWithUnit?): String? { - if (valueWithUnit == null) return null - val jsonObject = JSONObject() - jsonObject.put("sValue", valueWithUnit.sValue) - jsonObject.put("dValue", valueWithUnit.dValue) - jsonObject.put("iValue", valueWithUnit.iValue) - jsonObject.put("lValue", valueWithUnit.lValue) - jsonObject.put("unit", valueWithUnit.unit.name) - return jsonObject.toString() - } - - @TypeConverter - fun toValueWithUnit(jsonString: String?): UserEntry.ValueWithUnit? { - if (jsonString == null) return null - val jsonObject = JSONObject(jsonString) - return UserEntry.ValueWithUnit(jsonObject.getString("sValue"), jsonObject.getDouble("dValue"), jsonObject.getInt("iValue"), jsonObject.getLong("lValue"), UserEntry.Units.fromString(jsonObject.getString("unit")) ) - } - @TypeConverter fun fromMutableListOfValueWithUnit(values: MutableList?): String? { if (values == null) return null val jsonArray = JSONArray() values.forEach { val jsonObject = JSONObject() - jsonObject.put("dValue", it.dValue) - jsonObject.put("iValue", it.iValue) - jsonObject.put("lValue", it.lValue) - jsonObject.put("unit", it.unit.name) + if (!it.dValue.equals(0.0)) jsonObject.put("dValue", it.dValue).put("unit", it.unit.name) + if (!it.iValue.equals(0)) jsonObject.put("iValue", it.iValue).put("unit", it.unit.name) + if (!it.lValue.equals(0)) jsonObject.put("lValue", it.lValue).put("unit", it.unit.name) + if (!it.sValue.equals("")) jsonObject.put("sValue", it.sValue).put("unit", it.unit.name) jsonArray.put(jsonObject) } return jsonArray.toString() } @TypeConverter - fun toMutableListOfValueWithUnit(jsonString: String?): List? { + fun toMutableListOfValueWithUnit(jsonString: String?): MutableList? { if (jsonString == null) return null val jsonArray = JSONArray(jsonString) - val list = mutableListOf() + val list = mutableListOf() for (i in 0 until jsonArray.length()) { val jsonObject = jsonArray.getJSONObject(i) - list.add(Block(jsonObject.getLong("duration"), jsonObject.getDouble("amount"))) + if (jsonObject.has("dValue")) list.add(ValueWithUnit(jsonObject.getDouble("dValue"), jsonObject.getString("unit"))) + if (jsonObject.has("iValue")) list.add(ValueWithUnit(jsonObject.getDouble("iValue"), jsonObject.getString("unit"))) + if (jsonObject.has("lValue")) list.add(ValueWithUnit(jsonObject.getDouble("lValue"), jsonObject.getString("unit"))) + if (jsonObject.has("sValue")) list.add(ValueWithUnit(jsonObject.getDouble("sValue"), jsonObject.getString("unit"))) } return list } diff --git a/database/src/main/java/info/nightscout/androidaps/database/DatabaseModule.kt b/database/src/main/java/info/nightscout/androidaps/database/DatabaseModule.kt index 32dbba2511..75fd1e9394 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/DatabaseModule.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/DatabaseModule.kt @@ -22,6 +22,7 @@ open class DatabaseModule { Room .databaseBuilder(context, AppDatabase::class.java, fileName) .addMigrations(migration1to2) + .addMigrations(migration3to4) .fallbackToDestructiveMigration() .build() @@ -36,7 +37,8 @@ open class DatabaseModule { private val migration3to4 = object : Migration(3, 4) { override fun migrate(database: SupportSQLiteDatabase) { - database.execSQL("CREATE TABLE IF NOT EXISTS userEntry (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `action` TEXT NOT NULL, `s` TEXT NOT NULL, `d1` TEXT NOT NULL, `d2` TEXT NOT NULL, `i1` TEXT NOT NULL, `i2` TEXT NOT NULL)") + database.execSQL("DROP TABLE IF EXISTS userEntry") + database.execSQL("CREATE TABLE userEntry (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `action` TEXT NOT NULL, `s` TEXT NOT NULL, `d1` TEXT NOT NULL, `d2` TEXT NOT NULL, `i1` TEXT NOT NULL, `i2` TEXT NOT NULL)") } } } \ No newline at end of file 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 dd9dd003f0..1895e855cb 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 @@ -3,7 +3,6 @@ package info.nightscout.androidaps.database.entities import androidx.room.Entity import androidx.room.PrimaryKey import com.google.gson.annotations.SerializedName -import info.nightscout.androidaps.database.R import info.nightscout.androidaps.database.TABLE_USER_ENTRY import info.nightscout.androidaps.database.interfaces.DBEntry import info.nightscout.androidaps.database.interfaces.DBEntryWithTime @@ -120,26 +119,31 @@ data class UserEntry( fun fromString(source: String?) = UserEntry.Action.values().firstOrNull { it.name == source } ?: UserEntry.Action.UNKNOWN } } - data class ValueWithUnit (val dValue: Double, val iValue: Int, val lValue: Long, val unit: Units) { - constructor(dvalue:Double, unit:Units) : this(dvalue,0, 0, unit) - constructor(ivalue:Int, unit:Units) : this(0.0, ivalue, 0, unit) - constructor(lvalue:Long, unit:Units) : this(0.0,0, lvalue, unit) + data class ValueWithUnit (val dValue: Double, val iValue: Int, val lValue: Long, val sValue: String, val unit: Units) { + constructor(dvalue:Double?, unit:Units) : this(dvalue ?:0.0,0, 0, "", unit) + constructor(ivalue:Int?, unit:Units) : this(0.0, ivalue ?:0, 0, "", unit) + constructor(lvalue:Long?, unit:Units) : this(0.0,0, lvalue ?:0, "", unit) + constructor(svalue:String?, unit:Units) : this(0.0,0, 0, svalue ?:"", unit) + constructor(dvalue:Double?, unit:String) : this(dvalue ?:0.0,0, 0, "", Units.fromString(unit)) } enum class Units { @SerializedName("None") None, - @SerializedName("Mg_Dl") Mg_Dl, - @SerializedName("Mmol_L") Mmol_L, + @SerializedName("mg/dl") Mg_Dl, + @SerializedName("mmol") Mmol_L, @SerializedName("Timestamp") Timestamp, @SerializedName("U") U, - @SerializedName("U_H") U_H, - @SerializedName("G") G, - @SerializedName("M") M, - @SerializedName("H") H, - @SerializedName("Percent") Percent + @SerializedName("U/h") U_H, + @SerializedName("g") G, + @SerializedName("m") M, + @SerializedName("h") H, + @SerializedName("Percent") Percent, + @SerializedName("CPEvent") CPEvent, + @SerializedName("TT_Reason") TT_Reason, + @SerializedName("R_String") R_String ; companion object { - fun fromString(unit: String?) = UserEntry.Units.values().firstOrNull { it.name == unit } ?: UserEntry.Units.None + fun fromString(unit: String?) = values().firstOrNull { it.name == unit } ?: None } } } \ No newline at end of file From a2c3ec3a7ff07c3ea7787cbf5bd64cce6a84bdf6 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 28 Feb 2021 22:05:03 +0100 Subject: [PATCH 15/66] Fix Constants.MGDL and Constants.MMOL Fix .addMigrations(migration3to4) (I hope) --- .../info/nightscout/androidaps/Constants.java | 4 +- .../utils/extensions/UnitsStrings.kt | 23 ++---------- .../androidaps/database/DatabaseModule.kt | 2 +- .../androidaps/database/entities/UserEntry.kt | 37 +++++++++++-------- 4 files changed, 28 insertions(+), 38 deletions(-) diff --git a/core/src/main/java/info/nightscout/androidaps/Constants.java b/core/src/main/java/info/nightscout/androidaps/Constants.java index 81c201aed2..94f76cc2d7 100644 --- a/core/src/main/java/info/nightscout/androidaps/Constants.java +++ b/core/src/main/java/info/nightscout/androidaps/Constants.java @@ -7,8 +7,8 @@ import info.nightscout.androidaps.database.entities.UserEntry.*; * Created by mike on 07.06.2016. */ public class Constants { - public static final String MGDL = Units.Mg_Dl.name(); // This is Nightscout's representation - public static final String MMOL = Units.Mmol_L.name(); + public static final String MGDL = Units.Mg_Dl.getText(); // This is Nightscout's representation + public static final String MMOL = Units.Mmol_L.getText(); public static final double MMOLL_TO_MGDL = 18; // 18.0182; public static final double MGDL_TO_MMOLL = 1 / MMOLL_TO_MGDL; diff --git a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UnitsStrings.kt b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UnitsStrings.kt index 08e0afa1bc..167f32e4c1 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UnitsStrings.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UnitsStrings.kt @@ -3,13 +3,12 @@ package info.nightscout.androidaps.utils.extensions import info.nightscout.androidaps.Constants import info.nightscout.androidaps.core.R import info.nightscout.androidaps.database.entities.UserEntry -import info.nightscout.androidaps.utils.resources.ResourceHelper fun UserEntry.Units.stringId(): Int { return when { - this == UserEntry.Units.Mg_Dl -> R.string.mgdl + this == UserEntry.Units.Mg_Dl -> R.string.mgdl this == UserEntry.Units.Mmol_L -> R.string.mmol - this == UserEntry.Units.U -> R.string.insulin_unit_shortname + this == UserEntry.Units.U -> R.string.insulin_unit_shortname this == UserEntry.Units.U_H -> R.string.profile_ins_units_per_hour this == UserEntry.Units.G -> R.string.shortgram this == UserEntry.Units.M -> R.string.shortminute @@ -17,20 +16,4 @@ fun UserEntry.Units.stringId(): Int { this == UserEntry.Units.Percent -> R.string.shortpercent else -> 0 } -} - -fun UserEntry.Units.stringkey(): String { - return when { - this == UserEntry.Units.Mg_Dl -> Constants.MGDL - this == UserEntry.Units.Mmol_L -> Constants.MMOL - this == UserEntry.Units.U -> UserEntry.Units.U.name - this == UserEntry.Units.U_H -> UserEntry.Units.U_H.name - this == UserEntry.Units.G -> UserEntry.Units.G.name - this == UserEntry.Units.M -> UserEntry.Units.M.name - this == UserEntry.Units.H -> UserEntry.Units.H.name - this == UserEntry.Units.Percent -> "%" - else -> "" - } -} - -fun UserEntry.Units.Companion(source: String?) = UserEntry.Units.values().firstOrNull { it.stringkey() == source } ?: UserEntry.Units.None \ No newline at end of file +} \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/DatabaseModule.kt b/database/src/main/java/info/nightscout/androidaps/database/DatabaseModule.kt index 75fd1e9394..cb4904bd85 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/DatabaseModule.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/DatabaseModule.kt @@ -38,7 +38,7 @@ open class DatabaseModule { private val migration3to4 = object : Migration(3, 4) { override fun migrate(database: SupportSQLiteDatabase) { database.execSQL("DROP TABLE IF EXISTS userEntry") - database.execSQL("CREATE TABLE userEntry (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `action` TEXT NOT NULL, `s` TEXT NOT NULL, `d1` TEXT NOT NULL, `d2` TEXT NOT NULL, `i1` TEXT NOT NULL, `i2` TEXT NOT NULL)") + database.execSQL("CREATE TABLE userEntry (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `action` TEXT NOT NULL, `s` TEXT NOT NULL, `values` TEXT NOT NULL)") } } } \ No newline at end of file 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 1895e855cb..6642f038c9 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 @@ -124,26 +124,33 @@ data class UserEntry( constructor(ivalue:Int?, unit:Units) : this(0.0, ivalue ?:0, 0, "", unit) constructor(lvalue:Long?, unit:Units) : this(0.0,0, lvalue ?:0, "", unit) constructor(svalue:String?, unit:Units) : this(0.0,0, 0, svalue ?:"", unit) - constructor(dvalue:Double?, unit:String) : this(dvalue ?:0.0,0, 0, "", Units.fromString(unit)) + constructor(dvalue:Double?, unit:String) : this(dvalue ?:0.0,0, 0, "", Units.fromText(unit)) + fun value() : Any { + if (!dValue.equals(0.0)) return dValue + if (!iValue.equals(0)) return iValue + if (!lValue.equals(0)) return lValue + return sValue + } } - enum class Units { - @SerializedName("None") None, - @SerializedName("mg/dl") Mg_Dl, - @SerializedName("mmol") Mmol_L, - @SerializedName("Timestamp") Timestamp, - @SerializedName("U") U, - @SerializedName("U/h") U_H, - @SerializedName("g") G, - @SerializedName("m") M, - @SerializedName("h") H, - @SerializedName("Percent") Percent, - @SerializedName("CPEvent") CPEvent, - @SerializedName("TT_Reason") TT_Reason, - @SerializedName("R_String") R_String + enum class Units(val text: String) { + @SerializedName("None") None (""), + @SerializedName("Mg_Dl") Mg_Dl ("mg/dl"), + @SerializedName("Mmol_L") Mmol_L ("mmol"), + @SerializedName("Timestamp") Timestamp("Timestamp"), + @SerializedName("U") U ("U"), + @SerializedName("U_H") U_H ("U/h"), + @SerializedName("G") G ("g"), + @SerializedName("M") M ("m"), + @SerializedName("H") H ("h"), + @SerializedName("Percent") Percent ("%"), + @SerializedName("CPEvent") CPEvent ("CPEvent"), + @SerializedName("TT_Reason") TT_Reason ("TTReason"), + @SerializedName("R_String") R_String ("R.string") ; companion object { fun fromString(unit: String?) = values().firstOrNull { it.name == unit } ?: None + fun fromText(unit: String?) = values().firstOrNull { it.text == unit } ?: None } } } \ No newline at end of file From f226a03c83532949679741392a194507ee4959cc Mon Sep 17 00:00:00 2001 From: Philoul Date: Tue, 2 Mar 2021 13:31:07 +0100 Subject: [PATCH 16/66] Fix Converters.kt Initialize a first version of Layout with Card and TreamentsUserEntryFragment --- .../fragments/TreatmentsUserEntryFragment.kt | 27 +++- .../res/layout/treatments_user_entry_item.xml | 124 ++++++++++-------- core/src/main/res/values/strings.xml | 2 +- .../androidaps/database/Converters.kt | 10 +- 4 files changed, 90 insertions(+), 73 deletions(-) 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 419e63f745..d64e3ed903 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 @@ -10,9 +10,12 @@ import dagger.android.support.DaggerFragment 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.* import info.nightscout.androidaps.databinding.TreatmentsUserEntryFragmentBinding import info.nightscout.androidaps.databinding.TreatmentsUserEntryItemBinding import info.nightscout.androidaps.utils.DateUtil +import info.nightscout.androidaps.utils.DecimalFormatter +import info.nightscout.androidaps.utils.Translator import info.nightscout.androidaps.utils.extensions.stringId import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.rx.AapsSchedulers @@ -26,6 +29,7 @@ class TreatmentsUserEntryFragment : DaggerFragment() { @Inject lateinit var aapsSchedulers: AapsSchedulers @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var dateUtil: DateUtil + @Inject lateinit var translator: Translator private val disposable = CompositeDisposable() @@ -68,13 +72,22 @@ class TreatmentsUserEntryFragment : DaggerFragment() { holder.binding.date.text = dateUtil.dateAndTimeAndSecondsString(current.timestamp) holder.binding.action.text = resourceHelper.gs(current.action.stringId()) if (current.s != "") holder.binding.s.text = current.s else holder.binding.s.visibility = View.GONE - /* - if (current.d1 != 0.0) holder.binding.d1.text = current.d1.toString() else holder.binding.d1.visibility = View.GONE - if (current.d2 != 0.0) holder.binding.d2.text = current.d2.toString() else holder.binding.d2.visibility = View.GONE - if (current.i1 != 0) holder.binding.i1.text = current.i1.toString() else holder.binding.i1.visibility = View.GONE - if (current.i2 != 0) holder.binding.i2.text = current.i2.toString() else holder.binding.i2.visibility = View.GONE - - */ + //holder.binding.s.text = current.toString() //for debug + var valuesWithUnitString = "" + for(v in current.values) { + when (v.unit) { + Units.Timestamp -> valuesWithUnitString += dateUtil.dateAndTimeAndSecondsString(v.lValue) + " " + Units.CPEvent -> valuesWithUnitString += translator.translate(v.sValue) + " " + Units.R_String -> valuesWithUnitString += resourceHelper.gs(v.iValue) + " " + Units.Mg_Dl -> valuesWithUnitString += DecimalFormatter.to0Decimal(v.dValue) + resourceHelper.gs(Units.Mg_Dl.stringId()) + " " + Units.Mmol_L -> valuesWithUnitString += DecimalFormatter.to1Decimal(v.dValue) + resourceHelper.gs(Units.Mmol_L.stringId()) + " " + Units.G -> valuesWithUnitString += DecimalFormatter.to0Decimal(v.dValue) + resourceHelper.gs(Units.G.stringId()) + " " + else -> valuesWithUnitString += if (!v.value().equals(0) && !v.value().equals("")) { v.value().toString() + if (!v.unit.stringId().equals(0)) resourceHelper.gs(v.unit.stringId()) + " " else " " } else "" + } + } + if (current.values.size > 0) + holder.binding.values.visibility = View.VISIBLE + holder.binding.values.text = valuesWithUnitString } inner class UserEntryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { diff --git a/app/src/main/res/layout/treatments_user_entry_item.xml b/app/src/main/res/layout/treatments_user_entry_item.xml index a3c3870c9a..1d0d65616c 100644 --- a/app/src/main/res/layout/treatments_user_entry_item.xml +++ b/app/src/main/res/layout/treatments_user_entry_item.xml @@ -1,70 +1,80 @@ - + android:layout_gravity="center" + card_view:cardBackgroundColor="?android:colorBackground"> - + android:orientation="vertical"> - + - + - + - + - + - + - + + + + + + + + + diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 4c1d556769..54a00d4ca1 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -119,7 +119,7 @@ mg/dl mmol/l g - %% + % Advanced Settings Bluetooth BT Watchdog diff --git a/database/src/main/java/info/nightscout/androidaps/database/Converters.kt b/database/src/main/java/info/nightscout/androidaps/database/Converters.kt index 04d5cb9901..3919742e6c 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/Converters.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/Converters.kt @@ -23,10 +23,7 @@ class Converters { val jsonArray = JSONArray() values.forEach { val jsonObject = JSONObject() - if (!it.dValue.equals(0.0)) jsonObject.put("dValue", it.dValue).put("unit", it.unit.name) - if (!it.iValue.equals(0)) jsonObject.put("iValue", it.iValue).put("unit", it.unit.name) - if (!it.lValue.equals(0)) jsonObject.put("lValue", it.lValue).put("unit", it.unit.name) - if (!it.sValue.equals("")) jsonObject.put("sValue", it.sValue).put("unit", it.unit.name) + jsonObject.put("dValue", it.dValue).put("iValue", it.iValue).put("lValue", it.lValue).put("sValue", it.sValue).put("unit", it.unit.name) jsonArray.put(jsonObject) } return jsonArray.toString() @@ -39,10 +36,7 @@ class Converters { val list = mutableListOf() for (i in 0 until jsonArray.length()) { val jsonObject = jsonArray.getJSONObject(i) - if (jsonObject.has("dValue")) list.add(ValueWithUnit(jsonObject.getDouble("dValue"), jsonObject.getString("unit"))) - if (jsonObject.has("iValue")) list.add(ValueWithUnit(jsonObject.getDouble("iValue"), jsonObject.getString("unit"))) - if (jsonObject.has("lValue")) list.add(ValueWithUnit(jsonObject.getDouble("lValue"), jsonObject.getString("unit"))) - if (jsonObject.has("sValue")) list.add(ValueWithUnit(jsonObject.getDouble("sValue"), jsonObject.getString("unit"))) + list.add(ValueWithUnit(jsonObject.getDouble("dValue"), jsonObject.getInt("iValue"), jsonObject.getLong("lValue"), jsonObject.getString("sValue"), Units.fromString(jsonObject.getString("unit")))) } return list } From efa9e18f83c407f985292efd00f476d38884e69c Mon Sep 17 00:00:00 2001 From: Philoul Date: Tue, 2 Mar 2021 22:43:18 +0100 Subject: [PATCH 17/66] Constructor for formated Strings with param, add notes, convert to AAPS units in fragment --- .../androidaps/dialogs/CarbsDialog.kt | 4 +- .../androidaps/dialogs/CareDialog.kt | 2 +- .../androidaps/dialogs/FillDialog.kt | 6 +-- .../androidaps/dialogs/InsulinDialog.kt | 6 +-- .../androidaps/dialogs/ProfileSwitchDialog.kt | 2 +- .../smsCommunicator/SmsCommunicatorPlugin.kt | 21 +++++----- .../fragments/TreatmentsUserEntryFragment.kt | 41 ++++++++++++++----- .../res/layout/treatments_user_entry_item.xml | 8 ++-- .../utils/extensions/UnitsStrings.kt | 19 --------- .../{UserEntryStrings.kt => UserEntryExt.kt} | 30 ++++++++++++++ core/src/main/res/values/strings.xml | 1 + .../androidaps/database/entities/UserEntry.kt | 6 ++- 12 files changed, 91 insertions(+), 55 deletions(-) delete mode 100644 core/src/main/java/info/nightscout/androidaps/utils/extensions/UnitsStrings.kt rename core/src/main/java/info/nightscout/androidaps/utils/extensions/{UserEntryStrings.kt => UserEntryExt.kt} (83%) 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 6d86136605..bd2a5fdea2 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt @@ -250,10 +250,10 @@ class CarbsDialog : DialogFragmentWithDate() { } if (carbsAfterConstraints > 0) { if (duration == 0) { - uel.log(Action.CARBS, ValueWithUnit(carbsAfterConstraints.toDouble(), Units.G), ValueWithUnit(timeOffset, Units.M)) + uel.log(Action.CARBS, notes, ValueWithUnit(carbsAfterConstraints.toDouble(), Units.G), ValueWithUnit(timeOffset, Units.M)) carbsGenerator.createCarb(carbsAfterConstraints, time, CareportalEvent.CARBCORRECTION, notes) } else { - uel.log(Action.CARBS, ValueWithUnit(carbsAfterConstraints.toDouble(), Units.G), ValueWithUnit(timeOffset,Units.M), ValueWithUnit(duration, Units.H)) + uel.log(Action.CARBS, notes, ValueWithUnit(carbsAfterConstraints.toDouble(), Units.G), ValueWithUnit(timeOffset,Units.M), ValueWithUnit(duration, Units.H)) carbsGenerator.generateCarbs(carbsAfterConstraints, time, duration, notes) nsUpload.uploadEvent(CareportalEvent.NOTE, DateUtil.now() - 2000, resourceHelper.gs(R.string.generated_ecarbs_note, carbsAfterConstraints, duration, timeOffset)) } 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 16a60df0dc..f558c8029d 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt @@ -223,7 +223,7 @@ class CareDialog : DialogFragmentWithDate() { EventType.ANNOUNCEMENT -> CareportalEvent.ANNOUNCEMENT } careportalEvent.json = json.toString() - uel.log(Action.CAREPORTAL, ValueWithUnit(careportalEvent.eventType, Units.CPEvent)) + uel.log(Action.CAREPORTAL, notes, ValueWithUnit(careportalEvent.eventType, Units.CPEvent)) MainApp.getDbHelper().createOrUpdate(careportalEvent) nsUpload.uploadCareportalEntryToNS(json) }, 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 118953e3e7..6ed328fa7a 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt @@ -128,16 +128,16 @@ class FillDialog : DialogFragmentWithDate() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.primefill), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { if (insulinAfterConstraints > 0) { - uel.log(Action.PRIME_BOLUS, ValueWithUnit(insulinAfterConstraints, Units.U)) + uel.log(Action.PRIME_BOLUS, notes, ValueWithUnit(insulinAfterConstraints, Units.U)) requestPrimeBolus(insulinAfterConstraints, notes) } if (siteChange) { - uel.log(Action.SITE_CHANGE) + uel.log(Action.SITE_CHANGE, notes) nsUpload.generateCareportalEvent(CareportalEvent.SITECHANGE, eventTime, notes) } if (insulinChange) { // add a second for case of both checked - uel.log(Action.INSULIN_CHANGE) + uel.log(Action.INSULIN_CHANGE, notes) nsUpload.generateCareportalEvent(CareportalEvent.INSULINCHANGE, eventTime + 1000, notes) } }, null) 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 7f25104243..db9a06fe97 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt @@ -179,7 +179,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, ValueWithUnit(eatingSoonTT, units), ValueWithUnit(eatingSoonTTDuration, Units.M)) + uel.log(Action.TT_EATING_SOON, notes, ValueWithUnit(eatingSoonTT, units), ValueWithUnit(eatingSoonTTDuration, Units.M)) val tempTarget = TempTarget() .date(System.currentTimeMillis()) .duration(eatingSoonTTDuration) @@ -197,11 +197,11 @@ class InsulinDialog : DialogFragmentWithDate() { detailedBolusInfo.source = Source.USER detailedBolusInfo.notes = notes if (recordOnlyChecked) { - uel.log(Action.BOLUS_RECORD, ValueWithUnit(insulinAfterConstraints, Units.U), ValueWithUnit(timeOffset, Units.M)) + uel.log(Action.BOLUS_RECORD, notes, ValueWithUnit(insulinAfterConstraints, Units.U), ValueWithUnit(timeOffset, Units.M)) detailedBolusInfo.date = time activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false) } else { - uel.log(Action.BOLUS, ValueWithUnit(insulinAfterConstraints, Units.U)) + uel.log(Action.BOLUS, notes, ValueWithUnit(insulinAfterConstraints, Units.U)) detailedBolusInfo.date = DateUtil.now() commandQueue.bolus(detailedBolusInfo, object : Callback() { override fun run() { diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt index 5eb2126de8..5b294b7ff1 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt @@ -125,7 +125,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { - uel.log(Action.PROFILE_SWITCH, ValueWithUnit(percent, Units.Percent), ValueWithUnit(timeShift, Units.H), ValueWithUnit(duration, Units.M)) + uel.log(Action.PROFILE_SWITCH, notes, ValueWithUnit(percent, Units.Percent), ValueWithUnit(timeShift, Units.H), ValueWithUnit(duration, Units.M)) treatmentsPlugin.doProfileSwitch(profileStore, profile, duration, percent, timeShift, eventTime) }) } 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 82853f1437..5af60ec200 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 @@ -648,9 +648,9 @@ 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, Units.R_String), ValueWithUnit(result.percent, Units.Percent), ValueWithUnit(result.duration, Units.M)) + 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)) else - uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalset, Units.R_String), ValueWithUnit(result.absolute, Units.U_H), ValueWithUnit(result.duration, Units.M)) + 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)) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) @@ -686,9 +686,9 @@ 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, Units.R_String), ValueWithUnit(result.percent, Units.Percent), ValueWithUnit(result.duration, Units.M)) + 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)) else - uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalset, Units.R_String), ValueWithUnit(result.absolute, Units.U_H), ValueWithUnit(result.duration, Units.M)) + 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)) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) @@ -747,9 +747,9 @@ class SmsCommunicatorPlugin @Inject constructor( replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) if (config.APS) - uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_extendedset, Units.R_String), ValueWithUnit(aDouble, Units.U), ValueWithUnit(duration, Units.M), ValueWithUnit(R.string.loopsuspended, Units.R_String)) + uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_extendedset, 2), ValueWithUnit(aDouble, 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, Units.R_String), ValueWithUnit(aDouble, Units.U), ValueWithUnit(duration, Units.M)) + uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_extendedset, 2), ValueWithUnit(aDouble, Units.U), ValueWithUnit(duration, Units.M)) } else { var replyText = resourceHelper.gs(R.string.smscommunicator_extendedfailed) replyText += "\n" + activePlugin.activePump.shortStatus(true) @@ -868,12 +868,12 @@ class SmsCommunicatorPlugin @Inject constructor( var replyText = String.format(resourceHelper.gs(R.string.smscommunicator_carbsset), anInteger) replyText += "\n" + activePlugin.activePump.shortStatus(true) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) - uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_carbsset, Units.R_String), ValueWithUnit(anInteger,Units.G)) + uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_carbsset, 1), ValueWithUnit(anInteger,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, Units.R_String), ValueWithUnit(anInteger,Units.G)) + uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_carbsfailed, 1), ValueWithUnit(anInteger,Units.G)) } } }) @@ -882,7 +882,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, Units.R_String), ValueWithUnit(anInteger,Units.G)) + uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_carbsset, 1), ValueWithUnit(anInteger,Units.G)) } } }) @@ -947,7 +947,8 @@ class SmsCommunicatorPlugin @Inject constructor( val ttString = if (units == Constants.MMOL) DecimalFormatter.to1Decimal(tt) else DecimalFormatter.to0Decimal(tt) 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, Units.R_String), ValueWithUnit(tt, units), ValueWithUnit(ttDuration, Units.M)) + //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)) } }) } else if (isStop) { 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 d64e3ed903..9b78120f09 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 @@ -7,16 +7,20 @@ import android.view.ViewGroup import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import dagger.android.support.DaggerFragment +import info.nightscout.androidaps.Constants 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.* import info.nightscout.androidaps.databinding.TreatmentsUserEntryFragmentBinding import info.nightscout.androidaps.databinding.TreatmentsUserEntryItemBinding +import info.nightscout.androidaps.interfaces.ProfileFunction +import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DecimalFormatter +import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.Translator -import info.nightscout.androidaps.utils.extensions.stringId +import info.nightscout.androidaps.utils.extensions.* import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.rx.AapsSchedulers import io.reactivex.disposables.CompositeDisposable @@ -29,6 +33,9 @@ class TreatmentsUserEntryFragment : DaggerFragment() { @Inject lateinit var aapsSchedulers: AapsSchedulers @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var dateUtil: DateUtil + @Inject lateinit var profileFunction: ProfileFunction + @Inject lateinit var fabricPrivacy: FabricPrivacy + @Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var translator: Translator private val disposable = CompositeDisposable() @@ -74,16 +81,30 @@ class TreatmentsUserEntryFragment : DaggerFragment() { if (current.s != "") holder.binding.s.text = current.s else holder.binding.s.visibility = View.GONE //holder.binding.s.text = current.toString() //for debug var valuesWithUnitString = "" + var rStringParam = 0 for(v in current.values) { - when (v.unit) { - Units.Timestamp -> valuesWithUnitString += dateUtil.dateAndTimeAndSecondsString(v.lValue) + " " - Units.CPEvent -> valuesWithUnitString += translator.translate(v.sValue) + " " - Units.R_String -> valuesWithUnitString += resourceHelper.gs(v.iValue) + " " - Units.Mg_Dl -> valuesWithUnitString += DecimalFormatter.to0Decimal(v.dValue) + resourceHelper.gs(Units.Mg_Dl.stringId()) + " " - Units.Mmol_L -> valuesWithUnitString += DecimalFormatter.to1Decimal(v.dValue) + resourceHelper.gs(Units.Mmol_L.stringId()) + " " - Units.G -> valuesWithUnitString += DecimalFormatter.to0Decimal(v.dValue) + resourceHelper.gs(Units.G.stringId()) + " " - else -> valuesWithUnitString += if (!v.value().equals(0) && !v.value().equals("")) { v.value().toString() + if (!v.unit.stringId().equals(0)) resourceHelper.gs(v.unit.stringId()) + " " else " " } else "" - } + if (rStringParam >0) + rStringParam-- + else + when (v.unit) { + Units.Timestamp -> valuesWithUnitString += dateUtil.dateAndTimeAndSecondsString(v.lValue) + " " + Units.CPEvent -> valuesWithUnitString += translator.translate(v.sValue) + " " + Units.R_String -> { + rStringParam = v.lValue.toInt() + when (rStringParam) { // + 0 -> valuesWithUnitString += resourceHelper.gs(v.iValue) + " " + 1 -> valuesWithUnitString += resourceHelper.gs(v.iValue, current.values[current.values.indexOf(v)+1].value()) + " " + 2 -> valuesWithUnitString += resourceHelper.gs(v.iValue, current.values[current.values.indexOf(v)+1].value(), current.values[current.values.indexOf(v)+2].value()) + " " + 3 -> valuesWithUnitString += resourceHelper.gs(v.iValue, current.values[current.values.indexOf(v)+1].value(), current.values[current.values.indexOf(v)+2].value(), current.values[current.values.indexOf(v)+3].value()) + " " + 4 -> rStringParam = 0 + } + } + Units.Mg_Dl -> valuesWithUnitString += if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue) + resourceHelper.gs(Units.Mg_Dl.stringId()) + " " else DecimalFormatter.to1Decimal(v.dValue/Constants.MMOLL_TO_MGDL) + resourceHelper.gs(Units.Mmol_L.stringId()) + " " + Units.Mmol_L -> valuesWithUnitString += if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue*Constants.MMOLL_TO_MGDL) + resourceHelper.gs(Units.Mg_Dl.stringId()) + " " else DecimalFormatter.to1Decimal(v.dValue) + resourceHelper.gs(Units.Mmol_L.stringId()) + " " + Units.G -> valuesWithUnitString += DecimalFormatter.to0Decimal(v.dValue) + resourceHelper.gs(Units.G.stringId()) + " " + Units.U_H -> valuesWithUnitString += DecimalFormatter.to2Decimal(v.dValue) + resourceHelper.gs(Units.U_H.stringId()) + " " + else -> valuesWithUnitString += if (!v.value().equals(0) && !v.value().equals("")) { v.value().toString() + if (!v.unit.stringId().equals(0)) resourceHelper.gs(v.unit.stringId()) + " " else " " } else "" + } } if (current.values.size > 0) holder.binding.values.visibility = View.VISIBLE diff --git a/app/src/main/res/layout/treatments_user_entry_item.xml b/app/src/main/res/layout/treatments_user_entry_item.xml index 1d0d65616c..94acbf9327 100644 --- a/app/src/main/res/layout/treatments_user_entry_item.xml +++ b/app/src/main/res/layout/treatments_user_entry_item.xml @@ -46,7 +46,7 @@ diff --git a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UnitsStrings.kt b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UnitsStrings.kt deleted file mode 100644 index 167f32e4c1..0000000000 --- a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UnitsStrings.kt +++ /dev/null @@ -1,19 +0,0 @@ -package info.nightscout.androidaps.utils.extensions - -import info.nightscout.androidaps.Constants -import info.nightscout.androidaps.core.R -import info.nightscout.androidaps.database.entities.UserEntry - -fun UserEntry.Units.stringId(): Int { - return when { - this == UserEntry.Units.Mg_Dl -> R.string.mgdl - this == UserEntry.Units.Mmol_L -> R.string.mmol - this == UserEntry.Units.U -> R.string.insulin_unit_shortname - this == UserEntry.Units.U_H -> R.string.profile_ins_units_per_hour - this == UserEntry.Units.G -> R.string.shortgram - this == UserEntry.Units.M -> R.string.shortminute - this == UserEntry.Units.H -> R.string.shorthour - this == UserEntry.Units.Percent -> R.string.shortpercent - else -> 0 - } -} \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryStrings.kt b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt similarity index 83% rename from core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryStrings.kt rename to core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt index 8da2ef3a3d..ecc3eeaa57 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryStrings.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt @@ -100,4 +100,34 @@ fun UserEntry.Action.stringId(): Int { this == UserEntry.Action.SMS_TT -> R.string.uel_sms_tt else -> R.string.uel_unknown } +} + + +fun UserEntry.Units.stringId(): Int { + return when { + this == UserEntry.Units.Mg_Dl -> R.string.mgdl + this == UserEntry.Units.Mmol_L -> R.string.mmol + this == UserEntry.Units.U -> R.string.insulin_unit_shortname + this == UserEntry.Units.U_H -> R.string.profile_ins_units_per_hour + this == UserEntry.Units.G -> R.string.shortgram + this == UserEntry.Units.M -> R.string.shortminute + this == UserEntry.Units.H -> R.string.shorthour + this == UserEntry.Units.Percent -> R.string.shortpercent + this == UserEntry.Units.R_String -> R.string.formated_string + else -> 0 + } +} + +fun UserEntry.ValueWithUnit.toStringWithUnit(): String { + /* need injection to maje convertion + return when (this.unit) { + UserEntry.Units.Timestamp -> dateUtil.dateAndTimeAndSecondsString(this.lValue) + UserEntry.Units.CPEvent -> translator.translate(this.sValue) + UserEntry.Units.R_String -> resourceHelper.gs(this.iValue) + UserEntry.Units.Mg_Dl -> DecimalFormatter.to0Decimal(this.dValue) + resourceHelper.gs(UserEntry.Units.Mg_Dl.stringId()) + UserEntry.Units.Mmol_L -> DecimalFormatter.to1Decimal(this.dValue) + resourceHelper.gs(UserEntry.Units.Mmol_L.stringId()) + UserEntry.Units.G -> DecimalFormatter.to0Decimal(this.dValue) + resourceHelper.gs(UserEntry.Units.G.stringId()) + else -> if (!this.value().equals(0) && !this.value().equals("")) { v.value().toString() + if (!this.unit.stringId().equals(0)) resourceHelper.gs(this.unit.stringId()) else "" } else "" + } */ + return "" } \ 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 54a00d4ca1..73f784408c 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -482,6 +482,7 @@ SMS SMS SMS TT UNKNOWN + Formated string %1$d day 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 6642f038c9..aa51ad55c1 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 @@ -125,11 +125,13 @@ data class UserEntry( constructor(lvalue:Long?, unit:Units) : this(0.0,0, lvalue ?:0, "", unit) constructor(svalue:String?, unit:Units) : this(0.0,0, 0, svalue ?:"", unit) constructor(dvalue:Double?, unit:String) : this(dvalue ?:0.0,0, 0, "", Units.fromText(unit)) + constructor(rStringRef:Int, nbParam: Long) : this(0.0, rStringRef, nbParam, "", Units.R_String) // additionnal constructors for formated strings with additional values as parameters (define number of parameters as long + fun value() : Any { + if (sValue != "") return sValue if (!dValue.equals(0.0)) return dValue if (!iValue.equals(0)) return iValue - if (!lValue.equals(0)) return lValue - return sValue + return lValue } } enum class Units(val text: String) { From e0610a8341a91248728bff70ac631b37ebcd07a0 Mon Sep 17 00:00:00 2001 From: Philoul Date: Wed, 3 Mar 2021 00:31:28 +0100 Subject: [PATCH 18/66] Fix 0 value not hidden and add separator for VWU --- .../TreatmentsProfileSwitchFragment.kt | 2 +- .../fragments/TreatmentsUserEntryFragment.kt | 23 ++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt index 9a204467d6..0a66bab79a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt @@ -160,7 +160,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() { val profileSwitch = it.tag as ProfileSwitch OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), resourceHelper.gs(R.string.copytolocalprofile) + "\n" + profileSwitch.customizedName + "\n" + dateUtil.dateAndTimeString(profileSwitch.date), Runnable { profileSwitch.profileObject?.let { - uel.log(Action.PROFILE_SWITCH_CLONED, profileSwitch.profileName, ValueWithUnit(profileSwitch.date, Units.Timestamp)) + uel.log(Action.PROFILE_SWITCH_CLONED, ValueWithUnit(profileSwitch.date, Units.Timestamp), ValueWithUnit(profileSwitch.profileName, Units.None)) val nonCustomized = it.convertToNonCustomizedProfile() if (nonCustomized.isValid(resourceHelper.gs(R.string.careportal_profileswitch, false))) { localProfilePlugin.addProfile(localProfilePlugin.copyFrom(nonCustomized, profileSwitch.customizedName + " " + dateUtil.dateAndTimeString(profileSwitch.date).replace(".", "_"))) 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 9b78120f09..f633349439 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 @@ -82,28 +82,29 @@ class TreatmentsUserEntryFragment : DaggerFragment() { //holder.binding.s.text = current.toString() //for debug var valuesWithUnitString = "" var rStringParam = 0 + val separator = " " for(v in current.values) { if (rStringParam >0) rStringParam-- else when (v.unit) { - Units.Timestamp -> valuesWithUnitString += dateUtil.dateAndTimeAndSecondsString(v.lValue) + " " - Units.CPEvent -> valuesWithUnitString += translator.translate(v.sValue) + " " + Units.Timestamp -> valuesWithUnitString += dateUtil.dateAndTimeAndSecondsString(v.lValue) + separator + Units.CPEvent -> valuesWithUnitString += translator.translate(v.sValue) + separator Units.R_String -> { rStringParam = v.lValue.toInt() when (rStringParam) { // - 0 -> valuesWithUnitString += resourceHelper.gs(v.iValue) + " " - 1 -> valuesWithUnitString += resourceHelper.gs(v.iValue, current.values[current.values.indexOf(v)+1].value()) + " " - 2 -> valuesWithUnitString += resourceHelper.gs(v.iValue, current.values[current.values.indexOf(v)+1].value(), current.values[current.values.indexOf(v)+2].value()) + " " - 3 -> valuesWithUnitString += resourceHelper.gs(v.iValue, current.values[current.values.indexOf(v)+1].value(), current.values[current.values.indexOf(v)+2].value(), current.values[current.values.indexOf(v)+3].value()) + " " + 0 -> valuesWithUnitString += resourceHelper.gs(v.iValue) + separator + 1 -> valuesWithUnitString += resourceHelper.gs(v.iValue, current.values[current.values.indexOf(v)+1].value()) + separator + 2 -> valuesWithUnitString += resourceHelper.gs(v.iValue, current.values[current.values.indexOf(v)+1].value(), current.values[current.values.indexOf(v)+2].value()) + separator + 3 -> valuesWithUnitString += resourceHelper.gs(v.iValue, current.values[current.values.indexOf(v)+1].value(), current.values[current.values.indexOf(v)+2].value(), current.values[current.values.indexOf(v)+3].value()) + separator 4 -> rStringParam = 0 } } - Units.Mg_Dl -> valuesWithUnitString += if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue) + resourceHelper.gs(Units.Mg_Dl.stringId()) + " " else DecimalFormatter.to1Decimal(v.dValue/Constants.MMOLL_TO_MGDL) + resourceHelper.gs(Units.Mmol_L.stringId()) + " " - Units.Mmol_L -> valuesWithUnitString += if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue*Constants.MMOLL_TO_MGDL) + resourceHelper.gs(Units.Mg_Dl.stringId()) + " " else DecimalFormatter.to1Decimal(v.dValue) + resourceHelper.gs(Units.Mmol_L.stringId()) + " " - Units.G -> valuesWithUnitString += DecimalFormatter.to0Decimal(v.dValue) + resourceHelper.gs(Units.G.stringId()) + " " - Units.U_H -> valuesWithUnitString += DecimalFormatter.to2Decimal(v.dValue) + resourceHelper.gs(Units.U_H.stringId()) + " " - else -> valuesWithUnitString += if (!v.value().equals(0) && !v.value().equals("")) { v.value().toString() + if (!v.unit.stringId().equals(0)) resourceHelper.gs(v.unit.stringId()) + " " else " " } else "" + Units.Mg_Dl -> valuesWithUnitString += if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue) + resourceHelper.gs(Units.Mg_Dl.stringId()) + separator else DecimalFormatter.to1Decimal(v.dValue/Constants.MMOLL_TO_MGDL) + resourceHelper.gs(Units.Mmol_L.stringId()) + separator + Units.Mmol_L -> valuesWithUnitString += if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue*Constants.MMOLL_TO_MGDL) + resourceHelper.gs(Units.Mg_Dl.stringId()) + separator else DecimalFormatter.to1Decimal(v.dValue) + resourceHelper.gs(Units.Mmol_L.stringId()) + separator + Units.G -> valuesWithUnitString += DecimalFormatter.to0Decimal(v.dValue) + resourceHelper.gs(Units.G.stringId()) + separator + Units.U_H -> valuesWithUnitString += DecimalFormatter.to2Decimal(v.dValue) + resourceHelper.gs(Units.U_H.stringId()) + separator + else -> valuesWithUnitString += if (v.dValue != 0.0 || v.iValue != 0 || v.sValue != "") { v.value().toString() + if (!v.unit.stringId().equals(0)) resourceHelper.gs(v.unit.stringId()) + separator else separator } else "" } } if (current.values.size > 0) From a556df86c54c7105d900e788a7d817c45fae019e Mon Sep 17 00:00:00 2001 From: Philoul Date: Wed, 3 Mar 2021 08:53:48 +0100 Subject: [PATCH 19/66] uel log, put name in value with unit --- .../androidaps/plugins/profile/ns/NSProfileFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfileFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfileFragment.kt index 050d6346e3..7da3674c17 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfileFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfileFragment.kt @@ -62,7 +62,7 @@ class NSProfileFragment : DaggerFragment() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.nsprofile), resourceHelper.gs(R.string.activate_profile) + ": " + name + " ?", Runnable { - uel.log(Action.PROFILE_SWITCH, name, ValueWithUnit(100.toInt(), Units.Percent)) + uel.log(Action.PROFILE_SWITCH, ValueWithUnit(name,Units.None), ValueWithUnit(100.toInt(), Units.Percent)) treatmentsPlugin.doProfileSwitch(store, name, 0, 100, 0, DateUtil.now()) }) } From db1b3b7328267911ccb4d6cc982586d8a485839e Mon Sep 17 00:00:00 2001 From: Philoul Date: Wed, 3 Mar 2021 21:16:37 +0100 Subject: [PATCH 20/66] Add EventTime if changed (Carbs, TT, CP, PS) --- .../androidaps/dialogs/CarbsDialog.kt | 5 +++- .../androidaps/dialogs/CareDialog.kt | 5 +++- .../androidaps/dialogs/ProfileSwitchDialog.kt | 5 +++- .../androidaps/dialogs/TempTargetDialog.kt | 23 +++++++++++++------ 4 files changed, 28 insertions(+), 10 deletions(-) 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 bd2a5fdea2..328c52ddea 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt @@ -250,7 +250,10 @@ class CarbsDialog : DialogFragmentWithDate() { } if (carbsAfterConstraints > 0) { if (duration == 0) { - uel.log(Action.CARBS, notes, ValueWithUnit(carbsAfterConstraints.toDouble(), Units.G), ValueWithUnit(timeOffset, Units.M)) + if (eventTimeChanged) + uel.log(Action.CARBS, notes, ValueWithUnit(eventTime, Units.Timestamp), ValueWithUnit(carbsAfterConstraints.toDouble(), Units.G), ValueWithUnit(timeOffset, Units.M)) + else + uel.log(Action.CARBS, notes, ValueWithUnit(carbsAfterConstraints.toDouble(), Units.G), ValueWithUnit(timeOffset, Units.M)) carbsGenerator.createCarb(carbsAfterConstraints, time, CareportalEvent.CARBCORRECTION, notes) } else { uel.log(Action.CARBS, notes, ValueWithUnit(carbsAfterConstraints.toDouble(), Units.G), ValueWithUnit(timeOffset,Units.M), ValueWithUnit(duration, Units.H)) 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 f558c8029d..1121681949 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt @@ -223,7 +223,10 @@ class CareDialog : DialogFragmentWithDate() { EventType.ANNOUNCEMENT -> CareportalEvent.ANNOUNCEMENT } careportalEvent.json = json.toString() - uel.log(Action.CAREPORTAL, notes, ValueWithUnit(careportalEvent.eventType, Units.CPEvent)) + if (eventTimeChanged) + uel.log(Action.CAREPORTAL, notes, ValueWithUnit(eventTime, Units.Timestamp), ValueWithUnit(careportalEvent.eventType, Units.CPEvent)) + else + uel.log(Action.CAREPORTAL, notes, ValueWithUnit(careportalEvent.eventType, Units.CPEvent)) MainApp.getDbHelper().createOrUpdate(careportalEvent) nsUpload.uploadCareportalEntryToNS(json) }, null) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt index 5b294b7ff1..1fd0c158cd 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt @@ -125,7 +125,10 @@ class ProfileSwitchDialog : DialogFragmentWithDate() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { - uel.log(Action.PROFILE_SWITCH, notes, ValueWithUnit(percent, Units.Percent), ValueWithUnit(timeShift, Units.H), ValueWithUnit(duration, Units.M)) + if (eventTimeChanged) + uel.log(Action.PROFILE_SWITCH, notes, ValueWithUnit(eventTime, Units.Timestamp), ValueWithUnit(percent, Units.Percent), ValueWithUnit(timeShift, Units.H), ValueWithUnit(duration, Units.M)) + else + uel.log(Action.PROFILE_SWITCH, notes, ValueWithUnit(percent, Units.Percent), ValueWithUnit(timeShift, Units.H), ValueWithUnit(duration, Units.M)) treatmentsPlugin.doProfileSwitch(profileStore, profile, duration, percent, timeShift, eventTime) }) } diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt index c7e364ae96..84a8ab9e42 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt @@ -168,13 +168,22 @@ class TempTargetDialog : DialogFragmentWithDate() { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { val units = profileFunction.getUnits() - when(reason) { - resourceHelper.gs(R.string.eatingsoon) -> uel.log(Action.TT_EATING_SOON, ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) - resourceHelper.gs(R.string.activity) -> uel.log(Action.TT_ACTIVITY, ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) - resourceHelper.gs(R.string.hypo) -> uel.log(Action.TT_HYPO, ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) - resourceHelper.gs(R.string.manual) -> uel.log(Action.TT, ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) - resourceHelper.gs(R.string.stoptemptarget) -> uel.log(Action.CANCEL_TT) - } + if (eventTimeChanged) + when(reason) { + resourceHelper.gs(R.string.eatingsoon) -> uel.log(Action.TT_EATING_SOON, ValueWithUnit(eventTime, Units.Timestamp), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) + resourceHelper.gs(R.string.activity) -> uel.log(Action.TT_ACTIVITY, ValueWithUnit(eventTime, Units.Timestamp), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) + resourceHelper.gs(R.string.hypo) -> uel.log(Action.TT_HYPO, ValueWithUnit(eventTime, Units.Timestamp), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) + resourceHelper.gs(R.string.manual) -> uel.log(Action.TT, ValueWithUnit(eventTime, Units.Timestamp), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) + resourceHelper.gs(R.string.stoptemptarget) -> uel.log(Action.CANCEL_TT, ValueWithUnit(eventTime, Units.Timestamp)) + } + else + when(reason) { + resourceHelper.gs(R.string.eatingsoon) -> uel.log(Action.TT_EATING_SOON, ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) + resourceHelper.gs(R.string.activity) -> uel.log(Action.TT_ACTIVITY, ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) + resourceHelper.gs(R.string.hypo) -> uel.log(Action.TT_HYPO, ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) + resourceHelper.gs(R.string.manual) -> uel.log(Action.TT, ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) + resourceHelper.gs(R.string.stoptemptarget) -> uel.log(Action.CANCEL_TT) + } if (target == 0.0 || duration == 0) { val tempTarget = TempTarget() .date(eventTime) From e89aaf4d11b5d7ee890a24282e497d2f963b2cbf Mon Sep 17 00:00:00 2001 From: Philoul Date: Wed, 3 Mar 2021 23:53:15 +0100 Subject: [PATCH 21/66] Merge Dev, Fix new uel.log in NSClientPlugin --- .../plugins/general/actions/ActionsFragment.kt | 2 +- .../plugins/general/nsclient/NSClientPlugin.java | 9 +++++---- .../treatments/fragments/TreatmentsTempTargetFragment.kt | 2 +- .../androidaps/utils/extensions/UserEntryExt.kt | 4 ++++ core/src/main/res/values/strings.xml | 3 +++ .../nightscout/androidaps/database/entities/UserEntry.kt | 3 +++ 6 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt index b33a90e935..776d33fed8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/actions/ActionsFragment.kt @@ -154,7 +154,7 @@ class ActionsFragment : DaggerFragment() { } } extendedBolusCancel?.setOnClickListener { - if (activePlugin.activeTreatments.isInHistoryExtendedBoluslInProgress) { + if (activePlugin.activeTreatments.isInHistoryExtendedBolusInProgress) { uel.log(Action.CANCEL_EXTENDED_BOLUS) commandQueue.cancelExtended(object : Callback() { override fun run() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java index 341422469c..367678021a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java @@ -30,6 +30,7 @@ import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.R; import info.nightscout.androidaps.database.AppRepository; import info.nightscout.androidaps.database.entities.TemporaryTarget; +import info.nightscout.androidaps.database.entities.UserEntry.*; import info.nightscout.androidaps.database.transactions.SyncTemporaryTargetTransaction; import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.events.EventAppExit; @@ -423,7 +424,7 @@ public class NSClientPlugin extends PluginBase { // room Temporary target TemporaryTarget temporaryTarget = temporaryTargetFromNsIdForInvalidating(_id); disposable.add(repository.runTransactionForResult(new SyncTemporaryTargetTransaction(temporaryTarget)).subscribe( - result -> result.getInvalidated().forEach(record -> uel.log("TT DELETED FROM NS", record.getReason().getText(), record.getLowTarget(), record.getHighTarget(), (int) record.getDuration(), 0)), + result -> result.getInvalidated().forEach(record -> uel.log(Action.TT_DELETED_FROM_NS, new ValueWithUnit(record.getReason().getText(), Units.TT_Reason), new ValueWithUnit(record.getLowTarget(), Units.Mg_Dl), new ValueWithUnit(record.getHighTarget(), Units.Mg_Dl), new ValueWithUnit((int) record.getDuration(), Units.M))), error -> aapsLogger.error(LTag.BGSOURCE, "Error while saving temporary target", error))); // new DB model EventNsTreatment evtTreatment = new EventNsTreatment(EventNsTreatment.Companion.getREMOVE(), json); @@ -453,9 +454,9 @@ public class NSClientPlugin extends PluginBase { if (temporaryTarget != null) { disposable.add(repository.runTransactionForResult(new SyncTemporaryTargetTransaction(temporaryTarget)).subscribe( result -> { - result.getInserted().forEach(record -> uel.log("TT FROM NS", record.getReason().getText(), record.getLowTarget(), record.getHighTarget(), (int) record.getDuration(), 0)); - result.getInvalidated().forEach(record -> uel.log("TT DELETED FROM NS", record.getReason().getText(), record.getLowTarget(), record.getHighTarget(), (int) record.getDuration(), 0)); - result.getEnded().forEach(record -> uel.log("TT CANCELED FROM NS", record.getReason().getText(), record.getLowTarget(), record.getHighTarget(), (int) record.getDuration(), 0)); + result.getInserted().forEach(record -> uel.log(Action.TT_FROM_NS, new ValueWithUnit(record.getReason().getText(), Units.TT_Reason), new ValueWithUnit(record.getLowTarget(), Units.Mg_Dl), new ValueWithUnit(record.getHighTarget(), Units.Mg_Dl), new ValueWithUnit((int) record.getDuration(), Units.M))); + result.getInvalidated().forEach(record -> uel.log(Action.TT_DELETED_FROM_NS, new ValueWithUnit(record.getReason().getText(), Units.TT_Reason), new ValueWithUnit(record.getLowTarget(), Units.Mg_Dl), new ValueWithUnit(record.getHighTarget(), Units.Mg_Dl), new ValueWithUnit((int) record.getDuration(), Units.M))); + result.getEnded().forEach(record -> uel.log(Action.TT_CANCELED_FROM_NS, new ValueWithUnit(record.getReason().getText(), Units.TT_Reason), new ValueWithUnit(record.getLowTarget(), Units.Mg_Dl), new ValueWithUnit(record.getHighTarget(), Units.Mg_Dl), new ValueWithUnit((int) record.getDuration(), Units.M))); }, error -> aapsLogger.error(LTag.BGSOURCE, "Error while saving temporary target", error))); } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt index 987e63527f..98c004ff8b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt @@ -194,7 +194,7 @@ class TreatmentsTempTargetFragment : DaggerFragment() { ${dateUtil.dateAndTimeString(tempTarget.timestamp)} """.trimIndent(), { _: DialogInterface?, _: Int -> - uel.log(Action.TT_REMOVED, ValueWithUnit(tempTarget.reason, Units.TT_Reason), ValueWithUnit(tempTarget.date, Units.Timestamp), ValueWithUnit(tempTarget.low, Units.Mg_Dl), ValueWithUnit(tempTarget.high, Units.Mg_Dl), ValueWithUnit(tempTarget.durationInMinutes, Units.M)) + uel.log(Action.TT_REMOVED, ValueWithUnit(tempTarget.reason.text, Units.TT_Reason), ValueWithUnit(tempTarget.timestamp, Units.Timestamp), ValueWithUnit(tempTarget.lowTarget, Units.Mg_Dl), ValueWithUnit(tempTarget.highTarget, Units.Mg_Dl), ValueWithUnit(tempTarget.duration.toInt(), Units.M)) disposable += repository.runTransactionForResult(InvalidateTemporaryTargetTransaction(tempTarget.id)) .subscribe({ val id = tempTarget.interfaceIDs.nightscoutId diff --git a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt index ecc3eeaa57..a6b84bf7e7 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt @@ -1,5 +1,6 @@ package info.nightscout.androidaps.utils.extensions +import com.google.gson.annotations.SerializedName import info.nightscout.androidaps.core.R import info.nightscout.androidaps.database.entities.UserEntry @@ -98,6 +99,9 @@ fun UserEntry.Action.stringId(): Int { this == UserEntry.Action.SMS_PUMP_DISCONNECT -> R.string.uel_sms_pump_disconnect this == UserEntry.Action.SMS_SMS -> R.string.uel_sms_sms this == UserEntry.Action.SMS_TT -> R.string.uel_sms_tt + this == UserEntry.Action.TT_DELETED_FROM_NS -> R.string.uel_tt_deleted_from_ns + this == UserEntry.Action.TT_FROM_NS -> R.string.uel_tt_from_ns + this == UserEntry.Action.TT_CANCELED_FROM_NS -> R.string.uel_tt_canceleted_from_ns else -> R.string.uel_unknown } } diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 73f784408c..13081a0743 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -481,6 +481,9 @@ SMS PUMP DISCONNECT SMS SMS SMS TT + TT DELETED FROM NS + TT FROM NS + TT CANCELED FROM NS UNKNOWN Formated string diff --git a/database/src/main/java/info/nightscout/androidaps/database/entities/UserEntry.kt b/database/src/main/java/info/nightscout/androidaps/database/entities/UserEntry.kt index aa51ad55c1..73adb845d9 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/entities/UserEntry.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/entities/UserEntry.kt @@ -112,6 +112,9 @@ data class UserEntry( @SerializedName("SMS_PUMP_DISCONNECT") SMS_PUMP_DISCONNECT, @SerializedName("SMS_SMS") SMS_SMS, @SerializedName("SMS_TT") SMS_TT, + @SerializedName("TT_DELETED_FROM_NS") TT_DELETED_FROM_NS, + @SerializedName("TT_FROM_NS") TT_FROM_NS, + @SerializedName("TT_CANCELED_FROM_NS") TT_CANCELED_FROM_NS, @SerializedName("UNKNOWN") UNKNOWN ; From 37777d7d82415228838506ddade693d24af48bf5 Mon Sep 17 00:00:00 2001 From: Philoul Date: Thu, 4 Mar 2021 00:22:40 +0100 Subject: [PATCH 22/66] Convert Long duration to min (TT from NS) --- .../plugins/general/nsclient/NSClientPlugin.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 367678021a..f193088f89 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 @@ -424,7 +424,7 @@ public class NSClientPlugin extends PluginBase { // room Temporary target TemporaryTarget temporaryTarget = temporaryTargetFromNsIdForInvalidating(_id); disposable.add(repository.runTransactionForResult(new SyncTemporaryTargetTransaction(temporaryTarget)).subscribe( - result -> result.getInvalidated().forEach(record -> uel.log(Action.TT_DELETED_FROM_NS, new ValueWithUnit(record.getReason().getText(), Units.TT_Reason), new ValueWithUnit(record.getLowTarget(), Units.Mg_Dl), new ValueWithUnit(record.getHighTarget(), Units.Mg_Dl), new ValueWithUnit((int) record.getDuration(), Units.M))), + result -> result.getInvalidated().forEach(record -> uel.log(Action.TT_DELETED_FROM_NS, new ValueWithUnit(record.getReason().getText(), Units.TT_Reason), new ValueWithUnit(record.getLowTarget(), Units.Mg_Dl), new ValueWithUnit(record.getHighTarget(), Units.Mg_Dl), new ValueWithUnit((int) record.getDuration()/60000, Units.M))), error -> aapsLogger.error(LTag.BGSOURCE, "Error while saving temporary target", error))); // new DB model EventNsTreatment evtTreatment = new EventNsTreatment(EventNsTreatment.Companion.getREMOVE(), json); @@ -454,9 +454,9 @@ public class NSClientPlugin extends PluginBase { if (temporaryTarget != null) { disposable.add(repository.runTransactionForResult(new SyncTemporaryTargetTransaction(temporaryTarget)).subscribe( result -> { - result.getInserted().forEach(record -> uel.log(Action.TT_FROM_NS, new ValueWithUnit(record.getReason().getText(), Units.TT_Reason), new ValueWithUnit(record.getLowTarget(), Units.Mg_Dl), new ValueWithUnit(record.getHighTarget(), Units.Mg_Dl), new ValueWithUnit((int) record.getDuration(), Units.M))); - result.getInvalidated().forEach(record -> uel.log(Action.TT_DELETED_FROM_NS, new ValueWithUnit(record.getReason().getText(), Units.TT_Reason), new ValueWithUnit(record.getLowTarget(), Units.Mg_Dl), new ValueWithUnit(record.getHighTarget(), Units.Mg_Dl), new ValueWithUnit((int) record.getDuration(), Units.M))); - result.getEnded().forEach(record -> uel.log(Action.TT_CANCELED_FROM_NS, new ValueWithUnit(record.getReason().getText(), Units.TT_Reason), new ValueWithUnit(record.getLowTarget(), Units.Mg_Dl), new ValueWithUnit(record.getHighTarget(), Units.Mg_Dl), new ValueWithUnit((int) record.getDuration(), Units.M))); + result.getInserted().forEach(record -> uel.log(Action.TT_FROM_NS, new ValueWithUnit(record.getReason().getText(), Units.TT_Reason), new ValueWithUnit(record.getLowTarget(), Units.Mg_Dl), new ValueWithUnit(record.getHighTarget(), Units.Mg_Dl), new ValueWithUnit((int) record.getDuration()/60000, Units.M))); + result.getInvalidated().forEach(record -> uel.log(Action.TT_DELETED_FROM_NS, new ValueWithUnit(record.getReason().getText(), Units.TT_Reason), new ValueWithUnit(record.getLowTarget(), Units.Mg_Dl), new ValueWithUnit(record.getHighTarget(), Units.Mg_Dl), new ValueWithUnit((int) record.getDuration()/60000, Units.M))); + result.getEnded().forEach(record -> uel.log(Action.TT_CANCELED_FROM_NS, new ValueWithUnit(record.getReason().getText(), Units.TT_Reason), new ValueWithUnit(record.getLowTarget(), Units.Mg_Dl), new ValueWithUnit(record.getHighTarget(), Units.Mg_Dl), new ValueWithUnit((int) record.getDuration()/60000, Units.M))); }, error -> aapsLogger.error(LTag.BGSOURCE, "Error while saving temporary target", error))); } else { From db4268f408509fe8a448654ccd6036c1b08524e0 Mon Sep 17 00:00:00 2001 From: Philoul Date: Thu, 4 Mar 2021 14:52:30 +0100 Subject: [PATCH 23/66] UserEntry text format and colors.xml ValueWithUnit Bold Note standard grey color Action Colored (table in UserEntryExt.kt) --- .../fragments/TreatmentsUserEntryFragment.kt | 5 +- .../res/drawable/ic_actions_startextbolus.xml | 4 +- app/src/main/res/drawable/ic_calibration.xml | 6 +- app/src/main/res/drawable/ic_loop_closed.xml | 2 +- .../main/res/drawable/ic_loop_disabled.xml | 6 +- .../res/drawable/ic_loop_disconnected.xml | 4 +- app/src/main/res/drawable/ic_loop_lgs.xml | 12 +- app/src/main/res/drawable/ic_loop_open.xml | 14 +- app/src/main/res/drawable/ic_loop_paused.xml | 6 +- .../main/res/drawable/ic_loop_reconnect.xml | 4 +- app/src/main/res/drawable/ic_loop_resume.xml | 4 +- .../res/layout/treatments_user_entry_item.xml | 1 + app/src/main/res/values/colors.xml | 2 - .../utils/extensions/UserEntryExt.kt | 311 +++++++++++------- core/src/main/res/drawable/ic_cp_bgcheck.xml | 6 +- core/src/main/res/values/colors.xml | 12 + 16 files changed, 249 insertions(+), 150 deletions(-) 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 f633349439..b0a1a60c3d 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 @@ -78,11 +78,12 @@ class TreatmentsUserEntryFragment : DaggerFragment() { val current = entries[position] holder.binding.date.text = dateUtil.dateAndTimeAndSecondsString(current.timestamp) holder.binding.action.text = resourceHelper.gs(current.action.stringId()) + holder.binding.action.setTextColor(resourceHelper.gc(current.action.colorId())) if (current.s != "") holder.binding.s.text = current.s else holder.binding.s.visibility = View.GONE //holder.binding.s.text = current.toString() //for debug var valuesWithUnitString = "" var rStringParam = 0 - val separator = " " + val separator = " " for(v in current.values) { if (rStringParam >0) rStringParam-- @@ -109,7 +110,7 @@ class TreatmentsUserEntryFragment : DaggerFragment() { } if (current.values.size > 0) holder.binding.values.visibility = View.VISIBLE - holder.binding.values.text = valuesWithUnitString + holder.binding.values.text = valuesWithUnitString.trim() } inner class UserEntryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { diff --git a/app/src/main/res/drawable/ic_actions_startextbolus.xml b/app/src/main/res/drawable/ic_actions_startextbolus.xml index 6436cad1d7..35aa4cfb27 100644 --- a/app/src/main/res/drawable/ic_actions_startextbolus.xml +++ b/app/src/main/res/drawable/ic_actions_startextbolus.xml @@ -4,6 +4,6 @@ android:viewportHeight="24" android:viewportWidth="24" xmlns:android="http://schemas.android.com/apk/res/android"> - - + + diff --git a/app/src/main/res/drawable/ic_calibration.xml b/app/src/main/res/drawable/ic_calibration.xml index 26511d7cbf..cf3f592a41 100644 --- a/app/src/main/res/drawable/ic_calibration.xml +++ b/app/src/main/res/drawable/ic_calibration.xml @@ -5,11 +5,11 @@ android:viewportHeight="24"> + android:fillColor="@color/calibration"/> + android:fillColor="@color/calibration"/> + android:fillColor="@color/calibration"/> diff --git a/app/src/main/res/drawable/ic_loop_closed.xml b/app/src/main/res/drawable/ic_loop_closed.xml index 1cb9278a1a..9bddec63b6 100644 --- a/app/src/main/res/drawable/ic_loop_closed.xml +++ b/app/src/main/res/drawable/ic_loop_closed.xml @@ -5,5 +5,5 @@ android:viewportHeight="24"> + android:fillColor="@color/loopClosed"/> diff --git a/app/src/main/res/drawable/ic_loop_disabled.xml b/app/src/main/res/drawable/ic_loop_disabled.xml index ed79c96429..685118b92d 100644 --- a/app/src/main/res/drawable/ic_loop_disabled.xml +++ b/app/src/main/res/drawable/ic_loop_disabled.xml @@ -5,11 +5,11 @@ android:viewportHeight="24"> + android:fillColor="@color/loopDisabled"/> + android:fillColor="@color/loopDisabled"/> + android:fillColor="@color/loopDisabled"/> diff --git a/app/src/main/res/drawable/ic_loop_disconnected.xml b/app/src/main/res/drawable/ic_loop_disconnected.xml index 81450ade17..ea2cd137f4 100644 --- a/app/src/main/res/drawable/ic_loop_disconnected.xml +++ b/app/src/main/res/drawable/ic_loop_disconnected.xml @@ -5,8 +5,8 @@ android:viewportHeight="24"> + android:fillColor="@color/loopDisconnected"/> + android:fillColor="@color/loopDisconnected"/> diff --git a/app/src/main/res/drawable/ic_loop_lgs.xml b/app/src/main/res/drawable/ic_loop_lgs.xml index c7b5dcd0b8..c570403dbf 100644 --- a/app/src/main/res/drawable/ic_loop_lgs.xml +++ b/app/src/main/res/drawable/ic_loop_lgs.xml @@ -5,20 +5,20 @@ android:viewportHeight="24"> + android:fillColor="@color/loopClosed"/> + android:fillColor="@color/loopClosed"/> + android:fillColor="@color/loopClosed"/> + android:fillColor="@color/loopClosed"/> + android:fillColor="@color/loopClosed"/> + android:fillColor="@color/loopClosed"/> diff --git a/app/src/main/res/drawable/ic_loop_open.xml b/app/src/main/res/drawable/ic_loop_open.xml index 3f00a12c23..6f97953808 100644 --- a/app/src/main/res/drawable/ic_loop_open.xml +++ b/app/src/main/res/drawable/ic_loop_open.xml @@ -5,23 +5,23 @@ android:viewportHeight="24"> + android:fillColor="@color/loopOpened"/> + android:fillColor="@color/loopOpened"/> + android:fillColor="@color/loopOpened"/> + android:fillColor="@color/loopOpened"/> + android:fillColor="@color/loopOpened"/> + android:fillColor="@color/loopOpened"/> + android:fillColor="@color/loopOpened"/> diff --git a/app/src/main/res/drawable/ic_loop_paused.xml b/app/src/main/res/drawable/ic_loop_paused.xml index 4b7951d4d0..c49d3084c3 100644 --- a/app/src/main/res/drawable/ic_loop_paused.xml +++ b/app/src/main/res/drawable/ic_loop_paused.xml @@ -5,11 +5,11 @@ android:viewportHeight="24"> + android:fillColor="@color/loopSuspended"/> + android:fillColor="@color/loopSuspended"/> + android:fillColor="@color/loopSuspended"/> diff --git a/app/src/main/res/drawable/ic_loop_reconnect.xml b/app/src/main/res/drawable/ic_loop_reconnect.xml index dd3592f2b0..d90927a081 100644 --- a/app/src/main/res/drawable/ic_loop_reconnect.xml +++ b/app/src/main/res/drawable/ic_loop_reconnect.xml @@ -5,8 +5,8 @@ android:viewportHeight="24"> + android:fillColor="@color/loopDisconnected"/> + android:fillColor="@color/loopDisconnected"/> diff --git a/app/src/main/res/drawable/ic_loop_resume.xml b/app/src/main/res/drawable/ic_loop_resume.xml index 9b3a842486..ade6ba2f8d 100644 --- a/app/src/main/res/drawable/ic_loop_resume.xml +++ b/app/src/main/res/drawable/ic_loop_resume.xml @@ -5,8 +5,8 @@ android:viewportHeight="24"> + android:fillColor="@color/loopClosed"/> + android:fillColor="@color/loopClosed"/> diff --git a/app/src/main/res/layout/treatments_user_entry_item.xml b/app/src/main/res/layout/treatments_user_entry_item.xml index 94acbf9327..b2ce8b24c9 100644 --- a/app/src/main/res/layout/treatments_user_entry_item.xml +++ b/app/src/main/res/layout/treatments_user_entry_item.xml @@ -52,6 +52,7 @@ android:layout_weight="1" android:paddingStart="20dp" android:paddingEnd="10dp" + android:textStyle="bold" android:visibility="gone" android:text="Values with units" /> diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index bb0bdaa8c1..5f3225f2a1 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -1,7 +1,6 @@ #ff00ff - #00ffff #00d2d2 #1ea3e5 #FFFFFF @@ -22,7 +21,6 @@ #323232 #424242 - #BBBBBB #B3FFFFFF #77dd77 diff --git a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt index a6b84bf7e7..5ab9139bc8 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt @@ -5,107 +5,208 @@ import info.nightscout.androidaps.core.R import info.nightscout.androidaps.database.entities.UserEntry fun UserEntry.Action.stringId(): Int { - return when { - this == UserEntry.Action.BOLUS -> R.string.uel_bolus - this == UserEntry.Action.BOLUS_WIZARD -> R.string.uel_bolus_wizard - this == UserEntry.Action.BOLUS_ADVISOR -> R.string.uel_bolus_advisor - this == UserEntry.Action.BOLUS_RECORD -> R.string.uel_bolus_record - this == UserEntry.Action.EXTENDED_BOLUS -> R.string.uel_extended_bolus - this == UserEntry.Action.SUPERBOLUS_TBR -> R.string.uel_superbolus_tbr - this == UserEntry.Action.CARBS -> R.string.uel_carbs - this == UserEntry.Action.EXTENDED_CARBS -> R.string.uel_extended_carbs - this == UserEntry.Action.TEMP_BASAL -> R.string.uel_temp_basal - this == UserEntry.Action.TT -> R.string.uel_tt - this == UserEntry.Action.TT_ACTIVITY -> R.string.uel_tt_activity - this == UserEntry.Action.TT_EATING_SOON -> R.string.uel_tt_eating_soon - this == UserEntry.Action.TT_HYPO -> R.string.uel_tt_hypo - this == UserEntry.Action.NEW_PROFILE -> R.string.uel_new_profile - this == UserEntry.Action.CLONE_PROFILE -> R.string.uel_clone_profile - this == UserEntry.Action.STORE_PROFILE -> R.string.uel_store_profile - this == UserEntry.Action.PROFILE_SWITCH -> R.string.uel_profile_switch - this == UserEntry.Action.PROFILE_SWITCH_CLONED -> R.string.uel_profile_switch_cloned - this == UserEntry.Action.CLOSED_LOOP_MODE -> R.string.uel_closed_loop_mode - this == UserEntry.Action.LGS_LOOP_MODE -> R.string.uel_lgs_loop_mode - this == UserEntry.Action.OPEN_LOOP_MODE -> R.string.uel_open_loop_mode - this == UserEntry.Action.LOOP_DISABLED -> R.string.uel_loop_disabled - this == UserEntry.Action.LOOP_ENABLED -> R.string.uel_loop_enabled - this == UserEntry.Action.RECONNECT -> R.string.uel_reconnect - this == UserEntry.Action.DISCONNECT_15M -> R.string.uel_disconnect_15m - this == UserEntry.Action.DISCONNECT_30M -> R.string.uel_disconnect_30m - this == UserEntry.Action.DISCONNECT_1H -> R.string.uel_disconnect_1h - this == UserEntry.Action.DISCONNECT_2H -> R.string.uel_disconnect_2h - this == UserEntry.Action.DISCONNECT_3H -> R.string.uel_disconnect_3h - this == UserEntry.Action.RESUME -> R.string.uel_resume - this == UserEntry.Action.SUSPEND_1H -> R.string.uel_suspend_1h - this == UserEntry.Action.SUSPEND_2H -> R.string.uel_suspend_2h - this == UserEntry.Action.SUSPEND_3H -> R.string.uel_suspend_3h - this == UserEntry.Action.SUSPEND_10H -> R.string.uel_suspend_10h - this == UserEntry.Action.HW_PUMP_ALLOWED -> R.string.uel_hw_pump_allowed - this == UserEntry.Action.CLEAR_PAIRING_KEYS -> R.string.uel_clear_pairing_keys - this == UserEntry.Action.ACCEPTS_TEMP_BASAL -> R.string.uel_accepts_temp_basal - this == UserEntry.Action.CANCEL_TEMP_BASAL -> R.string.uel_cancel_temp_basal - this == UserEntry.Action.CANCEL_EXTENDED_BOLUS -> R.string.uel_cancel_extended_bolus - this == UserEntry.Action.CANCEL_TT -> R.string.uel_cancel_tt - this == UserEntry.Action.CAREPORTAL -> R.string.uel_careportal - this == UserEntry.Action.CALIBRATION -> R.string.uel_calibration - this == UserEntry.Action.INSULIN_CHANGE -> R.string.uel_insulin_change - this == UserEntry.Action.PRIME_BOLUS -> R.string.uel_prime_bolus - this == UserEntry.Action.SITE_CHANGE -> R.string.uel_site_change - this == UserEntry.Action.TREATMENT -> R.string.uel_treatment - this == UserEntry.Action.CAREPORTAL_NS_REFRESH -> R.string.uel_careportal_ns_refresh - this == UserEntry.Action.PROFILE_SWITCH_NS_REFRESH -> R.string.uel_profile_switch_ns_refresh - this == UserEntry.Action.TREATMENTS_NS_REFRESH -> R.string.uel_treatments_ns_refresh - this == UserEntry.Action.TT_NS_REFRESH -> R.string.uel_tt_ns_refresh - this == UserEntry.Action.AUTOMATION_REMOVED -> R.string.uel_automation_removed - this == UserEntry.Action.BG_REMOVED -> R.string.uel_bg_removed - this == UserEntry.Action.CAREPORTAL_REMOVED -> R.string.uel_careportal_removed - this == UserEntry.Action.EXTENDED_BOLUS_REMOVED -> R.string.uel_extended_bolus_removed - this == UserEntry.Action.FOOD_REMOVED -> R.string.uel_food_removed - this == UserEntry.Action.PROFILE_REMOVED -> R.string.uel_profile_removed - this == UserEntry.Action.PROFILE_SWITCH_REMOVED -> R.string.uel_profile_switch_removed - this == UserEntry.Action.RESTART_EVENTS_REMOVED -> R.string.uel_restart_events_removed - this == UserEntry.Action.TREATMENT_REMOVED -> R.string.uel_treatment_removed - this == UserEntry.Action.TT_REMOVED -> R.string.uel_tt_removed - this == UserEntry.Action.NS_PAUSED -> R.string.uel_ns_paused - this == UserEntry.Action.NS_QUEUE_CLEARED -> R.string.uel_ns_queue_cleared - this == UserEntry.Action.NS_SETTINGS_COPIED -> R.string.uel_ns_settings_copied - this == UserEntry.Action.ERROR_DIALOG_OK -> R.string.uel_error_dialog_ok - this == UserEntry.Action.ERROR_DIALOG_MUTE -> R.string.uel_error_dialog_mute - this == UserEntry.Action.ERROR_DIALOG_MUTE_5MIN -> R.string.uel_error_dialog_mute_5min - this == UserEntry.Action.OBJECTIVE_STARTED -> R.string.uel_objective_started - this == UserEntry.Action.OBJECTIVE_UNSTARTED -> R.string.uel_objective_unstarted - this == UserEntry.Action.OBJECTIVES_SKIPPED -> R.string.uel_objectives_skipped - this == UserEntry.Action.STAT_RESET -> R.string.uel_stat_reset - this == UserEntry.Action.DELETE_LOGS -> R.string.uel_delete_logs - this == UserEntry.Action.DELETE_FUTURE_TREATMENTS -> R.string.uel_delete_future_treatments - this == UserEntry.Action.EXPORT_SETTINGS -> R.string.uel_export_settings - this == UserEntry.Action.IMPORT_SETTINGS -> R.string.uel_import_settings - this == UserEntry.Action.RESET_DATABASES -> R.string.uel_reset_databases - this == UserEntry.Action.EXPORT_DATABASES -> R.string.uel_export_databases - this == UserEntry.Action.IMPORT_DATABASES -> R.string.uel_import_databases - this == UserEntry.Action.OTP_EXPORT -> R.string.uel_otp_export - this == UserEntry.Action.OTP_RESET -> R.string.uel_otp_reset - this == UserEntry.Action.SMS_BASAL -> R.string.uel_sms_basal - this == UserEntry.Action.SMS_BOLUS -> R.string.uel_sms_bolus - this == UserEntry.Action.SMS_CAL -> R.string.uel_sms_cal - this == UserEntry.Action.SMS_CARBS -> R.string.uel_sms_carbs - this == UserEntry.Action.SMS_EXTENDED_BOLUS -> R.string.uel_sms_extended_bolus - this == UserEntry.Action.SMS_LOOP_DISABLED -> R.string.uel_sms_loop_disabled - this == UserEntry.Action.SMS_LOOP_ENABLED -> R.string.uel_sms_loop_enabled - this == UserEntry.Action.SMS_LOOP_RESUME -> R.string.uel_sms_loop_resume - this == UserEntry.Action.SMS_LOOP_SUSPEND -> R.string.uel_sms_loop_suspend - this == UserEntry.Action.SMS_PROFILE -> R.string.uel_sms_profile - this == UserEntry.Action.SMS_PUMP_CONNECT -> R.string.uel_sms_pump_connect - this == UserEntry.Action.SMS_PUMP_DISCONNECT -> R.string.uel_sms_pump_disconnect - this == UserEntry.Action.SMS_SMS -> R.string.uel_sms_sms - this == UserEntry.Action.SMS_TT -> R.string.uel_sms_tt - this == UserEntry.Action.TT_DELETED_FROM_NS -> R.string.uel_tt_deleted_from_ns - this == UserEntry.Action.TT_FROM_NS -> R.string.uel_tt_from_ns - this == UserEntry.Action.TT_CANCELED_FROM_NS -> R.string.uel_tt_canceleted_from_ns - else -> R.string.uel_unknown + return when (this) { + UserEntry.Action.BOLUS -> R.string.uel_bolus + UserEntry.Action.BOLUS_WIZARD -> R.string.uel_bolus_wizard + UserEntry.Action.BOLUS_ADVISOR -> R.string.uel_bolus_advisor + UserEntry.Action.BOLUS_RECORD -> R.string.uel_bolus_record + UserEntry.Action.EXTENDED_BOLUS -> R.string.uel_extended_bolus + UserEntry.Action.SUPERBOLUS_TBR -> R.string.uel_superbolus_tbr + UserEntry.Action.CARBS -> R.string.uel_carbs + UserEntry.Action.EXTENDED_CARBS -> R.string.uel_extended_carbs + UserEntry.Action.TEMP_BASAL -> R.string.uel_temp_basal + UserEntry.Action.TT -> R.string.uel_tt + UserEntry.Action.TT_ACTIVITY -> R.string.uel_tt_activity + UserEntry.Action.TT_EATING_SOON -> R.string.uel_tt_eating_soon + UserEntry.Action.TT_HYPO -> R.string.uel_tt_hypo + UserEntry.Action.NEW_PROFILE -> R.string.uel_new_profile + UserEntry.Action.CLONE_PROFILE -> R.string.uel_clone_profile + UserEntry.Action.STORE_PROFILE -> R.string.uel_store_profile + UserEntry.Action.PROFILE_SWITCH -> R.string.uel_profile_switch + UserEntry.Action.PROFILE_SWITCH_CLONED -> R.string.uel_profile_switch_cloned + UserEntry.Action.CLOSED_LOOP_MODE -> R.string.uel_closed_loop_mode + UserEntry.Action.LGS_LOOP_MODE -> R.string.uel_lgs_loop_mode + UserEntry.Action.OPEN_LOOP_MODE -> R.string.uel_open_loop_mode + UserEntry.Action.LOOP_DISABLED -> R.string.uel_loop_disabled + UserEntry.Action.LOOP_ENABLED -> R.string.uel_loop_enabled + UserEntry.Action.RECONNECT -> R.string.uel_reconnect + UserEntry.Action.DISCONNECT_15M -> R.string.uel_disconnect_15m + UserEntry.Action.DISCONNECT_30M -> R.string.uel_disconnect_30m + UserEntry.Action.DISCONNECT_1H -> R.string.uel_disconnect_1h + UserEntry.Action.DISCONNECT_2H -> R.string.uel_disconnect_2h + UserEntry.Action.DISCONNECT_3H -> R.string.uel_disconnect_3h + UserEntry.Action.RESUME -> R.string.uel_resume + UserEntry.Action.SUSPEND_1H -> R.string.uel_suspend_1h + UserEntry.Action.SUSPEND_2H -> R.string.uel_suspend_2h + UserEntry.Action.SUSPEND_3H -> R.string.uel_suspend_3h + UserEntry.Action.SUSPEND_10H -> R.string.uel_suspend_10h + UserEntry.Action.HW_PUMP_ALLOWED -> R.string.uel_hw_pump_allowed + UserEntry.Action.CLEAR_PAIRING_KEYS -> R.string.uel_clear_pairing_keys + UserEntry.Action.ACCEPTS_TEMP_BASAL -> R.string.uel_accepts_temp_basal + UserEntry.Action.CANCEL_TEMP_BASAL -> R.string.uel_cancel_temp_basal + UserEntry.Action.CANCEL_EXTENDED_BOLUS -> R.string.uel_cancel_extended_bolus + UserEntry.Action.CANCEL_TT -> R.string.uel_cancel_tt + UserEntry.Action.CAREPORTAL -> R.string.uel_careportal + UserEntry.Action.CALIBRATION -> R.string.uel_calibration + UserEntry.Action.INSULIN_CHANGE -> R.string.uel_insulin_change + UserEntry.Action.PRIME_BOLUS -> R.string.uel_prime_bolus + UserEntry.Action.SITE_CHANGE -> R.string.uel_site_change + UserEntry.Action.TREATMENT -> R.string.uel_treatment + UserEntry.Action.CAREPORTAL_NS_REFRESH -> R.string.uel_careportal_ns_refresh + UserEntry.Action.PROFILE_SWITCH_NS_REFRESH -> R.string.uel_profile_switch_ns_refresh + UserEntry.Action.TREATMENTS_NS_REFRESH -> R.string.uel_treatments_ns_refresh + UserEntry.Action.TT_NS_REFRESH -> R.string.uel_tt_ns_refresh + UserEntry.Action.AUTOMATION_REMOVED -> R.string.uel_automation_removed + UserEntry.Action.BG_REMOVED -> R.string.uel_bg_removed + UserEntry.Action.CAREPORTAL_REMOVED -> R.string.uel_careportal_removed + UserEntry.Action.EXTENDED_BOLUS_REMOVED -> R.string.uel_extended_bolus_removed + UserEntry.Action.FOOD_REMOVED -> R.string.uel_food_removed + UserEntry.Action.PROFILE_REMOVED -> R.string.uel_profile_removed + UserEntry.Action.PROFILE_SWITCH_REMOVED -> R.string.uel_profile_switch_removed + UserEntry.Action.RESTART_EVENTS_REMOVED -> R.string.uel_restart_events_removed + UserEntry.Action.TREATMENT_REMOVED -> R.string.uel_treatment_removed + UserEntry.Action.TT_REMOVED -> R.string.uel_tt_removed + UserEntry.Action.NS_PAUSED -> R.string.uel_ns_paused + UserEntry.Action.NS_QUEUE_CLEARED -> R.string.uel_ns_queue_cleared + UserEntry.Action.NS_SETTINGS_COPIED -> R.string.uel_ns_settings_copied + UserEntry.Action.ERROR_DIALOG_OK -> R.string.uel_error_dialog_ok + UserEntry.Action.ERROR_DIALOG_MUTE -> R.string.uel_error_dialog_mute + UserEntry.Action.ERROR_DIALOG_MUTE_5MIN -> R.string.uel_error_dialog_mute_5min + UserEntry.Action.OBJECTIVE_STARTED -> R.string.uel_objective_started + UserEntry.Action.OBJECTIVE_UNSTARTED -> R.string.uel_objective_unstarted + UserEntry.Action.OBJECTIVES_SKIPPED -> R.string.uel_objectives_skipped + UserEntry.Action.STAT_RESET -> R.string.uel_stat_reset + UserEntry.Action.DELETE_LOGS -> R.string.uel_delete_logs + UserEntry.Action.DELETE_FUTURE_TREATMENTS -> R.string.uel_delete_future_treatments + UserEntry.Action.EXPORT_SETTINGS -> R.string.uel_export_settings + UserEntry.Action.IMPORT_SETTINGS -> R.string.uel_import_settings + UserEntry.Action.RESET_DATABASES -> R.string.uel_reset_databases + UserEntry.Action.EXPORT_DATABASES -> R.string.uel_export_databases + UserEntry.Action.IMPORT_DATABASES -> R.string.uel_import_databases + UserEntry.Action.OTP_EXPORT -> R.string.uel_otp_export + UserEntry.Action.OTP_RESET -> R.string.uel_otp_reset + UserEntry.Action.SMS_BASAL -> R.string.uel_sms_basal + UserEntry.Action.SMS_BOLUS -> R.string.uel_sms_bolus + UserEntry.Action.SMS_CAL -> R.string.uel_sms_cal + UserEntry.Action.SMS_CARBS -> R.string.uel_sms_carbs + UserEntry.Action.SMS_EXTENDED_BOLUS -> R.string.uel_sms_extended_bolus + UserEntry.Action.SMS_LOOP_DISABLED -> R.string.uel_sms_loop_disabled + UserEntry.Action.SMS_LOOP_ENABLED -> R.string.uel_sms_loop_enabled + UserEntry.Action.SMS_LOOP_RESUME -> R.string.uel_sms_loop_resume + UserEntry.Action.SMS_LOOP_SUSPEND -> R.string.uel_sms_loop_suspend + UserEntry.Action.SMS_PROFILE -> R.string.uel_sms_profile + UserEntry.Action.SMS_PUMP_CONNECT -> R.string.uel_sms_pump_connect + UserEntry.Action.SMS_PUMP_DISCONNECT -> R.string.uel_sms_pump_disconnect + UserEntry.Action.SMS_SMS -> R.string.uel_sms_sms + UserEntry.Action.SMS_TT -> R.string.uel_sms_tt + UserEntry.Action.TT_DELETED_FROM_NS -> R.string.uel_tt_deleted_from_ns + UserEntry.Action.TT_FROM_NS -> R.string.uel_tt_from_ns + UserEntry.Action.TT_CANCELED_FROM_NS -> R.string.uel_tt_canceleted_from_ns + else -> R.string.uel_unknown } } +fun UserEntry.Action.colorId(): Int { + return when (this) { + UserEntry.Action.BOLUS -> R.color.iob + UserEntry.Action.BOLUS_WIZARD -> R.color.iob + UserEntry.Action.BOLUS_ADVISOR -> R.color.iob + UserEntry.Action.BOLUS_RECORD -> R.color.iob + UserEntry.Action.EXTENDED_BOLUS -> R.color.extendedBolus + UserEntry.Action.SUPERBOLUS_TBR -> R.color.carbs + UserEntry.Action.CARBS -> R.color.carbs + UserEntry.Action.EXTENDED_CARBS -> R.color.carbs + UserEntry.Action.TEMP_BASAL -> R.color.basal + UserEntry.Action.TT -> R.color.tempTargetConfirmation + UserEntry.Action.TT_ACTIVITY -> R.color.tempTargetConfirmation + UserEntry.Action.TT_EATING_SOON -> R.color.tempTargetConfirmation + UserEntry.Action.TT_HYPO -> R.color.tempTargetConfirmation + UserEntry.Action.NEW_PROFILE -> R.color.white + UserEntry.Action.CLONE_PROFILE -> R.color.white + UserEntry.Action.STORE_PROFILE -> R.color.white + UserEntry.Action.PROFILE_SWITCH -> R.color.white + UserEntry.Action.PROFILE_SWITCH_CLONED -> R.color.white + UserEntry.Action.CLOSED_LOOP_MODE -> R.color.loopClosed + UserEntry.Action.LGS_LOOP_MODE -> R.color.loopClosed + UserEntry.Action.OPEN_LOOP_MODE -> R.color.loopOpened + UserEntry.Action.LOOP_DISABLED -> R.color.loopDisabled + UserEntry.Action.LOOP_ENABLED -> R.color.loopClosed + UserEntry.Action.RECONNECT -> R.color.loopDisconnected + UserEntry.Action.DISCONNECT_15M -> R.color.loopDisconnected + UserEntry.Action.DISCONNECT_30M -> R.color.loopDisconnected + UserEntry.Action.DISCONNECT_1H -> R.color.loopDisconnected + UserEntry.Action.DISCONNECT_2H -> R.color.loopDisconnected + UserEntry.Action.DISCONNECT_3H -> R.color.loopDisconnected + UserEntry.Action.RESUME -> R.color.loopClosed + UserEntry.Action.SUSPEND_1H -> R.color.loopSuspended + UserEntry.Action.SUSPEND_2H -> R.color.loopSuspended + UserEntry.Action.SUSPEND_3H -> R.color.loopSuspended + UserEntry.Action.SUSPEND_10H -> R.color.loopSuspended + UserEntry.Action.HW_PUMP_ALLOWED -> R.color.defaulttext + UserEntry.Action.CLEAR_PAIRING_KEYS -> R.color.defaulttext + UserEntry.Action.ACCEPTS_TEMP_BASAL -> R.color.basal + UserEntry.Action.CANCEL_TEMP_BASAL -> R.color.basal + UserEntry.Action.CANCEL_EXTENDED_BOLUS -> R.color.extendedBolus + UserEntry.Action.CANCEL_TT -> R.color.tempTargetConfirmation + UserEntry.Action.CAREPORTAL -> R.color.notificationAnnouncement + UserEntry.Action.CALIBRATION -> R.color.calibration + UserEntry.Action.INSULIN_CHANGE -> R.color.iob + UserEntry.Action.PRIME_BOLUS -> R.color.defaulttext + UserEntry.Action.SITE_CHANGE -> R.color.defaulttext + UserEntry.Action.TREATMENT -> R.color.defaulttext + UserEntry.Action.CAREPORTAL_NS_REFRESH -> R.color.notificationAnnouncement + UserEntry.Action.PROFILE_SWITCH_NS_REFRESH -> R.color.white + UserEntry.Action.TREATMENTS_NS_REFRESH -> R.color.defaulttext + UserEntry.Action.TT_NS_REFRESH -> R.color.tempTargetConfirmation + UserEntry.Action.AUTOMATION_REMOVED -> R.color.defaulttext + UserEntry.Action.BG_REMOVED -> R.color.calibration + UserEntry.Action.CAREPORTAL_REMOVED -> R.color.notificationAnnouncement + UserEntry.Action.EXTENDED_BOLUS_REMOVED -> R.color.extendedBolus + UserEntry.Action.FOOD_REMOVED -> R.color.carbs + UserEntry.Action.PROFILE_REMOVED -> R.color.white + UserEntry.Action.PROFILE_SWITCH_REMOVED -> R.color.white + UserEntry.Action.RESTART_EVENTS_REMOVED -> R.color.defaulttext + UserEntry.Action.TREATMENT_REMOVED -> R.color.defaulttext + UserEntry.Action.TT_REMOVED -> R.color.tempTargetConfirmation + UserEntry.Action.NS_PAUSED -> R.color.defaulttext + UserEntry.Action.NS_QUEUE_CLEARED -> R.color.defaulttext + UserEntry.Action.NS_SETTINGS_COPIED -> R.color.defaulttext + UserEntry.Action.ERROR_DIALOG_OK -> R.color.defaulttext + UserEntry.Action.ERROR_DIALOG_MUTE -> R.color.defaulttext + UserEntry.Action.ERROR_DIALOG_MUTE_5MIN -> R.color.defaulttext + UserEntry.Action.OBJECTIVE_STARTED -> R.color.defaulttext + UserEntry.Action.OBJECTIVE_UNSTARTED -> R.color.defaulttext + UserEntry.Action.OBJECTIVES_SKIPPED -> R.color.defaulttext + UserEntry.Action.STAT_RESET -> R.color.defaulttext + UserEntry.Action.DELETE_LOGS -> R.color.defaulttext + UserEntry.Action.DELETE_FUTURE_TREATMENTS -> R.color.defaulttext + UserEntry.Action.EXPORT_SETTINGS -> R.color.defaulttext + UserEntry.Action.IMPORT_SETTINGS -> R.color.defaulttext + UserEntry.Action.RESET_DATABASES -> R.color.defaulttext + UserEntry.Action.EXPORT_DATABASES -> R.color.defaulttext + UserEntry.Action.IMPORT_DATABASES -> R.color.defaulttext + UserEntry.Action.OTP_EXPORT -> R.color.defaulttext + UserEntry.Action.OTP_RESET -> R.color.defaulttext + UserEntry.Action.SMS_BASAL -> R.color.basal + UserEntry.Action.SMS_BOLUS -> R.color.iob + UserEntry.Action.SMS_CAL -> R.color.calibration + UserEntry.Action.SMS_CARBS -> R.color.carbs + UserEntry.Action.SMS_EXTENDED_BOLUS -> R.color.extendedBolus + UserEntry.Action.SMS_LOOP_DISABLED -> R.color.loopDisabled + UserEntry.Action.SMS_LOOP_ENABLED -> R.color.loopClosed + UserEntry.Action.SMS_LOOP_RESUME -> R.color.loopClosed + UserEntry.Action.SMS_LOOP_SUSPEND -> R.color.loopSuspended + UserEntry.Action.SMS_PROFILE -> R.color.white + UserEntry.Action.SMS_PUMP_CONNECT -> R.color.loopDisconnected + UserEntry.Action.SMS_PUMP_DISCONNECT -> R.color.loopDisconnected + UserEntry.Action.SMS_SMS -> R.color.defaulttext + UserEntry.Action.SMS_TT -> R.color.tempTargetConfirmation + UserEntry.Action.TT_DELETED_FROM_NS -> R.color.tempTargetConfirmation + UserEntry.Action.TT_FROM_NS -> R.color.tempTargetConfirmation + UserEntry.Action.TT_CANCELED_FROM_NS -> R.color.tempTargetConfirmation + else -> R.color.defaulttext + } +} fun UserEntry.Units.stringId(): Int { return when { @@ -121,17 +222,3 @@ fun UserEntry.Units.stringId(): Int { else -> 0 } } - -fun UserEntry.ValueWithUnit.toStringWithUnit(): String { - /* need injection to maje convertion - return when (this.unit) { - UserEntry.Units.Timestamp -> dateUtil.dateAndTimeAndSecondsString(this.lValue) - UserEntry.Units.CPEvent -> translator.translate(this.sValue) - UserEntry.Units.R_String -> resourceHelper.gs(this.iValue) - UserEntry.Units.Mg_Dl -> DecimalFormatter.to0Decimal(this.dValue) + resourceHelper.gs(UserEntry.Units.Mg_Dl.stringId()) - UserEntry.Units.Mmol_L -> DecimalFormatter.to1Decimal(this.dValue) + resourceHelper.gs(UserEntry.Units.Mmol_L.stringId()) - UserEntry.Units.G -> DecimalFormatter.to0Decimal(this.dValue) + resourceHelper.gs(UserEntry.Units.G.stringId()) - else -> if (!this.value().equals(0) && !this.value().equals("")) { v.value().toString() + if (!this.unit.stringId().equals(0)) resourceHelper.gs(this.unit.stringId()) else "" } else "" - } */ - return "" -} \ No newline at end of file diff --git a/core/src/main/res/drawable/ic_cp_bgcheck.xml b/core/src/main/res/drawable/ic_cp_bgcheck.xml index ecde2d118b..76a9bbe22f 100644 --- a/core/src/main/res/drawable/ic_cp_bgcheck.xml +++ b/core/src/main/res/drawable/ic_cp_bgcheck.xml @@ -5,11 +5,11 @@ android:viewportHeight="24"> + android:fillColor="@color/calibration"/> + android:fillColor="@color/calibration"/> + android:fillColor="@color/calibration"/> diff --git a/core/src/main/res/values/colors.xml b/core/src/main/res/values/colors.xml index 4685b9e98b..694164b776 100644 --- a/core/src/main/res/values/colors.xml +++ b/core/src/main/res/values/colors.xml @@ -25,22 +25,34 @@ #FFFF5555 #FF000000 #FFFF5555 + #BBBBBB #C803A9F4 #505050 + #00ffff + + + + #939393 + #00C03E + #FFFF13 + #4983D7 + #FF1313 #00FF00 #FF0000 #FFFF00 #1e88e5 + #67DFE8 #1ea3e5 #FFFB8C00 #FFFB8C00 #c9bd60 #00d2d2 #ffffff + #E83258 #5a595b #D000FF00 From 177bf214fd2a459890b44278ffcdadbedc88c223 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sat, 6 Mar 2021 16:14:44 +0100 Subject: [PATCH 24/66] xml export initialization --- .../general/maintenance/ImportExportPrefs.kt | 47 +++++++++++++++++++ .../fragments/TreatmentsUserEntryFragment.kt | 14 ++++++ .../layout/treatments_user_entry_fragment.xml | 9 ++++ .../interfaces/ImportExportPrefsInterface.kt | 3 ++ .../maintenance/PrefFileListProvider.kt | 5 ++ .../utils/extensions/UserEntryExt.kt | 1 + core/src/main/res/values/strings.xml | 1 + .../androidaps/database/entities/UserEntry.kt | 1 + 8 files changed, 81 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt index c02f85658c..5b6923442f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt @@ -15,6 +15,7 @@ import info.nightscout.androidaps.BuildConfig import info.nightscout.androidaps.R import info.nightscout.androidaps.activities.DaggerAppCompatActivityWithResult import info.nightscout.androidaps.activities.PreferencesActivity +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.events.EventAppExit import info.nightscout.androidaps.interfaces.ConfigInterface @@ -35,6 +36,7 @@ import info.nightscout.androidaps.utils.buildHelper.BuildHelper import info.nightscout.androidaps.utils.protection.PasswordCheck import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.sharedPreferences.SP +import io.reactivex.Single import java.io.File import java.io.FileNotFoundException import java.io.IOException @@ -355,4 +357,49 @@ class ImportExportPrefs @Inject constructor( exitProcess(0) }) } + + + override fun exportUserEntriesXml(activity: FragmentActivity, listEntries: Single>) { + val entries = listEntries.blockingGet() + prefFileList.ensureExportDirExists() + val legacyFile = prefFileList.legacyFile() + val newFile = prefFileList.newExportXmlFile() +/* + askToConfirmExport(activity, newFile) { password -> + try { + val entries: MutableMap = mutableMapOf() + for ((key, value) in sp.getAll()) { + entries[key] = value.toString() + } + + val prefs = Prefs(entries, prepareMetadata(activity)) + + if (BuildConfig.DEBUG && buildHelper.isEngineeringMode()) { + classicPrefsFormat.savePreferences(legacyFile, prefs) + } + encryptedPrefsFormat.savePreferences(newFile, prefs, password) + + ToastUtils.okToast(activity, resourceHelper.gs(R.string.exported)) + } catch (e: FileNotFoundException) { + ToastUtils.errorToast(activity, resourceHelper.gs(R.string.filenotfound) + " " + newFile) + log.error(LTag.CORE, "Unhandled exception", e) + } catch (e: IOException) { + ToastUtils.errorToast(activity, e.message) + log.error(LTag.CORE, "Unhandled exception", e) + } catch (e: PrefFileNotFoundError) { + ToastUtils.Long.errorToast(activity, resourceHelper.gs(R.string.preferences_export_canceled) + + "\n\n" + resourceHelper.gs(R.string.filenotfound) + + ": " + e.message + + "\n\n" + resourceHelper.gs(R.string.needstoragepermission)) + log.error(LTag.CORE, "File system exception", e) + } catch (e: PrefIOError) { + ToastUtils.Long.errorToast(activity, resourceHelper.gs(R.string.preferences_export_canceled) + + "\n\n" + resourceHelper.gs(R.string.needstoragepermission) + + ": " + e.message) + log.error(LTag.CORE, "File system exception", e) + } + } + + */ + } } \ No newline at end of file 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 b0a1a60c3d..5bc75ec354 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 @@ -14,12 +14,16 @@ import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.database.entities.UserEntry.* import info.nightscout.androidaps.databinding.TreatmentsUserEntryFragmentBinding import info.nightscout.androidaps.databinding.TreatmentsUserEntryItemBinding +import info.nightscout.androidaps.interfaces.ImportExportPrefsInterface import info.nightscout.androidaps.interfaces.ProfileFunction +import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper +import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DecimalFormatter import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.Translator +import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.extensions.* import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.rx.AapsSchedulers @@ -37,6 +41,8 @@ class TreatmentsUserEntryFragment : DaggerFragment() { @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var translator: Translator + @Inject lateinit var importExportPrefs: ImportExportPrefsInterface + @Inject lateinit var uel: UserEntryLogger private val disposable = CompositeDisposable() @@ -53,6 +59,14 @@ class TreatmentsUserEntryFragment : DaggerFragment() { super.onViewCreated(view, savedInstanceState) binding.recyclerview.setHasFixedSize(true) binding.recyclerview.layoutManager = LinearLayoutManager(view.context) + binding.ueExportToXml.setOnClickListener { + activity?.let { activity -> + OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.ue_export_to_xml) + "?") { + uel.log(Action.TREATMENTS_NS_REFRESH) + importExportPrefs.exportUserEntriesXml(activity, repository.getAllUserEntries()) + } + } + } disposable += repository .getAllUserEntries() diff --git a/app/src/main/res/layout/treatments_user_entry_fragment.xml b/app/src/main/res/layout/treatments_user_entry_fragment.xml index 333de75943..dd8ba9f295 100644 --- a/app/src/main/res/layout/treatments_user_entry_fragment.xml +++ b/app/src/main/res/layout/treatments_user_entry_fragment.xml @@ -5,6 +5,15 @@ android:orientation="vertical" tools:context=".plugins.treatments.fragments.TreatmentsUserEntryFragment"> + + >) } \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/PrefFileListProvider.kt b/core/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/PrefFileListProvider.kt index 167446fd7e..1a86f59479 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/PrefFileListProvider.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/PrefFileListProvider.kt @@ -100,6 +100,11 @@ class PrefFileListProvider @Inject constructor( return File(aapsPath, timeLocal + "_" + config.FLAVOR + ".json") } + fun newExportXmlFile(): File { + val timeLocal = LocalDateTime.now().toString(DateTimeFormat.forPattern("yyyy-MM-dd'_'HHmmss")) + return File(aapsPath, timeLocal + "_UserEntry.xml") + } + // check metadata for known issues, change their status and add info with explanations fun checkMetadata(metadata: Map): Map { val meta = metadata.toMutableMap() diff --git a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt index 5ab9139bc8..4b02f8e21d 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt @@ -102,6 +102,7 @@ fun UserEntry.Action.stringId(): Int { UserEntry.Action.TT_DELETED_FROM_NS -> R.string.uel_tt_deleted_from_ns UserEntry.Action.TT_FROM_NS -> R.string.uel_tt_from_ns UserEntry.Action.TT_CANCELED_FROM_NS -> R.string.uel_tt_canceleted_from_ns + UserEntry.Action.UE_EXPORT_TO_XML -> R.string.ue_export_to_xml else -> R.string.uel_unknown } } diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 13081a0743..4643c840c4 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -486,6 +486,7 @@ TT CANCELED FROM NS UNKNOWN Formated string + Export User Entries to xml %1$d day 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 73adb845d9..db47fec809 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 @@ -115,6 +115,7 @@ data class UserEntry( @SerializedName("TT_DELETED_FROM_NS") TT_DELETED_FROM_NS, @SerializedName("TT_FROM_NS") TT_FROM_NS, @SerializedName("TT_CANCELED_FROM_NS") TT_CANCELED_FROM_NS, + @SerializedName("UE_EXPORT_TO_XML") UE_EXPORT_TO_XML, @SerializedName("UNKNOWN") UNKNOWN ; From 5d827d123e74621ae8b37c0bd03bef2a710e1d0c Mon Sep 17 00:00:00 2001 From: Philoul Date: Sat, 6 Mar 2021 17:42:41 +0100 Subject: [PATCH 25/66] 8 ColorGroup added for UI + Fix Carbs in WizardDialog --- .../androidaps/dialogs/CarbsDialog.kt | 6 +- .../fragments/TreatmentsUserEntryFragment.kt | 4 +- .../utils/extensions/UserEntryExt.kt | 422 +++++++++--------- .../androidaps/database/entities/UserEntry.kt | 209 +++++---- 4 files changed, 329 insertions(+), 312 deletions(-) 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 e7d6698819..a1e78070f3 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt @@ -272,12 +272,12 @@ class CarbsDialog : DialogFragmentWithDate() { if (carbsAfterConstraints > 0) { if (duration == 0) { if (eventTimeChanged) - uel.log(Action.CARBS, notes, ValueWithUnit(eventTime, Units.Timestamp), ValueWithUnit(carbsAfterConstraints.toDouble(), Units.G), ValueWithUnit(timeOffset, Units.M)) + uel.log(Action.CARBS, notes, ValueWithUnit(eventTime, Units.Timestamp), ValueWithUnit(carbsAfterConstraints, Units.G), ValueWithUnit(timeOffset, Units.M)) else - uel.log(Action.CARBS, notes, ValueWithUnit(carbsAfterConstraints.toDouble(), Units.G), ValueWithUnit(timeOffset, Units.M)) + uel.log(Action.CARBS, notes, ValueWithUnit(carbsAfterConstraints, Units.G), ValueWithUnit(timeOffset, Units.M)) carbsGenerator.createCarb(carbsAfterConstraints, time, CareportalEvent.CARBCORRECTION, notes) } else { - uel.log(Action.CARBS, notes, ValueWithUnit(carbsAfterConstraints.toDouble(), Units.G), ValueWithUnit(timeOffset,Units.M), ValueWithUnit(duration, Units.H)) + uel.log(Action.CARBS, notes, ValueWithUnit(carbsAfterConstraints, Units.G), ValueWithUnit(timeOffset,Units.M), ValueWithUnit(duration, Units.H)) carbsGenerator.generateCarbs(carbsAfterConstraints, time, duration, notes) nsUpload.uploadEvent(CareportalEvent.NOTE, DateUtil.now() - 2000, resourceHelper.gs(R.string.generated_ecarbs_note, carbsAfterConstraints, duration, timeOffset)) } 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 b0a1a60c3d..e60e0aeaf9 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 @@ -78,7 +78,7 @@ class TreatmentsUserEntryFragment : DaggerFragment() { val current = entries[position] holder.binding.date.text = dateUtil.dateAndTimeAndSecondsString(current.timestamp) holder.binding.action.text = resourceHelper.gs(current.action.stringId()) - holder.binding.action.setTextColor(resourceHelper.gc(current.action.colorId())) + holder.binding.action.setTextColor(resourceHelper.gc(current.action.colorGroup.colorId())) if (current.s != "") holder.binding.s.text = current.s else holder.binding.s.visibility = View.GONE //holder.binding.s.text = current.toString() //for debug var valuesWithUnitString = "" @@ -103,7 +103,7 @@ class TreatmentsUserEntryFragment : DaggerFragment() { } Units.Mg_Dl -> valuesWithUnitString += if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue) + resourceHelper.gs(Units.Mg_Dl.stringId()) + separator else DecimalFormatter.to1Decimal(v.dValue/Constants.MMOLL_TO_MGDL) + resourceHelper.gs(Units.Mmol_L.stringId()) + separator Units.Mmol_L -> valuesWithUnitString += if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue*Constants.MMOLL_TO_MGDL) + resourceHelper.gs(Units.Mg_Dl.stringId()) + separator else DecimalFormatter.to1Decimal(v.dValue) + resourceHelper.gs(Units.Mmol_L.stringId()) + separator - Units.G -> valuesWithUnitString += DecimalFormatter.to0Decimal(v.dValue) + resourceHelper.gs(Units.G.stringId()) + separator + Units.G -> valuesWithUnitString += v.iValue.toString() + resourceHelper.gs(Units.G.stringId()) + separator Units.U_H -> valuesWithUnitString += DecimalFormatter.to2Decimal(v.dValue) + resourceHelper.gs(Units.U_H.stringId()) + separator else -> valuesWithUnitString += if (v.dValue != 0.0 || v.iValue != 0 || v.sValue != "") { v.value().toString() + if (!v.unit.stringId().equals(0)) resourceHelper.gs(v.unit.stringId()) + separator else separator } else "" } diff --git a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt index 5ab9139bc8..a110d68827 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt @@ -1,224 +1,230 @@ package info.nightscout.androidaps.utils.extensions -import com.google.gson.annotations.SerializedName import info.nightscout.androidaps.core.R -import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* -fun UserEntry.Action.stringId(): Int { +fun Action.stringId(): Int { return when (this) { - UserEntry.Action.BOLUS -> R.string.uel_bolus - UserEntry.Action.BOLUS_WIZARD -> R.string.uel_bolus_wizard - UserEntry.Action.BOLUS_ADVISOR -> R.string.uel_bolus_advisor - UserEntry.Action.BOLUS_RECORD -> R.string.uel_bolus_record - UserEntry.Action.EXTENDED_BOLUS -> R.string.uel_extended_bolus - UserEntry.Action.SUPERBOLUS_TBR -> R.string.uel_superbolus_tbr - UserEntry.Action.CARBS -> R.string.uel_carbs - UserEntry.Action.EXTENDED_CARBS -> R.string.uel_extended_carbs - UserEntry.Action.TEMP_BASAL -> R.string.uel_temp_basal - UserEntry.Action.TT -> R.string.uel_tt - UserEntry.Action.TT_ACTIVITY -> R.string.uel_tt_activity - UserEntry.Action.TT_EATING_SOON -> R.string.uel_tt_eating_soon - UserEntry.Action.TT_HYPO -> R.string.uel_tt_hypo - UserEntry.Action.NEW_PROFILE -> R.string.uel_new_profile - UserEntry.Action.CLONE_PROFILE -> R.string.uel_clone_profile - UserEntry.Action.STORE_PROFILE -> R.string.uel_store_profile - UserEntry.Action.PROFILE_SWITCH -> R.string.uel_profile_switch - UserEntry.Action.PROFILE_SWITCH_CLONED -> R.string.uel_profile_switch_cloned - UserEntry.Action.CLOSED_LOOP_MODE -> R.string.uel_closed_loop_mode - UserEntry.Action.LGS_LOOP_MODE -> R.string.uel_lgs_loop_mode - UserEntry.Action.OPEN_LOOP_MODE -> R.string.uel_open_loop_mode - UserEntry.Action.LOOP_DISABLED -> R.string.uel_loop_disabled - UserEntry.Action.LOOP_ENABLED -> R.string.uel_loop_enabled - UserEntry.Action.RECONNECT -> R.string.uel_reconnect - UserEntry.Action.DISCONNECT_15M -> R.string.uel_disconnect_15m - UserEntry.Action.DISCONNECT_30M -> R.string.uel_disconnect_30m - UserEntry.Action.DISCONNECT_1H -> R.string.uel_disconnect_1h - UserEntry.Action.DISCONNECT_2H -> R.string.uel_disconnect_2h - UserEntry.Action.DISCONNECT_3H -> R.string.uel_disconnect_3h - UserEntry.Action.RESUME -> R.string.uel_resume - UserEntry.Action.SUSPEND_1H -> R.string.uel_suspend_1h - UserEntry.Action.SUSPEND_2H -> R.string.uel_suspend_2h - UserEntry.Action.SUSPEND_3H -> R.string.uel_suspend_3h - UserEntry.Action.SUSPEND_10H -> R.string.uel_suspend_10h - UserEntry.Action.HW_PUMP_ALLOWED -> R.string.uel_hw_pump_allowed - UserEntry.Action.CLEAR_PAIRING_KEYS -> R.string.uel_clear_pairing_keys - UserEntry.Action.ACCEPTS_TEMP_BASAL -> R.string.uel_accepts_temp_basal - UserEntry.Action.CANCEL_TEMP_BASAL -> R.string.uel_cancel_temp_basal - UserEntry.Action.CANCEL_EXTENDED_BOLUS -> R.string.uel_cancel_extended_bolus - UserEntry.Action.CANCEL_TT -> R.string.uel_cancel_tt - UserEntry.Action.CAREPORTAL -> R.string.uel_careportal - UserEntry.Action.CALIBRATION -> R.string.uel_calibration - UserEntry.Action.INSULIN_CHANGE -> R.string.uel_insulin_change - UserEntry.Action.PRIME_BOLUS -> R.string.uel_prime_bolus - UserEntry.Action.SITE_CHANGE -> R.string.uel_site_change - UserEntry.Action.TREATMENT -> R.string.uel_treatment - UserEntry.Action.CAREPORTAL_NS_REFRESH -> R.string.uel_careportal_ns_refresh - UserEntry.Action.PROFILE_SWITCH_NS_REFRESH -> R.string.uel_profile_switch_ns_refresh - UserEntry.Action.TREATMENTS_NS_REFRESH -> R.string.uel_treatments_ns_refresh - UserEntry.Action.TT_NS_REFRESH -> R.string.uel_tt_ns_refresh - UserEntry.Action.AUTOMATION_REMOVED -> R.string.uel_automation_removed - UserEntry.Action.BG_REMOVED -> R.string.uel_bg_removed - UserEntry.Action.CAREPORTAL_REMOVED -> R.string.uel_careportal_removed - UserEntry.Action.EXTENDED_BOLUS_REMOVED -> R.string.uel_extended_bolus_removed - UserEntry.Action.FOOD_REMOVED -> R.string.uel_food_removed - UserEntry.Action.PROFILE_REMOVED -> R.string.uel_profile_removed - UserEntry.Action.PROFILE_SWITCH_REMOVED -> R.string.uel_profile_switch_removed - UserEntry.Action.RESTART_EVENTS_REMOVED -> R.string.uel_restart_events_removed - UserEntry.Action.TREATMENT_REMOVED -> R.string.uel_treatment_removed - UserEntry.Action.TT_REMOVED -> R.string.uel_tt_removed - UserEntry.Action.NS_PAUSED -> R.string.uel_ns_paused - UserEntry.Action.NS_QUEUE_CLEARED -> R.string.uel_ns_queue_cleared - UserEntry.Action.NS_SETTINGS_COPIED -> R.string.uel_ns_settings_copied - UserEntry.Action.ERROR_DIALOG_OK -> R.string.uel_error_dialog_ok - UserEntry.Action.ERROR_DIALOG_MUTE -> R.string.uel_error_dialog_mute - UserEntry.Action.ERROR_DIALOG_MUTE_5MIN -> R.string.uel_error_dialog_mute_5min - UserEntry.Action.OBJECTIVE_STARTED -> R.string.uel_objective_started - UserEntry.Action.OBJECTIVE_UNSTARTED -> R.string.uel_objective_unstarted - UserEntry.Action.OBJECTIVES_SKIPPED -> R.string.uel_objectives_skipped - UserEntry.Action.STAT_RESET -> R.string.uel_stat_reset - UserEntry.Action.DELETE_LOGS -> R.string.uel_delete_logs - UserEntry.Action.DELETE_FUTURE_TREATMENTS -> R.string.uel_delete_future_treatments - UserEntry.Action.EXPORT_SETTINGS -> R.string.uel_export_settings - UserEntry.Action.IMPORT_SETTINGS -> R.string.uel_import_settings - UserEntry.Action.RESET_DATABASES -> R.string.uel_reset_databases - UserEntry.Action.EXPORT_DATABASES -> R.string.uel_export_databases - UserEntry.Action.IMPORT_DATABASES -> R.string.uel_import_databases - UserEntry.Action.OTP_EXPORT -> R.string.uel_otp_export - UserEntry.Action.OTP_RESET -> R.string.uel_otp_reset - UserEntry.Action.SMS_BASAL -> R.string.uel_sms_basal - UserEntry.Action.SMS_BOLUS -> R.string.uel_sms_bolus - UserEntry.Action.SMS_CAL -> R.string.uel_sms_cal - UserEntry.Action.SMS_CARBS -> R.string.uel_sms_carbs - UserEntry.Action.SMS_EXTENDED_BOLUS -> R.string.uel_sms_extended_bolus - UserEntry.Action.SMS_LOOP_DISABLED -> R.string.uel_sms_loop_disabled - UserEntry.Action.SMS_LOOP_ENABLED -> R.string.uel_sms_loop_enabled - UserEntry.Action.SMS_LOOP_RESUME -> R.string.uel_sms_loop_resume - UserEntry.Action.SMS_LOOP_SUSPEND -> R.string.uel_sms_loop_suspend - UserEntry.Action.SMS_PROFILE -> R.string.uel_sms_profile - UserEntry.Action.SMS_PUMP_CONNECT -> R.string.uel_sms_pump_connect - UserEntry.Action.SMS_PUMP_DISCONNECT -> R.string.uel_sms_pump_disconnect - UserEntry.Action.SMS_SMS -> R.string.uel_sms_sms - UserEntry.Action.SMS_TT -> R.string.uel_sms_tt - UserEntry.Action.TT_DELETED_FROM_NS -> R.string.uel_tt_deleted_from_ns - UserEntry.Action.TT_FROM_NS -> R.string.uel_tt_from_ns - UserEntry.Action.TT_CANCELED_FROM_NS -> R.string.uel_tt_canceleted_from_ns + Action.BOLUS -> R.string.uel_bolus + Action.BOLUS_WIZARD -> R.string.uel_bolus_wizard + Action.BOLUS_ADVISOR -> R.string.uel_bolus_advisor + Action.BOLUS_RECORD -> R.string.uel_bolus_record + Action.EXTENDED_BOLUS -> R.string.uel_extended_bolus + Action.SUPERBOLUS_TBR -> R.string.uel_superbolus_tbr + Action.CARBS -> R.string.uel_carbs + Action.EXTENDED_CARBS -> R.string.uel_extended_carbs + Action.TEMP_BASAL -> R.string.uel_temp_basal + Action.TT -> R.string.uel_tt + Action.TT_ACTIVITY -> R.string.uel_tt_activity + Action.TT_EATING_SOON -> R.string.uel_tt_eating_soon + Action.TT_HYPO -> R.string.uel_tt_hypo + Action.NEW_PROFILE -> R.string.uel_new_profile + Action.CLONE_PROFILE -> R.string.uel_clone_profile + Action.STORE_PROFILE -> R.string.uel_store_profile + Action.PROFILE_SWITCH -> R.string.uel_profile_switch + Action.PROFILE_SWITCH_CLONED -> R.string.uel_profile_switch_cloned + Action.CLOSED_LOOP_MODE -> R.string.uel_closed_loop_mode + Action.LGS_LOOP_MODE -> R.string.uel_lgs_loop_mode + Action.OPEN_LOOP_MODE -> R.string.uel_open_loop_mode + Action.LOOP_DISABLED -> R.string.uel_loop_disabled + Action.LOOP_ENABLED -> R.string.uel_loop_enabled + Action.RECONNECT -> R.string.uel_reconnect + Action.DISCONNECT_15M -> R.string.uel_disconnect_15m + Action.DISCONNECT_30M -> R.string.uel_disconnect_30m + Action.DISCONNECT_1H -> R.string.uel_disconnect_1h + Action.DISCONNECT_2H -> R.string.uel_disconnect_2h + Action.DISCONNECT_3H -> R.string.uel_disconnect_3h + Action.RESUME -> R.string.uel_resume + Action.SUSPEND_1H -> R.string.uel_suspend_1h + Action.SUSPEND_2H -> R.string.uel_suspend_2h + Action.SUSPEND_3H -> R.string.uel_suspend_3h + Action.SUSPEND_10H -> R.string.uel_suspend_10h + Action.HW_PUMP_ALLOWED -> R.string.uel_hw_pump_allowed + Action.CLEAR_PAIRING_KEYS -> R.string.uel_clear_pairing_keys + Action.ACCEPTS_TEMP_BASAL -> R.string.uel_accepts_temp_basal + Action.CANCEL_TEMP_BASAL -> R.string.uel_cancel_temp_basal + Action.CANCEL_EXTENDED_BOLUS -> R.string.uel_cancel_extended_bolus + Action.CANCEL_TT -> R.string.uel_cancel_tt + Action.CAREPORTAL -> R.string.uel_careportal + Action.CALIBRATION -> R.string.uel_calibration + Action.INSULIN_CHANGE -> R.string.uel_insulin_change + Action.PRIME_BOLUS -> R.string.uel_prime_bolus + Action.SITE_CHANGE -> R.string.uel_site_change + Action.TREATMENT -> R.string.uel_treatment + Action.CAREPORTAL_NS_REFRESH -> R.string.uel_careportal_ns_refresh + Action.PROFILE_SWITCH_NS_REFRESH -> R.string.uel_profile_switch_ns_refresh + Action.TREATMENTS_NS_REFRESH -> R.string.uel_treatments_ns_refresh + Action.TT_NS_REFRESH -> R.string.uel_tt_ns_refresh + Action.AUTOMATION_REMOVED -> R.string.uel_automation_removed + Action.BG_REMOVED -> R.string.uel_bg_removed + Action.CAREPORTAL_REMOVED -> R.string.uel_careportal_removed + Action.EXTENDED_BOLUS_REMOVED -> R.string.uel_extended_bolus_removed + Action.FOOD_REMOVED -> R.string.uel_food_removed + Action.PROFILE_REMOVED -> R.string.uel_profile_removed + Action.PROFILE_SWITCH_REMOVED -> R.string.uel_profile_switch_removed + Action.RESTART_EVENTS_REMOVED -> R.string.uel_restart_events_removed + Action.TREATMENT_REMOVED -> R.string.uel_treatment_removed + Action.TT_REMOVED -> R.string.uel_tt_removed + Action.NS_PAUSED -> R.string.uel_ns_paused + Action.NS_QUEUE_CLEARED -> R.string.uel_ns_queue_cleared + Action.NS_SETTINGS_COPIED -> R.string.uel_ns_settings_copied + Action.ERROR_DIALOG_OK -> R.string.uel_error_dialog_ok + Action.ERROR_DIALOG_MUTE -> R.string.uel_error_dialog_mute + Action.ERROR_DIALOG_MUTE_5MIN -> R.string.uel_error_dialog_mute_5min + Action.OBJECTIVE_STARTED -> R.string.uel_objective_started + Action.OBJECTIVE_UNSTARTED -> R.string.uel_objective_unstarted + Action.OBJECTIVES_SKIPPED -> R.string.uel_objectives_skipped + Action.STAT_RESET -> R.string.uel_stat_reset + Action.DELETE_LOGS -> R.string.uel_delete_logs + Action.DELETE_FUTURE_TREATMENTS -> R.string.uel_delete_future_treatments + Action.EXPORT_SETTINGS -> R.string.uel_export_settings + Action.IMPORT_SETTINGS -> R.string.uel_import_settings + Action.RESET_DATABASES -> R.string.uel_reset_databases + Action.EXPORT_DATABASES -> R.string.uel_export_databases + Action.IMPORT_DATABASES -> R.string.uel_import_databases + Action.OTP_EXPORT -> R.string.uel_otp_export + Action.OTP_RESET -> R.string.uel_otp_reset + Action.SMS_BASAL -> R.string.uel_sms_basal + Action.SMS_BOLUS -> R.string.uel_sms_bolus + Action.SMS_CAL -> R.string.uel_sms_cal + Action.SMS_CARBS -> R.string.uel_sms_carbs + Action.SMS_EXTENDED_BOLUS -> R.string.uel_sms_extended_bolus + Action.SMS_LOOP_DISABLED -> R.string.uel_sms_loop_disabled + Action.SMS_LOOP_ENABLED -> R.string.uel_sms_loop_enabled + Action.SMS_LOOP_RESUME -> R.string.uel_sms_loop_resume + Action.SMS_LOOP_SUSPEND -> R.string.uel_sms_loop_suspend + Action.SMS_PROFILE -> R.string.uel_sms_profile + Action.SMS_PUMP_CONNECT -> R.string.uel_sms_pump_connect + Action.SMS_PUMP_DISCONNECT -> R.string.uel_sms_pump_disconnect + Action.SMS_SMS -> R.string.uel_sms_sms + Action.SMS_TT -> R.string.uel_sms_tt + Action.TT_DELETED_FROM_NS -> R.string.uel_tt_deleted_from_ns + Action.TT_FROM_NS -> R.string.uel_tt_from_ns + Action.TT_CANCELED_FROM_NS -> R.string.uel_tt_canceleted_from_ns else -> R.string.uel_unknown } } -fun UserEntry.Action.colorId(): Int { +fun Action.colorId(): Int { return when (this) { - UserEntry.Action.BOLUS -> R.color.iob - UserEntry.Action.BOLUS_WIZARD -> R.color.iob - UserEntry.Action.BOLUS_ADVISOR -> R.color.iob - UserEntry.Action.BOLUS_RECORD -> R.color.iob - UserEntry.Action.EXTENDED_BOLUS -> R.color.extendedBolus - UserEntry.Action.SUPERBOLUS_TBR -> R.color.carbs - UserEntry.Action.CARBS -> R.color.carbs - UserEntry.Action.EXTENDED_CARBS -> R.color.carbs - UserEntry.Action.TEMP_BASAL -> R.color.basal - UserEntry.Action.TT -> R.color.tempTargetConfirmation - UserEntry.Action.TT_ACTIVITY -> R.color.tempTargetConfirmation - UserEntry.Action.TT_EATING_SOON -> R.color.tempTargetConfirmation - UserEntry.Action.TT_HYPO -> R.color.tempTargetConfirmation - UserEntry.Action.NEW_PROFILE -> R.color.white - UserEntry.Action.CLONE_PROFILE -> R.color.white - UserEntry.Action.STORE_PROFILE -> R.color.white - UserEntry.Action.PROFILE_SWITCH -> R.color.white - UserEntry.Action.PROFILE_SWITCH_CLONED -> R.color.white - UserEntry.Action.CLOSED_LOOP_MODE -> R.color.loopClosed - UserEntry.Action.LGS_LOOP_MODE -> R.color.loopClosed - UserEntry.Action.OPEN_LOOP_MODE -> R.color.loopOpened - UserEntry.Action.LOOP_DISABLED -> R.color.loopDisabled - UserEntry.Action.LOOP_ENABLED -> R.color.loopClosed - UserEntry.Action.RECONNECT -> R.color.loopDisconnected - UserEntry.Action.DISCONNECT_15M -> R.color.loopDisconnected - UserEntry.Action.DISCONNECT_30M -> R.color.loopDisconnected - UserEntry.Action.DISCONNECT_1H -> R.color.loopDisconnected - UserEntry.Action.DISCONNECT_2H -> R.color.loopDisconnected - UserEntry.Action.DISCONNECT_3H -> R.color.loopDisconnected - UserEntry.Action.RESUME -> R.color.loopClosed - UserEntry.Action.SUSPEND_1H -> R.color.loopSuspended - UserEntry.Action.SUSPEND_2H -> R.color.loopSuspended - UserEntry.Action.SUSPEND_3H -> R.color.loopSuspended - UserEntry.Action.SUSPEND_10H -> R.color.loopSuspended - UserEntry.Action.HW_PUMP_ALLOWED -> R.color.defaulttext - UserEntry.Action.CLEAR_PAIRING_KEYS -> R.color.defaulttext - UserEntry.Action.ACCEPTS_TEMP_BASAL -> R.color.basal - UserEntry.Action.CANCEL_TEMP_BASAL -> R.color.basal - UserEntry.Action.CANCEL_EXTENDED_BOLUS -> R.color.extendedBolus - UserEntry.Action.CANCEL_TT -> R.color.tempTargetConfirmation - UserEntry.Action.CAREPORTAL -> R.color.notificationAnnouncement - UserEntry.Action.CALIBRATION -> R.color.calibration - UserEntry.Action.INSULIN_CHANGE -> R.color.iob - UserEntry.Action.PRIME_BOLUS -> R.color.defaulttext - UserEntry.Action.SITE_CHANGE -> R.color.defaulttext - UserEntry.Action.TREATMENT -> R.color.defaulttext - UserEntry.Action.CAREPORTAL_NS_REFRESH -> R.color.notificationAnnouncement - UserEntry.Action.PROFILE_SWITCH_NS_REFRESH -> R.color.white - UserEntry.Action.TREATMENTS_NS_REFRESH -> R.color.defaulttext - UserEntry.Action.TT_NS_REFRESH -> R.color.tempTargetConfirmation - UserEntry.Action.AUTOMATION_REMOVED -> R.color.defaulttext - UserEntry.Action.BG_REMOVED -> R.color.calibration - UserEntry.Action.CAREPORTAL_REMOVED -> R.color.notificationAnnouncement - UserEntry.Action.EXTENDED_BOLUS_REMOVED -> R.color.extendedBolus - UserEntry.Action.FOOD_REMOVED -> R.color.carbs - UserEntry.Action.PROFILE_REMOVED -> R.color.white - UserEntry.Action.PROFILE_SWITCH_REMOVED -> R.color.white - UserEntry.Action.RESTART_EVENTS_REMOVED -> R.color.defaulttext - UserEntry.Action.TREATMENT_REMOVED -> R.color.defaulttext - UserEntry.Action.TT_REMOVED -> R.color.tempTargetConfirmation - UserEntry.Action.NS_PAUSED -> R.color.defaulttext - UserEntry.Action.NS_QUEUE_CLEARED -> R.color.defaulttext - UserEntry.Action.NS_SETTINGS_COPIED -> R.color.defaulttext - UserEntry.Action.ERROR_DIALOG_OK -> R.color.defaulttext - UserEntry.Action.ERROR_DIALOG_MUTE -> R.color.defaulttext - UserEntry.Action.ERROR_DIALOG_MUTE_5MIN -> R.color.defaulttext - UserEntry.Action.OBJECTIVE_STARTED -> R.color.defaulttext - UserEntry.Action.OBJECTIVE_UNSTARTED -> R.color.defaulttext - UserEntry.Action.OBJECTIVES_SKIPPED -> R.color.defaulttext - UserEntry.Action.STAT_RESET -> R.color.defaulttext - UserEntry.Action.DELETE_LOGS -> R.color.defaulttext - UserEntry.Action.DELETE_FUTURE_TREATMENTS -> R.color.defaulttext - UserEntry.Action.EXPORT_SETTINGS -> R.color.defaulttext - UserEntry.Action.IMPORT_SETTINGS -> R.color.defaulttext - UserEntry.Action.RESET_DATABASES -> R.color.defaulttext - UserEntry.Action.EXPORT_DATABASES -> R.color.defaulttext - UserEntry.Action.IMPORT_DATABASES -> R.color.defaulttext - UserEntry.Action.OTP_EXPORT -> R.color.defaulttext - UserEntry.Action.OTP_RESET -> R.color.defaulttext - UserEntry.Action.SMS_BASAL -> R.color.basal - UserEntry.Action.SMS_BOLUS -> R.color.iob - UserEntry.Action.SMS_CAL -> R.color.calibration - UserEntry.Action.SMS_CARBS -> R.color.carbs - UserEntry.Action.SMS_EXTENDED_BOLUS -> R.color.extendedBolus - UserEntry.Action.SMS_LOOP_DISABLED -> R.color.loopDisabled - UserEntry.Action.SMS_LOOP_ENABLED -> R.color.loopClosed - UserEntry.Action.SMS_LOOP_RESUME -> R.color.loopClosed - UserEntry.Action.SMS_LOOP_SUSPEND -> R.color.loopSuspended - UserEntry.Action.SMS_PROFILE -> R.color.white - UserEntry.Action.SMS_PUMP_CONNECT -> R.color.loopDisconnected - UserEntry.Action.SMS_PUMP_DISCONNECT -> R.color.loopDisconnected - UserEntry.Action.SMS_SMS -> R.color.defaulttext - UserEntry.Action.SMS_TT -> R.color.tempTargetConfirmation - UserEntry.Action.TT_DELETED_FROM_NS -> R.color.tempTargetConfirmation - UserEntry.Action.TT_FROM_NS -> R.color.tempTargetConfirmation - UserEntry.Action.TT_CANCELED_FROM_NS -> R.color.tempTargetConfirmation - else -> R.color.defaulttext + Action.EXTENDED_CARBS -> R.color.carbs + Action.TEMP_BASAL -> R.color.basal + Action.TT -> R.color.tempTargetConfirmation + Action.TT_ACTIVITY -> R.color.tempTargetConfirmation + Action.TT_EATING_SOON -> R.color.tempTargetConfirmation + Action.TT_HYPO -> R.color.tempTargetConfirmation + Action.NEW_PROFILE -> R.color.white + Action.CLONE_PROFILE -> R.color.white + Action.STORE_PROFILE -> R.color.white + Action.PROFILE_SWITCH -> R.color.white + Action.PROFILE_SWITCH_CLONED -> R.color.white + Action.CLOSED_LOOP_MODE -> R.color.loopClosed + Action.LGS_LOOP_MODE -> R.color.loopClosed + Action.OPEN_LOOP_MODE -> R.color.loopOpened + Action.LOOP_DISABLED -> R.color.loopDisabled + Action.LOOP_ENABLED -> R.color.loopClosed + Action.RECONNECT -> R.color.loopDisconnected + Action.DISCONNECT_15M -> R.color.loopDisconnected + Action.DISCONNECT_30M -> R.color.loopDisconnected + Action.DISCONNECT_1H -> R.color.loopDisconnected + Action.DISCONNECT_2H -> R.color.loopDisconnected + Action.DISCONNECT_3H -> R.color.loopDisconnected + Action.RESUME -> R.color.loopClosed + Action.SUSPEND_1H -> R.color.loopSuspended + Action.SUSPEND_2H -> R.color.loopSuspended + Action.SUSPEND_3H -> R.color.loopSuspended + Action.SUSPEND_10H -> R.color.loopSuspended + Action.HW_PUMP_ALLOWED -> R.color.defaulttext + Action.CLEAR_PAIRING_KEYS -> R.color.defaulttext + Action.ACCEPTS_TEMP_BASAL -> R.color.basal + Action.CANCEL_TEMP_BASAL -> R.color.basal + Action.CANCEL_EXTENDED_BOLUS -> R.color.extendedBolus + Action.CANCEL_TT -> R.color.tempTargetConfirmation + Action.CAREPORTAL -> R.color.notificationAnnouncement + Action.CALIBRATION -> R.color.calibration + Action.INSULIN_CHANGE -> R.color.iob + Action.PRIME_BOLUS -> R.color.defaulttext + Action.SITE_CHANGE -> R.color.defaulttext + Action.TREATMENT -> R.color.defaulttext + Action.CAREPORTAL_NS_REFRESH -> R.color.notificationAnnouncement + Action.PROFILE_SWITCH_NS_REFRESH -> R.color.white + Action.TREATMENTS_NS_REFRESH -> R.color.defaulttext + Action.TT_NS_REFRESH -> R.color.tempTargetConfirmation + Action.AUTOMATION_REMOVED -> R.color.defaulttext + Action.BG_REMOVED -> R.color.calibration + Action.CAREPORTAL_REMOVED -> R.color.notificationAnnouncement + Action.EXTENDED_BOLUS_REMOVED -> R.color.extendedBolus + Action.FOOD_REMOVED -> R.color.carbs + Action.PROFILE_REMOVED -> R.color.white + Action.PROFILE_SWITCH_REMOVED -> R.color.white + Action.RESTART_EVENTS_REMOVED -> R.color.defaulttext + Action.TREATMENT_REMOVED -> R.color.defaulttext + Action.TT_REMOVED -> R.color.tempTargetConfirmation + Action.NS_PAUSED -> R.color.defaulttext + Action.NS_QUEUE_CLEARED -> R.color.defaulttext + Action.NS_SETTINGS_COPIED -> R.color.defaulttext + Action.ERROR_DIALOG_OK -> R.color.defaulttext + Action.ERROR_DIALOG_MUTE -> R.color.defaulttext + Action.ERROR_DIALOG_MUTE_5MIN -> R.color.defaulttext + Action.OBJECTIVE_STARTED -> R.color.defaulttext + Action.OBJECTIVE_UNSTARTED -> R.color.defaulttext + Action.OBJECTIVES_SKIPPED -> R.color.defaulttext + Action.STAT_RESET -> R.color.defaulttext + Action.DELETE_LOGS -> R.color.defaulttext + Action.DELETE_FUTURE_TREATMENTS -> R.color.defaulttext + Action.EXPORT_SETTINGS -> R.color.defaulttext + Action.IMPORT_SETTINGS -> R.color.defaulttext + Action.RESET_DATABASES -> R.color.defaulttext + Action.EXPORT_DATABASES -> R.color.defaulttext + Action.IMPORT_DATABASES -> R.color.defaulttext + Action.OTP_EXPORT -> R.color.defaulttext + Action.OTP_RESET -> R.color.defaulttext + Action.SMS_BASAL -> R.color.basal + Action.SMS_BOLUS -> R.color.iob + Action.SMS_CAL -> R.color.calibration + Action.SMS_CARBS -> R.color.carbs + Action.SMS_EXTENDED_BOLUS -> R.color.extendedBolus + Action.SMS_LOOP_DISABLED -> R.color.loopDisabled + Action.SMS_LOOP_ENABLED -> R.color.loopClosed + Action.SMS_LOOP_RESUME -> R.color.loopClosed + Action.SMS_LOOP_SUSPEND -> R.color.loopSuspended + Action.SMS_PROFILE -> R.color.white + Action.SMS_PUMP_CONNECT -> R.color.loopDisconnected + Action.SMS_PUMP_DISCONNECT -> R.color.loopDisconnected + Action.SMS_SMS -> R.color.defaulttext + Action.SMS_TT -> R.color.tempTargetConfirmation + Action.TT_DELETED_FROM_NS -> R.color.tempTargetConfirmation + Action.TT_FROM_NS -> R.color.tempTargetConfirmation + Action.TT_CANCELED_FROM_NS -> R.color.tempTargetConfirmation + else -> R.color.defaulttext } } -fun UserEntry.Units.stringId(): Int { - return when { - this == UserEntry.Units.Mg_Dl -> R.string.mgdl - this == UserEntry.Units.Mmol_L -> R.string.mmol - this == UserEntry.Units.U -> R.string.insulin_unit_shortname - this == UserEntry.Units.U_H -> R.string.profile_ins_units_per_hour - this == UserEntry.Units.G -> R.string.shortgram - this == UserEntry.Units.M -> R.string.shortminute - this == UserEntry.Units.H -> R.string.shorthour - this == UserEntry.Units.Percent -> R.string.shortpercent - this == UserEntry.Units.R_String -> R.string.formated_string +fun ColorGroup.colorId(): Int { + return when (this) { + ColorGroup.InsulinTreatment -> R.color.basal + ColorGroup.CarbTreatment -> R.color.carbs + ColorGroup.TT -> R.color.tempTargetConfirmation + ColorGroup.Profile -> R.color.white + ColorGroup.Loop -> R.color.loopClosed + ColorGroup.Careportal -> R.color.high + ColorGroup.Pump -> R.color.iob + ColorGroup.Aaps -> R.color.defaulttext + else -> R.color.defaulttext + } +} + +fun Units.stringId(): Int { + return when (this) { + Units.Mg_Dl -> R.string.mgdl + Units.Mmol_L -> R.string.mmol + Units.U -> R.string.insulin_unit_shortname + Units.U_H -> R.string.profile_ins_units_per_hour + Units.G -> R.string.shortgram + Units.M -> R.string.shortminute + Units.H -> R.string.shorthour + Units.Percent -> R.string.shortpercent + Units.R_String -> R.string.formated_string else -> 0 } } 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 73adb845d9..16e8503f59 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 @@ -18,108 +18,108 @@ data class UserEntry( var s: String, var values: MutableList ) : DBEntry, DBEntryWithTime { - enum class Action () { - @SerializedName("BOLUS") BOLUS, - @SerializedName("BOLUS_WIZARD") BOLUS_WIZARD, - @SerializedName("BOLUS_ADVISOR") BOLUS_ADVISOR, - @SerializedName("BOLUS_RECORD") BOLUS_RECORD, - @SerializedName("EXTENDED_BOLUS") EXTENDED_BOLUS, - @SerializedName("SUPERBOLUS_TBR") SUPERBOLUS_TBR, - @SerializedName("CARBS") CARBS, - @SerializedName("EXTENDED_CARBS") EXTENDED_CARBS, - @SerializedName("TEMP_BASAL") TEMP_BASAL, - @SerializedName("TT") TT, - @SerializedName("TT_ACTIVITY") TT_ACTIVITY, - @SerializedName("TT_EATING_SOON") TT_EATING_SOON, - @SerializedName("TT_HYPO") TT_HYPO, - @SerializedName("NEW_PROFILE") NEW_PROFILE, - @SerializedName("CLONE_PROFILE") CLONE_PROFILE, - @SerializedName("STORE_PROFILE") STORE_PROFILE, - @SerializedName("PROFILE_SWITCH") PROFILE_SWITCH, - @SerializedName("PROFILE_SWITCH_CLONED") PROFILE_SWITCH_CLONED, - @SerializedName("CLOSED_LOOP_MODE") CLOSED_LOOP_MODE, - @SerializedName("LGS_LOOP_MODE") LGS_LOOP_MODE, - @SerializedName("OPEN_LOOP_MODE") OPEN_LOOP_MODE, - @SerializedName("LOOP_DISABLED") LOOP_DISABLED, - @SerializedName("LOOP_ENABLED") LOOP_ENABLED, - @SerializedName("RECONNECT") RECONNECT, - @SerializedName("DISCONNECT_15M") DISCONNECT_15M, - @SerializedName("DISCONNECT_30M") DISCONNECT_30M, - @SerializedName("DISCONNECT_1H") DISCONNECT_1H, - @SerializedName("DISCONNECT_2H") DISCONNECT_2H, - @SerializedName("DISCONNECT_3H") DISCONNECT_3H, - @SerializedName("RESUME") RESUME, - @SerializedName("SUSPEND_1H") SUSPEND_1H, - @SerializedName("SUSPEND_2H") SUSPEND_2H, - @SerializedName("SUSPEND_3H") SUSPEND_3H, - @SerializedName("SUSPEND_10H") SUSPEND_10H, - @SerializedName("HW_PUMP_ALLOWED") HW_PUMP_ALLOWED, - @SerializedName("CLEAR_PAIRING_KEYS") CLEAR_PAIRING_KEYS, - @SerializedName("ACCEPTS_TEMP_BASAL") ACCEPTS_TEMP_BASAL, - @SerializedName("CANCEL_TEMP_BASAL") CANCEL_TEMP_BASAL, - @SerializedName("CANCEL_EXTENDED_BOLUS") CANCEL_EXTENDED_BOLUS, - @SerializedName("CANCEL_TT") CANCEL_TT, - @SerializedName("CAREPORTAL") CAREPORTAL, - @SerializedName("CALIBRATION") CALIBRATION, - @SerializedName("INSULIN_CHANGE") INSULIN_CHANGE, - @SerializedName("PRIME_BOLUS") PRIME_BOLUS, - @SerializedName("SITE_CHANGE") SITE_CHANGE, - @SerializedName("TREATMENT") TREATMENT, - @SerializedName("CAREPORTAL_NS_REFRESH") CAREPORTAL_NS_REFRESH, - @SerializedName("PROFILE_SWITCH_NS_REFRESH") PROFILE_SWITCH_NS_REFRESH, - @SerializedName("TREATMENTS_NS_REFRESH") TREATMENTS_NS_REFRESH, - @SerializedName("TT_NS_REFRESH") TT_NS_REFRESH, - @SerializedName("AUTOMATION_REMOVED") AUTOMATION_REMOVED, - @SerializedName("BG_REMOVED") BG_REMOVED, - @SerializedName("CAREPORTAL_REMOVED") CAREPORTAL_REMOVED, - @SerializedName("EXTENDED_BOLUS_REMOVED") EXTENDED_BOLUS_REMOVED, - @SerializedName("FOOD_REMOVED") FOOD_REMOVED, - @SerializedName("PROFILE_REMOVED") PROFILE_REMOVED, - @SerializedName("PROFILE_SWITCH_REMOVED") PROFILE_SWITCH_REMOVED, - @SerializedName("RESTART_EVENTS_REMOVED") RESTART_EVENTS_REMOVED, - @SerializedName("TREATMENT_REMOVED") TREATMENT_REMOVED, - @SerializedName("TT_REMOVED") TT_REMOVED, - @SerializedName("NS_PAUSED") NS_PAUSED, - @SerializedName("NS_QUEUE_CLEARED") NS_QUEUE_CLEARED, - @SerializedName("NS_SETTINGS_COPIED") NS_SETTINGS_COPIED, - @SerializedName("ERROR_DIALOG_OK") ERROR_DIALOG_OK, - @SerializedName("ERROR_DIALOG_MUTE") ERROR_DIALOG_MUTE, - @SerializedName("ERROR_DIALOG_MUTE_5MIN") ERROR_DIALOG_MUTE_5MIN, - @SerializedName("OBJECTIVE_STARTED") OBJECTIVE_STARTED, - @SerializedName("OBJECTIVE_UNSTARTED") OBJECTIVE_UNSTARTED, - @SerializedName("OBJECTIVES_SKIPPED") OBJECTIVES_SKIPPED, - @SerializedName("STAT_RESET") STAT_RESET, - @SerializedName("DELETE_LOGS") DELETE_LOGS, - @SerializedName("DELETE_FUTURE_TREATMENTS") DELETE_FUTURE_TREATMENTS, - @SerializedName("EXPORT_SETTINGS") EXPORT_SETTINGS, - @SerializedName("IMPORT_SETTINGS") IMPORT_SETTINGS, - @SerializedName("RESET_DATABASES") RESET_DATABASES, - @SerializedName("EXPORT_DATABASES") EXPORT_DATABASES, - @SerializedName("IMPORT_DATABASES") IMPORT_DATABASES, - @SerializedName("OTP_EXPORT") OTP_EXPORT, - @SerializedName("OTP_RESET") OTP_RESET, - @SerializedName("SMS_BASAL") SMS_BASAL, - @SerializedName("SMS_BOLUS") SMS_BOLUS, - @SerializedName("SMS_CAL") SMS_CAL, - @SerializedName("SMS_CARBS") SMS_CARBS, - @SerializedName("SMS_EXTENDED_BOLUS") SMS_EXTENDED_BOLUS, - @SerializedName("SMS_LOOP_DISABLED") SMS_LOOP_DISABLED, - @SerializedName("SMS_LOOP_ENABLED") SMS_LOOP_ENABLED, - @SerializedName("SMS_LOOP_RESUME") SMS_LOOP_RESUME, - @SerializedName("SMS_LOOP_SUSPEND") SMS_LOOP_SUSPEND, - @SerializedName("SMS_PROFILE") SMS_PROFILE, - @SerializedName("SMS_PUMP_CONNECT") SMS_PUMP_CONNECT, - @SerializedName("SMS_PUMP_DISCONNECT") SMS_PUMP_DISCONNECT, - @SerializedName("SMS_SMS") SMS_SMS, - @SerializedName("SMS_TT") SMS_TT, - @SerializedName("TT_DELETED_FROM_NS") TT_DELETED_FROM_NS, - @SerializedName("TT_FROM_NS") TT_FROM_NS, - @SerializedName("TT_CANCELED_FROM_NS") TT_CANCELED_FROM_NS, - @SerializedName("UNKNOWN") UNKNOWN + 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), + @SerializedName("SUPERBOLUS_TBR") SUPERBOLUS_TBR (ColorGroup.InsulinTreatment), + @SerializedName("CARBS") CARBS (ColorGroup.CarbTreatment), + @SerializedName("EXTENDED_CARBS") EXTENDED_CARBS (ColorGroup.CarbTreatment), + @SerializedName("TEMP_BASAL") TEMP_BASAL (ColorGroup.TT), + @SerializedName("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), + @SerializedName("PROFILE_SWITCH") PROFILE_SWITCH (ColorGroup.Profile), + @SerializedName("PROFILE_SWITCH_CLONED") PROFILE_SWITCH_CLONED (ColorGroup.Profile), + @SerializedName("CLOSED_LOOP_MODE") CLOSED_LOOP_MODE (ColorGroup.Loop), + @SerializedName("LGS_LOOP_MODE") LGS_LOOP_MODE (ColorGroup.Loop), + @SerializedName("OPEN_LOOP_MODE") OPEN_LOOP_MODE (ColorGroup.Loop), + @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("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("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), + @SerializedName("CANCEL_TEMP_BASAL") CANCEL_TEMP_BASAL (ColorGroup.InsulinTreatment), + @SerializedName("CANCEL_EXTENDED_BOLUS") CANCEL_EXTENDED_BOLUS (ColorGroup.InsulinTreatment), + @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.Careportal), + @SerializedName("PROFILE_SWITCH_NS_REFRESH") PROFILE_SWITCH_NS_REFRESH (ColorGroup.Profile), + @SerializedName("TREATMENTS_NS_REFRESH") TREATMENTS_NS_REFRESH (ColorGroup.InsulinTreatment), + @SerializedName("TT_NS_REFRESH") TT_NS_REFRESH (ColorGroup.TT), + @SerializedName("AUTOMATION_REMOVED") AUTOMATION_REMOVED (ColorGroup.Aaps), + @SerializedName("BG_REMOVED") BG_REMOVED (ColorGroup.Careportal), + @SerializedName("CAREPORTAL_REMOVED") CAREPORTAL_REMOVED (ColorGroup.Careportal), + @SerializedName("EXTENDED_BOLUS_REMOVED") EXTENDED_BOLUS_REMOVED (ColorGroup.InsulinTreatment), + @SerializedName("FOOD_REMOVED") FOOD_REMOVED (ColorGroup.Careportal), + @SerializedName("PROFILE_REMOVED") PROFILE_REMOVED (ColorGroup.Profile), + @SerializedName("PROFILE_SWITCH_REMOVED") PROFILE_SWITCH_REMOVED (ColorGroup.Profile), + @SerializedName("RESTART_EVENTS_REMOVED") RESTART_EVENTS_REMOVED (ColorGroup.Aaps), + @SerializedName("TREATMENT_REMOVED") TREATMENT_REMOVED (ColorGroup.InsulinTreatment), + @SerializedName("TT_REMOVED") TT_REMOVED (ColorGroup.TT), + @SerializedName("NS_PAUSED") NS_PAUSED (ColorGroup.Aaps), + @SerializedName("NS_QUEUE_CLEARED") NS_QUEUE_CLEARED (ColorGroup.Aaps), + @SerializedName("NS_SETTINGS_COPIED") NS_SETTINGS_COPIED (ColorGroup.Aaps), + @SerializedName("ERROR_DIALOG_OK") ERROR_DIALOG_OK (ColorGroup.Aaps), + @SerializedName("ERROR_DIALOG_MUTE") ERROR_DIALOG_MUTE (ColorGroup.Aaps), + @SerializedName("ERROR_DIALOG_MUTE_5MIN") ERROR_DIALOG_MUTE_5MIN (ColorGroup.Aaps), + @SerializedName("OBJECTIVE_STARTED") OBJECTIVE_STARTED (ColorGroup.Aaps), + @SerializedName("OBJECTIVE_UNSTARTED") OBJECTIVE_UNSTARTED (ColorGroup.Aaps), + @SerializedName("OBJECTIVES_SKIPPED") OBJECTIVES_SKIPPED (ColorGroup.Aaps), + @SerializedName("STAT_RESET") STAT_RESET (ColorGroup.Aaps), + @SerializedName("DELETE_LOGS") DELETE_LOGS (ColorGroup.Aaps), + @SerializedName("DELETE_FUTURE_TREATMENTS") DELETE_FUTURE_TREATMENTS (ColorGroup.Aaps), + @SerializedName("EXPORT_SETTINGS") EXPORT_SETTINGS (ColorGroup.Aaps), + @SerializedName("IMPORT_SETTINGS") IMPORT_SETTINGS (ColorGroup.Aaps), + @SerializedName("RESET_DATABASES") RESET_DATABASES (ColorGroup.Aaps), + @SerializedName("EXPORT_DATABASES") EXPORT_DATABASES (ColorGroup.Aaps), + @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("TT_FROM_NS") TT_FROM_NS (ColorGroup.TT), + @SerializedName("TT_CANCELED_FROM_NS") TT_CANCELED_FROM_NS (ColorGroup.TT), + @SerializedName("UNKNOWN") UNKNOWN (ColorGroup.Aaps) ; companion object { - fun fromString(source: String?) = UserEntry.Action.values().firstOrNull { it.name == source } ?: UserEntry.Action.UNKNOWN + fun fromString(source: String?) = values().firstOrNull { it.name == source } ?: UNKNOWN } } data class ValueWithUnit (val dValue: Double, val iValue: Int, val lValue: Long, val sValue: String, val unit: Units) { @@ -158,4 +158,15 @@ data class UserEntry( fun fromText(unit: String?) = values().firstOrNull { it.text == unit } ?: None } } + + enum class ColorGroup() { + InsulinTreatment, + CarbTreatment, + TT, + Profile, + Loop, + Careportal, + Pump, + Aaps + } } \ No newline at end of file From 523a9f280026aa35c557206b5484699e1bd2cd0e Mon Sep 17 00:00:00 2001 From: Philoul Date: Sat, 6 Mar 2021 19:45:13 +0100 Subject: [PATCH 26/66] Add detailed information for Careportal entries --- .../nightscout/androidaps/dialogs/CareDialog.kt | 14 +++++++++----- .../androidaps/logging/UserEntryLogger.kt | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) 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 80df9ce2c3..96bab1b369 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt @@ -54,6 +54,7 @@ class CareDialog : DialogFragmentWithDate() { } private var options: EventType = EventType.BGCHECK + private var valuesWithUnit = mutableListOf() @StringRes private var event: Int = R.string.none @@ -178,11 +179,14 @@ class CareDialog : DialogFragmentWithDate() { } actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_glucosetype) + ": " + translator.translate(type)) actions.add(resourceHelper.gs(R.string.treatments_wizard_bg_label) + ": " + Profile.toCurrentUnitsString(profileFunction, binding.bg.value) + " " + resourceHelper.gs(unitResId)) + valuesWithUnit.add(ValueWithUnit(binding.bg.value.toDouble(), profileFunction.getUnits())) + valuesWithUnit.add(ValueWithUnit(type,Units.CPEvent)) json.put("glucose", binding.bg.value) json.put("glucoseType", type) } 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())) + valuesWithUnit.add(ValueWithUnit(binding.duration.value.toInt(), Units.M)) json.put("duration", binding.duration.value.toInt()) } val notes = binding.notesLayout.notes.text.toString() @@ -192,8 +196,10 @@ class CareDialog : DialogFragmentWithDate() { } eventTime -= eventTime % 1000 - if (eventTimeChanged) + if (eventTimeChanged) { actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime)) + valuesWithUnit.add(0, ValueWithUnit(eventTime, Units.Timestamp)) + } json.put("created_at", DateUtil.toISOString(eventTime)) json.put("mills", eventTime) @@ -224,11 +230,9 @@ class CareDialog : DialogFragmentWithDate() { EventType.QUESTION -> CareportalEvent.QUESTION EventType.ANNOUNCEMENT -> CareportalEvent.ANNOUNCEMENT } + valuesWithUnit.add(if (eventTimeChanged) 1 else 0, ValueWithUnit(careportalEvent.eventType, Units.CPEvent)) careportalEvent.json = json.toString() - if (eventTimeChanged) - uel.log(Action.CAREPORTAL, notes, ValueWithUnit(eventTime, Units.Timestamp), ValueWithUnit(careportalEvent.eventType, Units.CPEvent)) - else - uel.log(Action.CAREPORTAL, notes, ValueWithUnit(careportalEvent.eventType, Units.CPEvent)) + uel.log(Action.CAREPORTAL, notes, valuesWithUnit) databaseHelper.createOrUpdate(careportalEvent) nsUpload.uploadCareportalEntryToNS(json, eventTime) }, null) diff --git a/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt b/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt index 1cc1895c48..1ddbca4d7f 100644 --- a/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt +++ b/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt @@ -68,4 +68,18 @@ class UserEntryLogger @Inject constructor( onComplete = { aapsLogger.debug("USER ENTRY: $action") } ) } + + fun log(action: Action, s: String = "", values: MutableList) { + compositeDisposable += repository.runTransaction(UserEntryTransaction( + action = action, + s = s, + values = values + )) + .subscribeOn(aapsSchedulers.io) + .observeOn(aapsSchedulers.io) + .subscribeBy( + onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $s $values") }, + onComplete = { aapsLogger.debug("USER ENTRY: $action $s $values") } + ) + } } \ No newline at end of file From 6096825f4c9c99a7867a25715a74f05b1572c07d Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 7 Mar 2021 03:09:30 +0100 Subject: [PATCH 27/66] =?UTF-8?q?Formatage=20xml=201=C3=A8re=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../general/maintenance/ImportExportPrefs.kt | 22 ++---- app/src/main/res/values/strings.xml | 1 + .../maintenance/PrefFileListProvider.kt | 6 +- .../maintenance/formats/ClassicPrefsFormat.kt | 67 +++++++++++++++++++ .../maintenance/formats/PrefsFormat.kt | 1 + .../utils/extensions/UserEntryExt.kt | 6 ++ .../androidaps/database/entities/UserEntry.kt | 8 +++ 7 files changed, 94 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt index 5b6923442f..23e7ec93c9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt @@ -361,25 +361,16 @@ class ImportExportPrefs @Inject constructor( override fun exportUserEntriesXml(activity: FragmentActivity, listEntries: Single>) { val entries = listEntries.blockingGet() + log.debug("XXXXX " + entries.size) prefFileList.ensureExportDirExists() - val legacyFile = prefFileList.legacyFile() val newFile = prefFileList.newExportXmlFile() -/* + log.debug("XXXXX " + classicPrefsFormat.returnXml(entries)) + askToConfirmExport(activity, newFile) { password -> try { - val entries: MutableMap = mutableMapOf() - for ((key, value) in sp.getAll()) { - entries[key] = value.toString() - } - - val prefs = Prefs(entries, prepareMetadata(activity)) - - if (BuildConfig.DEBUG && buildHelper.isEngineeringMode()) { - classicPrefsFormat.savePreferences(legacyFile, prefs) - } - encryptedPrefsFormat.savePreferences(newFile, prefs, password) - - ToastUtils.okToast(activity, resourceHelper.gs(R.string.exported)) + classicPrefsFormat.saveXml(newFile, entries) + log.debug("XXXXX " + newFile.isHidden + " " + newFile.absolutePath) + ToastUtils.okToast(activity, resourceHelper.gs(R.string.ue_exported)) } catch (e: FileNotFoundException) { ToastUtils.errorToast(activity, resourceHelper.gs(R.string.filenotfound) + " " + newFile) log.error(LTag.CORE, "Unhandled exception", e) @@ -400,6 +391,5 @@ class ImportExportPrefs @Inject constructor( } } - */ } } \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1484ce8709..1248d37520 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -179,6 +179,7 @@ Nightscout version: Missing %1$d g Preferences exported + User Entries exported Export settings to Import settings from Settings imported diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/PrefFileListProvider.kt b/core/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/PrefFileListProvider.kt index 1a86f59479..a94c50668c 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/PrefFileListProvider.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/PrefFileListProvider.kt @@ -31,6 +31,7 @@ class PrefFileListProvider @Inject constructor( private val path = File(Environment.getExternalStorageDirectory().toString()) private val aapsPath = File(path, "AAPS" + File.separator + "preferences") + private val xmlPath = File(path, "AAPS" + File.separator + "xml") private const val IMPORT_AGE_NOT_YET_OLD_DAYS = 60 } @@ -93,6 +94,9 @@ class PrefFileListProvider @Inject constructor( if (!aapsPath.exists()) { aapsPath.mkdirs() } + if (!xmlPath.exists()) { + xmlPath.mkdirs() + } } fun newExportFile(): File { @@ -102,7 +106,7 @@ class PrefFileListProvider @Inject constructor( fun newExportXmlFile(): File { val timeLocal = LocalDateTime.now().toString(DateTimeFormat.forPattern("yyyy-MM-dd'_'HHmmss")) - return File(aapsPath, timeLocal + "_UserEntry.xml") + return File(xmlPath, timeLocal + "_UserEntry.xml") } // check metadata for known issues, change their status and add info with explanations 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 8123be8d98..3ab55fed9c 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 @@ -2,6 +2,13 @@ package info.nightscout.androidaps.plugins.general.maintenance.formats import info.nightscout.androidaps.Constants import info.nightscout.androidaps.core.R +import info.nightscout.androidaps.database.entities.UserEntry +import info.nightscout.androidaps.database.entities.UserEntry.* +import info.nightscout.androidaps.interfaces.ProfileFunction +import info.nightscout.androidaps.utils.DateUtil +import info.nightscout.androidaps.utils.DecimalFormatter +import info.nightscout.androidaps.utils.Translator +import info.nightscout.androidaps.utils.extensions.stringId import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.storage.Storage import java.io.File @@ -13,6 +20,9 @@ import javax.inject.Singleton @Singleton class ClassicPrefsFormat @Inject constructor( private var resourceHelper: ResourceHelper, + private var dateUtil: DateUtil, + private var translator: Translator, + private var profileFunction: ProfileFunction, private var storage: Storage ) : PrefsFormat { @@ -67,4 +77,61 @@ class ClassicPrefsFormat @Inject constructor( return metadata } + fun saveXml(file: File, userEntries: List) { + try { + val contents = userEntries.joinToString("\n") { entry -> + if (entry.values.size > 0) { + dateUtil.dateAndTimeAndSecondsString(entry.timestamp) + "," + + dateUtil.dateAndTimeAndSecondsString(entry.utcOffset) + "," + + resourceHelper.gs(entry.action.stringId()) + "," + + "\""+ entry.s.replace("\"", "\\\"") + "\"," + + entry.values.joinToString(",") { value -> valueWithUnitToStringXml(value) } + "\n" + } else { + dateUtil.dateAndTimeAndSecondsString(entry.timestamp) + "," + + dateUtil.dateAndTimeAndSecondsString(entry.utcOffset) + "," + + resourceHelper.gs(entry.action.stringId()) + "," + + "\""+ entry.s.replace("\"", "\\\"") + "\",,\n" + } + } + storage.putFileContents(file, contents) + } catch (e: FileNotFoundException) { + throw PrefFileNotFoundError(file.absolutePath) + } catch (e: IOException) { + throw PrefIOError(file.absolutePath) + } + } + + fun returnXml(userEntries: List): String { + + return userEntries.joinToString("\n") { entry -> + if (entry.values.size > 0) { + entry.values.joinToString("\n") { value -> + "\"" + dateUtil.dateAndTimeAndSecondsString(entry.timestamp) + "\"," + + "\"" + dateUtil.timeString(entry.utcOffset) + "\"," + + "\"" + resourceHelper.gs(entry.action.stringId()) + "\"," + + if (entry.s != "") {"\""+ entry.s.replace("\"", "\\\"") + "\"," } else { "," } + + valueWithUnitToStringXml(value) } + } else { + "\"" + dateUtil.dateAndTimeAndSecondsString(entry.timestamp) + "\"," + + "\"" + dateUtil.timeString(entry.utcOffset) + "\"," + + "\"" + resourceHelper.gs(entry.action.stringId()) + "\"," + + if (entry.s != "") {"\""+ entry.s.replace("\"", "\\\"") + "\"," } else { ",," } + } + } + } + + fun valueWithUnitToStringXml(v: ValueWithUnit): String { + return when (v.unit) { + Units.Timestamp -> "\"" + dateUtil.dateAndTimeAndSecondsString(v.lValue) + "\",\"" + resourceHelper.gs(R.string.date) + "\"" + Units.CPEvent -> "\"" + translator.translate(v.sValue) + "\"," + Units.R_String -> "\"" + resourceHelper.gs(v.iValue) + "\"," + Units.Mg_Dl -> if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue) + ",\"" + resourceHelper.gs(Units.Mg_Dl.stringId()) + "\"" else DecimalFormatter.to1Decimal(v.dValue/Constants.MMOLL_TO_MGDL) + ",\"" + resourceHelper.gs(Units.Mmol_L.stringId()) + "\"" + Units.Mmol_L -> if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue*Constants.MMOLL_TO_MGDL) + ",\"" + resourceHelper.gs(Units.Mg_Dl.stringId()) + "\"" else DecimalFormatter.to1Decimal(v.dValue) + ",\"" + resourceHelper.gs(Units.Mmol_L.stringId()) + "\"" + Units.G -> v.iValue.toString() + ",\"" + resourceHelper.gs(Units.G.stringId()) + "\"" + Units.U_H -> DecimalFormatter.to2Decimal(v.dValue) + ",\"" + resourceHelper.gs(Units.U_H.stringId()) + "\"" + else -> if (v.sValue != "") {"\""+ v.sValue.replace("\"", "\\\"") + if (!v.unit.stringId().equals(0)) "\",\"" + resourceHelper.gs(v.unit.stringId()) + "\"" else "\","} + else if (v.dValue != 0.0 || v.iValue != 0) { v.value().toString() + if (!v.unit.stringId().equals(0)) ",\"" + resourceHelper.gs(v.unit.stringId()) + "\"" else "," } + else "," + } + } } \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/formats/PrefsFormat.kt b/core/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/formats/PrefsFormat.kt index 42cfa18f1e..3a1b754194 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/formats/PrefsFormat.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/formats/PrefsFormat.kt @@ -5,6 +5,7 @@ import android.os.Parcelable import androidx.annotation.DrawableRes import androidx.annotation.StringRes import info.nightscout.androidaps.core.R +import info.nightscout.androidaps.database.entities.UserEntry import kotlinx.parcelize.Parcelize import java.io.File diff --git a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt index a110d68827..5aadcceff9 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt @@ -1,6 +1,7 @@ package info.nightscout.androidaps.utils.extensions import info.nightscout.androidaps.core.R +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.database.entities.UserEntry.* fun Action.stringId(): Int { @@ -228,3 +229,8 @@ fun Units.stringId(): Int { else -> 0 } } + +fun UserEntry.toXml(): String { + val content = action.name + "," + values.joinToString(",") {value -> value.toXml()} + return "" +} 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 16e8503f59..668da47006 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 @@ -136,6 +136,13 @@ data class UserEntry( if (!iValue.equals(0)) return iValue return lValue } + + fun toXml() : String { + if (sValue != "") return "\""+ sValue.replace("\"", "\\\"") + "\"," + unit.text + if (!dValue.equals(0.0)) return dValue.toString() + "," + unit.text + if (!iValue.equals(0)) return return iValue.toString() + "," + unit.text + return return lValue.toString() + "," + unit.text + } } enum class Units(val text: String) { @SerializedName("None") None (""), @@ -169,4 +176,5 @@ data class UserEntry( Pump, Aaps } + } \ No newline at end of file From c259aa345c56fb546d1e41b3239fdf3f98ee61c3 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 7 Mar 2021 10:43:33 +0100 Subject: [PATCH 28/66] Csv format (not xml) modified to Excel default remove unnecessary " and use ; as separator --- .../general/maintenance/ImportExportPrefs.kt | 2 +- .../fragments/TreatmentsUserEntryFragment.kt | 3 +- .../layout/treatments_user_entry_fragment.xml | 2 +- .../maintenance/PrefFileListProvider.kt | 8 +-- .../maintenance/formats/ClassicPrefsFormat.kt | 61 ++++++++----------- .../utils/extensions/UserEntryExt.kt | 5 -- core/src/main/res/values/strings.xml | 2 +- .../androidaps/database/entities/UserEntry.kt | 7 --- 8 files changed, 32 insertions(+), 58 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt index 23e7ec93c9..57ac66033e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt @@ -364,7 +364,7 @@ class ImportExportPrefs @Inject constructor( log.debug("XXXXX " + entries.size) prefFileList.ensureExportDirExists() val newFile = prefFileList.newExportXmlFile() - log.debug("XXXXX " + classicPrefsFormat.returnXml(entries)) + log.debug("XXXXX " + classicPrefsFormat.UserEntriesToCsv(entries)) askToConfirmExport(activity, newFile) { password -> try { 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 9442a069e3..d6cddf75b1 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 @@ -18,7 +18,6 @@ import info.nightscout.androidaps.interfaces.ImportExportPrefsInterface import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper -import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DecimalFormatter import info.nightscout.androidaps.utils.FabricPrivacy @@ -61,7 +60,7 @@ class TreatmentsUserEntryFragment : DaggerFragment() { binding.recyclerview.layoutManager = LinearLayoutManager(view.context) binding.ueExportToXml.setOnClickListener { activity?.let { activity -> - OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.ue_export_to_xml) + "?") { + OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.ue_export_to_csv) + "?") { uel.log(Action.TREATMENTS_NS_REFRESH) importExportPrefs.exportUserEntriesXml(activity, repository.getAllUserEntries()) } diff --git a/app/src/main/res/layout/treatments_user_entry_fragment.xml b/app/src/main/res/layout/treatments_user_entry_fragment.xml index dd8ba9f295..f4b98829b8 100644 --- a/app/src/main/res/layout/treatments_user_entry_fragment.xml +++ b/app/src/main/res/layout/treatments_user_entry_fragment.xml @@ -12,7 +12,7 @@ android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:drawableStart="@drawable/ic_header_export" - android:text="@string/ue_export_to_xml" /> + android:text="@string/ue_export_to_csv" /> ) { try { - val contents = userEntries.joinToString("\n") { entry -> - if (entry.values.size > 0) { - dateUtil.dateAndTimeAndSecondsString(entry.timestamp) + "," + - dateUtil.dateAndTimeAndSecondsString(entry.utcOffset) + "," + - resourceHelper.gs(entry.action.stringId()) + "," + - "\""+ entry.s.replace("\"", "\\\"") + "\"," + - entry.values.joinToString(",") { value -> valueWithUnitToStringXml(value) } + "\n" - } else { - dateUtil.dateAndTimeAndSecondsString(entry.timestamp) + "," + - dateUtil.dateAndTimeAndSecondsString(entry.utcOffset) + "," + - resourceHelper.gs(entry.action.stringId()) + "," + - "\""+ entry.s.replace("\"", "\\\"") + "\",,\n" - } - } + val contents = UserEntriesToCsv(userEntries) storage.putFileContents(file, contents) } catch (e: FileNotFoundException) { throw PrefFileNotFoundError(file.absolutePath) @@ -101,37 +88,37 @@ class ClassicPrefsFormat @Inject constructor( } } - fun returnXml(userEntries: List): String { - - return userEntries.joinToString("\n") { entry -> + fun UserEntriesToCsv(userEntries: List): String { + val userEntryHeader = "Date;UTC Offset;Action;Note;Value;Unit\n" + return userEntryHeader + userEntries.joinToString("\n") { entry -> if (entry.values.size > 0) { entry.values.joinToString("\n") { value -> - "\"" + dateUtil.dateAndTimeAndSecondsString(entry.timestamp) + "\"," + - "\"" + dateUtil.timeString(entry.utcOffset) + "\"," + - "\"" + resourceHelper.gs(entry.action.stringId()) + "\"," + - if (entry.s != "") {"\""+ entry.s.replace("\"", "\\\"") + "\"," } else { "," } + - valueWithUnitToStringXml(value) } + dateUtil.dateAndTimeAndSecondsString(entry.timestamp) + ";" + + dateUtil.timeString(entry.utcOffset) + ";" + + "\"" + resourceHelper.gs(entry.action.stringId()) + "\";" + + if (entry.s != "") {"\""+ entry.s.replace("\"", "\"\"") + "\";" } else { ";" } + + valueWithUnitToCsv(value) } } else { - "\"" + dateUtil.dateAndTimeAndSecondsString(entry.timestamp) + "\"," + - "\"" + dateUtil.timeString(entry.utcOffset) + "\"," + - "\"" + resourceHelper.gs(entry.action.stringId()) + "\"," + - if (entry.s != "") {"\""+ entry.s.replace("\"", "\\\"") + "\"," } else { ",," } + dateUtil.dateAndTimeAndSecondsString(entry.timestamp) + ";" + + dateUtil.timeString(entry.utcOffset) + ";" + + "\"" + resourceHelper.gs(entry.action.stringId()) + "\";" + + if (entry.s != "") {"\""+ entry.s.replace("\"", "\"\"") + "\";" } else { ";;" } } } } - fun valueWithUnitToStringXml(v: ValueWithUnit): String { + fun valueWithUnitToCsv(v: ValueWithUnit): String { return when (v.unit) { - Units.Timestamp -> "\"" + dateUtil.dateAndTimeAndSecondsString(v.lValue) + "\",\"" + resourceHelper.gs(R.string.date) + "\"" - Units.CPEvent -> "\"" + translator.translate(v.sValue) + "\"," - Units.R_String -> "\"" + resourceHelper.gs(v.iValue) + "\"," - Units.Mg_Dl -> if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue) + ",\"" + resourceHelper.gs(Units.Mg_Dl.stringId()) + "\"" else DecimalFormatter.to1Decimal(v.dValue/Constants.MMOLL_TO_MGDL) + ",\"" + resourceHelper.gs(Units.Mmol_L.stringId()) + "\"" - Units.Mmol_L -> if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue*Constants.MMOLL_TO_MGDL) + ",\"" + resourceHelper.gs(Units.Mg_Dl.stringId()) + "\"" else DecimalFormatter.to1Decimal(v.dValue) + ",\"" + resourceHelper.gs(Units.Mmol_L.stringId()) + "\"" - Units.G -> v.iValue.toString() + ",\"" + resourceHelper.gs(Units.G.stringId()) + "\"" - Units.U_H -> DecimalFormatter.to2Decimal(v.dValue) + ",\"" + resourceHelper.gs(Units.U_H.stringId()) + "\"" - else -> if (v.sValue != "") {"\""+ v.sValue.replace("\"", "\\\"") + if (!v.unit.stringId().equals(0)) "\",\"" + resourceHelper.gs(v.unit.stringId()) + "\"" else "\","} - else if (v.dValue != 0.0 || v.iValue != 0) { v.value().toString() + if (!v.unit.stringId().equals(0)) ",\"" + resourceHelper.gs(v.unit.stringId()) + "\"" else "," } - else "," + Units.Timestamp -> dateUtil.dateAndTimeAndSecondsString(v.lValue) + ";" + resourceHelper.gs(R.string.date) + Units.CPEvent -> translator.translate(v.sValue) + ";" + Units.R_String -> "\"" + resourceHelper.gs(v.iValue).replace("\"", "\"\"") + "\";" + Units.Mg_Dl -> if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue) + ";" + resourceHelper.gs(Units.Mg_Dl.stringId()) else DecimalFormatter.to1Decimal(v.dValue/Constants.MMOLL_TO_MGDL) + ";" + resourceHelper.gs(Units.Mmol_L.stringId()) + Units.Mmol_L -> if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue*Constants.MMOLL_TO_MGDL) + ";" + resourceHelper.gs(Units.Mg_Dl.stringId()) else DecimalFormatter.to1Decimal(v.dValue) + ";" + resourceHelper.gs(Units.Mmol_L.stringId()) + Units.G -> v.iValue.toString() + ";" + resourceHelper.gs(Units.G.stringId()) + Units.U_H -> DecimalFormatter.to2Decimal(v.dValue) + ";" + resourceHelper.gs(Units.U_H.stringId()) + else -> if (v.sValue != "") {"\""+ v.sValue.replace("\"", "\"\"") + if (!v.unit.stringId().equals(0)) "\";\"" + resourceHelper.gs(v.unit.stringId()).replace("\"", "\"\"") + "\"" else "\";"} + else if (v.dValue != 0.0 || v.iValue != 0) { v.value().toString() + if (!v.unit.stringId().equals(0)) ";" + resourceHelper.gs(v.unit.stringId()) else ";" } + else ";" } } } \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt index 5aadcceff9..223ab8fb46 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt @@ -229,8 +229,3 @@ fun Units.stringId(): Int { else -> 0 } } - -fun UserEntry.toXml(): String { - val content = action.name + "," + values.joinToString(",") {value -> value.toXml()} - return "" -} diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 4643c840c4..8538201cae 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -486,7 +486,7 @@ TT CANCELED FROM NS UNKNOWN Formated string - Export User Entries to xml + Export User Entries to Excel (csv) %1$d day 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 668da47006..3929394c67 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 @@ -136,13 +136,6 @@ data class UserEntry( if (!iValue.equals(0)) return iValue return lValue } - - fun toXml() : String { - if (sValue != "") return "\""+ sValue.replace("\"", "\\\"") + "\"," + unit.text - if (!dValue.equals(0.0)) return dValue.toString() + "," + unit.text - if (!iValue.equals(0)) return return iValue.toString() + "," + unit.text - return return lValue.toString() + "," + unit.text - } } enum class Units(val text: String) { @SerializedName("None") None (""), From 46cc4d9e85aa877bd28992792aa190d710ebb27c Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 7 Mar 2021 10:52:42 +0100 Subject: [PATCH 29/66] Careportal Remove Duration ValueWithUnit if empty --- .../java/info/nightscout/androidaps/dialogs/CareDialog.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 96bab1b369..7faf59dcca 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt @@ -180,13 +180,13 @@ class CareDialog : DialogFragmentWithDate() { actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_glucosetype) + ": " + translator.translate(type)) actions.add(resourceHelper.gs(R.string.treatments_wizard_bg_label) + ": " + Profile.toCurrentUnitsString(profileFunction, binding.bg.value) + " " + resourceHelper.gs(unitResId)) valuesWithUnit.add(ValueWithUnit(binding.bg.value.toDouble(), profileFunction.getUnits())) - valuesWithUnit.add(ValueWithUnit(type,Units.CPEvent)) + valuesWithUnit.add(ValueWithUnit(type, Units.CPEvent)) json.put("glucose", binding.bg.value) json.put("glucoseType", type) } 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())) - valuesWithUnit.add(ValueWithUnit(binding.duration.value.toInt(), Units.M)) + if (!binding.duration.value.equals(0.0)) valuesWithUnit.add(ValueWithUnit(binding.duration.value.toInt(), Units.M)) json.put("duration", binding.duration.value.toInt()) } val notes = binding.notesLayout.notes.text.toString() From c931c8d25a59aef28798287c2c690074544231f1 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 7 Mar 2021 10:52:42 +0100 Subject: [PATCH 30/66] Careportal Remove Duration ValueWithUnit if empty --- .../java/info/nightscout/androidaps/dialogs/CareDialog.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 96bab1b369..7faf59dcca 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt @@ -180,13 +180,13 @@ class CareDialog : DialogFragmentWithDate() { actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_glucosetype) + ": " + translator.translate(type)) actions.add(resourceHelper.gs(R.string.treatments_wizard_bg_label) + ": " + Profile.toCurrentUnitsString(profileFunction, binding.bg.value) + " " + resourceHelper.gs(unitResId)) valuesWithUnit.add(ValueWithUnit(binding.bg.value.toDouble(), profileFunction.getUnits())) - valuesWithUnit.add(ValueWithUnit(type,Units.CPEvent)) + valuesWithUnit.add(ValueWithUnit(type, Units.CPEvent)) json.put("glucose", binding.bg.value) json.put("glucoseType", type) } 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())) - valuesWithUnit.add(ValueWithUnit(binding.duration.value.toInt(), Units.M)) + if (!binding.duration.value.equals(0.0)) valuesWithUnit.add(ValueWithUnit(binding.duration.value.toInt(), Units.M)) json.put("duration", binding.duration.value.toInt()) } val notes = binding.notesLayout.notes.text.toString() From cc889cfa0ab26aa05ada9fb60ec2f97c7d098410 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sun, 7 Mar 2021 15:11:36 +0100 Subject: [PATCH 31/66] Remove Action.colorID, and modify Group for NS REFRESH --- .../utils/extensions/UserEntryExt.kt | 95 ------------------- .../androidaps/database/entities/UserEntry.kt | 8 +- 2 files changed, 4 insertions(+), 99 deletions(-) diff --git a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt index a110d68827..47a0373f4c 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt @@ -105,101 +105,6 @@ fun Action.stringId(): Int { } } -fun Action.colorId(): Int { - return when (this) { - Action.EXTENDED_CARBS -> R.color.carbs - Action.TEMP_BASAL -> R.color.basal - Action.TT -> R.color.tempTargetConfirmation - Action.TT_ACTIVITY -> R.color.tempTargetConfirmation - Action.TT_EATING_SOON -> R.color.tempTargetConfirmation - Action.TT_HYPO -> R.color.tempTargetConfirmation - Action.NEW_PROFILE -> R.color.white - Action.CLONE_PROFILE -> R.color.white - Action.STORE_PROFILE -> R.color.white - Action.PROFILE_SWITCH -> R.color.white - Action.PROFILE_SWITCH_CLONED -> R.color.white - Action.CLOSED_LOOP_MODE -> R.color.loopClosed - Action.LGS_LOOP_MODE -> R.color.loopClosed - Action.OPEN_LOOP_MODE -> R.color.loopOpened - Action.LOOP_DISABLED -> R.color.loopDisabled - Action.LOOP_ENABLED -> R.color.loopClosed - Action.RECONNECT -> R.color.loopDisconnected - Action.DISCONNECT_15M -> R.color.loopDisconnected - Action.DISCONNECT_30M -> R.color.loopDisconnected - Action.DISCONNECT_1H -> R.color.loopDisconnected - Action.DISCONNECT_2H -> R.color.loopDisconnected - Action.DISCONNECT_3H -> R.color.loopDisconnected - Action.RESUME -> R.color.loopClosed - Action.SUSPEND_1H -> R.color.loopSuspended - Action.SUSPEND_2H -> R.color.loopSuspended - Action.SUSPEND_3H -> R.color.loopSuspended - Action.SUSPEND_10H -> R.color.loopSuspended - Action.HW_PUMP_ALLOWED -> R.color.defaulttext - Action.CLEAR_PAIRING_KEYS -> R.color.defaulttext - Action.ACCEPTS_TEMP_BASAL -> R.color.basal - Action.CANCEL_TEMP_BASAL -> R.color.basal - Action.CANCEL_EXTENDED_BOLUS -> R.color.extendedBolus - Action.CANCEL_TT -> R.color.tempTargetConfirmation - Action.CAREPORTAL -> R.color.notificationAnnouncement - Action.CALIBRATION -> R.color.calibration - Action.INSULIN_CHANGE -> R.color.iob - Action.PRIME_BOLUS -> R.color.defaulttext - Action.SITE_CHANGE -> R.color.defaulttext - Action.TREATMENT -> R.color.defaulttext - Action.CAREPORTAL_NS_REFRESH -> R.color.notificationAnnouncement - Action.PROFILE_SWITCH_NS_REFRESH -> R.color.white - Action.TREATMENTS_NS_REFRESH -> R.color.defaulttext - Action.TT_NS_REFRESH -> R.color.tempTargetConfirmation - Action.AUTOMATION_REMOVED -> R.color.defaulttext - Action.BG_REMOVED -> R.color.calibration - Action.CAREPORTAL_REMOVED -> R.color.notificationAnnouncement - Action.EXTENDED_BOLUS_REMOVED -> R.color.extendedBolus - Action.FOOD_REMOVED -> R.color.carbs - Action.PROFILE_REMOVED -> R.color.white - Action.PROFILE_SWITCH_REMOVED -> R.color.white - Action.RESTART_EVENTS_REMOVED -> R.color.defaulttext - Action.TREATMENT_REMOVED -> R.color.defaulttext - Action.TT_REMOVED -> R.color.tempTargetConfirmation - Action.NS_PAUSED -> R.color.defaulttext - Action.NS_QUEUE_CLEARED -> R.color.defaulttext - Action.NS_SETTINGS_COPIED -> R.color.defaulttext - Action.ERROR_DIALOG_OK -> R.color.defaulttext - Action.ERROR_DIALOG_MUTE -> R.color.defaulttext - Action.ERROR_DIALOG_MUTE_5MIN -> R.color.defaulttext - Action.OBJECTIVE_STARTED -> R.color.defaulttext - Action.OBJECTIVE_UNSTARTED -> R.color.defaulttext - Action.OBJECTIVES_SKIPPED -> R.color.defaulttext - Action.STAT_RESET -> R.color.defaulttext - Action.DELETE_LOGS -> R.color.defaulttext - Action.DELETE_FUTURE_TREATMENTS -> R.color.defaulttext - Action.EXPORT_SETTINGS -> R.color.defaulttext - Action.IMPORT_SETTINGS -> R.color.defaulttext - Action.RESET_DATABASES -> R.color.defaulttext - Action.EXPORT_DATABASES -> R.color.defaulttext - Action.IMPORT_DATABASES -> R.color.defaulttext - Action.OTP_EXPORT -> R.color.defaulttext - Action.OTP_RESET -> R.color.defaulttext - Action.SMS_BASAL -> R.color.basal - Action.SMS_BOLUS -> R.color.iob - Action.SMS_CAL -> R.color.calibration - Action.SMS_CARBS -> R.color.carbs - Action.SMS_EXTENDED_BOLUS -> R.color.extendedBolus - Action.SMS_LOOP_DISABLED -> R.color.loopDisabled - Action.SMS_LOOP_ENABLED -> R.color.loopClosed - Action.SMS_LOOP_RESUME -> R.color.loopClosed - Action.SMS_LOOP_SUSPEND -> R.color.loopSuspended - Action.SMS_PROFILE -> R.color.white - Action.SMS_PUMP_CONNECT -> R.color.loopDisconnected - Action.SMS_PUMP_DISCONNECT -> R.color.loopDisconnected - Action.SMS_SMS -> R.color.defaulttext - Action.SMS_TT -> R.color.tempTargetConfirmation - Action.TT_DELETED_FROM_NS -> R.color.tempTargetConfirmation - Action.TT_FROM_NS -> R.color.tempTargetConfirmation - Action.TT_CANCELED_FROM_NS -> R.color.tempTargetConfirmation - else -> R.color.defaulttext - } -} - fun ColorGroup.colorId(): Int { return when (this) { ColorGroup.InsulinTreatment -> R.color.basal 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 16e8503f59..c38dbe194d 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 @@ -65,10 +65,10 @@ data class UserEntry( @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.Careportal), - @SerializedName("PROFILE_SWITCH_NS_REFRESH") PROFILE_SWITCH_NS_REFRESH (ColorGroup.Profile), - @SerializedName("TREATMENTS_NS_REFRESH") TREATMENTS_NS_REFRESH (ColorGroup.InsulinTreatment), - @SerializedName("TT_NS_REFRESH") TT_NS_REFRESH (ColorGroup.TT), + @SerializedName("CAREPORTAL_NS_REFRESH") CAREPORTAL_NS_REFRESH (ColorGroup.Aaps), + @SerializedName("PROFILE_SWITCH_NS_REFRESH") PROFILE_SWITCH_NS_REFRESH (ColorGroup.Aaps), + @SerializedName("TREATMENTS_NS_REFRESH") TREATMENTS_NS_REFRESH (ColorGroup.Aaps), + @SerializedName("TT_NS_REFRESH") TT_NS_REFRESH (ColorGroup.Aaps), @SerializedName("AUTOMATION_REMOVED") AUTOMATION_REMOVED (ColorGroup.Aaps), @SerializedName("BG_REMOVED") BG_REMOVED (ColorGroup.Careportal), @SerializedName("CAREPORTAL_REMOVED") CAREPORTAL_REMOVED (ColorGroup.Careportal), From f3d6fff565c8e6094ef21871ed28356d8533ff97 Mon Sep 17 00:00:00 2001 From: Philoul Date: Mon, 8 Mar 2021 21:42:16 +0100 Subject: [PATCH 32/66] Add Export CSV in Maintenance Fragment --- .../general/maintenance/ImportExportPrefs.kt | 39 ++++++------------- .../maintenance/MaintenanceFragment.kt | 8 ++++ .../fragments/TreatmentsUserEntryFragment.kt | 4 +- .../main/res/layout/maintenance_fragment.xml | 14 +++++++ .../interfaces/ImportExportPrefsInterface.kt | 2 +- .../maintenance/formats/ClassicPrefsFormat.kt | 2 +- .../maintenance/formats/PrefsFormat.kt | 1 - .../utils/extensions/UserEntryExt.kt | 4 +- core/src/main/res/values/strings.xml | 1 + .../androidaps/database/entities/UserEntry.kt | 2 +- 10 files changed, 41 insertions(+), 36 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt index 57ac66033e..8e9456ffda 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/ImportExportPrefs.kt @@ -358,38 +358,21 @@ class ImportExportPrefs @Inject constructor( }) } - - override fun exportUserEntriesXml(activity: FragmentActivity, listEntries: Single>) { + override fun exportUserEntriesCsv(activity: FragmentActivity, listEntries: Single>) { val entries = listEntries.blockingGet() - log.debug("XXXXX " + entries.size) prefFileList.ensureExportDirExists() val newFile = prefFileList.newExportXmlFile() - log.debug("XXXXX " + classicPrefsFormat.UserEntriesToCsv(entries)) + //log.debug("XXXXX " + classicPrefsFormat.UserEntriesToCsv(entries)) - askToConfirmExport(activity, newFile) { password -> - try { - classicPrefsFormat.saveXml(newFile, entries) - log.debug("XXXXX " + newFile.isHidden + " " + newFile.absolutePath) - ToastUtils.okToast(activity, resourceHelper.gs(R.string.ue_exported)) - } catch (e: FileNotFoundException) { - ToastUtils.errorToast(activity, resourceHelper.gs(R.string.filenotfound) + " " + newFile) - log.error(LTag.CORE, "Unhandled exception", e) - } catch (e: IOException) { - ToastUtils.errorToast(activity, e.message) - log.error(LTag.CORE, "Unhandled exception", e) - } catch (e: PrefFileNotFoundError) { - ToastUtils.Long.errorToast(activity, resourceHelper.gs(R.string.preferences_export_canceled) - + "\n\n" + resourceHelper.gs(R.string.filenotfound) - + ": " + e.message - + "\n\n" + resourceHelper.gs(R.string.needstoragepermission)) - log.error(LTag.CORE, "File system exception", e) - } catch (e: PrefIOError) { - ToastUtils.Long.errorToast(activity, resourceHelper.gs(R.string.preferences_export_canceled) - + "\n\n" + resourceHelper.gs(R.string.needstoragepermission) - + ": " + e.message) - log.error(LTag.CORE, "File system exception", e) - } + try { + classicPrefsFormat.saveCsv(newFile, entries) + ToastUtils.okToast(activity, resourceHelper.gs(R.string.ue_exported)) + } catch (e: FileNotFoundException) { + ToastUtils.errorToast(activity, resourceHelper.gs(R.string.filenotfound) + " " + newFile) + log.error(LTag.CORE, "Unhandled exception", e) + } catch (e: IOException) { + ToastUtils.errorToast(activity, e.message) + log.error(LTag.CORE, "Unhandled exception", e) } - } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenanceFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenanceFragment.kt index 4c0420acf3..882cfc389f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenanceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenanceFragment.kt @@ -99,6 +99,14 @@ class MaintenanceFragment : DaggerFragment() { } } binding.navLogsettings.setOnClickListener { startActivity(Intent(activity, LogSettingActivity::class.java)) } + binding.exportCsv.setOnClickListener { + activity?.let { activity -> + OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.ue_export_to_csv) + "?") { + uel.log(Action.EXPORT_CSV) + importExportPrefs.exportUserEntriesCsv(activity, repository.getAllUserEntries()) + } + } + } } @Synchronized 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 d6cddf75b1..86e30cbf2f 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 @@ -61,8 +61,8 @@ class TreatmentsUserEntryFragment : DaggerFragment() { binding.ueExportToXml.setOnClickListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.ue_export_to_csv) + "?") { - uel.log(Action.TREATMENTS_NS_REFRESH) - importExportPrefs.exportUserEntriesXml(activity, repository.getAllUserEntries()) + uel.log(Action.EXPORT_CSV) + importExportPrefs.exportUserEntriesCsv(activity, repository.getAllUserEntries()) } } } diff --git a/app/src/main/res/layout/maintenance_fragment.xml b/app/src/main/res/layout/maintenance_fragment.xml index 30d5a6520e..c5b8e6cb7c 100644 --- a/app/src/main/res/layout/maintenance_fragment.xml +++ b/app/src/main/res/layout/maintenance_fragment.xml @@ -75,6 +75,20 @@ android:text="@string/nav_import" android:textColor="@color/colorTreatmentButton" /> + +