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 688f8c5de6..8ecada80d7 100644
--- a/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt
+++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt
@@ -80,7 +80,8 @@ 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, XXXValueWithUnit.fromGlucoseUnit(bg, units))
+ //uel.log(Action.CALIBRATION, XXXValueWithUnit.fromGlucoseUnit(bg, units))
+ uel.log(Action.CALIBRATION, ValueWithUnit(Sources.CalibrationDialog), 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 c11400c7b0..1507103e07 100644
--- a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt
+++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt
@@ -223,7 +223,8 @@ class CarbsDialog : DialogFragmentWithDate() {
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.carbs), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), {
when {
activitySelected -> {
- uel.log(Action.TT, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.ACTIVITY), XXXValueWithUnit.fromGlucoseUnit(activityTT, units) , XXXValueWithUnit.Minute(activityTTDuration))
+ //uel.log(Action.TT, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.ACTIVITY), XXXValueWithUnit.fromGlucoseUnit(activityTT, units) , XXXValueWithUnit.Minute(activityTTDuration))
+ uel.log(Action.TT, ValueWithUnit(Sources.CarbDialog), ValueWithUnit(TemporaryTarget.Reason.ACTIVITY.text, Units.TherapyEvent), ValueWithUnit(activityTT, units) , ValueWithUnit(activityTTDuration, Units.M))
disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
timestamp = System.currentTimeMillis(),
duration = TimeUnit.MINUTES.toMillis(activityTTDuration.toLong()),
@@ -239,7 +240,8 @@ class CarbsDialog : DialogFragmentWithDate() {
}
eatingSoonSelected -> {
- uel.log(Action.TT, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.EATING_SOON), XXXValueWithUnit.fromGlucoseUnit(eatingSoonTT, units) , XXXValueWithUnit.Minute(eatingSoonTTDuration))
+ //uel.log(Action.TT, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.EATING_SOON), XXXValueWithUnit.fromGlucoseUnit(eatingSoonTT, units) , XXXValueWithUnit.Minute(eatingSoonTTDuration))
+ uel.log(Action.TT, ValueWithUnit(Sources.CarbDialog), ValueWithUnit(TemporaryTarget.Reason.EATING_SOON.text, Units.TherapyEvent), ValueWithUnit(eatingSoonTT, units) , ValueWithUnit(eatingSoonTTDuration, Units.M))
disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
timestamp = System.currentTimeMillis(),
duration = TimeUnit.MINUTES.toMillis(eatingSoonTTDuration.toLong()),
@@ -255,7 +257,8 @@ class CarbsDialog : DialogFragmentWithDate() {
}
hypoSelected -> {
- uel.log(Action.TT, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.HYPOGLYCEMIA), XXXValueWithUnit.fromGlucoseUnit(hypoTT, units) , XXXValueWithUnit.Minute(hypoTTDuration))
+ //uel.log(Action.TT, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.HYPOGLYCEMIA), XXXValueWithUnit.fromGlucoseUnit(hypoTT, units) , XXXValueWithUnit.Minute(hypoTTDuration))
+ uel.log(Action.TT, ValueWithUnit(Sources.CarbDialog), ValueWithUnit(TemporaryTarget.Reason.HYPOGLYCEMIA.text, Units.TherapyEvent), ValueWithUnit(hypoTT, units) , ValueWithUnit(hypoTTDuration, Units.M))
disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
timestamp = System.currentTimeMillis(),
duration = TimeUnit.MINUTES.toMillis(hypoTTDuration.toLong()),
@@ -273,11 +276,14 @@ class CarbsDialog : DialogFragmentWithDate() {
if (carbsAfterConstraints > 0) {
if (duration == 0) {
carbsGenerator.createCarb(carbsAfterConstraints, time, TherapyEvent.Type.CARBS_CORRECTION, notes)
+ uel.log(Action.CARBS, notes, ValueWithUnit(Sources.CarbDialog), ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(carbsAfterConstraints, Units.G), ValueWithUnit(timeOffset, Units.M, timeOffset != 0))
+
} else {
carbsGenerator.generateCarbs(carbsAfterConstraints, time, duration, notes)
nsUpload.uploadEvent(TherapyEvent.Type.NOTE.text, DateUtil.now() - 2000, resourceHelper.gs(R.string.generated_ecarbs_note, carbsAfterConstraints, duration, timeOffset))
+ uel.log(Action.EXTENDED_CARBS, notes, ValueWithUnit(Sources.CarbDialog), ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(carbsAfterConstraints, Units.G), ValueWithUnit(timeOffset, Units.M, timeOffset != 0), ValueWithUnit(duration, Units.H))
}
- uel.log(Action.CARBS, notes, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, XXXValueWithUnit.Gram(carbsAfterConstraints), XXXValueWithUnit.Minute(timeOffset).takeIf { timeOffset != 0 }, XXXValueWithUnit.Hour(duration).takeIf { duration != 0 })
+ //uel.log(Action.CARBS, notes, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, XXXValueWithUnit.Gram(carbsAfterConstraints), XXXValueWithUnit.Minute(timeOffset).takeIf { timeOffset != 0 }, XXXValueWithUnit.Hour(duration).takeIf { duration != 0 })
}
if (useAlarm && carbs > 0 && timeOffset > 0) {
carbTimer.scheduleReminder(dateUtil._now() + T.mins(timeOffset.toLong()).msecs())
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 91cc6cf5e5..e6d9ebeac8 100644
--- a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt
+++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt
@@ -221,6 +221,17 @@ class CareDialog : DialogFragmentWithDate() {
therapyEvent.enteredBy = enteredBy
+ var source = when (options) {
+ EventType.BGCHECK -> Sources.BgCheck
+ EventType.SENSOR_INSERT -> Sources.SensorInsert
+ EventType.BATTERY_CHANGE -> Sources.BatteryChange
+ EventType.NOTE -> Sources.Note
+ EventType.EXERCISE -> Sources.Exercise
+ EventType.QUESTION -> Sources.Question
+ EventType.ANNOUNCEMENT -> Sources.Announcement
+ }
+ valuesWithUnit.add(ValueWithUnit(source))
+
activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(event), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), {
disposable += repository.runTransactionForResult(InsertTherapyEventIfNewTransaction(therapyEvent)).subscribe({ result ->
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 1e15ecb369..925629d9a9 100644
--- a/app/src/main/java/info/nightscout/androidaps/dialogs/ExtendedBolusDialog.kt
+++ b/app/src/main/java/info/nightscout/androidaps/dialogs/ExtendedBolusDialog.kt
@@ -89,7 +89,8 @@ class ExtendedBolusDialog : DialogFragmentWithDate() {
activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.extended_bolus), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), {
- uel.log(Action.EXTENDED_BOLUS, XXXValueWithUnit.Insulin(insulinAfterConstraint), XXXValueWithUnit.Minute(durationInMinutes))
+ //uel.log(Action.EXTENDED_BOLUS, XXXValueWithUnit.Insulin(insulinAfterConstraint), XXXValueWithUnit.Minute(durationInMinutes))
+ uel.log(Action.EXTENDED_BOLUS, ValueWithUnit(Sources.ExtendedBolusDialog), 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 63f1032ed3..f12b29abb7 100644
--- a/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt
+++ b/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt
@@ -137,11 +137,13 @@ 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, notes, XXXValueWithUnit.Insulin(insulinAfterConstraints).takeIf { insulinAfterConstraints != 0.0 })
+ //uel.log(Action.PRIME_BOLUS, notes, XXXValueWithUnit.Insulin(insulinAfterConstraints).takeIf { insulinAfterConstraints != 0.0 })
+ uel.log(Action.PRIME_BOLUS, notes, ValueWithUnit(Sources.FillDialog), ValueWithUnit(insulinAfterConstraints, Units.U, insulinAfterConstraints != 0.0))
requestPrimeBolus(insulinAfterConstraints, notes)
}
if (siteChange) {
- uel.log(Action.CAREPORTAL, notes, XXXValueWithUnit.TherapyEventType(TherapyEvent.Type.CANNULA_CHANGE))
+ //uel.log(Action.CAREPORTAL, notes, XXXValueWithUnit.TherapyEventType(TherapyEvent.Type.CANNULA_CHANGE))
+ uel.log(Action.CAREPORTAL, notes, ValueWithUnit(Sources.FillDialog), ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TherapyEvent.Type.CANNULA_CHANGE.text, Units.TherapyEvent))
disposable += repository.runTransactionForResult(InsertTherapyEventIfNewTransaction(
timestamp = eventTime,
type = TherapyEvent.Type.CANNULA_CHANGE,
@@ -155,7 +157,8 @@ class FillDialog : DialogFragmentWithDate() {
}
if (insulinChange) {
// add a second for case of both checked
- uel.log(Action.CAREPORTAL, notes, XXXValueWithUnit.TherapyEventType(TherapyEvent.Type.INSULIN_CHANGE))
+ //uel.log(Action.CAREPORTAL, notes, XXXValueWithUnit.TherapyEventType(TherapyEvent.Type.INSULIN_CHANGE))
+ uel.log(Action.CAREPORTAL, notes, ValueWithUnit(Sources.FillDialog), ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TherapyEvent.Type.INSULIN_CHANGE.text, Units.TherapyEvent))
disposable += repository.runTransactionForResult(InsertTherapyEventIfNewTransaction(
timestamp = eventTime + 1000,
type = TherapyEvent.Type.INSULIN_CHANGE,
diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt
index 12f771edb1..e66c6fdd63 100644
--- a/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt
+++ b/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt
@@ -190,7 +190,8 @@ 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, notes, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.EATING_SOON), XXXValueWithUnit.fromGlucoseUnit(eatingSoonTT, units), XXXValueWithUnit.Minute(eatingSoonTTDuration))
+ //uel.log(Action.TT, notes, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.EATING_SOON), XXXValueWithUnit.fromGlucoseUnit(eatingSoonTT, units), XXXValueWithUnit.Minute(eatingSoonTTDuration))
+ uel.log(Action.TT, notes, ValueWithUnit(Sources.InsulinDialog), ValueWithUnit(TemporaryTarget.Reason.EATING_SOON.text, Units.TherapyEvent), ValueWithUnit(eatingSoonTT, units), ValueWithUnit(eatingSoonTTDuration, Units.M))
disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
timestamp = System.currentTimeMillis(),
duration = TimeUnit.MINUTES.toMillis(eatingSoonTTDuration.toLong()),
@@ -212,11 +213,13 @@ class InsulinDialog : DialogFragmentWithDate() {
detailedBolusInfo.source = Source.USER
detailedBolusInfo.notes = notes
if (recordOnlyChecked) {
- uel.log(Action.BOLUS_RECORD, notes, XXXValueWithUnit.Insulin(insulinAfterConstraints), XXXValueWithUnit.Minute(timeOffset).takeIf { timeOffset!= 0 })
+ //uel.log(Action.BOLUS_RECORD, notes, XXXValueWithUnit.Insulin(insulinAfterConstraints), XXXValueWithUnit.Minute(timeOffset).takeIf { timeOffset!= 0 })
+ uel.log(Action.BOLUS, notes, ValueWithUnit(Sources.InsulinDialog), ValueWithUnit(R.string.record, Units.R_String), ValueWithUnit(insulinAfterConstraints, Units.U), ValueWithUnit(timeOffset, Units.M, timeOffset!= 0))
detailedBolusInfo.date = time
activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false)
} else {
- uel.log(Action.BOLUS, notes, XXXValueWithUnit.Insulin(insulinAfterConstraints))
+ //uel.log(Action.BOLUS, notes, XXXValueWithUnit.Insulin(insulinAfterConstraints))
+ uel.log(Action.BOLUS, notes, ValueWithUnit(Sources.InsulinDialog), 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 904596bfd2..89c2c5463a 100644
--- a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt
+++ b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt
@@ -240,28 +240,28 @@ class LoopDialog : DaggerDialogFragment() {
val profile = profileFunction.getProfile() ?: return true
when (v.id) {
R.id.overview_closeloop -> {
- uel.log(Action.CLOSED_LOOP_MODE)
+ uel.log(Action.CLOSED_LOOP_MODE, ValueWithUnit(Sources.LoopDialog))
sp.putString(R.string.key_aps_mode, "closed")
rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.closedloop)))
return true
}
R.id.overview_lgsloop -> {
- uel.log(Action.LGS_LOOP_MODE)
+ uel.log(Action.LGS_LOOP_MODE, ValueWithUnit(Sources.LoopDialog))
sp.putString(R.string.key_aps_mode, "lgs")
rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend)))
return true
}
R.id.overview_openloop -> {
- uel.log(Action.OPEN_LOOP_MODE)
+ uel.log(Action.OPEN_LOOP_MODE, ValueWithUnit(Sources.LoopDialog))
sp.putString(R.string.key_aps_mode, "open")
rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend)))
return true
}
R.id.overview_disable -> {
- uel.log(Action.LOOP_DISABLED)
+ uel.log(Action.LOOP_DISABLED, ValueWithUnit(Sources.LoopDialog))
loopPlugin.setPluginEnabled(PluginType.LOOP, false)
loopPlugin.setFragmentVisible(PluginType.LOOP, false)
configBuilderPlugin.storeSettings("DisablingLoop")
@@ -278,7 +278,7 @@ class LoopDialog : DaggerDialogFragment() {
}
R.id.overview_enable -> {
- uel.log(Action.LOOP_ENABLED)
+ uel.log(Action.LOOP_ENABLED, ValueWithUnit(Sources.LoopDialog))
loopPlugin.setPluginEnabled(PluginType.LOOP, true)
loopPlugin.setFragmentVisible(PluginType.LOOP, true)
configBuilderPlugin.storeSettings("EnablingLoop")
@@ -288,7 +288,8 @@ class LoopDialog : DaggerDialogFragment() {
}
R.id.overview_resume, R.id.overview_reconnect -> {
- uel.log(if (v.id == R.id.overview_resume) Action.RESUME else Action.RECONNECT )
+ //uel.log(if (v.id == R.id.overview_resume) Action.RESUME else Action.RECONNECT )
+ uel.log(if (v.id==R.id.overview_resume) Action.RESUME else Action.RECONNECT, ValueWithUnit(Sources.LoopDialog))
loopPlugin.suspendTo(0L)
rxBus.send(EventRefreshOverview("suspendmenu"))
commandQueue.cancelTempBasal(true, object : Callback() {
@@ -304,49 +305,56 @@ class LoopDialog : DaggerDialogFragment() {
}
R.id.overview_suspend_1h -> {
- uel.log(Action.SUSPEND, XXXValueWithUnit.Hour(1))
+ //uel.log(Action.SUSPEND, XXXValueWithUnit.Hour(1))
+ uel.log(Action.SUSPEND, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(1, Units.H))
loopPlugin.suspendLoop(60)
rxBus.send(EventRefreshOverview("suspendmenu"))
return true
}
R.id.overview_suspend_2h -> {
- uel.log(Action.SUSPEND, XXXValueWithUnit.Hour(2))
+ //uel.log(Action.SUSPEND, XXXValueWithUnit.Hour(2))
+ uel.log(Action.SUSPEND, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(2, Units.H))
loopPlugin.suspendLoop(120)
rxBus.send(EventRefreshOverview("suspendmenu"))
return true
}
R.id.overview_suspend_3h -> {
- uel.log(Action.SUSPEND, XXXValueWithUnit.Hour(3))
+ //uel.log(Action.SUSPEND, XXXValueWithUnit.Hour(3))
+ uel.log(Action.SUSPEND, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(3, Units.H))
loopPlugin.suspendLoop(180)
rxBus.send(EventRefreshOverview("suspendmenu"))
return true
}
R.id.overview_suspend_10h -> {
- uel.log(Action.SUSPEND, XXXValueWithUnit.Hour(10))
+ //uel.log(Action.SUSPEND, XXXValueWithUnit.Hour(10))
+ uel.log(Action.SUSPEND, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(10, Units.H))
loopPlugin.suspendLoop(600)
rxBus.send(EventRefreshOverview("suspendmenu"))
return true
}
R.id.overview_disconnect_15m -> {
- uel.log(Action.DISCONNECT, XXXValueWithUnit.Minute(15))
+ //Muel.log(Action.DISCONNECT, XXXValueWithUnit.Minute(15))
+ uel.log(Action.DISCONNECT, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(15, Units.M))
loopPlugin.disconnectPump(15, profile)
rxBus.send(EventRefreshOverview("suspendmenu"))
return true
}
R.id.overview_disconnect_30m -> {
- uel.log(Action.DISCONNECT, XXXValueWithUnit.Minute(30))
+ //uel.log(Action.DISCONNECT, XXXValueWithUnit.Minute(30))
+ uel.log(Action.DISCONNECT, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(30, Units.M))
loopPlugin.disconnectPump(30, profile)
rxBus.send(EventRefreshOverview("suspendmenu"))
return true
}
R.id.overview_disconnect_1h -> {
- uel.log(Action.DISCONNECT, XXXValueWithUnit.Hour(1))
+ //uel.log(Action.DISCONNECT, XXXValueWithUnit.Hour(1))
+ uel.log(Action.DISCONNECT, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(1, Units.H))
loopPlugin.disconnectPump(60, profile)
sp.putBoolean(R.string.key_objectiveusedisconnect, true)
rxBus.send(EventRefreshOverview("suspendmenu"))
@@ -354,14 +362,16 @@ class LoopDialog : DaggerDialogFragment() {
}
R.id.overview_disconnect_2h -> {
- uel.log(Action.DISCONNECT, XXXValueWithUnit.Hour(2))
+ //uel.log(Action.DISCONNECT, XXXValueWithUnit.Hour(2))
+ uel.log(Action.DISCONNECT, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(2, Units.H))
loopPlugin.disconnectPump(120, profile)
rxBus.send(EventRefreshOverview("suspendmenu"))
return true
}
R.id.overview_disconnect_3h -> {
- uel.log(Action.DISCONNECT, XXXValueWithUnit.Hour(3))
+ //uel.log(Action.DISCONNECT, XXXValueWithUnit.Hour(3))
+ uel.log(Action.DISCONNECT, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(3, Units.H))
loopPlugin.disconnectPump(180, profile)
rxBus.send(EventRefreshOverview("suspendmenu"))
return true
diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt
index 4b13f9f66b..db24f56a58 100644
--- a/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt
+++ b/app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt
@@ -126,7 +126,8 @@ 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, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged } , XXXValueWithUnit.SimpleString(profile), XXXValueWithUnit.Percent(percent), XXXValueWithUnit.Hour(timeShift).takeIf { timeShift != 0 }, XXXValueWithUnit.Minute(duration).takeIf { duration != 0 })
+ //uel.log(Action.PROFILE_SWITCH, notes, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged } , XXXValueWithUnit.SimpleString(profile), XXXValueWithUnit.Percent(percent), XXXValueWithUnit.Hour(timeShift).takeIf { timeShift != 0 }, XXXValueWithUnit.Minute(duration).takeIf { duration != 0 })
+ uel.log(Action.PROFILE_SWITCH, notes, ValueWithUnit(Sources.ProfileSwitchDialog), ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(profile, Units.None), ValueWithUnit(percent, Units.Percent), ValueWithUnit(timeShift, Units.H, timeShift != 0), ValueWithUnit(duration, Units.M, duration != 0))
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 b5e96a2cc7..dfe3074c25 100644
--- a/app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt
+++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt
@@ -127,10 +127,12 @@ class TempBasalDialog : DialogFragmentWithDate() {
}
}
if (isPercentPump) {
- uel.log(Action.TEMP_BASAL, XXXValueWithUnit.Percent(percent), XXXValueWithUnit.Minute(durationInMinutes))
+ //uel.log(Action.TEMP_BASAL, XXXValueWithUnit.Percent(percent), XXXValueWithUnit.Minute(durationInMinutes))
+ uel.log(Action.TEMP_BASAL, ValueWithUnit(Sources.TempBasalDialog), ValueWithUnit(percent, Units.Percent), ValueWithUnit(durationInMinutes, Units.M))
commandQueue.tempBasalPercent(percent, durationInMinutes, true, profile, callback)
} else {
- uel.log(Action.TEMP_BASAL, XXXValueWithUnit.Insulin(absolute), XXXValueWithUnit.Minute(durationInMinutes))
+ //uel.log(Action.TEMP_BASAL, XXXValueWithUnit.Insulin(absolute), XXXValueWithUnit.Minute(durationInMinutes))
+ uel.log(Action.TEMP_BASAL, ValueWithUnit(Sources.TempBasalDialog), 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 67c7d7cfde..7754c51e09 100644
--- a/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt
+++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt
@@ -182,11 +182,16 @@ class TempTargetDialog : DialogFragmentWithDate() {
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), {
val units = profileFunction.getUnits()
when(reason) {
- resourceHelper.gs(R.string.eatingsoon) -> uel.log(Action.TT, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.EATING_SOON), XXXValueWithUnit.fromGlucoseUnit(target, units), XXXValueWithUnit.Minute(duration))
- resourceHelper.gs(R.string.activity) -> uel.log(Action.TT, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.ACTIVITY), XXXValueWithUnit.fromGlucoseUnit(target, units), XXXValueWithUnit.Minute(duration))
- resourceHelper.gs(R.string.hypo) -> uel.log(Action.TT, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.HYPOGLYCEMIA), XXXValueWithUnit.fromGlucoseUnit(target, units), XXXValueWithUnit.Minute(duration))
- resourceHelper.gs(R.string.manual) -> uel.log(Action.TT, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.CUSTOM), XXXValueWithUnit.fromGlucoseUnit(target, units), XXXValueWithUnit.Minute(duration))
- resourceHelper.gs(R.string.stoptemptarget) -> uel.log(Action.CANCEL_TT, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged })
+ //resourceHelper.gs(R.string.eatingsoon) -> uel.log(Action.TT, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.EATING_SOON), XXXValueWithUnit.fromGlucoseUnit(target, units), XXXValueWithUnit.Minute(duration))
+ //resourceHelper.gs(R.string.activity) -> uel.log(Action.TT, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.ACTIVITY), XXXValueWithUnit.fromGlucoseUnit(target, units), XXXValueWithUnit.Minute(duration))
+ //resourceHelper.gs(R.string.hypo) -> uel.log(Action.TT, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.HYPOGLYCEMIA), XXXValueWithUnit.fromGlucoseUnit(target, units), XXXValueWithUnit.Minute(duration))
+ //resourceHelper.gs(R.string.manual) -> uel.log(Action.TT, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.CUSTOM), XXXValueWithUnit.fromGlucoseUnit(target, units), XXXValueWithUnit.Minute(duration))
+ //resourceHelper.gs(R.string.stoptemptarget) -> uel.log(Action.CANCEL_TT, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged })
+ resourceHelper.gs(R.string.eatingsoon) -> uel.log(Action.TT, ValueWithUnit(Sources.TTDialog), ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.EATING_SOON.text, Units.TherapyEvent), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
+ resourceHelper.gs(R.string.activity) -> uel.log(Action.TT, ValueWithUnit(Sources.TTDialog), ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.ACTIVITY.text, Units.TherapyEvent), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
+ resourceHelper.gs(R.string.hypo) -> uel.log(Action.TT, ValueWithUnit(Sources.TTDialog), ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.HYPOGLYCEMIA.text, Units.TherapyEvent), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
+ resourceHelper.gs(R.string.manual) -> uel.log(Action.TT, ValueWithUnit(Sources.TTDialog), ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.CUSTOM.text, Units.TherapyEvent), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
+ resourceHelper.gs(R.string.stoptemptarget) -> uel.log(Action.CANCEL_TT, ValueWithUnit(Sources.TTDialog), ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged))
}
if (target == 0.0 || duration == 0) {
disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(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 9d79c8d9d3..456ea7b9aa 100644
--- a/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt
+++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt
@@ -131,7 +131,13 @@ 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(Action.TREATMENT, XXXValueWithUnit.Insulin(insulin ).takeIf { insulin != 0.0 }, XXXValueWithUnit.Gram(carbs).takeIf { carbs != 0 })
+ //uel.log(Action.TREATMENT, XXXValueWithUnit.Insulin(insulin ).takeIf { insulin != 0.0 }, XXXValueWithUnit.Gram(carbs).takeIf { carbs != 0 })
+ val action = when {
+ insulinAfterConstraints.equals(0.0) -> Action.CARBS
+ carbsAfterConstraints.equals(0) -> Action.BOLUS
+ else -> Action.TREATMENT
+ }
+ uel.log(action, ValueWithUnit(Sources.TreatmentDialog), ValueWithUnit(insulin, Units.U, insulin != 0.0), ValueWithUnit(carbs, Units.G, carbs != 0))
val detailedBolusInfo = DetailedBolusInfo()
if (insulinAfterConstraints == 0.0) detailedBolusInfo.eventType = TherapyEvent.Type.CARBS_CORRECTION
if (carbsAfterConstraints == 0) detailedBolusInfo.eventType = TherapyEvent.Type.CORRECTION_BOLUS
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt
index b80d78ef5c..d47043c840 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt
@@ -17,6 +17,7 @@ import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.TherapyEvent
+import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.database.transactions.InsertTherapyEventIfNewTransaction
import info.nightscout.androidaps.db.Source
import info.nightscout.androidaps.events.EventAcceptOpenLoopChange
@@ -27,6 +28,7 @@ import info.nightscout.androidaps.interfaces.*
import info.nightscout.androidaps.interfaces.LoopInterface.LastRun
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag
+import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopSetLastRunGui
import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopUpdateGui
import info.nightscout.androidaps.plugins.aps.loop.events.EventNewOpenLoopNotification
@@ -78,6 +80,7 @@ open class LoopPlugin @Inject constructor(
private val fabricPrivacy: FabricPrivacy,
private val nsUpload: NSUpload,
private val dateUtil: DateUtil,
+ private val uel: UserEntryLogger,
private val repository: AppRepository
) : PluginBase(PluginDescription()
.mainType(PluginType.LOOP)
@@ -531,6 +534,7 @@ open class LoopPlugin @Inject constructor(
if (request.percent == 100 && request.duration == 0) {
if (activeTemp != null) {
aapsLogger.debug(LTag.APS, "applyAPSRequest: cancelTempBasal()")
+ uel.log(Action.CANCEL_TEMP_BASAL, ValueWithUnit(Sources.Loop))
commandQueue.cancelTempBasal(false, callback)
} else {
aapsLogger.debug(LTag.APS, "applyAPSRequest: Basal set correctly")
@@ -544,12 +548,14 @@ open class LoopPlugin @Inject constructor(
.comment(R.string.let_temp_basal_run))?.run()
} else {
aapsLogger.debug(LTag.APS, "applyAPSRequest: tempBasalPercent()")
+ uel.log(Action.TEMP_BASAL, ValueWithUnit(Sources.Loop), ValueWithUnit(request.percent, Units.Percent), ValueWithUnit(request.duration, Units.M))
commandQueue.tempBasalPercent(request.percent, request.duration, false, profile!!, callback)
}
} else {
if (request.rate == 0.0 && request.duration == 0 || abs(request.rate - pump.baseBasalRate) < pump.pumpDescription.basalStep) {
if (activeTemp != null) {
aapsLogger.debug(LTag.APS, "applyAPSRequest: cancelTempBasal()")
+ uel.log(Action.CANCEL_TEMP_BASAL, ValueWithUnit(Sources.Loop))
commandQueue.cancelTempBasal(false, callback)
} else {
aapsLogger.debug(LTag.APS, "applyAPSRequest: Basal set correctly")
@@ -563,6 +569,7 @@ open class LoopPlugin @Inject constructor(
.comment(R.string.let_temp_basal_run))?.run()
} else {
aapsLogger.debug(LTag.APS, "applyAPSRequest: setTempBasalAbsolute()")
+ uel.log(Action.TEMP_BASAL, ValueWithUnit(Sources.Loop), ValueWithUnit(request.rate, Units.U_H), ValueWithUnit(request.duration, Units.M))
commandQueue.tempBasalAbsolute(request.rate, request.duration, false, profile!!, callback)
}
}
@@ -602,6 +609,8 @@ open class LoopPlugin @Inject constructor(
detailedBolusInfo.source = Source.USER
detailedBolusInfo.deliverAt = request.deliverAt
aapsLogger.debug(LTag.APS, "applyAPSRequest: bolus()")
+ if (request.smb > 0.0)
+ uel.log(Action.SMB, ValueWithUnit(Sources.Loop), ValueWithUnit(detailedBolusInfo.insulin, Units.U))
commandQueue.bolus(detailedBolusInfo, callback)
}
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 6f735ba04b..e3d9926ea6 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
@@ -155,7 +155,7 @@ class ActionsFragment : DaggerFragment() {
}
extendedBolusCancel?.setOnClickListener {
if (activePlugin.activeTreatments.isInHistoryExtendedBolusInProgress) {
- uel.log(Action.CANCEL_EXTENDED_BOLUS)
+ uel.log(Action.CANCEL_EXTENDED_BOLUS, ValueWithUnit(Sources.Actions))
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(Action.CANCEL_TEMP_BASAL)
+ uel.log(Action.CANCEL_TEMP_BASAL, ValueWithUnit(Sources.Actions))
commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() {
if (!result.success) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodFragment.kt
index ceb0855819..f5ab3876ff 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodFragment.kt
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodFragment.kt
@@ -16,7 +16,7 @@ import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.Food
-import info.nightscout.androidaps.database.entities.UserEntry.Action
+import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.database.transactions.InvalidateFoodTransaction
import info.nightscout.androidaps.databinding.FoodFragmentBinding
import info.nightscout.androidaps.databinding.FoodItemBinding
@@ -76,7 +76,7 @@ class FoodFragment : DaggerFragment() {
binding.refreshFromNightscout.setOnClickListener {
context?.let { context ->
OKDialog.showConfirmation(context, resourceHelper.gs(R.string.refresheventsfromnightscout) + " ?", {
- uel.log(Action.FOOD_FROM_NS)
+ uel.log(Action.FOOD, ValueWithUnit(Sources.Food))
disposable += Completable.fromAction { repository.deleteAllFoods() }
.subscribeOn(aapsSchedulers.io)
.observeOn(aapsSchedulers.main)
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 32b3001911..48c8c4740b 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,12 @@ class MaintenanceFragment : DaggerFragment() {
super.onViewCreated(view, savedInstanceState)
binding.logSend.setOnClickListener { maintenancePlugin.sendLogs() }
binding.logDelete.setOnClickListener {
- uel.log(Action.DELETE_LOGS)
+ uel.log(Action.DELETE_LOGS, ValueWithUnit(Sources.Maintenance))
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(Action.RESET_DATABASES)
compositeDisposable.add(
fromAction {
databaseHelper.resetDatabases()
@@ -78,18 +77,19 @@ class MaintenanceFragment : DaggerFragment() {
onComplete = { rxBus.send(EventNewBG(null)) }
)
)
+ uel.log(Action.RESET_DATABASES, ValueWithUnit(Sources.Maintenance))
})
}
}
binding.navExport.setOnClickListener {
- uel.log(Action.EXPORT_SETTINGS)
+ uel.log(Action.EXPORT_SETTINGS, ValueWithUnit(Sources.Maintenance))
// start activity for checking permissions...
importExportPrefs.verifyStoragePermissions(this) {
importExportPrefs.exportSharedPreferences(this)
}
}
binding.navImport.setOnClickListener {
- uel.log(Action.IMPORT_SETTINGS)
+ uel.log(Action.IMPORT_SETTINGS, ValueWithUnit(Sources.Maintenance))
// start activity for checking permissions...
importExportPrefs.verifyStoragePermissions(this) {
importExportPrefs.importSharedPreferences(this)
@@ -99,7 +99,7 @@ class MaintenanceFragment : DaggerFragment() {
binding.exportCsv.setOnClickListener {
activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.ue_export_to_csv) + "?") {
- uel.log(Action.EXPORT_CSV)
+ uel.log(Action.EXPORT_CSV, ValueWithUnit(Sources.Maintenance))
importExportPrefs.exportUserEntriesCsv(activity, repository.getAllUserEntries())
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt
index 09f6b27e2d..1124bdfe34 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt
@@ -9,6 +9,7 @@ import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
import info.nightscout.androidaps.database.entities.TherapyEvent
import info.nightscout.androidaps.database.entities.UserEntry
+import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.database.transactions.SyncTemporaryTargetTransaction
import info.nightscout.androidaps.database.transactions.SyncTherapyEventTransaction
import info.nightscout.androidaps.events.EventNsTreatment
@@ -28,6 +29,7 @@ import info.nightscout.androidaps.utils.buildHelper.BuildHelper
import info.nightscout.androidaps.utils.extensions.temporaryTargetFromJson
import info.nightscout.androidaps.utils.extensions.therapyEventFromJson
import info.nightscout.androidaps.utils.sharedPreferences.SP
+import java.util.concurrent.TimeUnit
import javax.inject.Inject
class NSClientAddUpdateWorker(
@@ -85,28 +87,46 @@ class NSClientAddUpdateWorker(
}
.blockingGet()
.also { result ->
- result.inserted.forEach { tt ->
+ /*result.inserted.forEach { tt ->
uel.log(UserEntry.Action.TT_FROM_NS,
XXXValueWithUnit.TherapyEventTTReason(tt.reason),
XXXValueWithUnit.Mgdl(tt.lowTarget),
XXXValueWithUnit.Mgdl(tt.highTarget).takeIf { tt.lowTarget != tt.highTarget },
- XXXValueWithUnit.Minute(tt.duration.toInt() / 60000)
+ XXXValueWithUnit.Minute(tt.duration.toInt() / 60000)*/
+ result.inserted.forEach {
+ uel.log(Action.TT, ValueWithUnit(Sources.NSClient),
+ ValueWithUnit(it.reason.text, Units.TherapyEvent),
+ ValueWithUnit(it.lowTarget, Units.Mg_Dl, true),
+ ValueWithUnit(it.highTarget, Units.Mg_Dl, it.lowTarget != it.highTarget),
+ ValueWithUnit(TimeUnit.MILLISECONDS.toMinutes(it.duration).toInt(), Units.M, true)
)
}
- result.invalidated.forEach { tt ->
+ /*result.invalidated.forEach { tt ->
uel.log(UserEntry.Action.TT_DELETED_FROM_NS,
XXXValueWithUnit.TherapyEventTTReason(tt.reason),
XXXValueWithUnit.Mgdl(tt.lowTarget),
XXXValueWithUnit.Mgdl(tt.highTarget).takeIf { tt.lowTarget != tt.highTarget },
- XXXValueWithUnit.Minute(tt.duration.toInt() / 60000)
+ XXXValueWithUnit.Minute(tt.duration.toInt() / 60000)*/
+ result.invalidated.forEach {
+ uel.log(Action.TT_REMOVED, ValueWithUnit(Sources.NSClient),
+ ValueWithUnit(it.reason.text, Units.TherapyEvent),
+ ValueWithUnit(it.lowTarget, Units.Mg_Dl, true),
+ ValueWithUnit(it.highTarget, Units.Mg_Dl, it.lowTarget != it.highTarget),
+ ValueWithUnit(TimeUnit.MILLISECONDS.toMinutes(it.duration).toInt(), Units.M, true)
)
}
- result.ended.forEach { tt ->
+ /*result.ended.forEach { tt ->
uel.log(UserEntry.Action.TT_CANCELED_FROM_NS,
XXXValueWithUnit.TherapyEventTTReason(tt.reason),
XXXValueWithUnit.Mgdl(tt.lowTarget),
XXXValueWithUnit.Mgdl(tt.highTarget).takeIf { tt.lowTarget != tt.highTarget },
- XXXValueWithUnit.Minute(tt.duration.toInt() / 60000)
+ XXXValueWithUnit.Minute(tt.duration.toInt() / 60000)*/
+ result.ended.forEach {
+ uel.log(Action.CANCEL_TT, ValueWithUnit(Sources.NSClient),
+ ValueWithUnit(it.reason.text, Units.TherapyEvent),
+ ValueWithUnit(it.lowTarget, Units.Mg_Dl, true),
+ ValueWithUnit(it.highTarget, Units.Mg_Dl, it.lowTarget != it.highTarget),
+ ValueWithUnit(TimeUnit.MILLISECONDS.toMinutes(it.duration).toInt(), Units.M, true)
)
}
}
@@ -130,18 +150,28 @@ class NSClientAddUpdateWorker(
}
.blockingGet()
.also { result ->
- result.inserted.forEach {
+ /*result.inserted.forEach {
uel.log(UserEntry.Action.CAREPORTAL_FROM_NS,
it.note ?: "",
XXXValueWithUnit.Timestamp(it.timestamp),
- XXXValueWithUnit.TherapyEventType(it.type)
+ XXXValueWithUnit.TherapyEventType(it.type)*/
+ result.inserted.forEach {
+ uel.log(Action.CAREPORTAL,
+ it.note ?: "", ValueWithUnit(Sources.NSClient),
+ ValueWithUnit(it.timestamp, Units.Timestamp, true),
+ ValueWithUnit(it.type.text, Units.TherapyEvent)
)
}
- result.invalidated.forEach {
+ /*result.invalidated.forEach {
uel.log(UserEntry.Action.CAREPORTAL_DELETED_FROM_NS,
it.note ?: "",
XXXValueWithUnit.Timestamp(it.timestamp),
- XXXValueWithUnit.TherapyEventType(it.type)
+ XXXValueWithUnit.TherapyEventType(it.type)*/
+ result.invalidated.forEach {
+ uel.log(UserEntry.Action.CAREPORTAL_REMOVED,
+ it.note ?: "", ValueWithUnit(Sources.NSClient),
+ ValueWithUnit(it.timestamp, Units.Timestamp, true),
+ ValueWithUnit(it.type.text, Units.TherapyEvent)
)
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientRemoveWorker.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientRemoveWorker.kt
index db6a6405ff..5f86c0f846 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientRemoveWorker.kt
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientRemoveWorker.kt
@@ -8,6 +8,7 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
import info.nightscout.androidaps.database.entities.UserEntry
+import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.database.transactions.SyncTemporaryTargetTransaction
import info.nightscout.androidaps.database.transactions.SyncTherapyEventTransaction
import info.nightscout.androidaps.events.EventNsTreatment
@@ -24,6 +25,7 @@ import info.nightscout.androidaps.utils.buildHelper.BuildHelper
import info.nightscout.androidaps.utils.extensions.temporaryTargetFromNsIdForInvalidating
import info.nightscout.androidaps.utils.extensions.therapyEventFromNsIdForInvalidating
import info.nightscout.androidaps.utils.sharedPreferences.SP
+import java.util.concurrent.TimeUnit
import javax.inject.Inject
// This will not be needed fpr NS v3
@@ -66,7 +68,7 @@ class NSClientRemoveWorker(
}
.blockingGet()
.also { result ->
- result.invalidated.forEach { tt ->
+ /*result.invalidated.forEach { tt ->
uel.log(
UserEntry.Action.TT_DELETED_FROM_NS,
XXXValueWithUnit.TherapyEventTTReason(tt.reason),
@@ -74,6 +76,15 @@ class NSClientRemoveWorker(
XXXValueWithUnit.Mgdl(tt.highTarget).takeIf { tt.lowTarget != tt.highTarget },
XXXValueWithUnit.Minute(tt.duration.toInt() / 60000).takeIf { tt.duration != 0L }
)
+ }*/
+ result.invalidated.forEach {
+ uel.log(
+ Action.TT_REMOVED, ValueWithUnit(Sources.NSClient),
+ ValueWithUnit(it.reason.text, Units.TherapyEvent),
+ ValueWithUnit(it.lowTarget, Units.Mg_Dl, true),
+ ValueWithUnit(it.highTarget, Units.Mg_Dl, it.lowTarget != it.highTarget),
+ ValueWithUnit(TimeUnit.MILLISECONDS.toMinutes(it.duration).toInt(), Units.M, it.duration != 0L)
+ )
}
}
@@ -87,10 +98,15 @@ class NSClientRemoveWorker(
.blockingGet()
.also { result ->
result.invalidated.forEach {
- uel.log(
+ /*uel.log(
UserEntry.Action.CAREPORTAL_DELETED_FROM_NS, (it.note ?: ""),
XXXValueWithUnit.Timestamp(it.timestamp),
- XXXValueWithUnit.TherapyEventType(it.type))
+ XXXValueWithUnit.TherapyEventType(it.type))*/
+ uel.log(
+ Action.CAREPORTAL_REMOVED, (it.note ?: ""), ValueWithUnit(Sources.NSClient),
+ ValueWithUnit(it.timestamp, Units.Timestamp, true),
+ ValueWithUnit(it.type.text, Units.TherapyEvent))
+
}
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt
index 98eb0dbf2d..2cf20f9c45 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt
@@ -348,7 +348,7 @@ class SmsCommunicatorPlugin @Inject constructor(
receivedSms.processed = true
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
override fun run() {
- uel.log(Action.SMS_LOOP_DISABLED)
+ uel.log(Action.LOOP_DISABLED, ValueWithUnit(Sources.SMS))
loopPlugin.setPluginEnabled(PluginType.LOOP, false)
commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() {
@@ -372,7 +372,7 @@ class SmsCommunicatorPlugin @Inject constructor(
receivedSms.processed = true
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
override fun run() {
- uel.log(Action.SMS_LOOP_ENABLED)
+ uel.log(Action.LOOP_ENABLED, ValueWithUnit(Sources.SMS))
loopPlugin.setPluginEnabled(PluginType.LOOP, true)
sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_loophasbeenenabled)))
rxBus.send(EventRefreshOverview("SMS_LOOP_START"))
@@ -399,7 +399,7 @@ class SmsCommunicatorPlugin @Inject constructor(
receivedSms.processed = true
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
override fun run() {
- uel.log(Action.SMS_LOOP_RESUME)
+ uel.log(Action.RESUME, ValueWithUnit(Sources.SMS))
loopPlugin.suspendTo(0L)
rxBus.send(EventRefreshOverview("SMS_LOOP_RESUME"))
commandQueue.cancelTempBasal(true, object : Callback() {
@@ -432,7 +432,7 @@ class SmsCommunicatorPlugin @Inject constructor(
receivedSms.processed = true
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(duration) {
override fun run() {
- uel.log(Action.SMS_LOOP_SUSPEND)
+ uel.log(Action.SUSPEND, ValueWithUnit(Sources.SMS))
commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() {
if (result.success) {
@@ -516,7 +516,7 @@ class SmsCommunicatorPlugin @Inject constructor(
receivedSms.processed = true
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
override fun run() {
- uel.log(Action.SMS_PUMP_CONNECT)
+ uel.log(Action.RECONNECT, ValueWithUnit(Sources.SMS))
commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() {
if (!result.success) {
@@ -545,7 +545,7 @@ class SmsCommunicatorPlugin @Inject constructor(
receivedSms.processed = true
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
override fun run() {
- uel.log(Action.SMS_PUMP_DISCONNECT)
+ uel.log(Action.DISCONNECT, ValueWithUnit(Sources.SMS))
val profile = profileFunction.getProfile()
loopPlugin.disconnectPump(duration, profile)
rxBus.send(EventRefreshOverview("SMS_PUMP_DISCONNECT"))
@@ -602,7 +602,8 @@ class SmsCommunicatorPlugin @Inject constructor(
activePlugin.activeTreatments.doProfileSwitch(store, list[pIndex - 1] as String, 0, finalPercentage, 0, DateUtil.now())
val replyText = resourceHelper.gs(R.string.profileswitchcreated)
sendSMS(Sms(receivedSms.phoneNumber, replyText))
- uel.log(Action.SMS_PROFILE, XXXValueWithUnit.StringResource(R.string.profileswitchcreated))
+ //uel.log(Action.SMS_PROFILE, XXXValueWithUnit.StringResource(R.string.profileswitchcreated))
+ uel.log(Action.PROFILE_SWITCH, ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.profileswitchcreated, Units.R_String))
}
})
}
@@ -624,12 +625,14 @@ class SmsCommunicatorPlugin @Inject constructor(
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalcanceled)
replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
- uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_tempbasalcanceled))
+ //uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_tempbasalcanceled))
+ uel.log(Action.TEMP_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_tempbasalcanceled, Units.R_String))
} else {
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalcancelfailed)
replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText))
- uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_tempbasalcancelfailed))
+ //uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_tempbasalcancelfailed))
+ uel.log(Action.TEMP_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_tempbasalcancelfailed, Units.R_String))
}
}
})
@@ -658,14 +661,17 @@ 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), XXXValueWithUnit.StringResource(R.string.smscommunicator_tempbasalset_percent, listOf(XXXValueWithUnit.Percent(result.percent), XXXValueWithUnit.Minute(result.duration))) )
+ //uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_tempbasalset_percent, listOf(XXXValueWithUnit.Percent(result.percent), XXXValueWithUnit.Minute(result.duration))) )
+ uel.log(Action.TEMP_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_tempbasalset_percent, 2), ValueWithUnit(result.percent, Units.Percent), ValueWithUnit(result.duration, Units.M))
else
- uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_tempbasalset, listOf( XXXValueWithUnit.UnitPerHour(result.absolute), XXXValueWithUnit.Minute(result.duration))))
+ //uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_tempbasalset, listOf( XXXValueWithUnit.UnitPerHour(result.absolute), XXXValueWithUnit.Minute(result.duration))))
+ uel.log(Action.TEMP_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_tempbasalset, 2), ValueWithUnit(result.absolute, Units.U_H), ValueWithUnit(result.duration, Units.M))
} else {
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed)
replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText))
- uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_tempbasalfailed))
+ //uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_tempbasalfailed))
+ uel.log(Action.TEMP_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_tempbasalfailed, Units.R_String))
}
}
})
@@ -696,14 +702,17 @@ 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), XXXValueWithUnit.StringResource(R.string.smscommunicator_tempbasalset_percent, listOf(XXXValueWithUnit.Percent(result.percent), XXXValueWithUnit.Minute(result.duration))))
+ //uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_tempbasalset_percent, listOf(XXXValueWithUnit.Percent(result.percent), XXXValueWithUnit.Minute(result.duration))))
+ uel.log(Action.TEMP_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_tempbasalset_percent, 2), ValueWithUnit(result.percent, Units.Percent), ValueWithUnit(result.duration, Units.M))
else
- uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_tempbasalset, listOf(XXXValueWithUnit.UnitPerHour(result.absolute), XXXValueWithUnit.Minute(result.duration))))
+ //uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_tempbasalset, listOf(XXXValueWithUnit.UnitPerHour(result.absolute), XXXValueWithUnit.Minute(result.duration))))
+ uel.log(Action.TEMP_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_tempbasalset, 2), ValueWithUnit(result.absolute, Units.U_H), ValueWithUnit(result.duration, Units.M))
} else {
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed)
replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText))
- uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_tempbasalfailed))
+ //uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_tempbasalfailed))
+ uel.log(Action.TEMP_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_tempbasalfailed, Units.R_String))
}
}
})
@@ -730,7 +739,8 @@ class SmsCommunicatorPlugin @Inject constructor(
var replyText = resourceHelper.gs(R.string.smscommunicator_extendedcancelfailed)
replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText))
- uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_extendedcanceled))
+ //uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_extendedcanceled))
+ uel.log(Action.EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_extendedcanceled, Units.R_String))
}
}
})
@@ -757,16 +767,21 @@ 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), XXXValueWithUnit.StringResource(R.string.smscommunicator_extendedset, listOf(XXXValueWithUnit.Insulin(aDouble
- ?: 0.0), XXXValueWithUnit.Minute(duration))), XXXValueWithUnit.StringResource(R.string.loopsuspended))
+ //uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_extendedset, listOf(XXXValueWithUnit.Insulin(aDouble
+ // ?: 0.0), XXXValueWithUnit.Minute(duration))), XXXValueWithUnit.StringResource(R.string.loopsuspended))
+ uel.log(Action.EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_extendedset, 2), ValueWithUnit(aDouble
+ ?: 0.0, Units.U), ValueWithUnit(duration, Units.M), ValueWithUnit(R.string.loopsuspended, Units.R_String))
else
- uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_extendedset, listOf( XXXValueWithUnit.Insulin(aDouble
- ?: 0.0), XXXValueWithUnit.Minute(duration))))
+ //uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_extendedset, listOf( XXXValueWithUnit.Insulin(aDouble
+ // ?: 0.0), XXXValueWithUnit.Minute(duration))))
+ uel.log(Action.EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_extendedset, 2), ValueWithUnit(aDouble
+ ?: 0.0, Units.U), ValueWithUnit(duration, Units.M))
} else {
var replyText = resourceHelper.gs(R.string.smscommunicator_extendedfailed)
replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText))
- uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_extendedfailed))
+ //uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_extendedfailed))
+ uel.log(Action.EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_extendedfailed, Units.R_String))
}
}
})
@@ -839,12 +854,13 @@ class SmsCommunicatorPlugin @Inject constructor(
}
}
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
- uel.log(Action.SMS_BOLUS, replyText)
+ uel.log(Action.BOLUS, replyText, ValueWithUnit(Sources.SMS))
} else {
var replyText = resourceHelper.gs(R.string.smscommunicator_bolusfailed)
replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText))
- uel.log(Action.SMS_BOLUS, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_bolusfailed))
+ //uel.log(Action.SMS_BOLUS, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_bolusfailed))
+ uel.log(Action.BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_bolusfailed, Units.R_String))
}
}
})
@@ -884,13 +900,17 @@ 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), XXXValueWithUnit.StringResource(R.string.smscommunicator_carbsset, listOf(XXXValueWithUnit.Gram(anInteger ?: 0))))
+ //uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_carbsset, listOf(XXXValueWithUnit.Gram(anInteger ?: 0))))
+ uel.log(Action.CARBS, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_carbsset, 1), ValueWithUnit(anInteger
+ ?: 0, Units.G))
} else {
var replyText = resourceHelper.gs(R.string.smscommunicator_carbsfailed, anInteger)
replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText))
- uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_carbsfailed, listOf(XXXValueWithUnit.Gram(anInteger
- ?: 0))))
+ //uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_carbsfailed, listOf(XXXValueWithUnit.Gram(anInteger
+ // ?: 0))))
+ uel.log(Action.CARBS, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_carbsfailed, 1), ValueWithUnit(anInteger
+ ?: 0, Units.G))
}
}
})
@@ -899,8 +919,10 @@ 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), XXXValueWithUnit.StringResource(R.string.smscommunicator_carbsset, listOf(XXXValueWithUnit.Gram(anInteger
- ?: 0))))
+ //uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_carbsset, listOf(XXXValueWithUnit.Gram(anInteger
+ // ?: 0))))
+ uel.log(Action.CARBS, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_carbsset, 1), ValueWithUnit(anInteger
+ ?: 0, Units.G))
}
}
})
@@ -970,7 +992,8 @@ class SmsCommunicatorPlugin @Inject constructor(
val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_tt_set), ttString, ttDuration)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
//uel.log(Action.SMS_TT, ValueWithUnit(R.string.smscommunicator_tt_set, 2), ValueWithUnit(tt, units), ValueWithUnit(ttDuration, Units.M))
- uel.log(Action.SMS_TT, XXXValueWithUnit.fromGlucoseUnit(tt, units), XXXValueWithUnit.Minute(ttDuration))
+ //uel.log(Action.SMS_TT, XXXValueWithUnit.fromGlucoseUnit(tt, units), XXXValueWithUnit.Minute(ttDuration))
+ uel.log(Action.TT, ValueWithUnit(Sources.SMS), ValueWithUnit(tt, units), ValueWithUnit(ttDuration, Units.M))
}
})
} else if (isStop) {
@@ -987,7 +1010,8 @@ class SmsCommunicatorPlugin @Inject constructor(
})
val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_tt_canceled))
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
- uel.log(Action.SMS_TT, XXXValueWithUnit.StringResource(R.string.smscommunicator_tt_canceled))
+ //uel.log(Action.SMS_TT, XXXValueWithUnit.StringResource(R.string.smscommunicator_tt_canceled))
+ uel.log(Action.CANCEL_TT, ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_tt_canceled, Units.R_String))
}
})
} else
@@ -1006,7 +1030,8 @@ class SmsCommunicatorPlugin @Inject constructor(
sp.putBoolean(R.string.key_smscommunicator_remotecommandsallowed, false)
val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_stoppedsms))
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
- uel.log(Action.SMS_SMS, XXXValueWithUnit.StringResource(R.string.smscommunicator_stoppedsms))
+ //uel.log(Action.SMS_SMS, XXXValueWithUnit.StringResource(R.string.smscommunicator_stoppedsms))
+ uel.log(Action.STOP_SMS, ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_stoppedsms, Units.R_String))
}
})
} else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat)))
@@ -1025,9 +1050,11 @@ class SmsCommunicatorPlugin @Inject constructor(
if (result) resourceHelper.gs(R.string.smscommunicator_calibrationsent) else resourceHelper.gs(R.string.smscommunicator_calibrationfailed)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
if (result)
- uel.log(Action.SMS_CAL, XXXValueWithUnit.StringResource(R.string.smscommunicator_calibrationsent))
+ //uel.log(Action.SMS_CAL, XXXValueWithUnit.StringResource(R.string.smscommunicator_calibrationsent))
+ uel.log(Action.CALIBRATION, ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_calibrationsent, Units.R_String))
else
- uel.log(Action.SMS_CAL, XXXValueWithUnit.StringResource(R.string.smscommunicator_calibrationfailed))
+ //uel.log(Action.SMS_CAL, XXXValueWithUnit.StringResource(R.string.smscommunicator_calibrationfailed))
+ uel.log(Action.CALIBRATION, ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_calibrationfailed, Units.R_String))
}
})
} else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat)))
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt
index 9e672abbb4..e9a3cb9cd8 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt
@@ -17,6 +17,7 @@ import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.ValueWrapper
import info.nightscout.androidaps.database.entities.TemporaryTarget
import info.nightscout.androidaps.database.entities.TherapyEvent
+import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.database.interfaces.end
import info.nightscout.androidaps.database.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
import info.nightscout.androidaps.database.transactions.InsertTemporaryTargetAndCancelCurrentTransaction
@@ -24,6 +25,7 @@ import info.nightscout.androidaps.db.Source
import info.nightscout.androidaps.db.TDD
import info.nightscout.androidaps.interfaces.*
import info.nightscout.androidaps.logging.AAPSLogger
+import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
@@ -59,7 +61,7 @@ class ActionStringHandler @Inject constructor(
private val sp: SP,
private val rxBus: RxBusWrapper,
private val aapsLogger: AAPSLogger,
- aapsSchedulers: AapsSchedulers,
+ private val aapsSchedulers: AapsSchedulers,
private val resourceHelper: ResourceHelper,
private val injector: HasAndroidInjector,
private val context: Context,
@@ -82,6 +84,7 @@ class ActionStringHandler @Inject constructor(
private val config: Config,
private val databaseHelper: DatabaseHelperInterface,
private val repository: AppRepository,
+ private val uel: UserEntryLogger,
private val nsUpload: NSUpload
) {
@@ -92,7 +95,7 @@ class ActionStringHandler @Inject constructor(
private val disposable = CompositeDisposable()
- init {
+ fun setup() {
disposable += rxBus
.toObservable(EventWearInitiateAction::class.java)
.observeOn(aapsSchedulers.main)
@@ -104,6 +107,10 @@ class ActionStringHandler @Inject constructor(
.subscribe({ handleConfirmation(it.action) }, fabricPrivacy::logException)
}
+ fun tearDown(){
+ disposable.clear()
+ }
+
@Synchronized
private fun handleInitiate(actionString: String) {
if (!sp.getBoolean(R.string.key_wear_control, false)) return
@@ -546,8 +553,10 @@ class ActionStringHandler @Inject constructor(
if (carbs > 0) {
if (duration == 0) {
carbsGenerator.createCarb(carbs, time, TherapyEvent.Type.CARBS_CORRECTION, "watch")
+ uel.log(Action.CARBS, ValueWithUnit(Sources.Wear), ValueWithUnit(time, Units.Timestamp), ValueWithUnit(carbs, Units.G))
} else {
carbsGenerator.generateCarbs(carbs, time, duration, "watch eCarbs")
+ uel.log(Action.EXTENDED_CARBS, ValueWithUnit(Sources.Wear), ValueWithUnit(time, Units.Timestamp), ValueWithUnit(carbs, Units.G), ValueWithUnit(duration, Units.H))
}
}
}
@@ -575,11 +584,12 @@ class ActionStringHandler @Inject constructor(
return
}
//send profile to pump
+ uel.log(Action.PROFILE_SWITCH, ValueWithUnit(Sources.Wear), ValueWithUnit(percentage, Units.Percent), ValueWithUnit(timeshift, Units.H, timeshift != 0))
activePlugin.activeTreatments.doProfileSwitch(0, percentage, timeshift)
}
private fun generateTempTarget(duration: Int, low: Double, high: Double) {
- if (duration != 0)
+ if (duration != 0) {
disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
timestamp = System.currentTimeMillis(),
duration = TimeUnit.MINUTES.toMillis(duration.toLong()),
@@ -592,13 +602,16 @@ class ActionStringHandler @Inject constructor(
}, {
aapsLogger.error("Error while saving temporary target", it)
})
- else
+ uel.log(Action.TT, ValueWithUnit(Sources.Wear), ValueWithUnit(TemporaryTarget.Reason.WEAR.text, Units.TherapyEvent), ValueWithUnit(low, profileFunction.getUnits()), ValueWithUnit(high, profileFunction.getUnits(), low!=high), ValueWithUnit(duration, Units.M))
+ } else {
disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(System.currentTimeMillis()))
.subscribe({ result ->
result.updated.forEach { nsUpload.updateTempTarget(it) }
}, {
aapsLogger.error("Error while saving temporary target", it)
})
+ uel.log(Action.CANCEL_TT, ValueWithUnit(Sources.Wear), ValueWithUnit(TemporaryTarget.Reason.WEAR.text, Units.TherapyEvent))
+ }
}
private fun doFillBolus(amount: Double) {
@@ -606,6 +619,7 @@ class ActionStringHandler @Inject constructor(
detailedBolusInfo.insulin = amount
detailedBolusInfo.isValid = false
detailedBolusInfo.source = Source.USER
+ uel.log(Action.PRIME_BOLUS, ValueWithUnit(Sources.Wear), ValueWithUnit(amount, Units.U, amount != 0.0))
commandQueue.bolus(detailedBolusInfo, object : Callback() {
override fun run() {
if (!result.success) {
@@ -624,6 +638,12 @@ class ActionStringHandler @Inject constructor(
detailedBolusInfo.source = Source.USER
val storesCarbs = activePlugin.activePump.pumpDescription.storesCarbInfo
if (detailedBolusInfo.insulin > 0 || storesCarbs) {
+ val action = when {
+ amount.equals(0.0) -> Action.CARBS
+ carbs.equals(0) -> Action.BOLUS
+ else -> Action.TREATMENT
+ }
+ uel.log(action, ValueWithUnit(Sources.Wear), ValueWithUnit(amount, Units.U, amount != 0.0), ValueWithUnit(carbs, Units.G, carbs != 0))
commandQueue.bolus(detailedBolusInfo, object : Callback() {
override fun run() {
if (!result.success) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/WearPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/WearPlugin.kt
index f3cdd7a7f2..e4a486a89e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/WearPlugin.kt
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/WearPlugin.kt
@@ -35,7 +35,8 @@ class WearPlugin @Inject constructor(
private val mainApp: MainApp,
private val fabricPrivacy: FabricPrivacy,
private val loopPlugin: Lazy,
- private val rxBus: RxBusWrapper
+ private val rxBus: RxBusWrapper,
+ private val actionStringHandler: Lazy
) : PluginBase(PluginDescription()
.mainType(PluginType.GENERAL)
@@ -127,11 +128,13 @@ class WearPlugin @Inject constructor(
mainApp.startService(intent)
}
}, fabricPrivacy::logException))
+ actionStringHandler.get().setup()
}
override fun onStop() {
disposable.clear()
super.onStop()
+ actionStringHandler.get().tearDown()
}
private fun sendDataToWatch(status: Boolean, basals: Boolean, bgValue: Boolean) {
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 ccc2c19596..a5aa201156 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
@@ -163,7 +163,7 @@ class LocalProfileFragment : DaggerFragment() {
if (localProfilePlugin.isEdited) {
activity?.let { OKDialog.show(it, "", resourceHelper.gs(R.string.saveorresetchangesfirst)) }
} else {
- uel.log(Action.NEW_PROFILE)
+ uel.log(Action.NEW_PROFILE, ValueWithUnit(Sources.LocalProfile))
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(Action.CLONE_PROFILE, localProfilePlugin.currentProfile()?.name ?: "")
+ uel.log(Action.CLONE_PROFILE, ValueWithUnit(Sources.LocalProfile), ValueWithUnit(localProfilePlugin.currentProfile()?.name ?: "", Units.None))
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(Action.PROFILE_REMOVED, localProfilePlugin.currentProfile()?.name ?: "")
+ uel.log(Action.PROFILE_REMOVED, ValueWithUnit(Sources.LocalProfile), ValueWithUnit(localProfilePlugin.currentProfile()?.name ?: "", Units.None))
localProfilePlugin.removeCurrentProfile()
build()
}, null)
@@ -210,6 +210,7 @@ class LocalProfileFragment : DaggerFragment() {
if (!localProfilePlugin.isValidEditState()) {
return@setOnClickListener //Should not happen as saveButton should not be visible if not valid
}
+ uel.log(Action.STORE_PROFILE, ValueWithUnit(Sources.LocalProfile), ValueWithUnit(localProfilePlugin.currentProfile()?.name ?: "", Units.None))
localProfilePlugin.storeSettings(activity)
build()
}
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 8da1e6b188..42006090c5 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
@@ -116,7 +116,6 @@ class LocalProfilePlugin @Inject constructor(
createAndStoreConvertedProfile()
isEdited = false
aapsLogger.debug(LTag.PROFILE, "Storing settings: " + rawProfile?.data.toString())
- uel.log(Action.STORE_PROFILE)
rxBus.send(EventProfileStoreChanged())
var namesOK = true
profiles.forEach {
@@ -294,6 +293,7 @@ class LocalProfilePlugin @Inject constructor(
fun cloneProfile() {
val p = profiles[currentProfileIndex].deepClone()
+ val sourceName = p.name
p.name = p.name + " copy"
profiles.add(p)
currentProfileIndex = profiles.size - 1
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 23ca873cc0..c26376ad9e 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
@@ -70,7 +70,7 @@ class TreatmentsBolusFragment : DaggerFragment() {
binding.refreshFromNightscout.setOnClickListener {
activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.refresheventsfromnightscout) + "?") {
- uel.log(Action.TREATMENTS_NS_REFRESH)
+ uel.log(Action.TREATMENTS_NS_REFRESH, ValueWithUnit(Sources.Treatments))
treatmentsPlugin.service.resetTreatments()
rxBus.send(EventNSClientRestart())
}
@@ -79,7 +79,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(Action.DELETE_FUTURE_TREATMENTS)
+ uel.log(Action.DELETE_FUTURE_TREATMENTS, ValueWithUnit(Sources.Treatments))
val futureTreatments = treatmentsPlugin.service.getTreatmentDataFromTime(DateUtil.now() + 1000, true)
for (treatment in futureTreatments) {
if (NSUpload.isIdValid(treatment._id))
@@ -176,7 +176,8 @@ 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(Action.TREATMENT_REMOVED, XXXValueWithUnit.Timestamp(treatment.date), XXXValueWithUnit.Insulin(treatment.insulin).takeIf { treatment.insulin != 0.0 }, XXXValueWithUnit.Gram(treatment.carbs.toInt()).takeIf { treatment.carbs != 0.0 })
+ //uel.log(Action.TREATMENT_REMOVED, XXXValueWithUnit.Timestamp(treatment.date), XXXValueWithUnit.Insulin(treatment.insulin).takeIf { treatment.insulin != 0.0 }, XXXValueWithUnit.Gram(treatment.carbs.toInt()).takeIf { treatment.carbs != 0.0 })
+ uel.log(Action.TREATMENT_REMOVED, ValueWithUnit(Sources.Treatments), ValueWithUnit(treatment.date, Units.Timestamp), ValueWithUnit(treatment.insulin, Units.U, treatment.insulin != 0.0), ValueWithUnit(treatment.carbs.toInt(), Units.G, treatment.carbs != 0.0))
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 dd497a61d0..9b9abe8a05 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
@@ -80,7 +80,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(Action.CAREPORTAL_NS_REFRESH)
+ uel.log(Action.CAREPORTAL_NS_REFRESH, ValueWithUnit(Sources.Treatments))
disposable += Completable.fromAction { repository.deleteAllTherapyEventsEntries() }
.subscribeOn(aapsSchedulers.io)
.observeOn(aapsSchedulers.main)
@@ -95,7 +95,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(Action.RESTART_EVENTS_REMOVED)
+ uel.log(Action.RESTART_EVENTS_REMOVED, ValueWithUnit(Sources.Treatments))
// val events = databaseHelper.getCareportalEvents(false)
repository.runTransactionForResult(InvalidateAAPSStartedTherapyEventTransaction())
.subscribe({ result ->
@@ -197,7 +197,8 @@ class TreatmentsCareportalFragment : DaggerFragment() {
resourceHelper.gs(R.string.notes_label) + ": " + (therapyEvent.note ?: "") + "\n" +
resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(therapyEvent.timestamp)
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable {
- uel.log(Action.CAREPORTAL_REMOVED, therapyEvent.note , XXXValueWithUnit.Timestamp(therapyEvent.timestamp), XXXValueWithUnit.TherapyEventType(therapyEvent.type))
+ //uel.log(Action.CAREPORTAL_REMOVED, therapyEvent.note , XXXValueWithUnit.Timestamp(therapyEvent.timestamp), XXXValueWithUnit.TherapyEventType(therapyEvent.type))
+ uel.log(Action.CAREPORTAL_REMOVED, therapyEvent.note, ValueWithUnit(Sources.Treatments), ValueWithUnit(therapyEvent.timestamp, Units.Timestamp), ValueWithUnit(therapyEvent.type.text, Units.TherapyEvent))
disposable += repository.runTransactionForResult(InvalidateTherapyEventTransaction(therapyEvent.id))
.subscribe({
val id = therapyEvent.interfaceIDs.nightscoutId
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsExtendedBolusesFragment.kt
index bbecd9b5bd..93f0c49c09 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
@@ -123,7 +123,7 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() {
${resourceHelper.gs(R.string.extended_bolus)}
${resourceHelper.gs(R.string.date)}: ${dateUtil.dateAndTimeString(extendedBolus.date)}
""".trimIndent(), { _: DialogInterface, _: Int ->
- uel.log(Action.EXTENDED_BOLUS_REMOVED)
+ uel.log(Action.EXTENDED_BOLUS_REMOVED, ValueWithUnit(Sources.Treatments))
val id = extendedBolus._id
if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id)
else uploadQueue.removeByMongoId("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 df5baf3c90..f5bbba9c96 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
@@ -72,7 +72,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() {
binding.refreshFromNightscout.setOnClickListener {
activity?.let { activity ->
- uel.log(Action.PROFILE_SWITCH_NS_REFRESH)
+ uel.log(Action.PROFILE_SWITCH_NS_REFRESH, ValueWithUnit(Sources.Treatments))
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.refresheventsfromnightscout) + "?") {
databaseHelper.resetProfileSwitch()
rxBus.send(EventNSClientRestart())
@@ -149,7 +149,8 @@ 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(Action.PROFILE_SWITCH_REMOVED, profileSwitch.profileName, XXXValueWithUnit.Timestamp(profileSwitch.date))
+ //uel.log(Action.PROFILE_SWITCH_REMOVED, profileSwitch.profileName, XXXValueWithUnit.Timestamp(profileSwitch.date))
+ uel.log(Action.PROFILE_SWITCH_REMOVED, ValueWithUnit(Sources.Treatments), ValueWithUnit(profileSwitch.date, Units.Timestamp), ValueWithUnit(profileSwitch.profileName, Units.None))
val id = profileSwitch._id
if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id)
else uploadQueue.removeByMongoId("dbAdd", id)
@@ -162,7 +163,8 @@ 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, XXXValueWithUnit.Timestamp(profileSwitch.date), XXXValueWithUnit.SimpleString(profileSwitch.profileName))
+ //uel.log(Action.PROFILE_SWITCH_CLONED, XXXValueWithUnit.Timestamp(profileSwitch.date), XXXValueWithUnit.SimpleString(profileSwitch.profileName))
+ uel.log(Action.PROFILE_SWITCH_CLONED, profileSwitch.customizedName + " " + dateUtil.dateAndTimeString(profileSwitch.date).replace(".", "_") , ValueWithUnit(Sources.Treatments), 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/TreatmentsTempTargetFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt
index c481cde64c..c7d4336cc3 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
@@ -87,7 +87,7 @@ class TreatmentsTempTargetFragment : DaggerFragment() {
binding.refreshFromNightscout.setOnClickListener {
context?.let { context ->
OKDialog.showConfirmation(context, resourceHelper.gs(R.string.refresheventsfromnightscout) + " ?", {
- uel.log(Action.TT_NS_REFRESH)
+ uel.log(Action.TT_NS_REFRESH, ValueWithUnit(Sources.Treatments))
disposable += Completable.fromAction { repository.deleteAllTempTargetEntries() }
.subscribeOn(aapsSchedulers.io)
.observeOn(aapsSchedulers.main)
@@ -197,7 +197,8 @@ class TreatmentsTempTargetFragment : DaggerFragment() {
${dateUtil.dateAndTimeString(tempTarget.timestamp)}
""".trimIndent(),
{ _: DialogInterface?, _: Int ->
- uel.log(Action.TT_REMOVED, XXXValueWithUnit.Timestamp(tempTarget.timestamp), XXXValueWithUnit.TherapyEventTTReason(tempTarget.reason), XXXValueWithUnit.Mgdl(tempTarget.lowTarget), XXXValueWithUnit.Mgdl(tempTarget.highTarget).takeIf { tempTarget.lowTarget != tempTarget.highTarget }, XXXValueWithUnit.Minute(tempTarget.duration.toInt()))
+ //uel.log(Action.TT_REMOVED, XXXValueWithUnit.Timestamp(tempTarget.timestamp), XXXValueWithUnit.TherapyEventTTReason(tempTarget.reason), XXXValueWithUnit.Mgdl(tempTarget.lowTarget), XXXValueWithUnit.Mgdl(tempTarget.highTarget).takeIf { tempTarget.lowTarget != tempTarget.highTarget }, XXXValueWithUnit.Minute(tempTarget.duration.toInt()))
+ uel.log(Action.TT_REMOVED, ValueWithUnit(Sources.Treatments), ValueWithUnit(tempTarget.timestamp, Units.Timestamp), ValueWithUnit(tempTarget.reason.text, Units.TherapyEvent), ValueWithUnit(tempTarget.lowTarget, Units.Mg_Dl), ValueWithUnit(tempTarget.highTarget, Units.Mg_Dl, tempTarget.lowTarget != tempTarget.highTarget), ValueWithUnit(tempTarget.duration.toInt(), Units.M))
disposable += repository.runTransactionForResult(InvalidateTemporaryTargetTransaction(tempTarget.id))
.subscribe({
val id = tempTarget.interfaceIDs.nightscoutId
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 70fefc6d6e..40daaffc78 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
@@ -165,7 +165,8 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() {
${resourceHelper.gs(R.string.date)}: ${dateUtil.dateAndTimeString(tempBasal.date)}
""".trimIndent(),
{ _: DialogInterface?, _: Int ->
- uel.log(Action.TT_REMOVED, XXXValueWithUnit.Timestamp(tempBasal.date))
+ //uel.log(Action.TT_REMOVED, XXXValueWithUnit.Timestamp(tempBasal.date))
+ uel.log(Action.TT_REMOVED, ValueWithUnit(Sources.Treatments), 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 a3edbdf086..65a39e32c6 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
@@ -1,6 +1,7 @@
package info.nightscout.androidaps.plugins.treatments.fragments
import android.os.Bundle
+import android.renderscript.Sampler
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@@ -19,6 +20,7 @@ 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.treatments.events.EventTreatmentUpdateGui
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.DecimalFormatter
import info.nightscout.androidaps.utils.FabricPrivacy
@@ -28,6 +30,7 @@ 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
+import java.util.concurrent.TimeUnit
import javax.inject.Inject
class TreatmentsUserEntryFragment : DaggerFragment() {
@@ -62,20 +65,29 @@ class TreatmentsUserEntryFragment : DaggerFragment() {
binding.ueExportToXml.setOnClickListener {
activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.ue_export_to_csv) + "?") {
- uel.log(Action.EXPORT_CSV)
+ uel.log(Action.EXPORT_CSV, ValueWithUnit(Sources.Treatments))
importExportPrefs.exportUserEntriesCsv(activity, repository.getAllUserEntries())
}
}
}
-
+ binding.showLoop.setOnCheckedChangeListener { _, _ ->
+ rxBus.send(EventTreatmentUpdateGui())
+ }
}
fun swapAdapter() {
- disposable.add( repository
- .getAllUserEntries()
- .observeOn(aapsSchedulers.main)
- .subscribe { list -> binding.recyclerview.swapAdapter(UserEntryAdapter(list), true) }
- )
+ if (binding.showLoop.isChecked)
+ disposable.add( repository
+ .getAllUserEntries()
+ .observeOn(aapsSchedulers.main)
+ .subscribe { list -> binding.recyclerview.swapAdapter(UserEntryAdapter(list), true) }
+ )
+ else
+ disposable.add( repository
+ .getAllUserEntries()
+ .observeOn(aapsSchedulers.main)
+ .subscribe { list -> binding.recyclerview.swapAdapter(UserEntryAdapter(filterUserEntries(list)), true) }
+ )
}
@Synchronized
@@ -87,6 +99,11 @@ class TreatmentsUserEntryFragment : DaggerFragment() {
.toObservable(EventPreferenceChange::class.java)
.observeOn(aapsSchedulers.io)
.subscribe({ swapAdapter() }, fabricPrivacy::logException))
+ disposable.add(rxBus
+ .toObservable(EventTreatmentUpdateGui::class.java)
+ .observeOn(aapsSchedulers.io)
+ .debounce(1L, TimeUnit.SECONDS)
+ .subscribe({ swapAdapter() }, fabricPrivacy::logException))
}
@Synchronized
@@ -112,15 +129,15 @@ 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 = translator.translate(current.action)
- holder.binding.action.setTextColor(resourceHelper.gc(userEntryPresentationHelper.colorId(current.action.colorGroup)))
- if (current.remark != "") {
- holder.binding.s.text = current.remark
+
+ if (current.s != "") {
+ holder.binding.s.text = current.s
holder.binding.s.visibility = View.VISIBLE
} else
holder.binding.s.visibility = View.GONE
var valuesWithUnitString = ""
var rStringParam = 0
+ var source = Sources.Unknown
val separator = " "
for(v in current.values) {
if (rStringParam >0)
@@ -145,11 +162,19 @@ class TreatmentsUserEntryFragment : DaggerFragment() {
-> valuesWithUnitString += DecimalFormatter.to2Decimal(v.dValue) + translator.translate(v.unit) + separator
Units.G, Units.M, Units.H, Units.Percent
-> valuesWithUnitString += v.iValue.toString() + translator.translate(v.unit) + separator
+ Units.Source -> source = Sources.fromText(v.sValue) // = separator + translator.translate(v.sValue)
else -> valuesWithUnitString += if (v.iValue != 0 || v.sValue != "") { v.value().toString() + separator } else ""
}
}
+ if (source.iconId() > 0) {
+ holder.binding.iconSource.setImageResource(source.iconId())
+ holder.binding.iconSource.visibility = View.VISIBLE
+ } else
+ holder.binding.iconSource.visibility = View.INVISIBLE
holder.binding.values.text = valuesWithUnitString.trim()
- holder.binding.values.visibility = if (current.values.size > 0) View.VISIBLE else View.GONE
+ holder.binding.values.visibility = if (holder.binding.values.text != "") View.VISIBLE else View.GONE
+ holder.binding.action.text = translator.translate(current.action.name)
+ holder.binding.action.setTextColor(resourceHelper.gc(userEntryPresentationHelper.colorId(current.action.colorGroup)))
}
inner class UserEntryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
@@ -158,6 +183,13 @@ class TreatmentsUserEntryFragment : DaggerFragment() {
}
override fun getItemCount(): Int = entries.size
+ }
+ fun filterUserEntries(list: List): List {
+ val filteredList = mutableListOf()
+ for (ue in list) {
+ if (! ue.isLoop()) filteredList.add(ue)
+ }
+ return filteredList
}
}
\ No newline at end of file
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 ad9fed31aa..035e1e847a 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
@@ -350,7 +350,8 @@ class BolusWizard @Inject constructor(
boluscalc = nsJSON()
source = Source.USER
notes = this@BolusWizard.notes
- uel.log(Action.BOLUS_ADVISOR, notes, XXXValueWithUnit.TherapyEventType(eventType), XXXValueWithUnit.Insulin(insulinAfterConstraints))
+ //uel.log(Action.BOLUS_ADVISOR, notes, XXXValueWithUnit.TherapyEventType(eventType), XXXValueWithUnit.Insulin(insulinAfterConstraints))
+ uel.log(Action.BOLUS_ADVISOR, notes, ValueWithUnit(Sources.WizardDialog), ValueWithUnit(eventType, Units.TherapyEvent), ValueWithUnit(insulinAfterConstraints, Units.U))
if (insulin > 0) {
commandQueue.bolus(this, object : Callback() {
override fun run() {
@@ -373,7 +374,7 @@ class BolusWizard @Inject constructor(
OKDialog.showConfirmation(ctx, resourceHelper.gs(R.string.boluswizard), confirmMessage, {
if (insulinAfterConstraints > 0 || carbs > 0) {
if (useSuperBolus) {
- uel.log(Action.SUPERBOLUS_TBR)
+ uel.log(Action.SUPERBOLUS_TBR, ValueWithUnit(Sources.WizardDialog))
if (loopPlugin.isEnabled(PluginType.LOOP)) {
loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000)
rxBus.send(EventRefreshOverview("WizardDialog"))
@@ -414,7 +415,13 @@ class BolusWizard @Inject constructor(
boluscalc = nsJSON()
source = Source.USER
notes = this@BolusWizard.notes
- uel.log(Action.BOLUS, notes, XXXValueWithUnit.TherapyEventType(eventType), XXXValueWithUnit.Insulin(insulinAfterConstraints), XXXValueWithUnit.Gram(this@BolusWizard.carbs).takeIf { this@BolusWizard.carbs != 0 }, XXXValueWithUnit.Minute(carbTime).takeIf { carbTime != 0 })
+ //uel.log(Action.BOLUS, notes, XXXValueWithUnit.TherapyEventType(eventType), XXXValueWithUnit.Insulin(insulinAfterConstraints), XXXValueWithUnit.Gram(this@BolusWizard.carbs).takeIf { this@BolusWizard.carbs != 0 }, XXXValueWithUnit.Minute(carbTime).takeIf { carbTime != 0 })
+ val action = when {
+ insulinAfterConstraints.equals(0.0) -> Action.CARBS
+ carbs.equals(0.0) -> Action.BOLUS
+ else -> Action.TREATMENT
+ }
+ uel.log(action, notes, ValueWithUnit(Sources.WizardDialog), ValueWithUnit(insulinAfterConstraints, Units.U), ValueWithUnit(this@BolusWizard.carbs, Units.G, this@BolusWizard.carbs != 0), ValueWithUnit(carbTime, Units.M, carbTime != 0))
if (insulin > 0 || pump.pumpDescription.storesCarbInfo) {
commandQueue.bolus(this, object : Callback() {
override fun run() {
diff --git a/app/src/main/res/layout/treatments_user_entry_fragment.xml b/app/src/main/res/layout/treatments_user_entry_fragment.xml
index f4b98829b8..53c9f9199c 100644
--- a/app/src/main/res/layout/treatments_user_entry_fragment.xml
+++ b/app/src/main/res/layout/treatments_user_entry_fragment.xml
@@ -1,18 +1,44 @@
-
+ android:orientation="horizontal">
+
+
+
+
+
+
+
+
+
-
+ android:orientation="horizontal" >
-
-
-
+ app:layout_constraintStart_toEndOf="@id/date"
+ app:layout_constraintEnd_toStartOf="@+id/iconSource"
+ app:layout_constraintTop_toTopOf="parent"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+
+
-
@@ -54,8 +63,12 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="20dp"
- android:visibility="gone"
+ android:paddingEnd="10dp"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@id/values"
android:textAppearance="?android:attr/textAppearanceSmall"
+ android:visibility="gone"
+ android:text="Notes"
tools:ignore="HardcodedText,RtlSymmetry" />
-
-
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 52a1be72c3..8dfbcdc78a 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -131,7 +131,6 @@
Which constraints are applied?
Constraints
- Loop
Loop
Use this to activate AndroidAPS\' loop integration.
APS
@@ -511,7 +510,6 @@
Amount of hours in the past for sensitivity detection (carbs absorption time is excluded)
openapsama_autosens_period
nsclient_localbroadcasts
- Pump
OpenAPS
Uploader
Sensitivity detection
diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopDisable.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopDisable.kt
index a629243628..e7610bae06 100644
--- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopDisable.kt
+++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopDisable.kt
@@ -4,12 +4,15 @@ import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.data.PumpEnactResult
+import info.nightscout.androidaps.database.entities.UserEntry
+import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.events.EventRefreshOverview
import info.nightscout.androidaps.interfaces.CommandQueueProvider
import info.nightscout.androidaps.interfaces.ConfigBuilderInterface
import info.nightscout.androidaps.interfaces.LoopInterface
import info.nightscout.androidaps.interfaces.PluginBase
import info.nightscout.androidaps.interfaces.PluginType
+import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.resources.ResourceHelper
@@ -21,6 +24,7 @@ class ActionLoopDisable(injector: HasAndroidInjector) : Action(injector) {
@Inject lateinit var configBuilderPlugin: ConfigBuilderInterface
@Inject lateinit var commandQueue: CommandQueueProvider
@Inject lateinit var rxBus: RxBusWrapper
+ @Inject lateinit var uel: UserEntryLogger
override fun friendlyName(): Int = R.string.disableloop
override fun shortDescription(): String = resourceHelper.gs(R.string.disableloop)
@@ -30,6 +34,7 @@ class ActionLoopDisable(injector: HasAndroidInjector) : Action(injector) {
if ((loopPlugin as PluginBase).isEnabled()) {
(loopPlugin as PluginBase).setPluginEnabled(PluginType.LOOP, false)
configBuilderPlugin.storeSettings("ActionLoopDisable")
+ uel.log(UserEntry.Action.LOOP_DISABLED, ValueWithUnit(Sources.Automation))
commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() {
rxBus.send(EventRefreshOverview("ActionLoopDisable"))
diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopEnable.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopEnable.kt
index 43c7e897f7..86301aca48 100644
--- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopEnable.kt
+++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopEnable.kt
@@ -4,11 +4,14 @@ import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.data.PumpEnactResult
+import info.nightscout.androidaps.database.entities.UserEntry
+import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.events.EventRefreshOverview
import info.nightscout.androidaps.interfaces.ConfigBuilderInterface
import info.nightscout.androidaps.interfaces.LoopInterface
import info.nightscout.androidaps.interfaces.PluginBase
import info.nightscout.androidaps.interfaces.PluginType
+import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.resources.ResourceHelper
@@ -20,6 +23,7 @@ class ActionLoopEnable(injector: HasAndroidInjector) : Action(injector) {
@Inject lateinit var loopPlugin: LoopInterface
@Inject lateinit var configBuilderPlugin: ConfigBuilderInterface
@Inject lateinit var rxBus: RxBusWrapper
+ @Inject lateinit var uel: UserEntryLogger
override fun friendlyName(): Int = R.string.enableloop
override fun shortDescription(): String = resourceHelper.gs(R.string.enableloop)
@@ -30,6 +34,7 @@ class ActionLoopEnable(injector: HasAndroidInjector) : Action(injector) {
(loopPlugin as PluginBase).setPluginEnabled(PluginType.LOOP, true)
configBuilderPlugin.storeSettings("ActionLoopEnable")
rxBus.send(EventRefreshOverview("ActionLoopEnable"))
+ uel.log(UserEntry.Action.LOOP_ENABLED, ValueWithUnit(Sources.Automation))
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
} else {
callback.result(PumpEnactResult(injector).success(true).comment(R.string.alreadyenabled))?.run()
diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopResume.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopResume.kt
index 4e910c594c..05c7a47652 100644
--- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopResume.kt
+++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopResume.kt
@@ -4,9 +4,12 @@ import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.data.PumpEnactResult
+import info.nightscout.androidaps.database.entities.UserEntry
+import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.events.EventRefreshOverview
import info.nightscout.androidaps.interfaces.ConfigBuilderInterface
import info.nightscout.androidaps.interfaces.LoopInterface
+import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.resources.ResourceHelper
@@ -17,6 +20,7 @@ class ActionLoopResume(injector: HasAndroidInjector) : Action(injector) {
@Inject lateinit var loopPlugin: LoopInterface
@Inject lateinit var configBuilderPlugin: ConfigBuilderInterface
@Inject lateinit var rxBus: RxBusWrapper
+ @Inject lateinit var uel: UserEntryLogger
override fun friendlyName(): Int = R.string.resumeloop
override fun shortDescription(): String = resourceHelper.gs(R.string.resumeloop)
@@ -28,6 +32,7 @@ class ActionLoopResume(injector: HasAndroidInjector) : Action(injector) {
configBuilderPlugin.storeSettings("ActionLoopResume")
loopPlugin.createOfflineEvent(0)
rxBus.send(EventRefreshOverview("ActionLoopResume"))
+ uel.log(UserEntry.Action.RESUME, ValueWithUnit(Sources.Automation))
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
} else {
callback.result(PumpEnactResult(injector).success(true).comment(R.string.notsuspended))?.run()
diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopSuspend.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopSuspend.kt
index 92bb748abd..6b0e835984 100644
--- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopSuspend.kt
+++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopSuspend.kt
@@ -5,8 +5,11 @@ import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.data.PumpEnactResult
+import info.nightscout.androidaps.database.entities.UserEntry
+import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.events.EventRefreshOverview
import info.nightscout.androidaps.interfaces.LoopInterface
+import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration
import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement
@@ -21,6 +24,7 @@ class ActionLoopSuspend(injector: HasAndroidInjector) : Action(injector) {
@Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var loopPlugin: LoopInterface
@Inject lateinit var rxBus: RxBusWrapper
+ @Inject lateinit var uel: UserEntryLogger
var minutes = InputDuration(30, InputDuration.TimeUnit.MINUTES)
@@ -32,6 +36,7 @@ class ActionLoopSuspend(injector: HasAndroidInjector) : Action(injector) {
if (!loopPlugin.isSuspended) {
loopPlugin.suspendLoop(minutes.getMinutes())
rxBus.send(EventRefreshOverview("ActionLoopSuspend"))
+ uel.log(UserEntry.Action.SUSPEND, ValueWithUnit(Sources.Automation), ValueWithUnit(minutes.getMinutes(), Units.M))
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
} else {
callback.result(PumpEnactResult(injector).success(true).comment(R.string.alreadysuspended))?.run()
diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitch.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitch.kt
index de4f6e769f..f447fd8882 100644
--- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitch.kt
+++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitch.kt
@@ -5,9 +5,12 @@ import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.data.PumpEnactResult
+import info.nightscout.androidaps.database.entities.UserEntry
+import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.interfaces.ProfileFunction
+import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.general.automation.elements.InputProfileName
import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement
import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder
@@ -22,6 +25,7 @@ class ActionProfileSwitch(injector: HasAndroidInjector) : Action(injector) {
@Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var activePlugin: ActivePluginProvider
@Inject lateinit var profileFunction: ProfileFunction
+ @Inject lateinit var uel: UserEntryLogger
var inputProfileName: InputProfileName = InputProfileName(resourceHelper, activePlugin, "")
@@ -53,6 +57,7 @@ class ActionProfileSwitch(injector: HasAndroidInjector) : Action(injector) {
callback.result(PumpEnactResult(injector).success(false).comment(R.string.notexists))?.run()
return
}
+ uel.log(UserEntry.Action.PROFILE_SWITCH, ValueWithUnit(Sources.Automation), ValueWithUnit(inputProfileName.value, Units.None), ValueWithUnit(100, Units.Percent))
activePlugin.activeTreatments.doProfileSwitch(profileStore, inputProfileName.value, 0, 100, 0, DateUtil.now())
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
}
diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercent.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercent.kt
index 689fcd945f..e730ad93b0 100644
--- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercent.kt
+++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionProfileSwitchPercent.kt
@@ -5,7 +5,10 @@ import androidx.annotation.DrawableRes
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.data.PumpEnactResult
+import info.nightscout.androidaps.database.entities.UserEntry
+import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.interfaces.ActivePluginProvider
+import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration
import info.nightscout.androidaps.plugins.general.automation.elements.InputPercent
@@ -21,6 +24,7 @@ import javax.inject.Inject
class ActionProfileSwitchPercent(injector: HasAndroidInjector) : Action(injector) {
@Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var activePlugin: ActivePluginProvider
+ @Inject lateinit var uel: UserEntryLogger
var pct = InputPercent()
var duration = InputDuration(30, InputDuration.TimeUnit.MINUTES)
@@ -37,6 +41,7 @@ class ActionProfileSwitchPercent(injector: HasAndroidInjector) : Action(injector
}
override fun doAction(callback: Callback) {
+ uel.log(UserEntry.Action.PROFILE_SWITCH, ValueWithUnit(Sources.Automation), ValueWithUnit(pct.value.toInt(), Units.Percent), ValueWithUnit(duration.value, Units.M))
activePlugin.activeTreatments.doProfileSwitch(duration.value, pct.value.toInt(), 0)
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
}
diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTarget.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTarget.kt
index 7bebe4ac6c..89bf71def2 100644
--- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTarget.kt
+++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTarget.kt
@@ -9,10 +9,13 @@ import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.data.PumpEnactResult
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.entities.UserEntry.*
import info.nightscout.androidaps.database.transactions.InsertTemporaryTargetAndCancelCurrentTransaction
import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.logging.LTag
+import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.general.automation.elements.ComparatorExists
import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration
import info.nightscout.androidaps.plugins.general.automation.elements.InputTempTarget
@@ -39,6 +42,7 @@ class ActionStartTempTarget(injector: HasAndroidInjector) : Action(injector) {
@Inject lateinit var repository: AppRepository
@Inject lateinit var nsUpload: NSUpload
@Inject lateinit var profileFunction: ProfileFunction
+ @Inject lateinit var uel: UserEntryLogger
private val disposable = CompositeDisposable()
@@ -58,6 +62,7 @@ class ActionStartTempTarget(injector: HasAndroidInjector) : Action(injector) {
.subscribe({ result ->
result.inserted.forEach { nsUpload.uploadTempTarget(it) }
result.updated.forEach { nsUpload.updateTempTarget(it) }
+ uel.log(UserEntry.Action.TT, ValueWithUnit(Sources.Automation), ValueWithUnit(TemporaryTarget.Reason.AUTOMATION.text, Units.TherapyEvent), ValueWithUnit(tt().lowTarget, Units.Mg_Dl), ValueWithUnit(tt().highTarget, Units.Mg_Dl, tt().lowTarget!=tt().highTarget), ValueWithUnit(TimeUnit.MILLISECONDS.toMinutes(tt().duration).toInt(), Units.M))
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
}, {
aapsLogger.error(LTag.BGSOURCE, "Error while saving temporary target", it)
diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTarget.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTarget.kt
index e566c6f6cf..7c24ad8e6a 100644
--- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTarget.kt
+++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTarget.kt
@@ -4,9 +4,11 @@ import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.database.AppRepository
+import info.nightscout.androidaps.database.entities.UserEntry
import info.nightscout.androidaps.database.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.logging.LTag
+import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.DateUtil
@@ -22,6 +24,7 @@ class ActionStopTempTarget(injector: HasAndroidInjector) : Action(injector) {
@Inject lateinit var repository: AppRepository
@Inject lateinit var nsUpload: NSUpload
@Inject lateinit var dateUtil: DateUtil
+ @Inject lateinit var uel: UserEntryLogger
private val disposable = CompositeDisposable()
@@ -32,6 +35,7 @@ class ActionStopTempTarget(injector: HasAndroidInjector) : Action(injector) {
override fun doAction(callback: Callback) {
disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(DateUtil.now()))
.subscribe({ result ->
+ uel.log(UserEntry.Action.CANCEL_TT, UserEntry.ValueWithUnit(UserEntry.Sources.Automation))
result.updated.forEach { nsUpload.updateTempTarget(it) }
}, {
aapsLogger.error(LTag.BGSOURCE, "Error while saving temporary target", it)
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 da3558d584..bf043af81e 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
@@ -88,43 +88,79 @@ class ClassicPrefsFormat @Inject constructor(
}
fun UserEntriesToCsv(userEntries: List): String {
- val userEntryHeader = resourceHelper.gs(R.string.ue_csv_header) + "\n"
+ val userEntryHeader = resourceHelper.gs(R.string.ue_csv_header,
+ csvString(R.string.ue_timestamp),
+ csvString(R.string.date),
+ csvString(R.string.ue_utc_offset),
+ csvString(R.string.ue_action),
+ csvString(R.string.eventtype),
+ csvString(R.string.ue_source),
+ csvString(R.string.careportal_note),
+ csvString(R.string.ue_formated_string),
+ csvString(R.string.event_time_label),
+ csvString(Units.fromText(profileFunction.getUnits())),
+ csvString(Units.G),
+ csvString(Units.U),
+ csvString(Units.U_H),
+ csvString(Units.Percent),
+ csvString(Units.H),
+ csvString(Units.M),
+ csvString(R.string.ue_none)
+ ) + "\n"
return userEntryHeader + userEntries.joinToString("\n") { entry ->
- if (entry.values.size > 0) {
- entry.values.joinToString("\n") { value ->
- entry.timestamp.toString() + ";" +
- dateUtil.dateAndTimeAndSecondsString(entry.timestamp) + ";" +
- dateUtil.timeString(entry.utcOffset) + ";" +
- csvString(entry.action) + ";" +
- csvString(entry.remark) + ";" +
- valueWithUnitToCsv(value)
+ var timestampRec = "" + entry.timestamp
+ var dateTimestampRev = dateUtil.dateAndTimeAndSecondsString(entry.timestamp)
+ var utcOffset = dateUtil.timeString(entry.utcOffset)
+ var action = csvString(entry.action)
+ var therapyEvent = ""
+ var source = ""
+ var note = csvString(entry.s)
+ var formatedString = ""
+ var timestamp = ""
+ var bg = ""
+ var g = ""
+ var u = ""
+ var uh = ""
+ var percent = ""
+ var h = ""
+ var m = ""
+ var other = ""
+
+ for (v in entry.values) {
+ when (v.unit) {
+ Units.Timestamp -> timestamp = dateUtil.dateAndTimeAndSecondsString(v.lValue)
+ Units.TherapyEvent -> therapyEvent = if (therapyEvent == "") translator.translate(v.sValue) else therapyEvent + " / " + translator.translate(v.sValue) //Todo update with XXXValueWithUnit
+ Units.Source -> source = csvString(v.sValue)
+ Units.R_String -> if (v.iValue != 0) { //Formated string lValue is the number of parameters, up to 3
+ var rStringParam = v.lValue.toInt()
+ var tempString = ""
+ when (rStringParam) { //
+ 0 -> tempString = resourceHelper.gs(v.iValue)
+ 1 -> tempString = resourceHelper.gs(v.iValue, entry.values[entry.values.indexOf(v)+1].value())
+ 2 -> tempString = resourceHelper.gs(v.iValue, entry.values[entry.values.indexOf(v)+1].value(), entry.values[entry.values.indexOf(v)+2].value())
+ 3 -> tempString = resourceHelper.gs(v.iValue, entry.values[entry.values.indexOf(v)+1].value(), entry.values[entry.values.indexOf(v)+2].value(), entry.values[entry.values.indexOf(v)+3].value())
+ }
+ formatedString = if (formatedString == "") tempString else formatedString + " / " + tempString
+ }
+ Units.Mg_Dl -> bg = if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue) else DecimalFormatter.to1Decimal(v.dValue/Constants.MMOLL_TO_MGDL)
+ Units.Mmol_L -> bg = if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue*Constants.MMOLL_TO_MGDL) else DecimalFormatter.to1Decimal(v.dValue)
+ Units.G -> g = v.iValue.toString()
+ Units.U -> u = DecimalFormatter.to2Decimal(v.dValue)
+ Units.U_H -> uh = DecimalFormatter.to2Decimal(v.dValue)
+ Units.Percent -> percent = v.iValue.toString()
+ Units.H -> h = v.iValue.toString()
+ Units.M -> m = v.iValue.toString()
+ else -> other = if (other == "") v.value().toString() else other + " / " + v.value().toString()
}
- } else {
- entry.timestamp.toString() + ";" +
- dateUtil.dateAndTimeAndSecondsString(entry.timestamp) + ";" +
- dateUtil.timeString(entry.utcOffset) + ";" +
- csvString(entry.action) + ";" +
- csvString(entry.remark) + ";;"
}
+ therapyEvent = csvString(therapyEvent)
+ formatedString = csvString(formatedString)
+ other = csvString(other)
+ timestampRec + ";" + dateTimestampRev + ";" + utcOffset + ";" + action + ";" + therapyEvent + ";" + source + ";" + note + ";" + formatedString + ";" + timestamp + ";" + bg + ";" + g + ";" + u + ";" + uh + ";" + percent + ";" + h + ";" + m + ";" + other
}
}
- fun valueWithUnitToCsv(v: ValueWithUnit): String {
- return when (v.unit) {
- Units.Timestamp -> dateUtil.dateAndTimeAndSecondsString(v.lValue) + ";" + csvString(R.string.date)
- Units.TherapyEvent -> csvString(translator.translate(v.sValue)) + ";"
- Units.R_String -> if (v.lValue.toInt() == 0) csvString(v.iValue) + ";" else ";" //If lValue > 0 it's a formated string, so hidden for
- Units.Mg_Dl -> if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue) + ";" + csvString(Units.Mg_Dl) else DecimalFormatter.to1Decimal(v.dValue/Constants.MMOLL_TO_MGDL) + ";" + csvString(Units.Mmol_L)
- Units.Mmol_L -> if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue*Constants.MMOLL_TO_MGDL) + ";" + csvString(Units.Mg_Dl) else DecimalFormatter.to1Decimal(v.dValue) + ";" + csvString(Units.Mmol_L)
- Units.U_H, Units.U -> DecimalFormatter.to2Decimal(v.dValue) + ";" + csvString(v.unit)
- Units.G, Units.M, Units.H, Units.Percent
- -> v.iValue.toString() + ";" + csvString(v.unit)
- else -> if (v.sValue != "") { csvString(v.sValue) + ";" + csvString(v.unit)}
- else if (v.iValue != 0) { v.iValue.toString() + ";" + csvString(v.unit)}
- else ";"
- }
- }
-
+ private fun saveString(id: Int): String = if (id != 0) resourceHelper.gs(id) else ""
private fun csvString(action: Action): String = "\"" + translator.translate(action).replace("\"", "\"\"") + "\""
private fun csvString(unit: Units): String = "\"" + translator.translate(unit).replace("\"", "\"\"") + "\""
private fun csvString(id: Int): String = if (id != 0) "\"" + resourceHelper.gs(id).replace("\"", "\"\"") + "\"" else ""
diff --git a/core/src/main/java/info/nightscout/androidaps/utils/Translator.kt b/core/src/main/java/info/nightscout/androidaps/utils/Translator.kt
index a87f4701e3..d8f2efda06 100644
--- a/core/src/main/java/info/nightscout/androidaps/utils/Translator.kt
+++ b/core/src/main/java/info/nightscout/androidaps/utils/Translator.kt
@@ -170,5 +170,16 @@ class Translator @Inject internal constructor(
else -> resourceHelper.gs(R.string.unknown)
}
-
+
+ fun translate(source: Sources): String = when(source) {
+ Sources.Automation.text -> resourceHelper.gs(R.string.automation)
+ Sources.Loop.text -> resourceHelper.gs(R.string.loop)
+ Sources.NSClient.text -> resourceHelper.gs(R.string.ns)
+ Sources.Pump.text -> resourceHelper.gs(R.string.pump)
+ Sources.SMS.text -> resourceHelper.gs(R.string.smb_shortname)
+ Sources.Wear.text -> resourceHelper.gs(R.string.wear)
+ Sources.Unknown.text -> resourceHelper.gs(R.string.unknown)
+
+ else -> resourceHelper.gs(R.string.unknown)
+ }
}
\ No newline at end of file
diff --git a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt
new file mode 100644
index 0000000000..1ae362d5c1
--- /dev/null
+++ b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt
@@ -0,0 +1,51 @@
+package info.nightscout.androidaps.utils.extensions
+
+import info.nightscout.androidaps.core.R
+import info.nightscout.androidaps.database.entities.UserEntry.*
+
+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 Sources.iconId(): Int {
+ return when (this) {
+ Sources.TreatmentDialog -> R.drawable.icon_insulin_carbs
+ Sources.InsulinDialog -> R.drawable.ic_bolus
+ Sources.CarbDialog -> R.drawable.ic_cp_bolus_carbs
+ Sources.WizardDialog -> R.drawable.ic_calculator
+ Sources.QuickWizard -> R.drawable.ic_quick_wizard
+ Sources.ExtendedBolusDialog -> R.drawable.ic_actions_startextbolus
+ Sources.TTDialog -> R.drawable.ic_temptarget_high
+ Sources.ProfileSwitchDialog -> R.drawable.ic_actions_profileswitch
+ Sources.LoopDialog -> R.drawable.ic_loop_closed
+ Sources.TempBasalDialog -> R.drawable.ic_actions_starttempbasal
+ Sources.CalibrationDialog -> R.drawable.ic_calibration
+ Sources.FillDialog -> R.drawable.ic_cp_pump_canula
+ Sources.BgCheck -> R.drawable.ic_cp_bgcheck
+ Sources.SensorInsert -> R.drawable.ic_cp_cgm_insert
+ Sources.BatteryChange -> R.drawable.ic_cp_pump_battery
+ Sources.Note -> R.drawable.ic_cp_note
+ Sources.Exercise -> R.drawable.ic_cp_exercise
+ Sources.Question -> R.drawable.ic_cp_question
+ Sources.Announcement -> R.drawable.ic_cp_announcement
+ Sources.Maintenance -> R.drawable.ic_maintenance
+ Sources.Treatments -> R.drawable.ic_treatments
+ Sources.LocalProfile -> R.drawable.ic_local_profile
+ Sources.Actions -> R.drawable.ic_action
+ Sources.Automation -> R.drawable.ic_automation
+ Sources.Loop -> R.drawable.ic_loop_closed_white
+ Sources.NSClient -> R.drawable.ic_nightscout_syncs
+ Sources.Wear -> R.drawable.ic_watch
+ else -> -1
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_action.xml b/core/src/main/res/drawable/ic_action.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_action.xml
rename to core/src/main/res/drawable/ic_action.xml
diff --git a/app/src/main/res/drawable/ic_actions_startextbolus.xml b/core/src/main/res/drawable/ic_actions_startextbolus.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_actions_startextbolus.xml
rename to core/src/main/res/drawable/ic_actions_startextbolus.xml
diff --git a/app/src/main/res/drawable/ic_actions_starttempbasal.xml b/core/src/main/res/drawable/ic_actions_starttempbasal.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_actions_starttempbasal.xml
rename to core/src/main/res/drawable/ic_actions_starttempbasal.xml
diff --git a/automation/src/main/res/drawable/ic_automation.xml b/core/src/main/res/drawable/ic_automation.xml
similarity index 100%
rename from automation/src/main/res/drawable/ic_automation.xml
rename to core/src/main/res/drawable/ic_automation.xml
diff --git a/app/src/main/res/drawable/ic_calculator.xml b/core/src/main/res/drawable/ic_calculator.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_calculator.xml
rename to core/src/main/res/drawable/ic_calculator.xml
diff --git a/app/src/main/res/drawable/ic_calibration.xml b/core/src/main/res/drawable/ic_calibration.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_calibration.xml
rename to core/src/main/res/drawable/ic_calibration.xml
diff --git a/app/src/main/res/drawable/ic_cp_announcement.xml b/core/src/main/res/drawable/ic_cp_announcement.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_cp_announcement.xml
rename to core/src/main/res/drawable/ic_cp_announcement.xml
diff --git a/app/src/main/res/drawable/ic_cp_cgm_insert.xml b/core/src/main/res/drawable/ic_cp_cgm_insert.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_cp_cgm_insert.xml
rename to core/src/main/res/drawable/ic_cp_cgm_insert.xml
diff --git a/app/src/main/res/drawable/ic_cp_exercise.xml b/core/src/main/res/drawable/ic_cp_exercise.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_cp_exercise.xml
rename to core/src/main/res/drawable/ic_cp_exercise.xml
diff --git a/app/src/main/res/drawable/ic_cp_note.xml b/core/src/main/res/drawable/ic_cp_note.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_cp_note.xml
rename to core/src/main/res/drawable/ic_cp_note.xml
diff --git a/app/src/main/res/drawable/ic_cp_pump_battery.xml b/core/src/main/res/drawable/ic_cp_pump_battery.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_cp_pump_battery.xml
rename to core/src/main/res/drawable/ic_cp_pump_battery.xml
diff --git a/app/src/main/res/drawable/ic_cp_pump_canula.xml b/core/src/main/res/drawable/ic_cp_pump_canula.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_cp_pump_canula.xml
rename to core/src/main/res/drawable/ic_cp_pump_canula.xml
diff --git a/app/src/main/res/drawable/ic_cp_question.xml b/core/src/main/res/drawable/ic_cp_question.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_cp_question.xml
rename to core/src/main/res/drawable/ic_cp_question.xml
diff --git a/app/src/main/res/drawable/ic_local_profile.xml b/core/src/main/res/drawable/ic_local_profile.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_local_profile.xml
rename to core/src/main/res/drawable/ic_local_profile.xml
diff --git a/app/src/main/res/drawable/ic_loop_closed.xml b/core/src/main/res/drawable/ic_loop_closed.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_loop_closed.xml
rename to core/src/main/res/drawable/ic_loop_closed.xml
diff --git a/app/src/main/res/drawable/ic_loop_closed_white.xml b/core/src/main/res/drawable/ic_loop_closed_white.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_loop_closed_white.xml
rename to core/src/main/res/drawable/ic_loop_closed_white.xml
diff --git a/insight/src/main/res/drawable/ic_maintenance.xml b/core/src/main/res/drawable/ic_maintenance.xml
similarity index 100%
rename from insight/src/main/res/drawable/ic_maintenance.xml
rename to core/src/main/res/drawable/ic_maintenance.xml
diff --git a/app/src/main/res/drawable/ic_nightscout_syncs.xml b/core/src/main/res/drawable/ic_nightscout_syncs.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_nightscout_syncs.xml
rename to core/src/main/res/drawable/ic_nightscout_syncs.xml
diff --git a/app/src/main/res/drawable/ic_quick_wizard.xml b/core/src/main/res/drawable/ic_quick_wizard.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_quick_wizard.xml
rename to core/src/main/res/drawable/ic_quick_wizard.xml
diff --git a/app/src/main/res/drawable/ic_treatments.xml b/core/src/main/res/drawable/ic_treatments.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_treatments.xml
rename to core/src/main/res/drawable/ic_treatments.xml
diff --git a/app/src/main/res/drawable/ic_watch.xml b/core/src/main/res/drawable/ic_watch.xml
similarity index 100%
rename from app/src/main/res/drawable/ic_watch.xml
rename to core/src/main/res/drawable/ic_watch.xml
diff --git a/app/src/main/res/drawable/icon_insulin_carbs.xml b/core/src/main/res/drawable/icon_insulin_carbs.xml
similarity index 100%
rename from app/src/main/res/drawable/icon_insulin_carbs.xml
rename to core/src/main/res/drawable/icon_insulin_carbs.xml
diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml
index 7ccc01f2af..b06b77261c 100644
--- a/core/src/main/res/values/strings.xml
+++ b/core/src/main/res/values/strings.xml
@@ -276,6 +276,10 @@
Wear
Automation
Custom
+ Pump
+ Loop
+ NS
+ Record
Connection timed out
@@ -401,7 +405,6 @@
BOLUS
BOLUS ADVISOR
- BOLUS RECORD
EXTENDED BOLUS
SUPERBOLUS TBR
CARBS
@@ -466,30 +469,17 @@
IMPORT DATABASES
OTP EXPORT
OTP RESET
- SMS BASAL
- SMS BOLUS
- SMS CAL
- SMS CARBS
- SMS EXTENDED BOLUS
- SMS LOOP DISABLED
- SMS LOOP ENABLED
- SMS LOOP RESUME
- SMS LOOP SUSPEND
- SMS PROFILE
- SMS PUMP CONNECT
- SMS PUMP DISCONNECT
- SMS SMS
- SMS TT
- TT DELETED FROM NS
- CAREPORTAL DELETED FROM NS
- CAREPORTAL FROM NS
- TT FROM NS
- TT CANCELED FROM NS
+ STOP SMS
EXPORT USER ENTRIES
UNKNOWN
- Formated string
+ Formated string
+ Source
+ UTC Offset
+ Action
+ Timestamp
+ No Unit
Export User Entries to Excel (csv)
- "Timestamp;Date;UTC Offset;Action;Note;Value;Unit"
+ "%1$s;%2$s;%3$s;%4$s;%5$s;%6$s;%7$s;%8$s;%9$s;%10$s;%11$s;%12$s;%13$s;%14$s;%15$s;%16$s;%17$s"
- %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 1c43cbe25f..903854cb8e 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
@@ -15,14 +15,14 @@ data class UserEntry(
override var timestamp: Long,
override var utcOffset: Long = TimeZone.getDefault().getOffset(timestamp).toLong(),
var action: Action,
- var remark: String,
+ var s: String,
// val sources: Sources,
var values: MutableList
) : DBEntry, DBEntryWithTime {
enum class Action (val colorGroup: ColorGroup) {
@SerializedName("BOLUS") BOLUS (ColorGroup.InsulinTreatment),
+ @SerializedName("SMB") SMB (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),
@@ -87,26 +87,8 @@ data class UserEntry(
@SerializedName("IMPORT_DATABASES") IMPORT_DATABASES (ColorGroup.Aaps),
@SerializedName("OTP_EXPORT") OTP_EXPORT (ColorGroup.Aaps),
@SerializedName("OTP_RESET") OTP_RESET (ColorGroup.Aaps),
- @SerializedName("SMS_BASAL") SMS_BASAL (ColorGroup.InsulinTreatment),
- @SerializedName("SMS_BOLUS") SMS_BOLUS (ColorGroup.InsulinTreatment),
- @SerializedName("SMS_CAL") SMS_CAL (ColorGroup.Careportal),
- @SerializedName("SMS_CARBS") SMS_CARBS (ColorGroup.CarbTreatment),
- @SerializedName("SMS_EXTENDED_BOLUS") SMS_EXTENDED_BOLUS (ColorGroup.InsulinTreatment),
- @SerializedName("SMS_LOOP_DISABLED") SMS_LOOP_DISABLED (ColorGroup.Loop),
- @SerializedName("SMS_LOOP_ENABLED") SMS_LOOP_ENABLED (ColorGroup.Loop),
- @SerializedName("SMS_LOOP_RESUME") SMS_LOOP_RESUME (ColorGroup.Loop),
- @SerializedName("SMS_LOOP_SUSPEND") SMS_LOOP_SUSPEND (ColorGroup.Loop),
- @SerializedName("SMS_PROFILE") SMS_PROFILE (ColorGroup.Profile),
- @SerializedName("SMS_PUMP_CONNECT") SMS_PUMP_CONNECT (ColorGroup.Pump),
- @SerializedName("SMS_PUMP_DISCONNECT") SMS_PUMP_DISCONNECT (ColorGroup.Pump),
- @SerializedName("SMS_SMS") SMS_SMS (ColorGroup.Aaps),
- @SerializedName("SMS_TT") SMS_TT (ColorGroup.TT),
- @SerializedName("TT_DELETED_FROM_NS") TT_DELETED_FROM_NS (ColorGroup.TT),
- @SerializedName("CAREPORTAL_DELETED_FROM_NS") CAREPORTAL_DELETED_FROM_NS (ColorGroup.Careportal),
- @SerializedName("CAREPORTAL_FROM_NS") CAREPORTAL_FROM_NS (ColorGroup.Careportal),
- @SerializedName("FOOD_FROM_NS") FOOD_FROM_NS (ColorGroup.Careportal),
- @SerializedName("TT_FROM_NS") TT_FROM_NS (ColorGroup.TT),
- @SerializedName("TT_CANCELED_FROM_NS") TT_CANCELED_FROM_NS (ColorGroup.TT),
+ @SerializedName("STOP_SMS") STOP_SMS (ColorGroup.Aaps),
+ @SerializedName("FOOD") FOOD (ColorGroup.Careportal),
@SerializedName("EXPORT_CSV") EXPORT_CSV (ColorGroup.Aaps),
@SerializedName("UNKNOWN") UNKNOWN (ColorGroup.Aaps)
;
@@ -116,10 +98,18 @@ data class UserEntry(
}
}
data class ValueWithUnit (val dValue: Double=0.0, val iValue: Int=0, val lValue: Long=0, val sValue: String="", val unit: Units=Units.None, val condition:Boolean=true){
+ constructor(dvalue: Double, unit: Units, condition:Boolean = true) : this(dvalue, 0, 0, "", unit, condition)
+ constructor(ivalue: Int, unit: Units, condition:Boolean = true) : this(0.0, ivalue, 0, "", unit, condition)
+ constructor(lvalue: Long, unit: Units, condition:Boolean = true) : this(0.0,0, lvalue, "", unit, condition)
+ constructor(svalue: String, unit:Units) : this(0.0,0, 0, svalue, unit, svalue != "")
+ constructor(source: Sources) : this(0.0,0, 0, source.text, Units.Source, true)
+ constructor(dvalue: Double, unit:String, condition:Boolean = true) : this(dvalue,0, 0, "", Units.fromText(unit), condition)
+ constructor(rStringRef: Int, nbParam: Long) : this(0.0, rStringRef, nbParam, "", Units.R_String, !rStringRef.equals(0)) // additionnal constructors for formated strings with additional values as parameters (define number of parameters as long
+
fun value() : Any {
if (sValue != "") return sValue
if (!dValue.equals(0.0)) return dValue
- if (iValue != 0) return iValue
+ if (!iValue.equals(0)) return iValue
return lValue
}
}
@@ -135,7 +125,8 @@ data class UserEntry(
@SerializedName("H") H ("h"), //Int
@SerializedName("Percent") Percent ("%"), //Int
@SerializedName("TherapyEvent") TherapyEvent ("TherapyEvent"), //String (All enum key translated by Translator function, mainly TherapyEvent)
- @SerializedName("R_String") R_String ("R.string") //Int
+ @SerializedName("R_String") R_String ("R.string"), //Int
+ @SerializedName("Source") Source ("Source") //String
;
companion object {
@@ -143,6 +134,45 @@ data class UserEntry(
fun fromText(unit: String?) = values().firstOrNull { it.text == unit } ?: None
}
}
+ enum class Sources(val text: String) {
+ @SerializedName("TreatmentDialog") TreatmentDialog ("TreatmentDialog"),
+ @SerializedName("InsulinDialog") InsulinDialog ("InsulinDialog"),
+ @SerializedName("CarbDialog") CarbDialog ("CarbDialog"),
+ @SerializedName("WizardDialog") WizardDialog ("WizardDialog"),
+ @SerializedName("QuickWizard") QuickWizard ("QuickWizard"),
+ @SerializedName("ExtendedBolusDialog") ExtendedBolusDialog ("ExtendedBolusDialog"),
+ @SerializedName("TTDialog") TTDialog ("TTDialog"),
+ @SerializedName("ProfileSwitchDialog") ProfileSwitchDialog ("ProfileSwitchDialog"),
+ @SerializedName("LoopDialog") LoopDialog ("LoopDialog"),
+ @SerializedName("TempBasalDialog") TempBasalDialog ("TempBasalDialog"),
+ @SerializedName("CalibrationDialog") CalibrationDialog ("CalibrationDialog"),
+ @SerializedName("FillDialog") FillDialog ("FillDialog"),
+ @SerializedName("BgCheck") BgCheck ("BgCheck"),
+ @SerializedName("SensorInsert") SensorInsert ("SensorInsert"),
+ @SerializedName("BatteryChange") BatteryChange ("BatteryChange"),
+ @SerializedName("Note") Note ("Note"),
+ @SerializedName("Exercise") Exercise ("Exercise"),
+ @SerializedName("Question") Question ("Question"),
+ @SerializedName("Announcement") Announcement ("Announcement"),
+ @SerializedName("Actions") Actions ("Actions"), //From Actions plugin
+ @SerializedName("Automation") Automation ("Automation"), //From Automation plugin
+ @SerializedName("LocalProfile") LocalProfile ("LocalProfile"), //From LocalProfile plugin
+ @SerializedName("Loop") Loop ("Loop"), //From Loop plugin
+ @SerializedName("Maintenance") Maintenance ("Maintenance"), //From Maintenance plugin
+ @SerializedName("NSClient") NSClient ("NSClient"), //From NSClient plugin
+ @SerializedName("Pump") Pump ("Pump"), //From Pump plugin (for example from pump history)
+ @SerializedName("SMS") SMS ("SMS"), //From SMS plugin
+ @SerializedName("Treatments") Treatments ("Treatments"), //From Treatments plugin
+ @SerializedName("Wear") Wear ("Wear"), //From Wear plugin
+ @SerializedName("Food") Food ("Food"), //From Food plugin
+ @SerializedName("Unknown") Unknown ("Unknown") //if necessary
+ ;
+
+ companion object {
+ fun fromString(source: String?) = values().firstOrNull { it.name == source } ?: Unknown
+ fun fromText(source: String?) = values().firstOrNull { it.text == source } ?: Unknown
+ }
+ }
enum class ColorGroup() {
InsulinTreatment,
@@ -154,4 +184,12 @@ data class UserEntry(
Pump,
Aaps
}
+
+ fun isLoop(): Boolean {
+ var result = false
+ for (v in values) {
+ if (v.unit == Units.Source && Sources.fromText(v.sValue).equals(Sources.Loop)) result = true
+ }
+ return result
+ }
}
\ No newline at end of file