Add Source icon in UserEntryFragment, Update source in uel.log

This commit is contained in:
Philoul 2021-03-25 13:32:11 +01:00
parent d3a9947cb4
commit 6e0d21a874
32 changed files with 159 additions and 86 deletions

View file

@ -79,7 +79,7 @@ class CalibrationDialog : DialogFragmentWithDate() {
if (bg > 0) { if (bg > 0) {
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_calibration), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_calibration), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
uel.log(Action.CALIBRATION, ValueWithUnit(bg, units)) uel.log(Action.CALIBRATION, ValueWithUnit(Sources.CalibrationDialog), ValueWithUnit(bg, units))
xdripCalibrations.sendIntent(bg) xdripCalibrations.sendIntent(bg)
}) })
} }

View file

@ -222,7 +222,7 @@ class CarbsDialog : DialogFragmentWithDate() {
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.carbs), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.carbs), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
when { when {
activitySelected -> { activitySelected -> {
uel.log(Action.TT, ValueWithUnit(TemporaryTarget.Reason.ACTIVITY.text, Units.TherapyEvent), ValueWithUnit(activityTT, units) , ValueWithUnit(activityTTDuration, Units.M)) 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( disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
timestamp = System.currentTimeMillis(), timestamp = System.currentTimeMillis(),
duration = TimeUnit.MINUTES.toMillis(activityTTDuration.toLong()), duration = TimeUnit.MINUTES.toMillis(activityTTDuration.toLong()),
@ -238,7 +238,7 @@ class CarbsDialog : DialogFragmentWithDate() {
} }
eatingSoonSelected -> { eatingSoonSelected -> {
uel.log(Action.TT, ValueWithUnit(TemporaryTarget.Reason.EATING_SOON.text, Units.TherapyEvent), ValueWithUnit(eatingSoonTT, units) , ValueWithUnit(eatingSoonTTDuration, Units.M)) 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( disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
timestamp = System.currentTimeMillis(), timestamp = System.currentTimeMillis(),
duration = TimeUnit.MINUTES.toMillis(eatingSoonTTDuration.toLong()), duration = TimeUnit.MINUTES.toMillis(eatingSoonTTDuration.toLong()),
@ -254,7 +254,7 @@ class CarbsDialog : DialogFragmentWithDate() {
} }
hypoSelected -> { hypoSelected -> {
uel.log(Action.TT, ValueWithUnit(TemporaryTarget.Reason.HYPOGLYCEMIA.text, Units.TherapyEvent), ValueWithUnit(hypoTT, units) , ValueWithUnit(hypoTTDuration, Units.M)) 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( disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
timestamp = System.currentTimeMillis(), timestamp = System.currentTimeMillis(),
duration = TimeUnit.MINUTES.toMillis(hypoTTDuration.toLong()), duration = TimeUnit.MINUTES.toMillis(hypoTTDuration.toLong()),
@ -272,11 +272,13 @@ class CarbsDialog : DialogFragmentWithDate() {
if (carbsAfterConstraints > 0) { if (carbsAfterConstraints > 0) {
if (duration == 0) { if (duration == 0) {
carbsGenerator.createCarb(carbsAfterConstraints, time, TherapyEvent.Type.CARBS_CORRECTION.text, notes) carbsGenerator.createCarb(carbsAfterConstraints, time, TherapyEvent.Type.CARBS_CORRECTION.text, 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 { } else {
carbsGenerator.generateCarbs(carbsAfterConstraints, time, duration, notes) 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)) 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, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(carbsAfterConstraints, Units.G), ValueWithUnit(timeOffset, Units.M, timeOffset != 0), ValueWithUnit(duration, Units.H, duration != 0))
} }
if (useAlarm && carbs > 0 && timeOffset > 0) { if (useAlarm && carbs > 0 && timeOffset > 0) {
carbTimer.scheduleReminder(dateUtil._now() + T.mins(timeOffset.toLong()).msecs()) carbTimer.scheduleReminder(dateUtil._now() + T.mins(timeOffset.toLong()).msecs())

View file

@ -88,7 +88,7 @@ class ExtendedBolusDialog : DialogFragmentWithDate() {
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.extended_bolus), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.extended_bolus), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
uel.log(Action.EXTENDED_BOLUS, ValueWithUnit(insulinAfterConstraint, Units.U), ValueWithUnit(durationInMinutes, Units.M)) uel.log(Action.EXTENDED_BOLUS, ValueWithUnit(Sources.ExtendedBolusDialog), ValueWithUnit(insulinAfterConstraint, Units.U), ValueWithUnit(durationInMinutes, Units.M))
commandQueue.extendedBolus(insulinAfterConstraint, durationInMinutes, object : Callback() { commandQueue.extendedBolus(insulinAfterConstraint, durationInMinutes, object : Callback() {
override fun run() { override fun run() {
if (!result.success) { if (!result.success) {

View file

@ -189,7 +189,7 @@ class InsulinDialog : DialogFragmentWithDate() {
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.bolus), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.bolus), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
if (eatingSoonChecked) { if (eatingSoonChecked) {
uel.log(Action.TT, notes, ValueWithUnit(TemporaryTarget.Reason.EATING_SOON.text, Units.TherapyEvent), ValueWithUnit(eatingSoonTT, units), ValueWithUnit(eatingSoonTTDuration, Units.M)) 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( disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
timestamp = System.currentTimeMillis(), timestamp = System.currentTimeMillis(),
duration = TimeUnit.MINUTES.toMillis(eatingSoonTTDuration.toLong()), duration = TimeUnit.MINUTES.toMillis(eatingSoonTTDuration.toLong()),
@ -211,11 +211,11 @@ class InsulinDialog : DialogFragmentWithDate() {
detailedBolusInfo.source = Source.USER detailedBolusInfo.source = Source.USER
detailedBolusInfo.notes = notes detailedBolusInfo.notes = notes
if (recordOnlyChecked) { if (recordOnlyChecked) {
uel.log(Action.BOLUS, notes, ValueWithUnit(Sources.Record), ValueWithUnit(insulinAfterConstraints, Units.U), ValueWithUnit(timeOffset, Units.M, 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 detailedBolusInfo.date = time
activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false) activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false)
} else { } else {
uel.log(Action.BOLUS, notes, ValueWithUnit(insulinAfterConstraints, Units.U)) uel.log(Action.BOLUS, notes, ValueWithUnit(Sources.InsulinDialog), ValueWithUnit(insulinAfterConstraints, Units.U))
detailedBolusInfo.date = DateUtil.now() detailedBolusInfo.date = DateUtil.now()
commandQueue.bolus(detailedBolusInfo, object : Callback() { commandQueue.bolus(detailedBolusInfo, object : Callback() {
override fun run() { override fun run() {

View file

@ -239,28 +239,28 @@ class LoopDialog : DaggerDialogFragment() {
val profile = profileFunction.getProfile() ?: return true val profile = profileFunction.getProfile() ?: return true
when (v.id) { when (v.id) {
R.id.overview_closeloop -> { 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") sp.putString(R.string.key_aps_mode, "closed")
rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.closedloop))) rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.closedloop)))
return true return true
} }
R.id.overview_lgsloop -> { 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") sp.putString(R.string.key_aps_mode, "lgs")
rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend))) rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend)))
return true return true
} }
R.id.overview_openloop -> { 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") sp.putString(R.string.key_aps_mode, "open")
rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend))) rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend)))
return true return true
} }
R.id.overview_disable -> { R.id.overview_disable -> {
uel.log(Action.LOOP_DISABLED) uel.log(Action.LOOP_DISABLED, ValueWithUnit(Sources.LoopDialog))
loopPlugin.setPluginEnabled(PluginType.LOOP, false) loopPlugin.setPluginEnabled(PluginType.LOOP, false)
loopPlugin.setFragmentVisible(PluginType.LOOP, false) loopPlugin.setFragmentVisible(PluginType.LOOP, false)
configBuilderPlugin.storeSettings("DisablingLoop") configBuilderPlugin.storeSettings("DisablingLoop")
@ -277,7 +277,7 @@ class LoopDialog : DaggerDialogFragment() {
} }
R.id.overview_enable -> { R.id.overview_enable -> {
uel.log(Action.LOOP_ENABLED) uel.log(Action.LOOP_ENABLED, ValueWithUnit(Sources.LoopDialog))
loopPlugin.setPluginEnabled(PluginType.LOOP, true) loopPlugin.setPluginEnabled(PluginType.LOOP, true)
loopPlugin.setFragmentVisible(PluginType.LOOP, true) loopPlugin.setFragmentVisible(PluginType.LOOP, true)
configBuilderPlugin.storeSettings("EnablingLoop") configBuilderPlugin.storeSettings("EnablingLoop")
@ -287,7 +287,7 @@ class LoopDialog : DaggerDialogFragment() {
} }
R.id.overview_resume, R.id.overview_reconnect -> { 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, ValueWithUnit(Sources.LoopDialog))
loopPlugin.suspendTo(0L) loopPlugin.suspendTo(0L)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
commandQueue.cancelTempBasal(true, object : Callback() { commandQueue.cancelTempBasal(true, object : Callback() {
@ -303,49 +303,49 @@ class LoopDialog : DaggerDialogFragment() {
} }
R.id.overview_suspend_1h -> { R.id.overview_suspend_1h -> {
uel.log(Action.SUSPEND, ValueWithUnit(1, Units.H)) uel.log(Action.SUSPEND, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(1, Units.H))
loopPlugin.suspendLoop(60) loopPlugin.suspendLoop(60)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
return true return true
} }
R.id.overview_suspend_2h -> { R.id.overview_suspend_2h -> {
uel.log(Action.SUSPEND, ValueWithUnit(2, Units.H)) uel.log(Action.SUSPEND, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(2, Units.H))
loopPlugin.suspendLoop(120) loopPlugin.suspendLoop(120)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
return true return true
} }
R.id.overview_suspend_3h -> { R.id.overview_suspend_3h -> {
uel.log(Action.SUSPEND, ValueWithUnit(3, Units.H)) uel.log(Action.SUSPEND, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(3, Units.H))
loopPlugin.suspendLoop(180) loopPlugin.suspendLoop(180)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
return true return true
} }
R.id.overview_suspend_10h -> { R.id.overview_suspend_10h -> {
uel.log(Action.SUSPEND, ValueWithUnit(10, Units.H)) uel.log(Action.SUSPEND, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(10, Units.H))
loopPlugin.suspendLoop(600) loopPlugin.suspendLoop(600)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
return true return true
} }
R.id.overview_disconnect_15m -> { R.id.overview_disconnect_15m -> {
uel.log(Action.DISCONNECT, ValueWithUnit(15, Units.M)) uel.log(Action.DISCONNECT, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(15, Units.M))
loopPlugin.disconnectPump(15, profile) loopPlugin.disconnectPump(15, profile)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
return true return true
} }
R.id.overview_disconnect_30m -> { R.id.overview_disconnect_30m -> {
uel.log(Action.DISCONNECT, ValueWithUnit(30, Units.M)) uel.log(Action.DISCONNECT, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(30, Units.M))
loopPlugin.disconnectPump(30, profile) loopPlugin.disconnectPump(30, profile)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
return true return true
} }
R.id.overview_disconnect_1h -> { R.id.overview_disconnect_1h -> {
uel.log(Action.DISCONNECT, ValueWithUnit(1, Units.H)) uel.log(Action.DISCONNECT, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(1, Units.H))
loopPlugin.disconnectPump(60, profile) loopPlugin.disconnectPump(60, profile)
sp.putBoolean(R.string.key_objectiveusedisconnect, true) sp.putBoolean(R.string.key_objectiveusedisconnect, true)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
@ -353,14 +353,14 @@ class LoopDialog : DaggerDialogFragment() {
} }
R.id.overview_disconnect_2h -> { R.id.overview_disconnect_2h -> {
uel.log(Action.DISCONNECT, ValueWithUnit(2, Units.H)) uel.log(Action.DISCONNECT, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(2, Units.H))
loopPlugin.disconnectPump(120, profile) loopPlugin.disconnectPump(120, profile)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
return true return true
} }
R.id.overview_disconnect_3h -> { R.id.overview_disconnect_3h -> {
uel.log(Action.DISCONNECT, ValueWithUnit(3, Units.H)) uel.log(Action.DISCONNECT, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(3, Units.H))
loopPlugin.disconnectPump(180, profile) loopPlugin.disconnectPump(180, profile)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
return true return true

View file

@ -125,7 +125,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
uel.log(Action.PROFILE_SWITCH, notes, 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)) 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) treatmentsPlugin.doProfileSwitch(profileStore, profile, duration, percent, timeShift, eventTime)
}) })
} }

View file

@ -126,10 +126,10 @@ class TempBasalDialog : DialogFragmentWithDate() {
} }
} }
if (isPercentPump) { if (isPercentPump) {
uel.log(Action.TEMP_BASAL, ValueWithUnit(percent, Units.Percent), ValueWithUnit(durationInMinutes, Units.M)) uel.log(Action.TEMP_BASAL, ValueWithUnit(Sources.TempBasalDialog), ValueWithUnit(percent, Units.Percent), ValueWithUnit(durationInMinutes, Units.M))
commandQueue.tempBasalPercent(percent, durationInMinutes, true, profile, callback) commandQueue.tempBasalPercent(percent, durationInMinutes, true, profile, callback)
} else { } else {
uel.log(Action.TEMP_BASAL, ValueWithUnit(absolute, Units.U), ValueWithUnit(durationInMinutes, Units.M)) uel.log(Action.TEMP_BASAL, ValueWithUnit(Sources.TempBasalDialog), ValueWithUnit(absolute, Units.U), ValueWithUnit(durationInMinutes, Units.M))
commandQueue.tempBasalAbsolute(absolute, durationInMinutes, true, profile, callback) commandQueue.tempBasalAbsolute(absolute, durationInMinutes, true, profile, callback)
} }
}) })

View file

@ -181,11 +181,11 @@ class TempTargetDialog : DialogFragmentWithDate() {
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
val units = profileFunction.getUnits() val units = profileFunction.getUnits()
when(reason) { when(reason) {
resourceHelper.gs(R.string.eatingsoon) -> uel.log(Action.TT, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.EATING_SOON.text, Units.TherapyEvent), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M)) 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(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.ACTIVITY.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(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.HYPOGLYCEMIA.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(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.CUSTOM.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(eventTime, Units.Timestamp, eventTimeChanged)) resourceHelper.gs(R.string.stoptemptarget) -> uel.log(Action.CANCEL_TT, ValueWithUnit(Sources.TTDialog), ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged))
} }
if (target == 0.0 || duration == 0) { if (target == 0.0 || duration == 0) {
disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(eventTime)) disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(eventTime))

View file

@ -130,7 +130,12 @@ class TreatmentDialog : DialogFragmentWithDate() {
if (insulinAfterConstraints > 0 || carbsAfterConstraints > 0) { if (insulinAfterConstraints > 0 || carbsAfterConstraints > 0) {
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_treatment_label), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_treatment_label), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
uel.log(Action.TREATMENT, ValueWithUnit(insulin, Units.U, insulin != 0.0), ValueWithUnit(carbs, Units.G, 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() val detailedBolusInfo = DetailedBolusInfo()
if (insulinAfterConstraints == 0.0) detailedBolusInfo.eventType = TherapyEvent.Type.CARBS_CORRECTION.text if (insulinAfterConstraints == 0.0) detailedBolusInfo.eventType = TherapyEvent.Type.CARBS_CORRECTION.text
if (carbsAfterConstraints == 0) detailedBolusInfo.eventType = TherapyEvent.Type.CORRECTION_BOLUS.text if (carbsAfterConstraints == 0) detailedBolusInfo.eventType = TherapyEvent.Type.CORRECTION_BOLUS.text

View file

@ -17,6 +17,7 @@ import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.TherapyEvent 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.database.transactions.InsertTherapyEventIfNewTransaction
import info.nightscout.androidaps.db.Source import info.nightscout.androidaps.db.Source
import info.nightscout.androidaps.events.EventAcceptOpenLoopChange 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.interfaces.LoopInterface.LastRun
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag 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.EventLoopSetLastRunGui
import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopUpdateGui import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopUpdateGui
import info.nightscout.androidaps.plugins.aps.loop.events.EventNewOpenLoopNotification import info.nightscout.androidaps.plugins.aps.loop.events.EventNewOpenLoopNotification
@ -78,6 +80,7 @@ open class LoopPlugin @Inject constructor(
private val fabricPrivacy: FabricPrivacy, private val fabricPrivacy: FabricPrivacy,
private val nsUpload: NSUpload, private val nsUpload: NSUpload,
private val dateUtil: DateUtil, private val dateUtil: DateUtil,
private val uel: UserEntryLogger,
private val repository: AppRepository private val repository: AppRepository
) : PluginBase(PluginDescription() ) : PluginBase(PluginDescription()
.mainType(PluginType.LOOP) .mainType(PluginType.LOOP)
@ -531,6 +534,7 @@ open class LoopPlugin @Inject constructor(
if (request.percent == 100 && request.duration == 0) { if (request.percent == 100 && request.duration == 0) {
if (activeTemp != null) { if (activeTemp != null) {
aapsLogger.debug(LTag.APS, "applyAPSRequest: cancelTempBasal()") aapsLogger.debug(LTag.APS, "applyAPSRequest: cancelTempBasal()")
uel.log(Action.CANCEL_TEMP_BASAL, ValueWithUnit(Sources.Loop))
commandQueue.cancelTempBasal(false, callback) commandQueue.cancelTempBasal(false, callback)
} else { } else {
aapsLogger.debug(LTag.APS, "applyAPSRequest: Basal set correctly") 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() .comment(R.string.let_temp_basal_run))?.run()
} else { } else {
aapsLogger.debug(LTag.APS, "applyAPSRequest: tempBasalPercent()") 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) commandQueue.tempBasalPercent(request.percent, request.duration, false, profile!!, callback)
} }
} else { } else {
if (request.rate == 0.0 && request.duration == 0 || abs(request.rate - pump.baseBasalRate) < pump.pumpDescription.basalStep) { if (request.rate == 0.0 && request.duration == 0 || abs(request.rate - pump.baseBasalRate) < pump.pumpDescription.basalStep) {
if (activeTemp != null) { if (activeTemp != null) {
aapsLogger.debug(LTag.APS, "applyAPSRequest: cancelTempBasal()") aapsLogger.debug(LTag.APS, "applyAPSRequest: cancelTempBasal()")
uel.log(Action.CANCEL_TEMP_BASAL, ValueWithUnit(Sources.Loop))
commandQueue.cancelTempBasal(false, callback) commandQueue.cancelTempBasal(false, callback)
} else { } else {
aapsLogger.debug(LTag.APS, "applyAPSRequest: Basal set correctly") 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() .comment(R.string.let_temp_basal_run))?.run()
} else { } else {
aapsLogger.debug(LTag.APS, "applyAPSRequest: setTempBasalAbsolute()") 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) commandQueue.tempBasalAbsolute(request.rate, request.duration, false, profile!!, callback)
} }
} }
@ -602,6 +609,7 @@ open class LoopPlugin @Inject constructor(
detailedBolusInfo.source = Source.USER detailedBolusInfo.source = Source.USER
detailedBolusInfo.deliverAt = request.deliverAt detailedBolusInfo.deliverAt = request.deliverAt
aapsLogger.debug(LTag.APS, "applyAPSRequest: bolus()") aapsLogger.debug(LTag.APS, "applyAPSRequest: bolus()")
uel.log(Action.SMB, ValueWithUnit(Sources.Loop), ValueWithUnit(detailedBolusInfo.insulin, Units.U))
commandQueue.bolus(detailedBolusInfo, callback) commandQueue.bolus(detailedBolusInfo, callback)
} }

View file

@ -16,8 +16,7 @@ import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.Food import info.nightscout.androidaps.database.entities.Food
import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.database.entities.UserEntry.Action
import info.nightscout.androidaps.database.transactions.InvalidateFoodTransaction import info.nightscout.androidaps.database.transactions.InvalidateFoodTransaction
import info.nightscout.androidaps.databinding.FoodFragmentBinding import info.nightscout.androidaps.databinding.FoodFragmentBinding
import info.nightscout.androidaps.databinding.FoodItemBinding import info.nightscout.androidaps.databinding.FoodItemBinding
@ -77,7 +76,7 @@ class FoodFragment : DaggerFragment() {
binding.refreshFromNightscout.setOnClickListener { binding.refreshFromNightscout.setOnClickListener {
context?.let { context -> context?.let { context ->
OKDialog.showConfirmation(context, resourceHelper.gs(R.string.refresheventsfromnightscout) + " ?", { OKDialog.showConfirmation(context, resourceHelper.gs(R.string.refresheventsfromnightscout) + " ?", {
uel.log(Action.FOOD, UserEntry.ValueWithUnit(UserEntry.Sources.NS)) uel.log(Action.FOOD, ValueWithUnit(Sources.Food))
disposable += Completable.fromAction { repository.deleteAllFoods() } disposable += Completable.fromAction { repository.deleteAllFoods() }
.subscribeOn(aapsSchedulers.io) .subscribeOn(aapsSchedulers.io)
.observeOn(aapsSchedulers.main) .observeOn(aapsSchedulers.main)

View file

@ -86,7 +86,7 @@ class NSClientAddUpdateWorker(
.blockingGet() .blockingGet()
.also { result -> .also { result ->
result.inserted.forEach { result.inserted.forEach {
uel.log(UserEntry.Action.TT, ValueWithUnit(UserEntry.Sources.NS), uel.log(UserEntry.Action.TT, ValueWithUnit(UserEntry.Sources.NSClient),
ValueWithUnit(it.reason.text, UserEntry.Units.TherapyEvent), ValueWithUnit(it.reason.text, UserEntry.Units.TherapyEvent),
ValueWithUnit(it.lowTarget, UserEntry.Units.Mg_Dl, true), ValueWithUnit(it.lowTarget, UserEntry.Units.Mg_Dl, true),
ValueWithUnit(it.highTarget, UserEntry.Units.Mg_Dl, it.lowTarget != it.highTarget), ValueWithUnit(it.highTarget, UserEntry.Units.Mg_Dl, it.lowTarget != it.highTarget),
@ -94,7 +94,7 @@ class NSClientAddUpdateWorker(
) )
} }
result.invalidated.forEach { result.invalidated.forEach {
uel.log(UserEntry.Action.TT_REMOVED, ValueWithUnit(UserEntry.Sources.NS), uel.log(UserEntry.Action.TT_REMOVED, ValueWithUnit(UserEntry.Sources.NSClient),
ValueWithUnit(it.reason.text, UserEntry.Units.TherapyEvent), ValueWithUnit(it.reason.text, UserEntry.Units.TherapyEvent),
ValueWithUnit(it.lowTarget, UserEntry.Units.Mg_Dl, true), ValueWithUnit(it.lowTarget, UserEntry.Units.Mg_Dl, true),
ValueWithUnit(it.highTarget, UserEntry.Units.Mg_Dl, it.lowTarget != it.highTarget), ValueWithUnit(it.highTarget, UserEntry.Units.Mg_Dl, it.lowTarget != it.highTarget),
@ -102,7 +102,7 @@ class NSClientAddUpdateWorker(
) )
} }
result.ended.forEach { result.ended.forEach {
uel.log(UserEntry.Action.CANCEL_TT, ValueWithUnit(UserEntry.Sources.NS), uel.log(UserEntry.Action.CANCEL_TT, ValueWithUnit(UserEntry.Sources.NSClient),
ValueWithUnit(it.reason.text, UserEntry.Units.TherapyEvent), ValueWithUnit(it.reason.text, UserEntry.Units.TherapyEvent),
ValueWithUnit(it.lowTarget, UserEntry.Units.Mg_Dl, true), ValueWithUnit(it.lowTarget, UserEntry.Units.Mg_Dl, true),
ValueWithUnit(it.highTarget, UserEntry.Units.Mg_Dl, it.lowTarget != it.highTarget), ValueWithUnit(it.highTarget, UserEntry.Units.Mg_Dl, it.lowTarget != it.highTarget),
@ -132,14 +132,14 @@ class NSClientAddUpdateWorker(
.also { result -> .also { result ->
result.inserted.forEach { result.inserted.forEach {
uel.log(UserEntry.Action.CAREPORTAL, uel.log(UserEntry.Action.CAREPORTAL,
it.note ?: "", ValueWithUnit(UserEntry.Sources.NS), it.note ?: "", ValueWithUnit(UserEntry.Sources.NSClient),
ValueWithUnit(it.timestamp, UserEntry.Units.Timestamp, true), ValueWithUnit(it.timestamp, UserEntry.Units.Timestamp, true),
ValueWithUnit(it.type.text, UserEntry.Units.TherapyEvent) ValueWithUnit(it.type.text, UserEntry.Units.TherapyEvent)
) )
} }
result.invalidated.forEach { result.invalidated.forEach {
uel.log(UserEntry.Action.CAREPORTAL_REMOVED, uel.log(UserEntry.Action.CAREPORTAL_REMOVED,
it.note ?: "", ValueWithUnit(UserEntry.Sources.NS), it.note ?: "", ValueWithUnit(UserEntry.Sources.NSClient),
ValueWithUnit(it.timestamp, UserEntry.Units.Timestamp, true), ValueWithUnit(it.timestamp, UserEntry.Units.Timestamp, true),
ValueWithUnit(it.type.text, UserEntry.Units.TherapyEvent) ValueWithUnit(it.type.text, UserEntry.Units.TherapyEvent)
) )

View file

@ -68,7 +68,7 @@ class NSClientRemoveWorker(
.also { result -> .also { result ->
result.invalidated.forEach { result.invalidated.forEach {
uel.log( uel.log(
Action.TT_REMOVED, ValueWithUnit(Sources.NS), Action.TT_REMOVED, ValueWithUnit(Sources.NSClient),
ValueWithUnit(it.reason.text, Units.TherapyEvent), ValueWithUnit(it.reason.text, Units.TherapyEvent),
ValueWithUnit(it.lowTarget, Units.Mg_Dl, true), ValueWithUnit(it.lowTarget, Units.Mg_Dl, true),
ValueWithUnit(it.highTarget, Units.Mg_Dl, it.lowTarget != it.highTarget), ValueWithUnit(it.highTarget, Units.Mg_Dl, it.lowTarget != it.highTarget),
@ -88,7 +88,7 @@ class NSClientRemoveWorker(
.also { result -> .also { result ->
result.invalidated.forEach { result.invalidated.forEach {
uel.log( uel.log(
Action.CAREPORTAL_REMOVED, (it.note ?: ""), ValueWithUnit(Sources.NS), Action.CAREPORTAL_REMOVED, (it.note ?: ""), ValueWithUnit(Sources.NSClient),
ValueWithUnit(it.timestamp, Units.Timestamp, true), ValueWithUnit(it.timestamp, Units.Timestamp, true),
ValueWithUnit(it.type.text, Units.TherapyEvent)) ValueWithUnit(it.type.text, Units.TherapyEvent))
} }

View file

@ -40,7 +40,6 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProv
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.receivers.DataWorker import info.nightscout.androidaps.receivers.DataWorker
import info.nightscout.androidaps.receivers.DataReceiver
import info.nightscout.androidaps.utils.* import info.nightscout.androidaps.utils.*
import info.nightscout.androidaps.utils.extensions.valueToUnitsString import info.nightscout.androidaps.utils.extensions.valueToUnitsString
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
@ -1007,7 +1006,7 @@ class SmsCommunicatorPlugin @Inject constructor(
sp.putBoolean(R.string.key_smscommunicator_remotecommandsallowed, false) sp.putBoolean(R.string.key_smscommunicator_remotecommandsallowed, false)
val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_stoppedsms)) val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_stoppedsms))
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
uel.log(Action.SMS_SMS, ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_stoppedsms, Units.R_String)) 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))) } else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat)))

View file

@ -119,8 +119,9 @@ class TreatmentsUserEntryFragment : DaggerFragment() {
holder.binding.s.visibility = View.GONE holder.binding.s.visibility = View.GONE
var valuesWithUnitString = "" var valuesWithUnitString = ""
var rStringParam = 0 var rStringParam = 0
var source = Sources.Unknown
val separator = " " val separator = " "
var source = "" //var source = ""
for(v in current.values) { for(v in current.values) {
if (rStringParam >0) if (rStringParam >0)
rStringParam-- rStringParam--
@ -144,13 +145,18 @@ class TreatmentsUserEntryFragment : DaggerFragment() {
-> valuesWithUnitString += DecimalFormatter.to2Decimal(v.dValue) + translator.translate(v.unit.name) + separator -> valuesWithUnitString += DecimalFormatter.to2Decimal(v.dValue) + translator.translate(v.unit.name) + separator
Units.G, Units.M, Units.H, Units.Percent Units.G, Units.M, Units.H, Units.Percent
-> valuesWithUnitString += v.iValue.toString() + translator.translate(v.unit.name) + separator -> valuesWithUnitString += v.iValue.toString() + translator.translate(v.unit.name) + separator
Units.Source -> source = separator + translator.translate(v.sValue) 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 "" 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.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) + source holder.binding.action.text = translator.translate(current.action.name)
holder.binding.action.setTextColor(resourceHelper.gc(current.action.colorGroup.colorId())) holder.binding.action.setTextColor(resourceHelper.gc(current.action.colorGroup.colorId()))
} }

View file

@ -349,7 +349,7 @@ class BolusWizard @Inject constructor(
boluscalc = nsJSON() boluscalc = nsJSON()
source = Source.USER source = Source.USER
notes = this@BolusWizard.notes notes = this@BolusWizard.notes
uel.log(Action.BOLUS_ADVISOR, notes, ValueWithUnit(eventType, Units.TherapyEvent), ValueWithUnit(insulinAfterConstraints, Units.U)) uel.log(Action.BOLUS_ADVISOR, notes, ValueWithUnit(Sources.WizardDialog), ValueWithUnit(eventType, Units.TherapyEvent), ValueWithUnit(insulinAfterConstraints, Units.U))
if (insulin > 0) { if (insulin > 0) {
commandQueue.bolus(this, object : Callback() { commandQueue.bolus(this, object : Callback() {
override fun run() { override fun run() {
@ -372,7 +372,7 @@ class BolusWizard @Inject constructor(
OKDialog.showConfirmation(ctx, resourceHelper.gs(R.string.boluswizard), confirmMessage, { OKDialog.showConfirmation(ctx, resourceHelper.gs(R.string.boluswizard), confirmMessage, {
if (insulinAfterConstraints > 0 || carbs > 0) { if (insulinAfterConstraints > 0 || carbs > 0) {
if (useSuperBolus) { if (useSuperBolus) {
uel.log(Action.SUPERBOLUS_TBR) uel.log(Action.SUPERBOLUS_TBR, ValueWithUnit(Sources.WizardDialog))
if (loopPlugin.isEnabled(PluginType.LOOP)) { if (loopPlugin.isEnabled(PluginType.LOOP)) {
loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000) loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000)
rxBus.send(EventRefreshOverview("WizardDialog")) rxBus.send(EventRefreshOverview("WizardDialog"))
@ -413,7 +413,12 @@ class BolusWizard @Inject constructor(
boluscalc = nsJSON() boluscalc = nsJSON()
source = Source.USER source = Source.USER
notes = this@BolusWizard.notes notes = this@BolusWizard.notes
uel.log(Action.BOLUS, notes, ValueWithUnit(eventType,Units.TherapyEvent), ValueWithUnit(insulinAfterConstraints, Units.U), ValueWithUnit(this@BolusWizard.carbs, Units.G, this@BolusWizard.carbs != 0), ValueWithUnit(carbTime, Units.M, carbTime != 0)) 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) { if (insulin > 0 || pump.pumpDescription.storesCarbInfo) {
commandQueue.bolus(this, object : Callback() { commandQueue.bolus(this, object : Callback() {
override fun run() { override fun run() {

View file

@ -1,22 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/info_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:orientation="horizontal" >
card_view:cardBackgroundColor="?android:colorBackground">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="true"
android:orientation="horizontal">
<TextView <TextView
android:id="@+id/date" android:id="@+id/date"
@ -24,6 +14,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="5dp" android:paddingStart="5dp"
android:text="1.1.2021 09:00" android:text="1.1.2021 09:00"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/iconSource"
app:layout_constraintBottom_toBottomOf="@+id/iconSource"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
tools:ignore="HardcodedText,RtlSymmetry" /> tools:ignore="HardcodedText,RtlSymmetry" />
@ -33,10 +26,21 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="10dp" android:paddingStart="10dp"
android:text="USER ENTRY" android:text="USER ENTRY"
android:textAppearance="?android:attr/textAppearanceSmall" app:layout_constraintStart_toEndOf="@id/date"
tools:ignore="HardcodedText,RtlSymmetry" /> app:layout_constraintTop_toTopOf="@+id/iconSource"
app:layout_constraintBottom_toBottomOf="@+id/iconSource"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:id="@+id/iconSource"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginEnd="8dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_cp_bolus_carbs" />
</LinearLayout>
<TextView <TextView
android:id="@+id/values" android:id="@+id/values"
@ -46,6 +50,8 @@
android:paddingStart="20dp" android:paddingStart="20dp"
android:paddingEnd="10dp" android:paddingEnd="10dp"
android:textStyle="bold" android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/date"
android:visibility="gone" android:visibility="gone"
android:text="Values with units" /> android:text="Values with units" />
@ -54,8 +60,11 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="20dp" android:paddingStart="20dp"
android:visibility="gone" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/values"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="gone"
android:text="Notes"
tools:ignore="HardcodedText,RtlSymmetry" /> tools:ignore="HardcodedText,RtlSymmetry" />
<View <View
@ -65,8 +74,9 @@
android:layout_marginStart="5dp" android:layout_marginStart="5dp"
android:layout_marginEnd="5dp" android:layout_marginEnd="5dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/s"
android:background="@color/list_delimiter" /> android:background="@color/list_delimiter" />
</LinearLayout>
</androidx.cardview.widget.CardView> </androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -89,9 +89,14 @@ class ClassicPrefsFormat @Inject constructor(
fun UserEntriesToCsv(userEntries: List<UserEntry>): String { fun UserEntriesToCsv(userEntries: List<UserEntry>): String {
val userEntryHeader = resourceHelper.gs(R.string.ue_csv_header, val userEntryHeader = resourceHelper.gs(R.string.ue_csv_header,
csvString(R.string.ue_timestamp),
csvString(R.string.date), csvString(R.string.date),
csvString(R.string.ue_utc_offset),
csvString(R.string.ue_action),
csvString(R.string.eventtype), csvString(R.string.eventtype),
csvString(R.string.ue_source),
csvString(R.string.careportal_note), csvString(R.string.careportal_note),
csvString(R.string.ue_formated_string),
csvString(R.string.event_time_label), csvString(R.string.event_time_label),
csvString(Units.fromText(profileFunction.getUnits())), csvString(Units.fromText(profileFunction.getUnits())),
csvString(Units.G), csvString(Units.G),
@ -99,7 +104,8 @@ class ClassicPrefsFormat @Inject constructor(
csvString(Units.U_H), csvString(Units.U_H),
csvString(Units.Percent), csvString(Units.Percent),
csvString(Units.H), csvString(Units.H),
csvString(Units.M) csvString(Units.M),
csvString(R.string.ue_none)
) + "\n" ) + "\n"
return userEntryHeader + userEntries.joinToString("\n") { entry -> return userEntryHeader + userEntries.joinToString("\n") { entry ->
var timestampRec = "" + entry.timestamp var timestampRec = "" + entry.timestamp
@ -124,7 +130,7 @@ class ClassicPrefsFormat @Inject constructor(
when (v.unit) { when (v.unit) {
Units.Timestamp -> timestamp = dateUtil.dateAndTimeAndSecondsString(v.lValue) Units.Timestamp -> timestamp = dateUtil.dateAndTimeAndSecondsString(v.lValue)
Units.TherapyEvent -> therapyEvent = if (therapyEvent == "") translator.translate(v.sValue) else therapyEvent + " / " + translator.translate(v.sValue) Units.TherapyEvent -> therapyEvent = if (therapyEvent == "") translator.translate(v.sValue) else therapyEvent + " / " + translator.translate(v.sValue)
Units.Source -> source = csvString(translator.translate(v.sValue)) Units.Source -> source = csvString(v.sValue)
Units.R_String -> if (v.iValue != 0) { //Formated string lValue is the number of parameters, up to 3 Units.R_String -> if (v.iValue != 0) { //Formated string lValue is the number of parameters, up to 3
var rStringParam = v.lValue.toInt() var rStringParam = v.lValue.toInt()
var tempString = "" var tempString = ""

View file

@ -52,6 +52,7 @@ class Translator @Inject internal constructor(
TemporaryTarget.Reason.WEAR.text -> resourceHelper.gs(R.string.wear) TemporaryTarget.Reason.WEAR.text -> resourceHelper.gs(R.string.wear)
Action.BOLUS.name -> resourceHelper.gs(R.string.uel_bolus) Action.BOLUS.name -> resourceHelper.gs(R.string.uel_bolus)
Action.SMB.name -> resourceHelper.gs(R.string.smb_shortname)
Action.BOLUS_ADVISOR.name -> resourceHelper.gs(R.string.uel_bolus_advisor) Action.BOLUS_ADVISOR.name -> resourceHelper.gs(R.string.uel_bolus_advisor)
Action.EXTENDED_BOLUS.name -> resourceHelper.gs(R.string.uel_extended_bolus) Action.EXTENDED_BOLUS.name -> resourceHelper.gs(R.string.uel_extended_bolus)
Action.SUPERBOLUS_TBR.name -> resourceHelper.gs(R.string.uel_superbolus_tbr) Action.SUPERBOLUS_TBR.name -> resourceHelper.gs(R.string.uel_superbolus_tbr)
@ -117,7 +118,7 @@ class Translator @Inject internal constructor(
Action.IMPORT_DATABASES.name -> resourceHelper.gs(R.string.uel_import_databases) Action.IMPORT_DATABASES.name -> resourceHelper.gs(R.string.uel_import_databases)
Action.OTP_EXPORT.name -> resourceHelper.gs(R.string.uel_otp_export) Action.OTP_EXPORT.name -> resourceHelper.gs(R.string.uel_otp_export)
Action.OTP_RESET.name -> resourceHelper.gs(R.string.uel_otp_reset) Action.OTP_RESET.name -> resourceHelper.gs(R.string.uel_otp_reset)
Action.SMS_SMS.name -> resourceHelper.gs(R.string.uel_sms_sms) Action.STOP_SMS.name -> resourceHelper.gs(R.string.uel_stop_sms)
Action.EXPORT_CSV.name -> resourceHelper.gs(R.string.uel_export_csv) Action.EXPORT_CSV.name -> resourceHelper.gs(R.string.uel_export_csv)
Units.Mg_Dl.name -> resourceHelper.gs(R.string.mgdl) Units.Mg_Dl.name -> resourceHelper.gs(R.string.mgdl)
@ -130,11 +131,9 @@ class Translator @Inject internal constructor(
Units.Percent.name -> resourceHelper.gs(R.string.shortpercent) Units.Percent.name -> resourceHelper.gs(R.string.shortpercent)
Units.None.name -> "" Units.None.name -> ""
Sources.Manual.text -> resourceHelper.gs(R.string.manual)
Sources.Record.text -> resourceHelper.gs(R.string.record)
Sources.Automation.text -> resourceHelper.gs(R.string.automation) Sources.Automation.text -> resourceHelper.gs(R.string.automation)
Sources.Loop.text -> resourceHelper.gs(R.string.loop) Sources.Loop.text -> resourceHelper.gs(R.string.loop)
Sources.NS.text -> resourceHelper.gs(R.string.ns) Sources.NSClient.text -> resourceHelper.gs(R.string.ns)
Sources.Pump.text -> resourceHelper.gs(R.string.pump) Sources.Pump.text -> resourceHelper.gs(R.string.pump)
Sources.SMS.text -> resourceHelper.gs(R.string.smb_shortname) Sources.SMS.text -> resourceHelper.gs(R.string.smb_shortname)
Sources.Wear.text -> resourceHelper.gs(R.string.wear) Sources.Wear.text -> resourceHelper.gs(R.string.wear)

View file

@ -17,3 +17,22 @@ fun ColorGroup.colorId(): Int {
} }
} }
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.Automation -> R.drawable.ic_automation
Sources.Loop -> R.drawable.ic_loop_closed_white
Sources.NSClient -> R.drawable.ic_nightscout_syncs
else -> -1
}
}

View file

@ -469,12 +469,17 @@
<string name="uel_import_databases">IMPORT DATABASES</string> <string name="uel_import_databases">IMPORT DATABASES</string>
<string name="uel_otp_export">OTP EXPORT</string> <string name="uel_otp_export">OTP EXPORT</string>
<string name="uel_otp_reset">OTP RESET</string> <string name="uel_otp_reset">OTP RESET</string>
<string name="uel_sms_sms">SMS SMS</string> <string name="uel_stop_sms">STOP SMS</string>
<string name="uel_export_csv">EXPORT USER ENTRIES</string> <string name="uel_export_csv">EXPORT USER ENTRIES</string>
<string name="uel_unknown">UNKNOWN</string> <string name="uel_unknown">UNKNOWN</string>
<string name="formated_string">Formated string</string> <string name="ue_formated_string">Formated string</string>
<string name="ue_source">Source</string>
<string name="ue_utc_offset">UTC Offset</string>
<string name="ue_action">Action</string>
<string name="ue_timestamp">Timestamp</string>
<string name="ue_none">No Unit</string>
<string name="ue_export_to_csv">Export User Entries to Excel (csv)</string> <string name="ue_export_to_csv">Export User Entries to Excel (csv)</string>
<string name="ue_csv_header">"Timestamp;%1$s;UTC Offset;Action;%2$s;Source;%3$s;Formated string;%4$s;%5$s;%6$s;%7$s;%8$s;%9$s;%10$s;%11$s;other"</string> <string name="ue_csv_header">"%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"</string>
<plurals name="days"> <plurals name="days">
<item quantity="one">%1$d day</item> <item quantity="one">%1$d day</item>

View file

@ -20,8 +20,8 @@ data class UserEntry(
) : DBEntry, DBEntryWithTime { ) : DBEntry, DBEntryWithTime {
enum class Action (val colorGroup: ColorGroup) { enum class Action (val colorGroup: ColorGroup) {
@SerializedName("BOLUS") BOLUS (ColorGroup.InsulinTreatment), @SerializedName("BOLUS") BOLUS (ColorGroup.InsulinTreatment),
@SerializedName("SMB") SMB (ColorGroup.InsulinTreatment),
@SerializedName("BOLUS_ADVISOR") BOLUS_ADVISOR (ColorGroup.InsulinTreatment), @SerializedName("BOLUS_ADVISOR") BOLUS_ADVISOR (ColorGroup.InsulinTreatment),
@SerializedName("BOLUS_RECORD") BOLUS_RECORD (ColorGroup.InsulinTreatment),
@SerializedName("EXTENDED_BOLUS") EXTENDED_BOLUS (ColorGroup.InsulinTreatment), @SerializedName("EXTENDED_BOLUS") EXTENDED_BOLUS (ColorGroup.InsulinTreatment),
@SerializedName("SUPERBOLUS_TBR") SUPERBOLUS_TBR (ColorGroup.InsulinTreatment), @SerializedName("SUPERBOLUS_TBR") SUPERBOLUS_TBR (ColorGroup.InsulinTreatment),
@SerializedName("CARBS") CARBS (ColorGroup.CarbTreatment), @SerializedName("CARBS") CARBS (ColorGroup.CarbTreatment),
@ -86,7 +86,7 @@ data class UserEntry(
@SerializedName("IMPORT_DATABASES") IMPORT_DATABASES (ColorGroup.Aaps), @SerializedName("IMPORT_DATABASES") IMPORT_DATABASES (ColorGroup.Aaps),
@SerializedName("OTP_EXPORT") OTP_EXPORT (ColorGroup.Aaps), @SerializedName("OTP_EXPORT") OTP_EXPORT (ColorGroup.Aaps),
@SerializedName("OTP_RESET") OTP_RESET (ColorGroup.Aaps), @SerializedName("OTP_RESET") OTP_RESET (ColorGroup.Aaps),
@SerializedName("SMS_SMS") SMS_SMS (ColorGroup.Aaps), @SerializedName("STOP_SMS") STOP_SMS (ColorGroup.Aaps),
@SerializedName("FOOD") FOOD (ColorGroup.Careportal), @SerializedName("FOOD") FOOD (ColorGroup.Careportal),
@SerializedName("EXPORT_CSV") EXPORT_CSV (ColorGroup.Aaps), @SerializedName("EXPORT_CSV") EXPORT_CSV (ColorGroup.Aaps),
@SerializedName("UNKNOWN") UNKNOWN (ColorGroup.Aaps) @SerializedName("UNKNOWN") UNKNOWN (ColorGroup.Aaps)
@ -134,14 +134,24 @@ data class UserEntry(
} }
} }
enum class Sources(val text: String) { enum class Sources(val text: String) {
@SerializedName("Manual") Manual ("Manual"), //Manual entry by user, given through AAPS (default) @SerializedName("TreatmentDialog") TreatmentDialog ("TreatmentDialog"),
@SerializedName("Record") Record ("Record"), //Manual entry by user, treatment given outside AAPS (for example Bolus with Serynge) @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("Automation") Automation ("Automation"), //From Automation plugin @SerializedName("Automation") Automation ("Automation"), //From Automation plugin
@SerializedName("Loop") Loop ("Loop"), //From Loop plugin @SerializedName("Loop") Loop ("Loop"), //From Loop plugin
@SerializedName("NS") NS ("NS"), //From NSClient plugin @SerializedName("NSClient") NSClient ("NSClient"), //From NSClient plugin
@SerializedName("Pump") Pump ("Pump"), //From Pump plugin (for example from pump history) @SerializedName("Pump") Pump ("Pump"), //From Pump plugin (for example from pump history)
@SerializedName("SMS") SMS ("SMS"), //From SMS plugin @SerializedName("SMS") SMS ("SMS"), //From SMS plugin
@SerializedName("Wear") Wear ("Wear"), //From Wear plugin @SerializedName("Wear") Wear ("Wear"), //From Wear plugin
@SerializedName("Food") Food ("Food"), //From Food plugin
@SerializedName("Unknown") Unknown ("Unknown") //if necessary @SerializedName("Unknown") Unknown ("Unknown") //if necessary
; ;