Merge branch 'UserEntryImprovement' into AdrianVWU_Update
# Conflicts: # app/src/main/java/info/nightscout/androidaps/dialogs/CalibrationDialog.kt # app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt # app/src/main/java/info/nightscout/androidaps/dialogs/ExtendedBolusDialog.kt # app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt # app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt # app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt # app/src/main/java/info/nightscout/androidaps/dialogs/ProfileSwitchDialog.kt # app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt # app/src/main/java/info/nightscout/androidaps/dialogs/TempTargetDialog.kt # app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt # app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt # app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientRemoveWorker.kt # app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt # app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt # app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsBolusFragment.kt # app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsCareportalFragment.kt # app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsProfileSwitchFragment.kt # app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTempTargetFragment.kt # app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsTemporaryBasalsFragment.kt # app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsUserEntryFragment.kt # app/src/main/java/info/nightscout/androidaps/utils/wizard/BolusWizard.kt # core/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/formats/ClassicPrefsFormat.kt # core/src/main/java/info/nightscout/androidaps/utils/Translator.kt # core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt # database/src/main/java/info/nightscout/androidaps/database/entities/UserEntry.kt
This commit is contained in:
commit
654ca35dd1
|
@ -80,7 +80,8 @@ 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, 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)
|
xdripCalibrations.sendIntent(bg)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,7 +223,8 @@ 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, 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(
|
disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
|
||||||
timestamp = System.currentTimeMillis(),
|
timestamp = System.currentTimeMillis(),
|
||||||
duration = TimeUnit.MINUTES.toMillis(activityTTDuration.toLong()),
|
duration = TimeUnit.MINUTES.toMillis(activityTTDuration.toLong()),
|
||||||
|
@ -239,7 +240,8 @@ class CarbsDialog : DialogFragmentWithDate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
eatingSoonSelected -> {
|
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(
|
disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
|
||||||
timestamp = System.currentTimeMillis(),
|
timestamp = System.currentTimeMillis(),
|
||||||
duration = TimeUnit.MINUTES.toMillis(eatingSoonTTDuration.toLong()),
|
duration = TimeUnit.MINUTES.toMillis(eatingSoonTTDuration.toLong()),
|
||||||
|
@ -255,7 +257,8 @@ class CarbsDialog : DialogFragmentWithDate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
hypoSelected -> {
|
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(
|
disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
|
||||||
timestamp = System.currentTimeMillis(),
|
timestamp = System.currentTimeMillis(),
|
||||||
duration = TimeUnit.MINUTES.toMillis(hypoTTDuration.toLong()),
|
duration = TimeUnit.MINUTES.toMillis(hypoTTDuration.toLong()),
|
||||||
|
@ -273,11 +276,14 @@ class CarbsDialog : DialogFragmentWithDate() {
|
||||||
if (carbsAfterConstraints > 0) {
|
if (carbsAfterConstraints > 0) {
|
||||||
if (duration == 0) {
|
if (duration == 0) {
|
||||||
carbsGenerator.createCarb(carbsAfterConstraints, time, TherapyEvent.Type.CARBS_CORRECTION, notes)
|
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 {
|
} 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, 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) {
|
if (useAlarm && carbs > 0 && timeOffset > 0) {
|
||||||
carbTimer.scheduleReminder(dateUtil._now() + T.mins(timeOffset.toLong()).msecs())
|
carbTimer.scheduleReminder(dateUtil._now() + T.mins(timeOffset.toLong()).msecs())
|
||||||
|
|
|
@ -221,6 +221,17 @@ class CareDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
therapyEvent.enteredBy = enteredBy
|
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 ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(event), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
|
OKDialog.showConfirmation(activity, resourceHelper.gs(event), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
|
||||||
disposable += repository.runTransactionForResult(InsertTherapyEventIfNewTransaction(therapyEvent)).subscribe({ result ->
|
disposable += repository.runTransactionForResult(InsertTherapyEventIfNewTransaction(therapyEvent)).subscribe({ result ->
|
||||||
|
|
|
@ -89,7 +89,8 @@ 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, 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() {
|
commandQueue.extendedBolus(insulinAfterConstraint, durationInMinutes, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
|
|
@ -137,11 +137,13 @@ class FillDialog : DialogFragmentWithDate() {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.primefill), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
|
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.primefill), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
|
||||||
if (insulinAfterConstraints > 0) {
|
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)
|
requestPrimeBolus(insulinAfterConstraints, notes)
|
||||||
}
|
}
|
||||||
if (siteChange) {
|
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(
|
disposable += repository.runTransactionForResult(InsertTherapyEventIfNewTransaction(
|
||||||
timestamp = eventTime,
|
timestamp = eventTime,
|
||||||
type = TherapyEvent.Type.CANNULA_CHANGE,
|
type = TherapyEvent.Type.CANNULA_CHANGE,
|
||||||
|
@ -155,7 +157,8 @@ class FillDialog : DialogFragmentWithDate() {
|
||||||
}
|
}
|
||||||
if (insulinChange) {
|
if (insulinChange) {
|
||||||
// add a second for case of both checked
|
// 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(
|
disposable += repository.runTransactionForResult(InsertTherapyEventIfNewTransaction(
|
||||||
timestamp = eventTime + 1000,
|
timestamp = eventTime + 1000,
|
||||||
type = TherapyEvent.Type.INSULIN_CHANGE,
|
type = TherapyEvent.Type.INSULIN_CHANGE,
|
||||||
|
|
|
@ -190,7 +190,8 @@ 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, 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(
|
disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
|
||||||
timestamp = System.currentTimeMillis(),
|
timestamp = System.currentTimeMillis(),
|
||||||
duration = TimeUnit.MINUTES.toMillis(eatingSoonTTDuration.toLong()),
|
duration = TimeUnit.MINUTES.toMillis(eatingSoonTTDuration.toLong()),
|
||||||
|
@ -212,11 +213,13 @@ 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_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
|
detailedBolusInfo.date = time
|
||||||
activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false)
|
activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false)
|
||||||
} else {
|
} 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()
|
detailedBolusInfo.date = DateUtil.now()
|
||||||
commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
|
|
|
@ -240,28 +240,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")
|
||||||
|
@ -278,7 +278,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")
|
||||||
|
@ -288,7 +288,8 @@ 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 )
|
||||||
|
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() {
|
||||||
|
@ -304,49 +305,56 @@ class LoopDialog : DaggerDialogFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.overview_suspend_1h -> {
|
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)
|
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, XXXValueWithUnit.Hour(2))
|
//uel.log(Action.SUSPEND, XXXValueWithUnit.Hour(2))
|
||||||
|
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, XXXValueWithUnit.Hour(3))
|
//uel.log(Action.SUSPEND, XXXValueWithUnit.Hour(3))
|
||||||
|
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, XXXValueWithUnit.Hour(10))
|
//uel.log(Action.SUSPEND, XXXValueWithUnit.Hour(10))
|
||||||
|
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, 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)
|
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, 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)
|
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, 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)
|
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"))
|
||||||
|
@ -354,14 +362,16 @@ class LoopDialog : DaggerDialogFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.overview_disconnect_2h -> {
|
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)
|
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, 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)
|
loopPlugin.disconnectPump(180, profile)
|
||||||
rxBus.send(EventRefreshOverview("suspendmenu"))
|
rxBus.send(EventRefreshOverview("suspendmenu"))
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -126,7 +126,8 @@ 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, 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)
|
treatmentsPlugin.doProfileSwitch(profileStore, profile, duration, percent, timeShift, eventTime)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,10 +127,12 @@ class TempBasalDialog : DialogFragmentWithDate() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isPercentPump) {
|
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)
|
commandQueue.tempBasalPercent(percent, durationInMinutes, true, profile, callback)
|
||||||
} else {
|
} 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)
|
commandQueue.tempBasalAbsolute(absolute, durationInMinutes, true, profile, callback)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -182,11 +182,16 @@ 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, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, XXXValueWithUnit.TherapyEventTTReason(TemporaryTarget.Reason.EATING_SOON), XXXValueWithUnit.fromGlucoseUnit(target, units), XXXValueWithUnit.Minute(duration))
|
//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.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.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.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.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) {
|
if (target == 0.0 || duration == 0) {
|
||||||
disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(eventTime))
|
disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(eventTime))
|
||||||
|
|
|
@ -131,7 +131,13 @@ 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, 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()
|
val detailedBolusInfo = DetailedBolusInfo()
|
||||||
if (insulinAfterConstraints == 0.0) detailedBolusInfo.eventType = TherapyEvent.Type.CARBS_CORRECTION
|
if (insulinAfterConstraints == 0.0) detailedBolusInfo.eventType = TherapyEvent.Type.CARBS_CORRECTION
|
||||||
if (carbsAfterConstraints == 0) detailedBolusInfo.eventType = TherapyEvent.Type.CORRECTION_BOLUS
|
if (carbsAfterConstraints == 0) detailedBolusInfo.eventType = TherapyEvent.Type.CORRECTION_BOLUS
|
||||||
|
|
|
@ -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,8 @@ 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()")
|
||||||
|
if (request.smb > 0.0)
|
||||||
|
uel.log(Action.SMB, ValueWithUnit(Sources.Loop), ValueWithUnit(detailedBolusInfo.insulin, Units.U))
|
||||||
commandQueue.bolus(detailedBolusInfo, callback)
|
commandQueue.bolus(detailedBolusInfo, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -155,7 +155,7 @@ class ActionsFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
extendedBolusCancel?.setOnClickListener {
|
extendedBolusCancel?.setOnClickListener {
|
||||||
if (activePlugin.activeTreatments.isInHistoryExtendedBolusInProgress) {
|
if (activePlugin.activeTreatments.isInHistoryExtendedBolusInProgress) {
|
||||||
uel.log(Action.CANCEL_EXTENDED_BOLUS)
|
uel.log(Action.CANCEL_EXTENDED_BOLUS, ValueWithUnit(Sources.Actions))
|
||||||
commandQueue.cancelExtended(object : Callback() {
|
commandQueue.cancelExtended(object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
@ -170,7 +170,7 @@ class ActionsFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
cancelTempBasal?.setOnClickListener {
|
cancelTempBasal?.setOnClickListener {
|
||||||
if (activePlugin.activeTreatments.isTempBasalInProgress) {
|
if (activePlugin.activeTreatments.isTempBasalInProgress) {
|
||||||
uel.log(Action.CANCEL_TEMP_BASAL)
|
uel.log(Action.CANCEL_TEMP_BASAL, ValueWithUnit(Sources.Actions))
|
||||||
commandQueue.cancelTempBasal(true, object : Callback() {
|
commandQueue.cancelTempBasal(true, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
|
|
@ -16,7 +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.Action
|
import info.nightscout.androidaps.database.entities.UserEntry.*
|
||||||
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
|
||||||
|
@ -76,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_FROM_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)
|
||||||
|
|
|
@ -56,13 +56,12 @@ class MaintenanceFragment : DaggerFragment() {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
binding.logSend.setOnClickListener { maintenancePlugin.sendLogs() }
|
binding.logSend.setOnClickListener { maintenancePlugin.sendLogs() }
|
||||||
binding.logDelete.setOnClickListener {
|
binding.logDelete.setOnClickListener {
|
||||||
uel.log(Action.DELETE_LOGS)
|
uel.log(Action.DELETE_LOGS, ValueWithUnit(Sources.Maintenance))
|
||||||
maintenancePlugin.deleteLogs()
|
maintenancePlugin.deleteLogs()
|
||||||
}
|
}
|
||||||
binding.navResetdb.setOnClickListener {
|
binding.navResetdb.setOnClickListener {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.maintenance), resourceHelper.gs(R.string.reset_db_confirm), Runnable {
|
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.maintenance), resourceHelper.gs(R.string.reset_db_confirm), Runnable {
|
||||||
uel.log(Action.RESET_DATABASES)
|
|
||||||
compositeDisposable.add(
|
compositeDisposable.add(
|
||||||
fromAction {
|
fromAction {
|
||||||
databaseHelper.resetDatabases()
|
databaseHelper.resetDatabases()
|
||||||
|
@ -78,18 +77,19 @@ class MaintenanceFragment : DaggerFragment() {
|
||||||
onComplete = { rxBus.send(EventNewBG(null)) }
|
onComplete = { rxBus.send(EventNewBG(null)) }
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
uel.log(Action.RESET_DATABASES, ValueWithUnit(Sources.Maintenance))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
binding.navExport.setOnClickListener {
|
binding.navExport.setOnClickListener {
|
||||||
uel.log(Action.EXPORT_SETTINGS)
|
uel.log(Action.EXPORT_SETTINGS, ValueWithUnit(Sources.Maintenance))
|
||||||
// start activity for checking permissions...
|
// start activity for checking permissions...
|
||||||
importExportPrefs.verifyStoragePermissions(this) {
|
importExportPrefs.verifyStoragePermissions(this) {
|
||||||
importExportPrefs.exportSharedPreferences(this)
|
importExportPrefs.exportSharedPreferences(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
binding.navImport.setOnClickListener {
|
binding.navImport.setOnClickListener {
|
||||||
uel.log(Action.IMPORT_SETTINGS)
|
uel.log(Action.IMPORT_SETTINGS, ValueWithUnit(Sources.Maintenance))
|
||||||
// start activity for checking permissions...
|
// start activity for checking permissions...
|
||||||
importExportPrefs.verifyStoragePermissions(this) {
|
importExportPrefs.verifyStoragePermissions(this) {
|
||||||
importExportPrefs.importSharedPreferences(this)
|
importExportPrefs.importSharedPreferences(this)
|
||||||
|
@ -99,7 +99,7 @@ class MaintenanceFragment : DaggerFragment() {
|
||||||
binding.exportCsv.setOnClickListener {
|
binding.exportCsv.setOnClickListener {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.ue_export_to_csv) + "?") {
|
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())
|
importExportPrefs.exportUserEntriesCsv(activity, repository.getAllUserEntries())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import info.nightscout.androidaps.database.AppRepository
|
||||||
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
|
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
|
||||||
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.entities.UserEntry
|
||||||
|
import info.nightscout.androidaps.database.entities.UserEntry.*
|
||||||
import info.nightscout.androidaps.database.transactions.SyncTemporaryTargetTransaction
|
import info.nightscout.androidaps.database.transactions.SyncTemporaryTargetTransaction
|
||||||
import info.nightscout.androidaps.database.transactions.SyncTherapyEventTransaction
|
import info.nightscout.androidaps.database.transactions.SyncTherapyEventTransaction
|
||||||
import info.nightscout.androidaps.events.EventNsTreatment
|
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.temporaryTargetFromJson
|
||||||
import info.nightscout.androidaps.utils.extensions.therapyEventFromJson
|
import info.nightscout.androidaps.utils.extensions.therapyEventFromJson
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class NSClientAddUpdateWorker(
|
class NSClientAddUpdateWorker(
|
||||||
|
@ -85,28 +87,46 @@ class NSClientAddUpdateWorker(
|
||||||
}
|
}
|
||||||
.blockingGet()
|
.blockingGet()
|
||||||
.also { result ->
|
.also { result ->
|
||||||
result.inserted.forEach { tt ->
|
/*result.inserted.forEach { tt ->
|
||||||
uel.log(UserEntry.Action.TT_FROM_NS,
|
uel.log(UserEntry.Action.TT_FROM_NS,
|
||||||
XXXValueWithUnit.TherapyEventTTReason(tt.reason),
|
XXXValueWithUnit.TherapyEventTTReason(tt.reason),
|
||||||
XXXValueWithUnit.Mgdl(tt.lowTarget),
|
XXXValueWithUnit.Mgdl(tt.lowTarget),
|
||||||
XXXValueWithUnit.Mgdl(tt.highTarget).takeIf { tt.lowTarget != tt.highTarget },
|
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,
|
uel.log(UserEntry.Action.TT_DELETED_FROM_NS,
|
||||||
XXXValueWithUnit.TherapyEventTTReason(tt.reason),
|
XXXValueWithUnit.TherapyEventTTReason(tt.reason),
|
||||||
XXXValueWithUnit.Mgdl(tt.lowTarget),
|
XXXValueWithUnit.Mgdl(tt.lowTarget),
|
||||||
XXXValueWithUnit.Mgdl(tt.highTarget).takeIf { tt.lowTarget != tt.highTarget },
|
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,
|
uel.log(UserEntry.Action.TT_CANCELED_FROM_NS,
|
||||||
XXXValueWithUnit.TherapyEventTTReason(tt.reason),
|
XXXValueWithUnit.TherapyEventTTReason(tt.reason),
|
||||||
XXXValueWithUnit.Mgdl(tt.lowTarget),
|
XXXValueWithUnit.Mgdl(tt.lowTarget),
|
||||||
XXXValueWithUnit.Mgdl(tt.highTarget).takeIf { tt.lowTarget != tt.highTarget },
|
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()
|
.blockingGet()
|
||||||
.also { result ->
|
.also { result ->
|
||||||
result.inserted.forEach {
|
/*result.inserted.forEach {
|
||||||
uel.log(UserEntry.Action.CAREPORTAL_FROM_NS,
|
uel.log(UserEntry.Action.CAREPORTAL_FROM_NS,
|
||||||
it.note ?: "",
|
it.note ?: "",
|
||||||
XXXValueWithUnit.Timestamp(it.timestamp),
|
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,
|
uel.log(UserEntry.Action.CAREPORTAL_DELETED_FROM_NS,
|
||||||
it.note ?: "",
|
it.note ?: "",
|
||||||
XXXValueWithUnit.Timestamp(it.timestamp),
|
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)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.database.AppRepository
|
import info.nightscout.androidaps.database.AppRepository
|
||||||
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
|
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.entities.UserEntry.*
|
||||||
import info.nightscout.androidaps.database.transactions.SyncTemporaryTargetTransaction
|
import info.nightscout.androidaps.database.transactions.SyncTemporaryTargetTransaction
|
||||||
import info.nightscout.androidaps.database.transactions.SyncTherapyEventTransaction
|
import info.nightscout.androidaps.database.transactions.SyncTherapyEventTransaction
|
||||||
import info.nightscout.androidaps.events.EventNsTreatment
|
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.temporaryTargetFromNsIdForInvalidating
|
||||||
import info.nightscout.androidaps.utils.extensions.therapyEventFromNsIdForInvalidating
|
import info.nightscout.androidaps.utils.extensions.therapyEventFromNsIdForInvalidating
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
// This will not be needed fpr NS v3
|
// This will not be needed fpr NS v3
|
||||||
|
@ -66,7 +68,7 @@ class NSClientRemoveWorker(
|
||||||
}
|
}
|
||||||
.blockingGet()
|
.blockingGet()
|
||||||
.also { result ->
|
.also { result ->
|
||||||
result.invalidated.forEach { tt ->
|
/*result.invalidated.forEach { tt ->
|
||||||
uel.log(
|
uel.log(
|
||||||
UserEntry.Action.TT_DELETED_FROM_NS,
|
UserEntry.Action.TT_DELETED_FROM_NS,
|
||||||
XXXValueWithUnit.TherapyEventTTReason(tt.reason),
|
XXXValueWithUnit.TherapyEventTTReason(tt.reason),
|
||||||
|
@ -74,6 +76,15 @@ class NSClientRemoveWorker(
|
||||||
XXXValueWithUnit.Mgdl(tt.highTarget).takeIf { tt.lowTarget != tt.highTarget },
|
XXXValueWithUnit.Mgdl(tt.highTarget).takeIf { tt.lowTarget != tt.highTarget },
|
||||||
XXXValueWithUnit.Minute(tt.duration.toInt() / 60000).takeIf { tt.duration != 0L }
|
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()
|
.blockingGet()
|
||||||
.also { result ->
|
.also { result ->
|
||||||
result.invalidated.forEach {
|
result.invalidated.forEach {
|
||||||
uel.log(
|
/*uel.log(
|
||||||
UserEntry.Action.CAREPORTAL_DELETED_FROM_NS, (it.note ?: ""),
|
UserEntry.Action.CAREPORTAL_DELETED_FROM_NS, (it.note ?: ""),
|
||||||
XXXValueWithUnit.Timestamp(it.timestamp),
|
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))
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -348,7 +348,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
receivedSms.processed = true
|
receivedSms.processed = true
|
||||||
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
|
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
uel.log(Action.SMS_LOOP_DISABLED)
|
uel.log(Action.LOOP_DISABLED, ValueWithUnit(Sources.SMS))
|
||||||
loopPlugin.setPluginEnabled(PluginType.LOOP, false)
|
loopPlugin.setPluginEnabled(PluginType.LOOP, false)
|
||||||
commandQueue.cancelTempBasal(true, object : Callback() {
|
commandQueue.cancelTempBasal(true, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
|
@ -372,7 +372,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
receivedSms.processed = true
|
receivedSms.processed = true
|
||||||
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
|
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
uel.log(Action.SMS_LOOP_ENABLED)
|
uel.log(Action.LOOP_ENABLED, ValueWithUnit(Sources.SMS))
|
||||||
loopPlugin.setPluginEnabled(PluginType.LOOP, true)
|
loopPlugin.setPluginEnabled(PluginType.LOOP, true)
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_loophasbeenenabled)))
|
sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_loophasbeenenabled)))
|
||||||
rxBus.send(EventRefreshOverview("SMS_LOOP_START"))
|
rxBus.send(EventRefreshOverview("SMS_LOOP_START"))
|
||||||
|
@ -399,7 +399,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
receivedSms.processed = true
|
receivedSms.processed = true
|
||||||
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
|
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
uel.log(Action.SMS_LOOP_RESUME)
|
uel.log(Action.RESUME, ValueWithUnit(Sources.SMS))
|
||||||
loopPlugin.suspendTo(0L)
|
loopPlugin.suspendTo(0L)
|
||||||
rxBus.send(EventRefreshOverview("SMS_LOOP_RESUME"))
|
rxBus.send(EventRefreshOverview("SMS_LOOP_RESUME"))
|
||||||
commandQueue.cancelTempBasal(true, object : Callback() {
|
commandQueue.cancelTempBasal(true, object : Callback() {
|
||||||
|
@ -432,7 +432,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
receivedSms.processed = true
|
receivedSms.processed = true
|
||||||
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(duration) {
|
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(duration) {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
uel.log(Action.SMS_LOOP_SUSPEND)
|
uel.log(Action.SUSPEND, ValueWithUnit(Sources.SMS))
|
||||||
commandQueue.cancelTempBasal(true, object : Callback() {
|
commandQueue.cancelTempBasal(true, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
|
@ -516,7 +516,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
receivedSms.processed = true
|
receivedSms.processed = true
|
||||||
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
|
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
uel.log(Action.SMS_PUMP_CONNECT)
|
uel.log(Action.RECONNECT, ValueWithUnit(Sources.SMS))
|
||||||
commandQueue.cancelTempBasal(true, object : Callback() {
|
commandQueue.cancelTempBasal(true, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
@ -545,7 +545,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
receivedSms.processed = true
|
receivedSms.processed = true
|
||||||
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
|
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
uel.log(Action.SMS_PUMP_DISCONNECT)
|
uel.log(Action.DISCONNECT, ValueWithUnit(Sources.SMS))
|
||||||
val profile = profileFunction.getProfile()
|
val profile = profileFunction.getProfile()
|
||||||
loopPlugin.disconnectPump(duration, profile)
|
loopPlugin.disconnectPump(duration, profile)
|
||||||
rxBus.send(EventRefreshOverview("SMS_PUMP_DISCONNECT"))
|
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())
|
activePlugin.activeTreatments.doProfileSwitch(store, list[pIndex - 1] as String, 0, finalPercentage, 0, DateUtil.now())
|
||||||
val replyText = resourceHelper.gs(R.string.profileswitchcreated)
|
val replyText = resourceHelper.gs(R.string.profileswitchcreated)
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
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)
|
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalcanceled)
|
||||||
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
||||||
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
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 {
|
} else {
|
||||||
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalcancelfailed)
|
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalcancelfailed)
|
||||||
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
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)
|
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
||||||
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
||||||
if (result.isPercent)
|
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
|
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 {
|
} else {
|
||||||
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed)
|
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed)
|
||||||
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
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)
|
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
||||||
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
||||||
if (result.isPercent)
|
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
|
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 {
|
} else {
|
||||||
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed)
|
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed)
|
||||||
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
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)
|
var replyText = resourceHelper.gs(R.string.smscommunicator_extendedcancelfailed)
|
||||||
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
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)
|
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
||||||
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
||||||
if (config.APS)
|
if (config.APS)
|
||||||
uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_extendedset, listOf(XXXValueWithUnit.Insulin(aDouble
|
//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))
|
// ?: 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
|
else
|
||||||
uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_extendedset, listOf( XXXValueWithUnit.Insulin(aDouble
|
//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))))
|
// ?: 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 {
|
} else {
|
||||||
var replyText = resourceHelper.gs(R.string.smscommunicator_extendedfailed)
|
var replyText = resourceHelper.gs(R.string.smscommunicator_extendedfailed)
|
||||||
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
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))
|
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
||||||
uel.log(Action.SMS_BOLUS, replyText)
|
uel.log(Action.BOLUS, replyText, ValueWithUnit(Sources.SMS))
|
||||||
} else {
|
} else {
|
||||||
var replyText = resourceHelper.gs(R.string.smscommunicator_bolusfailed)
|
var replyText = resourceHelper.gs(R.string.smscommunicator_bolusfailed)
|
||||||
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
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)
|
var replyText = String.format(resourceHelper.gs(R.string.smscommunicator_carbsset), anInteger)
|
||||||
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
||||||
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
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 {
|
} else {
|
||||||
var replyText = resourceHelper.gs(R.string.smscommunicator_carbsfailed, anInteger)
|
var replyText = resourceHelper.gs(R.string.smscommunicator_carbsfailed, anInteger)
|
||||||
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
||||||
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
sendSMS(Sms(receivedSms.phoneNumber, replyText))
|
||||||
uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_carbsfailed, listOf(XXXValueWithUnit.Gram(anInteger
|
//uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_carbsfailed, listOf(XXXValueWithUnit.Gram(anInteger
|
||||||
?: 0))))
|
// ?: 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)
|
var replyText = String.format(resourceHelper.gs(R.string.smscommunicator_carbsset), anInteger)
|
||||||
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
replyText += "\n" + activePlugin.activePump.shortStatus(true)
|
||||||
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
||||||
uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_carbsset, listOf(XXXValueWithUnit.Gram(anInteger
|
//uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_carbsset, listOf(XXXValueWithUnit.Gram(anInteger
|
||||||
?: 0))))
|
// ?: 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)
|
val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_tt_set), ttString, ttDuration)
|
||||||
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
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, 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) {
|
} else if (isStop) {
|
||||||
|
@ -987,7 +1010,8 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
})
|
})
|
||||||
val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_tt_canceled))
|
val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_tt_canceled))
|
||||||
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
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
|
} else
|
||||||
|
@ -1006,7 +1030,8 @@ 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, 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)))
|
} 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)
|
if (result) resourceHelper.gs(R.string.smscommunicator_calibrationsent) else resourceHelper.gs(R.string.smscommunicator_calibrationfailed)
|
||||||
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
|
||||||
if (result)
|
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
|
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)))
|
} else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat)))
|
||||||
|
|
|
@ -17,6 +17,7 @@ import info.nightscout.androidaps.database.AppRepository
|
||||||
import info.nightscout.androidaps.database.ValueWrapper
|
import info.nightscout.androidaps.database.ValueWrapper
|
||||||
import info.nightscout.androidaps.database.entities.TemporaryTarget
|
import info.nightscout.androidaps.database.entities.TemporaryTarget
|
||||||
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.interfaces.end
|
import info.nightscout.androidaps.database.interfaces.end
|
||||||
import info.nightscout.androidaps.database.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
|
import info.nightscout.androidaps.database.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
|
||||||
import info.nightscout.androidaps.database.transactions.InsertTemporaryTargetAndCancelCurrentTransaction
|
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.db.TDD
|
||||||
import info.nightscout.androidaps.interfaces.*
|
import info.nightscout.androidaps.interfaces.*
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
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.aps.loop.LoopPlugin
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
|
@ -59,7 +61,7 @@ class ActionStringHandler @Inject constructor(
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val rxBus: RxBusWrapper,
|
private val rxBus: RxBusWrapper,
|
||||||
private val aapsLogger: AAPSLogger,
|
private val aapsLogger: AAPSLogger,
|
||||||
aapsSchedulers: AapsSchedulers,
|
private val aapsSchedulers: AapsSchedulers,
|
||||||
private val resourceHelper: ResourceHelper,
|
private val resourceHelper: ResourceHelper,
|
||||||
private val injector: HasAndroidInjector,
|
private val injector: HasAndroidInjector,
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
|
@ -82,6 +84,7 @@ class ActionStringHandler @Inject constructor(
|
||||||
private val config: Config,
|
private val config: Config,
|
||||||
private val databaseHelper: DatabaseHelperInterface,
|
private val databaseHelper: DatabaseHelperInterface,
|
||||||
private val repository: AppRepository,
|
private val repository: AppRepository,
|
||||||
|
private val uel: UserEntryLogger,
|
||||||
private val nsUpload: NSUpload
|
private val nsUpload: NSUpload
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
@ -92,7 +95,7 @@ class ActionStringHandler @Inject constructor(
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
|
||||||
init {
|
fun setup() {
|
||||||
disposable += rxBus
|
disposable += rxBus
|
||||||
.toObservable(EventWearInitiateAction::class.java)
|
.toObservable(EventWearInitiateAction::class.java)
|
||||||
.observeOn(aapsSchedulers.main)
|
.observeOn(aapsSchedulers.main)
|
||||||
|
@ -104,6 +107,10 @@ class ActionStringHandler @Inject constructor(
|
||||||
.subscribe({ handleConfirmation(it.action) }, fabricPrivacy::logException)
|
.subscribe({ handleConfirmation(it.action) }, fabricPrivacy::logException)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun tearDown(){
|
||||||
|
disposable.clear()
|
||||||
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
private fun handleInitiate(actionString: String) {
|
private fun handleInitiate(actionString: String) {
|
||||||
if (!sp.getBoolean(R.string.key_wear_control, false)) return
|
if (!sp.getBoolean(R.string.key_wear_control, false)) return
|
||||||
|
@ -546,8 +553,10 @@ class ActionStringHandler @Inject constructor(
|
||||||
if (carbs > 0) {
|
if (carbs > 0) {
|
||||||
if (duration == 0) {
|
if (duration == 0) {
|
||||||
carbsGenerator.createCarb(carbs, time, TherapyEvent.Type.CARBS_CORRECTION, "watch")
|
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 {
|
} else {
|
||||||
carbsGenerator.generateCarbs(carbs, time, duration, "watch eCarbs")
|
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
|
return
|
||||||
}
|
}
|
||||||
//send profile to pump
|
//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)
|
activePlugin.activeTreatments.doProfileSwitch(0, percentage, timeshift)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun generateTempTarget(duration: Int, low: Double, high: Double) {
|
private fun generateTempTarget(duration: Int, low: Double, high: Double) {
|
||||||
if (duration != 0)
|
if (duration != 0) {
|
||||||
disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
|
disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
|
||||||
timestamp = System.currentTimeMillis(),
|
timestamp = System.currentTimeMillis(),
|
||||||
duration = TimeUnit.MINUTES.toMillis(duration.toLong()),
|
duration = TimeUnit.MINUTES.toMillis(duration.toLong()),
|
||||||
|
@ -592,13 +602,16 @@ class ActionStringHandler @Inject constructor(
|
||||||
}, {
|
}, {
|
||||||
aapsLogger.error("Error while saving temporary target", it)
|
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()))
|
disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(System.currentTimeMillis()))
|
||||||
.subscribe({ result ->
|
.subscribe({ result ->
|
||||||
result.updated.forEach { nsUpload.updateTempTarget(it) }
|
result.updated.forEach { nsUpload.updateTempTarget(it) }
|
||||||
}, {
|
}, {
|
||||||
aapsLogger.error("Error while saving temporary target", 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) {
|
private fun doFillBolus(amount: Double) {
|
||||||
|
@ -606,6 +619,7 @@ class ActionStringHandler @Inject constructor(
|
||||||
detailedBolusInfo.insulin = amount
|
detailedBolusInfo.insulin = amount
|
||||||
detailedBolusInfo.isValid = false
|
detailedBolusInfo.isValid = false
|
||||||
detailedBolusInfo.source = Source.USER
|
detailedBolusInfo.source = Source.USER
|
||||||
|
uel.log(Action.PRIME_BOLUS, ValueWithUnit(Sources.Wear), ValueWithUnit(amount, Units.U, amount != 0.0))
|
||||||
commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
@ -624,6 +638,12 @@ class ActionStringHandler @Inject constructor(
|
||||||
detailedBolusInfo.source = Source.USER
|
detailedBolusInfo.source = Source.USER
|
||||||
val storesCarbs = activePlugin.activePump.pumpDescription.storesCarbInfo
|
val storesCarbs = activePlugin.activePump.pumpDescription.storesCarbInfo
|
||||||
if (detailedBolusInfo.insulin > 0 || storesCarbs) {
|
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() {
|
commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
|
|
@ -35,7 +35,8 @@ class WearPlugin @Inject constructor(
|
||||||
private val mainApp: MainApp,
|
private val mainApp: MainApp,
|
||||||
private val fabricPrivacy: FabricPrivacy,
|
private val fabricPrivacy: FabricPrivacy,
|
||||||
private val loopPlugin: Lazy<LoopPlugin>,
|
private val loopPlugin: Lazy<LoopPlugin>,
|
||||||
private val rxBus: RxBusWrapper
|
private val rxBus: RxBusWrapper,
|
||||||
|
private val actionStringHandler: Lazy<ActionStringHandler>
|
||||||
|
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
|
@ -127,11 +128,13 @@ class WearPlugin @Inject constructor(
|
||||||
mainApp.startService(intent)
|
mainApp.startService(intent)
|
||||||
}
|
}
|
||||||
}, fabricPrivacy::logException))
|
}, fabricPrivacy::logException))
|
||||||
|
actionStringHandler.get().setup()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
disposable.clear()
|
disposable.clear()
|
||||||
super.onStop()
|
super.onStop()
|
||||||
|
actionStringHandler.get().tearDown()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sendDataToWatch(status: Boolean, basals: Boolean, bgValue: Boolean) {
|
private fun sendDataToWatch(status: Boolean, basals: Boolean, bgValue: Boolean) {
|
||||||
|
|
|
@ -163,7 +163,7 @@ class LocalProfileFragment : DaggerFragment() {
|
||||||
if (localProfilePlugin.isEdited) {
|
if (localProfilePlugin.isEdited) {
|
||||||
activity?.let { OKDialog.show(it, "", resourceHelper.gs(R.string.saveorresetchangesfirst)) }
|
activity?.let { OKDialog.show(it, "", resourceHelper.gs(R.string.saveorresetchangesfirst)) }
|
||||||
} else {
|
} else {
|
||||||
uel.log(Action.NEW_PROFILE)
|
uel.log(Action.NEW_PROFILE, ValueWithUnit(Sources.LocalProfile))
|
||||||
localProfilePlugin.addNewProfile()
|
localProfilePlugin.addNewProfile()
|
||||||
build()
|
build()
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ class LocalProfileFragment : DaggerFragment() {
|
||||||
if (localProfilePlugin.isEdited) {
|
if (localProfilePlugin.isEdited) {
|
||||||
activity?.let { OKDialog.show(it, "", resourceHelper.gs(R.string.saveorresetchangesfirst)) }
|
activity?.let { OKDialog.show(it, "", resourceHelper.gs(R.string.saveorresetchangesfirst)) }
|
||||||
} else {
|
} 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()
|
localProfilePlugin.cloneProfile()
|
||||||
build()
|
build()
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ class LocalProfileFragment : DaggerFragment() {
|
||||||
binding.profileRemove.setOnClickListener {
|
binding.profileRemove.setOnClickListener {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.deletecurrentprofile), {
|
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()
|
localProfilePlugin.removeCurrentProfile()
|
||||||
build()
|
build()
|
||||||
}, null)
|
}, null)
|
||||||
|
@ -210,6 +210,7 @@ class LocalProfileFragment : DaggerFragment() {
|
||||||
if (!localProfilePlugin.isValidEditState()) {
|
if (!localProfilePlugin.isValidEditState()) {
|
||||||
return@setOnClickListener //Should not happen as saveButton should not be visible if not valid
|
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)
|
localProfilePlugin.storeSettings(activity)
|
||||||
build()
|
build()
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,6 @@ class LocalProfilePlugin @Inject constructor(
|
||||||
createAndStoreConvertedProfile()
|
createAndStoreConvertedProfile()
|
||||||
isEdited = false
|
isEdited = false
|
||||||
aapsLogger.debug(LTag.PROFILE, "Storing settings: " + rawProfile?.data.toString())
|
aapsLogger.debug(LTag.PROFILE, "Storing settings: " + rawProfile?.data.toString())
|
||||||
uel.log(Action.STORE_PROFILE)
|
|
||||||
rxBus.send(EventProfileStoreChanged())
|
rxBus.send(EventProfileStoreChanged())
|
||||||
var namesOK = true
|
var namesOK = true
|
||||||
profiles.forEach {
|
profiles.forEach {
|
||||||
|
@ -294,6 +293,7 @@ class LocalProfilePlugin @Inject constructor(
|
||||||
|
|
||||||
fun cloneProfile() {
|
fun cloneProfile() {
|
||||||
val p = profiles[currentProfileIndex].deepClone()
|
val p = profiles[currentProfileIndex].deepClone()
|
||||||
|
val sourceName = p.name
|
||||||
p.name = p.name + " copy"
|
p.name = p.name + " copy"
|
||||||
profiles.add(p)
|
profiles.add(p)
|
||||||
currentProfileIndex = profiles.size - 1
|
currentProfileIndex = profiles.size - 1
|
||||||
|
|
|
@ -70,7 +70,7 @@ class TreatmentsBolusFragment : DaggerFragment() {
|
||||||
binding.refreshFromNightscout.setOnClickListener {
|
binding.refreshFromNightscout.setOnClickListener {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.refresheventsfromnightscout) + "?") {
|
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()
|
treatmentsPlugin.service.resetTreatments()
|
||||||
rxBus.send(EventNSClientRestart())
|
rxBus.send(EventNSClientRestart())
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ class TreatmentsBolusFragment : DaggerFragment() {
|
||||||
binding.deleteFutureTreatments.setOnClickListener {
|
binding.deleteFutureTreatments.setOnClickListener {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_treatment_label), resourceHelper.gs(R.string.deletefuturetreatments) + "?", Runnable {
|
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)
|
val futureTreatments = treatmentsPlugin.service.getTreatmentDataFromTime(DateUtil.now() + 1000, true)
|
||||||
for (treatment in futureTreatments) {
|
for (treatment in futureTreatments) {
|
||||||
if (NSUpload.isIdValid(treatment._id))
|
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.carbs) + ": " + resourceHelper.gs(R.string.format_carbs, treatment.carbs.toInt()) + "\n" +
|
||||||
resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(treatment.date)
|
resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(treatment.date)
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable {
|
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) {
|
if (treatment.source == Source.PUMP) {
|
||||||
treatment.isValid = false
|
treatment.isValid = false
|
||||||
treatmentsPlugin.service.update(treatment)
|
treatmentsPlugin.service.update(treatment)
|
||||||
|
|
|
@ -80,7 +80,7 @@ class TreatmentsCareportalFragment : DaggerFragment() {
|
||||||
binding.refreshFromNightscout.setOnClickListener {
|
binding.refreshFromNightscout.setOnClickListener {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal), resourceHelper.gs(R.string.refresheventsfromnightscout) + " ?", Runnable {
|
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() }
|
disposable += Completable.fromAction { repository.deleteAllTherapyEventsEntries() }
|
||||||
.subscribeOn(aapsSchedulers.io)
|
.subscribeOn(aapsSchedulers.io)
|
||||||
.observeOn(aapsSchedulers.main)
|
.observeOn(aapsSchedulers.main)
|
||||||
|
@ -95,7 +95,7 @@ class TreatmentsCareportalFragment : DaggerFragment() {
|
||||||
binding.removeAndroidapsStartedEvents.setOnClickListener {
|
binding.removeAndroidapsStartedEvents.setOnClickListener {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal), resourceHelper.gs(R.string.careportal_removestartedevents), Runnable {
|
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)
|
// val events = databaseHelper.getCareportalEvents(false)
|
||||||
repository.runTransactionForResult(InvalidateAAPSStartedTherapyEventTransaction())
|
repository.runTransactionForResult(InvalidateAAPSStartedTherapyEventTransaction())
|
||||||
.subscribe({ result ->
|
.subscribe({ result ->
|
||||||
|
@ -197,7 +197,8 @@ class TreatmentsCareportalFragment : DaggerFragment() {
|
||||||
resourceHelper.gs(R.string.notes_label) + ": " + (therapyEvent.note ?: "") + "\n" +
|
resourceHelper.gs(R.string.notes_label) + ": " + (therapyEvent.note ?: "") + "\n" +
|
||||||
resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(therapyEvent.timestamp)
|
resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(therapyEvent.timestamp)
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable {
|
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))
|
disposable += repository.runTransactionForResult(InvalidateTherapyEventTransaction(therapyEvent.id))
|
||||||
.subscribe({
|
.subscribe({
|
||||||
val id = therapyEvent.interfaceIDs.nightscoutId
|
val id = therapyEvent.interfaceIDs.nightscoutId
|
||||||
|
|
|
@ -123,7 +123,7 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() {
|
||||||
${resourceHelper.gs(R.string.extended_bolus)}
|
${resourceHelper.gs(R.string.extended_bolus)}
|
||||||
${resourceHelper.gs(R.string.date)}: ${dateUtil.dateAndTimeString(extendedBolus.date)}
|
${resourceHelper.gs(R.string.date)}: ${dateUtil.dateAndTimeString(extendedBolus.date)}
|
||||||
""".trimIndent(), { _: DialogInterface, _: Int ->
|
""".trimIndent(), { _: DialogInterface, _: Int ->
|
||||||
uel.log(Action.EXTENDED_BOLUS_REMOVED)
|
uel.log(Action.EXTENDED_BOLUS_REMOVED, ValueWithUnit(Sources.Treatments))
|
||||||
val id = extendedBolus._id
|
val id = extendedBolus._id
|
||||||
if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id)
|
if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id)
|
||||||
else uploadQueue.removeByMongoId("dbAdd", id)
|
else uploadQueue.removeByMongoId("dbAdd", id)
|
||||||
|
|
|
@ -72,7 +72,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() {
|
||||||
|
|
||||||
binding.refreshFromNightscout.setOnClickListener {
|
binding.refreshFromNightscout.setOnClickListener {
|
||||||
activity?.let { activity ->
|
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) + "?") {
|
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.refresheventsfromnightscout) + "?") {
|
||||||
databaseHelper.resetProfileSwitch()
|
databaseHelper.resetProfileSwitch()
|
||||||
rxBus.send(EventNSClientRestart())
|
rxBus.send(EventNSClientRestart())
|
||||||
|
@ -149,7 +149,8 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() {
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord),
|
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord),
|
||||||
resourceHelper.gs(R.string.careportal_profileswitch) + ": " + profileSwitch.profileName +
|
resourceHelper.gs(R.string.careportal_profileswitch) + ": " + profileSwitch.profileName +
|
||||||
"\n" + resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(profileSwitch.date), Runnable {
|
"\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
|
val id = profileSwitch._id
|
||||||
if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id)
|
if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id)
|
||||||
else uploadQueue.removeByMongoId("dbAdd", id)
|
else uploadQueue.removeByMongoId("dbAdd", id)
|
||||||
|
@ -162,7 +163,8 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() {
|
||||||
val profileSwitch = it.tag as ProfileSwitch
|
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 {
|
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 {
|
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()
|
val nonCustomized = it.convertToNonCustomizedProfile()
|
||||||
if (nonCustomized.isValid(resourceHelper.gs(R.string.careportal_profileswitch, false))) {
|
if (nonCustomized.isValid(resourceHelper.gs(R.string.careportal_profileswitch, false))) {
|
||||||
localProfilePlugin.addProfile(localProfilePlugin.copyFrom(nonCustomized, profileSwitch.customizedName + " " + dateUtil.dateAndTimeString(profileSwitch.date).replace(".", "_")))
|
localProfilePlugin.addProfile(localProfilePlugin.copyFrom(nonCustomized, profileSwitch.customizedName + " " + dateUtil.dateAndTimeString(profileSwitch.date).replace(".", "_")))
|
||||||
|
|
|
@ -87,7 +87,7 @@ class TreatmentsTempTargetFragment : 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.TT_NS_REFRESH)
|
uel.log(Action.TT_NS_REFRESH, ValueWithUnit(Sources.Treatments))
|
||||||
disposable += Completable.fromAction { repository.deleteAllTempTargetEntries() }
|
disposable += Completable.fromAction { repository.deleteAllTempTargetEntries() }
|
||||||
.subscribeOn(aapsSchedulers.io)
|
.subscribeOn(aapsSchedulers.io)
|
||||||
.observeOn(aapsSchedulers.main)
|
.observeOn(aapsSchedulers.main)
|
||||||
|
@ -197,7 +197,8 @@ class TreatmentsTempTargetFragment : DaggerFragment() {
|
||||||
${dateUtil.dateAndTimeString(tempTarget.timestamp)}
|
${dateUtil.dateAndTimeString(tempTarget.timestamp)}
|
||||||
""".trimIndent(),
|
""".trimIndent(),
|
||||||
{ _: DialogInterface?, _: Int ->
|
{ _: 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))
|
disposable += repository.runTransactionForResult(InvalidateTemporaryTargetTransaction(tempTarget.id))
|
||||||
.subscribe({
|
.subscribe({
|
||||||
val id = tempTarget.interfaceIDs.nightscoutId
|
val id = tempTarget.interfaceIDs.nightscoutId
|
||||||
|
|
|
@ -165,7 +165,8 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() {
|
||||||
${resourceHelper.gs(R.string.date)}: ${dateUtil.dateAndTimeString(tempBasal.date)}
|
${resourceHelper.gs(R.string.date)}: ${dateUtil.dateAndTimeString(tempBasal.date)}
|
||||||
""".trimIndent(),
|
""".trimIndent(),
|
||||||
{ _: DialogInterface?, _: Int ->
|
{ _: 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)
|
activePlugin.activeTreatments.removeTempBasal(tempBasal)
|
||||||
}, null)
|
}, null)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.treatments.fragments
|
package info.nightscout.androidaps.plugins.treatments.fragments
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.renderscript.Sampler
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
@ -19,6 +20,7 @@ import info.nightscout.androidaps.interfaces.ImportExportPrefsInterface
|
||||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
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.DateUtil
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
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.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class TreatmentsUserEntryFragment : DaggerFragment() {
|
class TreatmentsUserEntryFragment : DaggerFragment() {
|
||||||
|
@ -62,20 +65,29 @@ class TreatmentsUserEntryFragment : DaggerFragment() {
|
||||||
binding.ueExportToXml.setOnClickListener {
|
binding.ueExportToXml.setOnClickListener {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.ue_export_to_csv) + "?") {
|
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())
|
importExportPrefs.exportUserEntriesCsv(activity, repository.getAllUserEntries())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
binding.showLoop.setOnCheckedChangeListener { _, _ ->
|
||||||
|
rxBus.send(EventTreatmentUpdateGui())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun swapAdapter() {
|
fun swapAdapter() {
|
||||||
disposable.add( repository
|
if (binding.showLoop.isChecked)
|
||||||
.getAllUserEntries()
|
disposable.add( repository
|
||||||
.observeOn(aapsSchedulers.main)
|
.getAllUserEntries()
|
||||||
.subscribe { list -> binding.recyclerview.swapAdapter(UserEntryAdapter(list), true) }
|
.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
|
@Synchronized
|
||||||
|
@ -87,6 +99,11 @@ class TreatmentsUserEntryFragment : DaggerFragment() {
|
||||||
.toObservable(EventPreferenceChange::class.java)
|
.toObservable(EventPreferenceChange::class.java)
|
||||||
.observeOn(aapsSchedulers.io)
|
.observeOn(aapsSchedulers.io)
|
||||||
.subscribe({ swapAdapter() }, fabricPrivacy::logException))
|
.subscribe({ swapAdapter() }, fabricPrivacy::logException))
|
||||||
|
disposable.add(rxBus
|
||||||
|
.toObservable(EventTreatmentUpdateGui::class.java)
|
||||||
|
.observeOn(aapsSchedulers.io)
|
||||||
|
.debounce(1L, TimeUnit.SECONDS)
|
||||||
|
.subscribe({ swapAdapter() }, fabricPrivacy::logException))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
|
@ -112,15 +129,15 @@ class TreatmentsUserEntryFragment : DaggerFragment() {
|
||||||
override fun onBindViewHolder(holder: UserEntryViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: UserEntryViewHolder, position: Int) {
|
||||||
val current = entries[position]
|
val current = entries[position]
|
||||||
holder.binding.date.text = dateUtil.dateAndTimeAndSecondsString(current.timestamp)
|
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.s != "") {
|
||||||
if (current.remark != "") {
|
holder.binding.s.text = current.s
|
||||||
holder.binding.s.text = current.remark
|
|
||||||
holder.binding.s.visibility = View.VISIBLE
|
holder.binding.s.visibility = View.VISIBLE
|
||||||
} else
|
} else
|
||||||
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 = " "
|
||||||
for(v in current.values) {
|
for(v in current.values) {
|
||||||
if (rStringParam >0)
|
if (rStringParam >0)
|
||||||
|
@ -145,11 +162,19 @@ class TreatmentsUserEntryFragment : DaggerFragment() {
|
||||||
-> valuesWithUnitString += DecimalFormatter.to2Decimal(v.dValue) + translator.translate(v.unit) + separator
|
-> valuesWithUnitString += DecimalFormatter.to2Decimal(v.dValue) + translator.translate(v.unit) + 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) + separator
|
-> 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 ""
|
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)
|
||||||
|
holder.binding.action.setTextColor(resourceHelper.gc(userEntryPresentationHelper.colorId(current.action.colorGroup)))
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class UserEntryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
inner class UserEntryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||||
|
@ -158,6 +183,13 @@ class TreatmentsUserEntryFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int = entries.size
|
override fun getItemCount(): Int = entries.size
|
||||||
|
}
|
||||||
|
|
||||||
|
fun filterUserEntries(list: List<UserEntry>): List<UserEntry> {
|
||||||
|
val filteredList = mutableListOf<UserEntry>()
|
||||||
|
for (ue in list) {
|
||||||
|
if (! ue.isLoop()) filteredList.add(ue)
|
||||||
|
}
|
||||||
|
return filteredList
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -350,7 +350,8 @@ 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, 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) {
|
if (insulin > 0) {
|
||||||
commandQueue.bolus(this, object : Callback() {
|
commandQueue.bolus(this, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
|
@ -373,7 +374,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"))
|
||||||
|
@ -414,7 +415,13 @@ 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, 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) {
|
if (insulin > 0 || pump.pumpDescription.storesCarbInfo) {
|
||||||
commandQueue.bolus(this, object : Callback() {
|
commandQueue.bolus(this, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
|
|
|
@ -1,18 +1,44 @@
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context=".plugins.treatments.fragments.TreatmentsUserEntryFragment">
|
tools:context=".plugins.treatments.fragments.TreatmentsUserEntryFragment">
|
||||||
|
|
||||||
<info.nightscout.androidaps.utils.ui.SingleClickButton
|
<LinearLayout
|
||||||
android:id="@+id/ue_export_to_xml"
|
|
||||||
style="?android:attr/buttonStyle"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:orientation="horizontal">
|
||||||
android:drawableStart="@drawable/ic_header_export"
|
|
||||||
android:text="@string/ue_export_to_csv" />
|
<info.nightscout.androidaps.utils.ui.SingleClickButton
|
||||||
|
android:id="@+id/ue_export_to_xml"
|
||||||
|
style="?android:attr/buttonStyle"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:drawableStart="@drawable/ic_header_export"
|
||||||
|
android:text="@string/ue_export_to_csv" />
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/show_loop"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="end|center_vertical"
|
||||||
|
android:checked="false"
|
||||||
|
android:paddingEnd="5dp"
|
||||||
|
tools:ignore="RtlSymmetry" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:contentDescription="@string/show_calculation"
|
||||||
|
app:srcCompat="@drawable/ic_loop_closed_white" />
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/recyclerview"
|
android:id="@+id/recyclerview"
|
||||||
|
|
|
@ -1,42 +1,49 @@
|
||||||
<?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"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingStart="5dp"
|
android:paddingStart="10dp"
|
||||||
|
android:paddingTop="3dp"
|
||||||
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" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/action"
|
android:id="@+id/action"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingStart="10dp"
|
android:paddingStart="10dp"
|
||||||
|
android:paddingTop="3dp"
|
||||||
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_constraintEnd_toStartOf="@+id/iconSource"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
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="@+id/action"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/action"
|
||||||
|
app:srcCompat="@drawable/ic_cp_bolus_carbs" />
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/values"
|
android:id="@+id/values"
|
||||||
|
@ -46,6 +53,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/action"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:text="Values with units" />
|
android:text="Values with units" />
|
||||||
|
|
||||||
|
@ -54,8 +63,12 @@
|
||||||
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"
|
android:paddingEnd="10dp"
|
||||||
|
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 +78,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>
|
||||||
|
|
|
@ -131,7 +131,6 @@
|
||||||
<string name="configbuilder_constraints_description">Which constraints are applied?</string>
|
<string name="configbuilder_constraints_description">Which constraints are applied?</string>
|
||||||
<string name="constraints">Constraints</string>
|
<string name="constraints">Constraints</string>
|
||||||
|
|
||||||
<string name="loop">Loop</string>
|
|
||||||
<string name="configbuilder_loop">Loop</string>
|
<string name="configbuilder_loop">Loop</string>
|
||||||
<string name="configbuilder_loop_description">Use this to activate AndroidAPS\' loop integration.</string>
|
<string name="configbuilder_loop_description">Use this to activate AndroidAPS\' loop integration.</string>
|
||||||
<string name="loop_aps_label">APS</string>
|
<string name="loop_aps_label">APS</string>
|
||||||
|
@ -511,7 +510,6 @@
|
||||||
<string name="openapsama_autosens_period_summary">Amount of hours in the past for sensitivity detection (carbs absorption time is excluded)</string>
|
<string name="openapsama_autosens_period_summary">Amount of hours in the past for sensitivity detection (carbs absorption time is excluded)</string>
|
||||||
<string name="key_openapsama_autosens_period" translatable="false">openapsama_autosens_period</string>
|
<string name="key_openapsama_autosens_period" translatable="false">openapsama_autosens_period</string>
|
||||||
<string name="key_nsclient_localbroadcasts" translatable="false">nsclient_localbroadcasts</string>
|
<string name="key_nsclient_localbroadcasts" translatable="false">nsclient_localbroadcasts</string>
|
||||||
<string name="pump">Pump</string>
|
|
||||||
<string name="openaps">OpenAPS</string>
|
<string name="openaps">OpenAPS</string>
|
||||||
<string name="uploader">Uploader</string>
|
<string name="uploader">Uploader</string>
|
||||||
<string name="configbuilder_sensitivity">Sensitivity detection</string>
|
<string name="configbuilder_sensitivity">Sensitivity detection</string>
|
||||||
|
|
|
@ -4,12 +4,15 @@ import androidx.annotation.DrawableRes
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.automation.R
|
import info.nightscout.androidaps.automation.R
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult
|
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.events.EventRefreshOverview
|
||||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
import info.nightscout.androidaps.interfaces.ConfigBuilderInterface
|
import info.nightscout.androidaps.interfaces.ConfigBuilderInterface
|
||||||
import info.nightscout.androidaps.interfaces.LoopInterface
|
import info.nightscout.androidaps.interfaces.LoopInterface
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
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 configBuilderPlugin: ConfigBuilderInterface
|
||||||
@Inject lateinit var commandQueue: CommandQueueProvider
|
@Inject lateinit var commandQueue: CommandQueueProvider
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
|
@Inject lateinit var uel: UserEntryLogger
|
||||||
|
|
||||||
override fun friendlyName(): Int = R.string.disableloop
|
override fun friendlyName(): Int = R.string.disableloop
|
||||||
override fun shortDescription(): String = resourceHelper.gs(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()) {
|
if ((loopPlugin as PluginBase).isEnabled()) {
|
||||||
(loopPlugin as PluginBase).setPluginEnabled(PluginType.LOOP, false)
|
(loopPlugin as PluginBase).setPluginEnabled(PluginType.LOOP, false)
|
||||||
configBuilderPlugin.storeSettings("ActionLoopDisable")
|
configBuilderPlugin.storeSettings("ActionLoopDisable")
|
||||||
|
uel.log(UserEntry.Action.LOOP_DISABLED, ValueWithUnit(Sources.Automation))
|
||||||
commandQueue.cancelTempBasal(true, object : Callback() {
|
commandQueue.cancelTempBasal(true, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
rxBus.send(EventRefreshOverview("ActionLoopDisable"))
|
rxBus.send(EventRefreshOverview("ActionLoopDisable"))
|
||||||
|
|
|
@ -4,11 +4,14 @@ import androidx.annotation.DrawableRes
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.automation.R
|
import info.nightscout.androidaps.automation.R
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult
|
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.events.EventRefreshOverview
|
||||||
import info.nightscout.androidaps.interfaces.ConfigBuilderInterface
|
import info.nightscout.androidaps.interfaces.ConfigBuilderInterface
|
||||||
import info.nightscout.androidaps.interfaces.LoopInterface
|
import info.nightscout.androidaps.interfaces.LoopInterface
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
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 loopPlugin: LoopInterface
|
||||||
@Inject lateinit var configBuilderPlugin: ConfigBuilderInterface
|
@Inject lateinit var configBuilderPlugin: ConfigBuilderInterface
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
|
@Inject lateinit var uel: UserEntryLogger
|
||||||
|
|
||||||
override fun friendlyName(): Int = R.string.enableloop
|
override fun friendlyName(): Int = R.string.enableloop
|
||||||
override fun shortDescription(): String = resourceHelper.gs(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)
|
(loopPlugin as PluginBase).setPluginEnabled(PluginType.LOOP, true)
|
||||||
configBuilderPlugin.storeSettings("ActionLoopEnable")
|
configBuilderPlugin.storeSettings("ActionLoopEnable")
|
||||||
rxBus.send(EventRefreshOverview("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()
|
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
|
||||||
} else {
|
} else {
|
||||||
callback.result(PumpEnactResult(injector).success(true).comment(R.string.alreadyenabled))?.run()
|
callback.result(PumpEnactResult(injector).success(true).comment(R.string.alreadyenabled))?.run()
|
||||||
|
|
|
@ -4,9 +4,12 @@ import androidx.annotation.DrawableRes
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.automation.R
|
import info.nightscout.androidaps.automation.R
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult
|
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.events.EventRefreshOverview
|
||||||
import info.nightscout.androidaps.interfaces.ConfigBuilderInterface
|
import info.nightscout.androidaps.interfaces.ConfigBuilderInterface
|
||||||
import info.nightscout.androidaps.interfaces.LoopInterface
|
import info.nightscout.androidaps.interfaces.LoopInterface
|
||||||
|
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
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 loopPlugin: LoopInterface
|
||||||
@Inject lateinit var configBuilderPlugin: ConfigBuilderInterface
|
@Inject lateinit var configBuilderPlugin: ConfigBuilderInterface
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
|
@Inject lateinit var uel: UserEntryLogger
|
||||||
|
|
||||||
override fun friendlyName(): Int = R.string.resumeloop
|
override fun friendlyName(): Int = R.string.resumeloop
|
||||||
override fun shortDescription(): String = resourceHelper.gs(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")
|
configBuilderPlugin.storeSettings("ActionLoopResume")
|
||||||
loopPlugin.createOfflineEvent(0)
|
loopPlugin.createOfflineEvent(0)
|
||||||
rxBus.send(EventRefreshOverview("ActionLoopResume"))
|
rxBus.send(EventRefreshOverview("ActionLoopResume"))
|
||||||
|
uel.log(UserEntry.Action.RESUME, ValueWithUnit(Sources.Automation))
|
||||||
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
|
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
|
||||||
} else {
|
} else {
|
||||||
callback.result(PumpEnactResult(injector).success(true).comment(R.string.notsuspended))?.run()
|
callback.result(PumpEnactResult(injector).success(true).comment(R.string.notsuspended))?.run()
|
||||||
|
|
|
@ -5,8 +5,11 @@ import androidx.annotation.DrawableRes
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.automation.R
|
import info.nightscout.androidaps.automation.R
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult
|
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.events.EventRefreshOverview
|
||||||
import info.nightscout.androidaps.interfaces.LoopInterface
|
import info.nightscout.androidaps.interfaces.LoopInterface
|
||||||
|
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration
|
import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement
|
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 resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var loopPlugin: LoopInterface
|
@Inject lateinit var loopPlugin: LoopInterface
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
|
@Inject lateinit var uel: UserEntryLogger
|
||||||
|
|
||||||
var minutes = InputDuration(30, InputDuration.TimeUnit.MINUTES)
|
var minutes = InputDuration(30, InputDuration.TimeUnit.MINUTES)
|
||||||
|
|
||||||
|
@ -32,6 +36,7 @@ class ActionLoopSuspend(injector: HasAndroidInjector) : Action(injector) {
|
||||||
if (!loopPlugin.isSuspended) {
|
if (!loopPlugin.isSuspended) {
|
||||||
loopPlugin.suspendLoop(minutes.getMinutes())
|
loopPlugin.suspendLoop(minutes.getMinutes())
|
||||||
rxBus.send(EventRefreshOverview("ActionLoopSuspend"))
|
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()
|
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
|
||||||
} else {
|
} else {
|
||||||
callback.result(PumpEnactResult(injector).success(true).comment(R.string.alreadysuspended))?.run()
|
callback.result(PumpEnactResult(injector).success(true).comment(R.string.alreadysuspended))?.run()
|
||||||
|
|
|
@ -5,9 +5,12 @@ import androidx.annotation.DrawableRes
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.automation.R
|
import info.nightscout.androidaps.automation.R
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult
|
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.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
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.InputProfileName
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement
|
import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder
|
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 resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
|
@Inject lateinit var uel: UserEntryLogger
|
||||||
|
|
||||||
var inputProfileName: InputProfileName = InputProfileName(resourceHelper, activePlugin, "")
|
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()
|
callback.result(PumpEnactResult(injector).success(false).comment(R.string.notexists))?.run()
|
||||||
return
|
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())
|
activePlugin.activeTreatments.doProfileSwitch(profileStore, inputProfileName.value, 0, 100, 0, DateUtil.now())
|
||||||
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
|
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,10 @@ import androidx.annotation.DrawableRes
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.automation.R
|
import info.nightscout.androidaps.automation.R
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult
|
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.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.Comparator
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration
|
import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.InputPercent
|
import info.nightscout.androidaps.plugins.general.automation.elements.InputPercent
|
||||||
|
@ -21,6 +24,7 @@ import javax.inject.Inject
|
||||||
class ActionProfileSwitchPercent(injector: HasAndroidInjector) : Action(injector) {
|
class ActionProfileSwitchPercent(injector: HasAndroidInjector) : Action(injector) {
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
|
@Inject lateinit var uel: UserEntryLogger
|
||||||
|
|
||||||
var pct = InputPercent()
|
var pct = InputPercent()
|
||||||
var duration = InputDuration(30, InputDuration.TimeUnit.MINUTES)
|
var duration = InputDuration(30, InputDuration.TimeUnit.MINUTES)
|
||||||
|
@ -37,6 +41,7 @@ class ActionProfileSwitchPercent(injector: HasAndroidInjector) : Action(injector
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun doAction(callback: Callback) {
|
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)
|
activePlugin.activeTreatments.doProfileSwitch(duration.value, pct.value.toInt(), 0)
|
||||||
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
|
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,13 @@ 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.TemporaryTarget
|
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.database.transactions.InsertTemporaryTargetAndCancelCurrentTransaction
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
import info.nightscout.androidaps.logging.LTag
|
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.ComparatorExists
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration
|
import info.nightscout.androidaps.plugins.general.automation.elements.InputDuration
|
||||||
import info.nightscout.androidaps.plugins.general.automation.elements.InputTempTarget
|
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 repository: AppRepository
|
||||||
@Inject lateinit var nsUpload: NSUpload
|
@Inject lateinit var nsUpload: NSUpload
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
|
@Inject lateinit var uel: UserEntryLogger
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -58,6 +62,7 @@ class ActionStartTempTarget(injector: HasAndroidInjector) : Action(injector) {
|
||||||
.subscribe({ result ->
|
.subscribe({ result ->
|
||||||
result.inserted.forEach { nsUpload.uploadTempTarget(it) }
|
result.inserted.forEach { nsUpload.uploadTempTarget(it) }
|
||||||
result.updated.forEach { nsUpload.updateTempTarget(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()
|
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
|
||||||
}, {
|
}, {
|
||||||
aapsLogger.error(LTag.BGSOURCE, "Error while saving temporary target", it)
|
aapsLogger.error(LTag.BGSOURCE, "Error while saving temporary target", it)
|
||||||
|
|
|
@ -4,9 +4,11 @@ import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.automation.R
|
import info.nightscout.androidaps.automation.R
|
||||||
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.UserEntry
|
||||||
import info.nightscout.androidaps.database.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
|
import info.nightscout.androidaps.database.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
|
@ -22,6 +24,7 @@ class ActionStopTempTarget(injector: HasAndroidInjector) : Action(injector) {
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var nsUpload: NSUpload
|
@Inject lateinit var nsUpload: NSUpload
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
|
@Inject lateinit var uel: UserEntryLogger
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -32,6 +35,7 @@ class ActionStopTempTarget(injector: HasAndroidInjector) : Action(injector) {
|
||||||
override fun doAction(callback: Callback) {
|
override fun doAction(callback: Callback) {
|
||||||
disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(DateUtil.now()))
|
disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(DateUtil.now()))
|
||||||
.subscribe({ result ->
|
.subscribe({ result ->
|
||||||
|
uel.log(UserEntry.Action.CANCEL_TT, UserEntry.ValueWithUnit(UserEntry.Sources.Automation))
|
||||||
result.updated.forEach { nsUpload.updateTempTarget(it) }
|
result.updated.forEach { nsUpload.updateTempTarget(it) }
|
||||||
}, {
|
}, {
|
||||||
aapsLogger.error(LTag.BGSOURCE, "Error while saving temporary target", it)
|
aapsLogger.error(LTag.BGSOURCE, "Error while saving temporary target", it)
|
||||||
|
|
|
@ -88,43 +88,79 @@ 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) + "\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 ->
|
return userEntryHeader + userEntries.joinToString("\n") { entry ->
|
||||||
if (entry.values.size > 0) {
|
var timestampRec = "" + entry.timestamp
|
||||||
entry.values.joinToString("\n") { value ->
|
var dateTimestampRev = dateUtil.dateAndTimeAndSecondsString(entry.timestamp)
|
||||||
entry.timestamp.toString() + ";" +
|
var utcOffset = dateUtil.timeString(entry.utcOffset)
|
||||||
dateUtil.dateAndTimeAndSecondsString(entry.timestamp) + ";" +
|
var action = csvString(entry.action)
|
||||||
dateUtil.timeString(entry.utcOffset) + ";" +
|
var therapyEvent = ""
|
||||||
csvString(entry.action) + ";" +
|
var source = ""
|
||||||
csvString(entry.remark) + ";" +
|
var note = csvString(entry.s)
|
||||||
valueWithUnitToCsv(value)
|
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 {
|
private fun saveString(id: Int): String = if (id != 0) resourceHelper.gs(id) else ""
|
||||||
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 csvString(action: Action): String = "\"" + translator.translate(action).replace("\"", "\"\"") + "\""
|
private fun csvString(action: Action): String = "\"" + translator.translate(action).replace("\"", "\"\"") + "\""
|
||||||
private fun csvString(unit: Units): String = "\"" + translator.translate(unit).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 ""
|
private fun csvString(id: Int): String = if (id != 0) "\"" + resourceHelper.gs(id).replace("\"", "\"\"") + "\"" else ""
|
||||||
|
|
|
@ -170,5 +170,16 @@ class Translator @Inject internal constructor(
|
||||||
|
|
||||||
else -> resourceHelper.gs(R.string.unknown)
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
|
@ -276,6 +276,10 @@
|
||||||
<string name="wear">Wear</string>
|
<string name="wear">Wear</string>
|
||||||
<string name="automation">Automation</string>
|
<string name="automation">Automation</string>
|
||||||
<string name="custom">Custom</string>
|
<string name="custom">Custom</string>
|
||||||
|
<string name="pump">Pump</string>
|
||||||
|
<string name="loop">Loop</string>
|
||||||
|
<string name="ns">NS</string>
|
||||||
|
<string name="record">Record</string>
|
||||||
|
|
||||||
<!-- Command-->
|
<!-- Command-->
|
||||||
<string name="connectiontimedout">Connection timed out</string>
|
<string name="connectiontimedout">Connection timed out</string>
|
||||||
|
@ -401,7 +405,6 @@
|
||||||
<!-- User Entry -->
|
<!-- User Entry -->
|
||||||
<string name="uel_bolus">BOLUS</string>
|
<string name="uel_bolus">BOLUS</string>
|
||||||
<string name="uel_bolus_advisor">BOLUS ADVISOR</string>
|
<string name="uel_bolus_advisor">BOLUS ADVISOR</string>
|
||||||
<string name="uel_bolus_record">BOLUS RECORD</string>
|
|
||||||
<string name="uel_extended_bolus">EXTENDED BOLUS</string>
|
<string name="uel_extended_bolus">EXTENDED BOLUS</string>
|
||||||
<string name="uel_superbolus_tbr">SUPERBOLUS TBR</string>
|
<string name="uel_superbolus_tbr">SUPERBOLUS TBR</string>
|
||||||
<string name="uel_carbs">CARBS</string>
|
<string name="uel_carbs">CARBS</string>
|
||||||
|
@ -466,30 +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_basal">SMS BASAL</string>
|
<string name="uel_stop_sms">STOP SMS</string>
|
||||||
<string name="uel_sms_bolus">SMS BOLUS</string>
|
|
||||||
<string name="uel_sms_cal">SMS CAL</string>
|
|
||||||
<string name="uel_sms_carbs">SMS CARBS</string>
|
|
||||||
<string name="uel_sms_extended_bolus">SMS EXTENDED BOLUS</string>
|
|
||||||
<string name="uel_sms_loop_disabled">SMS LOOP DISABLED</string>
|
|
||||||
<string name="uel_sms_loop_enabled">SMS LOOP ENABLED</string>
|
|
||||||
<string name="uel_sms_loop_resume">SMS LOOP RESUME</string>
|
|
||||||
<string name="uel_sms_loop_suspend">SMS LOOP SUSPEND</string>
|
|
||||||
<string name="uel_sms_profile">SMS PROFILE</string>
|
|
||||||
<string name="uel_sms_pump_connect">SMS PUMP CONNECT</string>
|
|
||||||
<string name="uel_sms_pump_disconnect">SMS PUMP DISCONNECT</string>
|
|
||||||
<string name="uel_sms_sms">SMS SMS</string>
|
|
||||||
<string name="uel_sms_tt">SMS TT</string>
|
|
||||||
<string name="uel_tt_deleted_from_ns">TT DELETED FROM NS</string>
|
|
||||||
<string name="uel_careportal_deleted_from_ns">CAREPORTAL DELETED FROM NS</string>
|
|
||||||
<string name="uel_careportal_from_ns">CAREPORTAL FROM NS</string>
|
|
||||||
<string name="uel_tt_from_ns">TT FROM NS</string>
|
|
||||||
<string name="uel_tt_canceleted_from_ns">TT CANCELED FROM NS</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;Date;UTC Offset;Action;Note;Value;Unit"</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>
|
||||||
|
|
|
@ -15,14 +15,14 @@ data class UserEntry(
|
||||||
override var timestamp: Long,
|
override var timestamp: Long,
|
||||||
override var utcOffset: Long = TimeZone.getDefault().getOffset(timestamp).toLong(),
|
override var utcOffset: Long = TimeZone.getDefault().getOffset(timestamp).toLong(),
|
||||||
var action: Action,
|
var action: Action,
|
||||||
var remark: String,
|
var s: String,
|
||||||
// val sources: Sources,
|
// val sources: Sources,
|
||||||
var values: MutableList<ValueWithUnit>
|
var values: MutableList<ValueWithUnit>
|
||||||
) : 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),
|
||||||
|
@ -87,26 +87,8 @@ 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_BASAL") SMS_BASAL (ColorGroup.InsulinTreatment),
|
@SerializedName("STOP_SMS") STOP_SMS (ColorGroup.Aaps),
|
||||||
@SerializedName("SMS_BOLUS") SMS_BOLUS (ColorGroup.InsulinTreatment),
|
@SerializedName("FOOD") FOOD (ColorGroup.Careportal),
|
||||||
@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("EXPORT_CSV") EXPORT_CSV (ColorGroup.Aaps),
|
@SerializedName("EXPORT_CSV") EXPORT_CSV (ColorGroup.Aaps),
|
||||||
@SerializedName("UNKNOWN") UNKNOWN (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){
|
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 {
|
fun value() : Any {
|
||||||
if (sValue != "") return sValue
|
if (sValue != "") return sValue
|
||||||
if (!dValue.equals(0.0)) return dValue
|
if (!dValue.equals(0.0)) return dValue
|
||||||
if (iValue != 0) return iValue
|
if (!iValue.equals(0)) return iValue
|
||||||
return lValue
|
return lValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,7 +125,8 @@ data class UserEntry(
|
||||||
@SerializedName("H") H ("h"), //Int
|
@SerializedName("H") H ("h"), //Int
|
||||||
@SerializedName("Percent") Percent ("%"), //Int
|
@SerializedName("Percent") Percent ("%"), //Int
|
||||||
@SerializedName("TherapyEvent") TherapyEvent ("TherapyEvent"), //String (All enum key translated by Translator function, mainly TherapyEvent)
|
@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 {
|
companion object {
|
||||||
|
@ -143,6 +134,45 @@ data class UserEntry(
|
||||||
fun fromText(unit: String?) = values().firstOrNull { it.text == unit } ?: None
|
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() {
|
enum class ColorGroup() {
|
||||||
InsulinTreatment,
|
InsulinTreatment,
|
||||||
|
@ -154,4 +184,12 @@ data class UserEntry(
|
||||||
Pump,
|
Pump,
|
||||||
Aaps
|
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
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue