Merge branch 'Adrian_ValueWithUnit_Refactor' into meallink_ValueWithUnit
# Conflicts: # app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt # app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.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/TempTargetDialog.kt # app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt # app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt # app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt # app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientPlugin.java # app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientRemoveWorker.kt # app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt # app/src/main/java/info/nightscout/androidaps/plugins/treatments/CarbsGenerator.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/utils/wizard/BolusWizard.kt # automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTarget.kt # automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStopTempTarget.kt # combo/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java # core/src/main/java/info/nightscout/androidaps/data/DetailedBolusInfo.java # core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt # database/src/main/java/info/nightscout/androidaps/database/entities/UserEntry.kt # omnipod-eros/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/data/ActiveBolus.java
This commit is contained in:
commit
22384ef2e8
89 changed files with 1171 additions and 516 deletions
|
@ -2,6 +2,22 @@
|
||||||
<code_scheme name="Project" version="173">
|
<code_scheme name="Project" version="173">
|
||||||
<option name="AUTODETECT_INDENTS" value="false" />
|
<option name="AUTODETECT_INDENTS" value="false" />
|
||||||
<JetCodeStyleSettings>
|
<JetCodeStyleSettings>
|
||||||
|
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
||||||
|
<value>
|
||||||
|
<package name="java.util" alias="false" withSubpackages="false" />
|
||||||
|
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
|
||||||
|
<package name="io.ktor" alias="false" withSubpackages="true" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="PACKAGES_IMPORT_LAYOUT">
|
||||||
|
<value>
|
||||||
|
<package name="" alias="false" withSubpackages="true" />
|
||||||
|
<package name="java" alias="false" withSubpackages="true" />
|
||||||
|
<package name="javax" alias="false" withSubpackages="true" />
|
||||||
|
<package name="kotlin" alias="false" withSubpackages="true" />
|
||||||
|
<package name="" alias="true" withSubpackages="true" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
<option name="ALIGN_IN_COLUMNS_CASE_BRANCH" value="true" />
|
<option name="ALIGN_IN_COLUMNS_CASE_BRANCH" value="true" />
|
||||||
<option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="6" />
|
<option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="6" />
|
||||||
<option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" value="6" />
|
<option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" value="6" />
|
||||||
|
|
|
@ -9,6 +9,7 @@ import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.Constants
|
import info.nightscout.androidaps.Constants
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.Profile
|
import info.nightscout.androidaps.data.Profile
|
||||||
|
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.databinding.DialogCalibrationBinding
|
import info.nightscout.androidaps.databinding.DialogCalibrationBinding
|
||||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
|
@ -79,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, ValueWithUnit(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)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,9 @@ import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo
|
import info.nightscout.androidaps.data.DetailedBolusInfo
|
||||||
import info.nightscout.androidaps.data.Profile
|
import info.nightscout.androidaps.data.Profile
|
||||||
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.TemporaryTarget
|
import info.nightscout.androidaps.database.entities.TemporaryTarget
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.Action
|
import info.nightscout.androidaps.database.entities.UserEntry.*
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.Units
|
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.ValueWithUnit
|
|
||||||
import info.nightscout.androidaps.database.transactions.InsertTemporaryTargetAndCancelCurrentTransaction
|
import info.nightscout.androidaps.database.transactions.InsertTemporaryTargetAndCancelCurrentTransaction
|
||||||
import info.nightscout.androidaps.databinding.DialogCarbsBinding
|
import info.nightscout.androidaps.databinding.DialogCarbsBinding
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
|
@ -224,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, ValueWithUnit(TemporaryTarget.Reason.ACTIVITY.text, Units.TherapyEvent), ValueWithUnit(activityTT, units), ValueWithUnit(activityTTDuration, Units.M))
|
//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()),
|
||||||
|
@ -240,7 +240,8 @@ class CarbsDialog : DialogFragmentWithDate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
eatingSoonSelected -> {
|
eatingSoonSelected -> {
|
||||||
uel.log(Action.TT, ValueWithUnit(TemporaryTarget.Reason.EATING_SOON.text, Units.TherapyEvent), ValueWithUnit(eatingSoonTT, units), ValueWithUnit(eatingSoonTTDuration, Units.M))
|
//uel.log(Action.TT, 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()),
|
||||||
|
@ -256,7 +257,8 @@ class CarbsDialog : DialogFragmentWithDate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
hypoSelected -> {
|
hypoSelected -> {
|
||||||
uel.log(Action.TT, ValueWithUnit(TemporaryTarget.Reason.HYPOGLYCEMIA.text, Units.TherapyEvent), ValueWithUnit(hypoTT, units), ValueWithUnit(hypoTTDuration, Units.M))
|
//uel.log(Action.TT, 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()),
|
||||||
|
@ -279,12 +281,15 @@ class CarbsDialog : DialogFragmentWithDate() {
|
||||||
detailedBolusInfo.notes = notes
|
detailedBolusInfo.notes = notes
|
||||||
detailedBolusInfo.carbsDuration = T.mins(duration.toLong()).msecs()
|
detailedBolusInfo.carbsDuration = T.mins(duration.toLong()).msecs()
|
||||||
detailedBolusInfo.carbsTimestamp = time
|
detailedBolusInfo.carbsTimestamp = time
|
||||||
uel.log(Action.CARBS, detailedBolusInfo.notes,
|
uel.log(if (detailedBolusInfo.carbsDuration == 0) Action.CARBS else Action.EXTENDED_CARBS,
|
||||||
|
detailedBolusInfo.notes,
|
||||||
|
ValueWithUnit(Sources.CarbDialog),
|
||||||
ValueWithUnit(detailedBolusInfo.timestamp, Units.Timestamp),
|
ValueWithUnit(detailedBolusInfo.timestamp, Units.Timestamp),
|
||||||
ValueWithUnit(detailedBolusInfo.carbs, Units.G),
|
ValueWithUnit(detailedBolusInfo.carbs, Units.G),
|
||||||
ValueWithUnit(detailedBolusInfo.carbTime, Units.M, detailedBolusInfo.carbTime != 0),
|
ValueWithUnit(detailedBolusInfo.carbTime, Units.M, detailedBolusInfo.carbTime != 0),
|
||||||
ValueWithUnit(detailedBolusInfo.carbsDuration, Units.H, detailedBolusInfo.carbsDuration != 0L)
|
ValueWithUnit(detailedBolusInfo.carbsDuration, Units.H, detailedBolusInfo.carbsDuration != 0L)
|
||||||
)
|
)
|
||||||
|
//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 })
|
||||||
commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
|
|
@ -14,10 +14,9 @@ import info.nightscout.androidaps.Constants
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.Profile
|
import info.nightscout.androidaps.data.Profile
|
||||||
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.TherapyEvent
|
import info.nightscout.androidaps.database.entities.TherapyEvent
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.Action
|
import info.nightscout.androidaps.database.entities.UserEntry.*
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.Units
|
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.ValueWithUnit
|
|
||||||
import info.nightscout.androidaps.database.transactions.InsertIfNewByTimestampTherapyEventTransaction
|
import info.nightscout.androidaps.database.transactions.InsertIfNewByTimestampTherapyEventTransaction
|
||||||
import info.nightscout.androidaps.databinding.DialogCareBinding
|
import info.nightscout.androidaps.databinding.DialogCareBinding
|
||||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
|
@ -60,6 +59,7 @@ class CareDialog : DialogFragmentWithDate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private var options: EventType = EventType.BGCHECK
|
private var options: EventType = EventType.BGCHECK
|
||||||
|
//private var valuesWithUnit = mutableListOf<XXXValueWithUnit?>()
|
||||||
private var valuesWithUnit = mutableListOf<ValueWithUnit>()
|
private var valuesWithUnit = mutableListOf<ValueWithUnit>()
|
||||||
|
|
||||||
@StringRes
|
@StringRes
|
||||||
|
@ -198,16 +198,19 @@ class CareDialog : DialogFragmentWithDate() {
|
||||||
binding.sensor.isChecked -> TherapyEvent.MeterType.SENSOR
|
binding.sensor.isChecked -> TherapyEvent.MeterType.SENSOR
|
||||||
else -> TherapyEvent.MeterType.MANUAL
|
else -> TherapyEvent.MeterType.MANUAL
|
||||||
}
|
}
|
||||||
actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_glucosetype) + ": " + translator.translate(meterType.text))
|
actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_glucosetype) + ": " + translator.translate(meterType))
|
||||||
actions.add(resourceHelper.gs(R.string.treatments_wizard_bg_label) + ": " + Profile.toCurrentUnitsString(profileFunction, binding.bg.value) + " " + resourceHelper.gs(unitResId))
|
actions.add(resourceHelper.gs(R.string.treatments_wizard_bg_label) + ": " + Profile.toCurrentUnitsString(profileFunction, binding.bg.value) + " " + resourceHelper.gs(unitResId))
|
||||||
therapyEvent.glucoseType = meterType
|
therapyEvent.glucoseType = meterType
|
||||||
therapyEvent.glucose = binding.bg.value
|
therapyEvent.glucose = binding.bg.value
|
||||||
|
//valuesWithUnit.add(XXXValueWithUnit.fromGlucoseUnit(binding.bg.value.toDouble(), profileFunction.getUnits()))
|
||||||
|
//valuesWithUnit.add(XXXValueWithUnit.TherapyEventMeterType(meterType))
|
||||||
valuesWithUnit.add(ValueWithUnit(binding.bg.value.toDouble(), profileFunction.getUnits()))
|
valuesWithUnit.add(ValueWithUnit(binding.bg.value.toDouble(), profileFunction.getUnits()))
|
||||||
valuesWithUnit.add(ValueWithUnit(meterType.text, Units.TherapyEvent))
|
valuesWithUnit.add(ValueWithUnit(meterType.text, Units.TherapyEvent))
|
||||||
}
|
}
|
||||||
if (options == EventType.NOTE || options == EventType.EXERCISE) {
|
if (options == EventType.NOTE || options == EventType.EXERCISE) {
|
||||||
actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_duration_label) + ": " + resourceHelper.gs(R.string.format_mins, binding.duration.value.toInt()))
|
actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_duration_label) + ": " + resourceHelper.gs(R.string.format_mins, binding.duration.value.toInt()))
|
||||||
therapyEvent.duration = T.mins(binding.duration.value.toLong()).msecs()
|
therapyEvent.duration = T.mins(binding.duration.value.toLong()).msecs()
|
||||||
|
//valuesWithUnit.add(XXXValueWithUnit.Minute(binding.duration.value.toInt()).takeIf { !binding.duration.value.equals(0.0) })
|
||||||
valuesWithUnit.add(ValueWithUnit(binding.duration.value.toInt(), Units.M, !binding.duration.value.equals(0.0)))
|
valuesWithUnit.add(ValueWithUnit(binding.duration.value.toInt(), Units.M, !binding.duration.value.equals(0.0)))
|
||||||
}
|
}
|
||||||
val notes = binding.notesLayout.notes.text.toString()
|
val notes = binding.notesLayout.notes.text.toString()
|
||||||
|
@ -220,6 +223,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(InsertIfNewByTimestampTherapyEventTransaction(therapyEvent))
|
disposable += repository.runTransactionForResult(InsertIfNewByTimestampTherapyEventTransaction(therapyEvent))
|
||||||
|
@ -227,6 +241,8 @@ class CareDialog : DialogFragmentWithDate() {
|
||||||
{ result -> result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted therapy event $it") } },
|
{ result -> result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted therapy event $it") } },
|
||||||
{ aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", it) }
|
{ aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", it) }
|
||||||
)
|
)
|
||||||
|
//valuesWithUnit.add(0, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged })
|
||||||
|
//valuesWithUnit.add(1, XXXValueWithUnit.TherapyEventType(therapyEvent.type))
|
||||||
valuesWithUnit.add(0, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged))
|
valuesWithUnit.add(0, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged))
|
||||||
valuesWithUnit.add(1, ValueWithUnit(therapyEvent.type.text, Units.TherapyEvent))
|
valuesWithUnit.add(1, ValueWithUnit(therapyEvent.type.text, Units.TherapyEvent))
|
||||||
uel.log(Action.CAREPORTAL, notes, valuesWithUnit)
|
uel.log(Action.CAREPORTAL, notes, valuesWithUnit)
|
||||||
|
|
|
@ -8,6 +8,7 @@ import android.view.ViewGroup
|
||||||
import com.google.common.base.Joiner
|
import com.google.common.base.Joiner
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||||
|
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.databinding.DialogExtendedbolusBinding
|
import info.nightscout.androidaps.databinding.DialogExtendedbolusBinding
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
@ -88,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, ValueWithUnit(insulinAfterConstraint, Units.U), ValueWithUnit(durationInMinutes, Units.M))
|
//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) {
|
||||||
|
|
|
@ -10,10 +10,9 @@ import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo
|
import info.nightscout.androidaps.data.DetailedBolusInfo
|
||||||
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.TherapyEvent
|
import info.nightscout.androidaps.database.entities.TherapyEvent
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.Action
|
import info.nightscout.androidaps.database.entities.UserEntry.*
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.Units
|
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.ValueWithUnit
|
|
||||||
import info.nightscout.androidaps.database.transactions.InsertIfNewByTimestampTherapyEventTransaction
|
import info.nightscout.androidaps.database.transactions.InsertIfNewByTimestampTherapyEventTransaction
|
||||||
import info.nightscout.androidaps.databinding.DialogFillBinding
|
import info.nightscout.androidaps.databinding.DialogFillBinding
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
@ -123,7 +122,7 @@ class FillDialog : DialogFragmentWithDate() {
|
||||||
val insulinChange = binding.fillCartridgeChange.isChecked
|
val insulinChange = binding.fillCartridgeChange.isChecked
|
||||||
if (insulinChange)
|
if (insulinChange)
|
||||||
actions.add(resourceHelper.gs(R.string.record_insulin_cartridge_change).formatColor(resourceHelper, R.color.actionsConfirm))
|
actions.add(resourceHelper.gs(R.string.record_insulin_cartridge_change).formatColor(resourceHelper, R.color.actionsConfirm))
|
||||||
val notes = binding.notesLayout.notes.text.toString()
|
val notes: String = binding.notesLayout.notes.text.toString()
|
||||||
if (notes.isNotEmpty())
|
if (notes.isNotEmpty())
|
||||||
actions.add(resourceHelper.gs(R.string.notes_label) + ": " + notes)
|
actions.add(resourceHelper.gs(R.string.notes_label) + ": " + notes)
|
||||||
eventTime -= eventTime % 1000
|
eventTime -= eventTime % 1000
|
||||||
|
@ -135,11 +134,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, ValueWithUnit(insulinAfterConstraints, Units.U, 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, ValueWithUnit(TherapyEvent.Type.CANNULA_CHANGE.text, Units.TherapyEvent))
|
//uel.log(Action.CAREPORTAL, notes, XXXValueWithUnit.TherapyEventType(TherapyEvent.Type.CANNULA_CHANGE))
|
||||||
|
uel.log(Action.CAREPORTAL, notes, ValueWithUnit(Sources.FillDialog), ValueWithUnit(TherapyEvent.Type.CANNULA_CHANGE.text, Units.TherapyEvent))
|
||||||
disposable += repository.runTransactionForResult(InsertIfNewByTimestampTherapyEventTransaction(
|
disposable += repository.runTransactionForResult(InsertIfNewByTimestampTherapyEventTransaction(
|
||||||
timestamp = eventTime,
|
timestamp = eventTime,
|
||||||
type = TherapyEvent.Type.CANNULA_CHANGE,
|
type = TherapyEvent.Type.CANNULA_CHANGE,
|
||||||
|
@ -152,7 +153,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, ValueWithUnit(TherapyEvent.Type.INSULIN_CHANGE.text, Units.TherapyEvent))
|
//uel.log(Action.CAREPORTAL, notes, XXXValueWithUnit.TherapyEventType(TherapyEvent.Type.INSULIN_CHANGE))
|
||||||
|
uel.log(Action.CAREPORTAL, notes, ValueWithUnit(Sources.FillDialog), ValueWithUnit(TherapyEvent.Type.INSULIN_CHANGE.text, Units.TherapyEvent))
|
||||||
disposable += repository.runTransactionForResult(InsertIfNewByTimestampTherapyEventTransaction(
|
disposable += repository.runTransactionForResult(InsertIfNewByTimestampTherapyEventTransaction(
|
||||||
timestamp = eventTime + 1000,
|
timestamp = eventTime + 1000,
|
||||||
type = TherapyEvent.Type.INSULIN_CHANGE,
|
type = TherapyEvent.Type.INSULIN_CHANGE,
|
||||||
|
|
|
@ -15,10 +15,9 @@ import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo
|
import info.nightscout.androidaps.data.DetailedBolusInfo
|
||||||
import info.nightscout.androidaps.data.Profile
|
import info.nightscout.androidaps.data.Profile
|
||||||
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.TemporaryTarget
|
import info.nightscout.androidaps.database.entities.TemporaryTarget
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.Action
|
import info.nightscout.androidaps.database.entities.UserEntry.*
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.Units
|
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.ValueWithUnit
|
|
||||||
import info.nightscout.androidaps.database.transactions.InsertTemporaryTargetAndCancelCurrentTransaction
|
import info.nightscout.androidaps.database.transactions.InsertTemporaryTargetAndCancelCurrentTransaction
|
||||||
import info.nightscout.androidaps.databinding.DialogInsulinBinding
|
import info.nightscout.androidaps.databinding.DialogInsulinBinding
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
@ -189,7 +188,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, ValueWithUnit(TemporaryTarget.Reason.EATING_SOON.text, Units.TherapyEvent), ValueWithUnit(eatingSoonTT, units), ValueWithUnit(eatingSoonTTDuration, Units.M))
|
//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()),
|
||||||
|
@ -210,8 +210,10 @@ class InsulinDialog : DialogFragmentWithDate() {
|
||||||
detailedBolusInfo.context = context
|
detailedBolusInfo.context = context
|
||||||
detailedBolusInfo.notes = notes
|
detailedBolusInfo.notes = notes
|
||||||
detailedBolusInfo.timestamp = time
|
detailedBolusInfo.timestamp = time
|
||||||
uel.log(Action.BOLUS_RECORD, notes,
|
//uel.log(Action.BOLUS_RECORD, notes, XXXValueWithUnit.Insulin(insulinAfterConstraints), XXXValueWithUnit.Minute(timeOffset).takeIf { timeOffset!= 0 })
|
||||||
|
uel.log(Action.BOLUS, notes,
|
||||||
ValueWithUnit(detailedBolusInfo.timestamp, Units.Timestamp),
|
ValueWithUnit(detailedBolusInfo.timestamp, Units.Timestamp),
|
||||||
|
, ValueWithUnit(R.string.record, Units.R_String, recordOnlyChecked),
|
||||||
ValueWithUnit(detailedBolusInfo.insulin, Units.U),
|
ValueWithUnit(detailedBolusInfo.insulin, Units.U),
|
||||||
ValueWithUnit(timeOffset, Units.M, timeOffset != 0)
|
ValueWithUnit(timeOffset, Units.M, timeOffset != 0)
|
||||||
)
|
)
|
||||||
|
|
|
@ -12,6 +12,7 @@ import androidx.fragment.app.FragmentManager
|
||||||
import dagger.android.support.DaggerDialogFragment
|
import dagger.android.support.DaggerDialogFragment
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||||
|
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.databinding.DialogLoopBinding
|
import info.nightscout.androidaps.databinding.DialogLoopBinding
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange
|
import info.nightscout.androidaps.events.EventPreferenceChange
|
||||||
|
@ -239,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")
|
||||||
|
@ -277,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")
|
||||||
|
@ -287,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() {
|
||||||
|
@ -303,49 +305,56 @@ class LoopDialog : DaggerDialogFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.overview_suspend_1h -> {
|
R.id.overview_suspend_1h -> {
|
||||||
uel.log(Action.SUSPEND, ValueWithUnit(1, Units.H))
|
//uel.log(Action.SUSPEND, 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, ValueWithUnit(2, Units.H))
|
//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, ValueWithUnit(3, Units.H))
|
//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, ValueWithUnit(10, Units.H))
|
//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, ValueWithUnit(15, Units.M))
|
//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, ValueWithUnit(30, Units.M))
|
//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, ValueWithUnit(1, Units.H))
|
//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"))
|
||||||
|
@ -353,14 +362,16 @@ class LoopDialog : DaggerDialogFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.overview_disconnect_2h -> {
|
R.id.overview_disconnect_2h -> {
|
||||||
uel.log(Action.DISCONNECT, ValueWithUnit(2, Units.H))
|
//uel.log(Action.DISCONNECT, 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, ValueWithUnit(3, Units.H))
|
//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
|
||||||
|
|
|
@ -8,6 +8,7 @@ import android.widget.ArrayAdapter
|
||||||
import com.google.common.base.Joiner
|
import com.google.common.base.Joiner
|
||||||
import info.nightscout.androidaps.Constants
|
import info.nightscout.androidaps.Constants
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
|
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.databinding.DialogProfileswitchBinding
|
import info.nightscout.androidaps.databinding.DialogProfileswitchBinding
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
@ -125,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, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(profile, Units.None), ValueWithUnit(percent, Units.Percent), ValueWithUnit(timeShift, Units.H, timeShift != 0), ValueWithUnit(duration, Units.M, duration != 0))
|
//uel.log(Action.PROFILE_SWITCH, notes, 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)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import android.view.ViewGroup
|
||||||
import com.google.common.base.Joiner
|
import com.google.common.base.Joiner
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||||
|
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.databinding.DialogTempbasalBinding
|
import info.nightscout.androidaps.databinding.DialogTempbasalBinding
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
@ -126,10 +127,12 @@ class TempBasalDialog : DialogFragmentWithDate() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isPercentPump) {
|
if (isPercentPump) {
|
||||||
uel.log(Action.TEMP_BASAL, ValueWithUnit(percent, Units.Percent), ValueWithUnit(durationInMinutes, Units.M))
|
//uel.log(Action.TEMP_BASAL, 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, ValueWithUnit(absolute, Units.U), ValueWithUnit(durationInMinutes, Units.M))
|
//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)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -12,6 +12,7 @@ import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.Profile
|
import info.nightscout.androidaps.data.Profile
|
||||||
import info.nightscout.androidaps.database.AppRepository
|
import info.nightscout.androidaps.database.AppRepository
|
||||||
import info.nightscout.androidaps.database.ValueWrapper
|
import info.nightscout.androidaps.database.ValueWrapper
|
||||||
|
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
|
||||||
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.CancelCurrentTemporaryTargetIfAnyTransaction
|
import info.nightscout.androidaps.database.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
|
||||||
|
@ -178,12 +179,17 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
|
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
|
||||||
val units = profileFunction.getUnits()
|
val units = profileFunction.getUnits()
|
||||||
when (reason) {
|
when(reason) {
|
||||||
resourceHelper.gs(R.string.eatingsoon) -> uel.log(Action.TT, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.EATING_SOON.text, Units.TherapyEvent), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
|
//resourceHelper.gs(R.string.eatingsoon) -> uel.log(Action.TT, 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, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.ACTIVITY.text, Units.TherapyEvent), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
|
//resourceHelper.gs(R.string.activity) -> uel.log(Action.TT, 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, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.HYPOGLYCEMIA.text, Units.TherapyEvent), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
|
//resourceHelper.gs(R.string.hypo) -> uel.log(Action.TT, 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, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(TemporaryTarget.Reason.CUSTOM.text, Units.TherapyEvent), ValueWithUnit(target, units), ValueWithUnit(duration, Units.M))
|
//resourceHelper.gs(R.string.manual) -> uel.log(Action.TT, 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, ValueWithUnit(eventTime, Units.Timestamp, 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))
|
||||||
|
|
|
@ -13,9 +13,8 @@ import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo
|
import info.nightscout.androidaps.data.DetailedBolusInfo
|
||||||
import info.nightscout.androidaps.database.AppRepository
|
import info.nightscout.androidaps.database.AppRepository
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.Action
|
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.Units
|
import info.nightscout.androidaps.database.entities.UserEntry.*
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.ValueWithUnit
|
|
||||||
import info.nightscout.androidaps.databinding.DialogTreatmentBinding
|
import info.nightscout.androidaps.databinding.DialogTreatmentBinding
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
||||||
|
@ -139,6 +138,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 })
|
||||||
|
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 = DetailedBolusInfo.EventType.CARBS_CORRECTION
|
if (insulinAfterConstraints == 0.0) detailedBolusInfo.eventType = DetailedBolusInfo.EventType.CARBS_CORRECTION
|
||||||
if (carbsAfterConstraints == 0) detailedBolusInfo.eventType = DetailedBolusInfo.EventType.CORRECTION_BOLUS
|
if (carbsAfterConstraints == 0) detailedBolusInfo.eventType = DetailedBolusInfo.EventType.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.InsertTherapyEventAnnouncementTransaction
|
import info.nightscout.androidaps.database.transactions.InsertTherapyEventAnnouncementTransaction
|
||||||
import info.nightscout.androidaps.database.transactions.InsertIfNewByTimestampTherapyEventTransaction
|
import info.nightscout.androidaps.database.transactions.InsertIfNewByTimestampTherapyEventTransaction
|
||||||
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -601,6 +608,8 @@ open class LoopPlugin @Inject constructor(
|
||||||
detailedBolusInfo.bolusType = DetailedBolusInfo.BolusType.SMB
|
detailedBolusInfo.bolusType = DetailedBolusInfo.BolusType.SMB
|
||||||
detailedBolusInfo.deliverAtTheLatest = request.deliverAt
|
detailedBolusInfo.deliverAtTheLatest = 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||||
import dagger.android.support.DaggerFragment
|
import dagger.android.support.DaggerFragment
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.*
|
import info.nightscout.androidaps.database.entities.UserEntry.*
|
||||||
|
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
|
||||||
import info.nightscout.androidaps.databinding.ObjectivesFragmentBinding
|
import info.nightscout.androidaps.databinding.ObjectivesFragmentBinding
|
||||||
import info.nightscout.androidaps.databinding.ObjectivesItemBinding
|
import info.nightscout.androidaps.databinding.ObjectivesItemBinding
|
||||||
import info.nightscout.androidaps.dialogs.NtpProgressDialog
|
import info.nightscout.androidaps.dialogs.NtpProgressDialog
|
||||||
|
@ -308,6 +309,7 @@ class ObjectivesFragment : DaggerFragment() {
|
||||||
holder.binding.unstart.setOnClickListener {
|
holder.binding.unstart.setOnClickListener {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.objectives), resourceHelper.gs(R.string.doyouwantresetstart), Runnable {
|
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.objectives), resourceHelper.gs(R.string.doyouwantresetstart), Runnable {
|
||||||
|
//uel.log(Action.OBJECTIVE_UNSTARTED, XXXValueWithUnit.SimpleInt(position + 1))
|
||||||
uel.log(Action.OBJECTIVE_UNSTARTED, ValueWithUnit(position + 1, Units.None))
|
uel.log(Action.OBJECTIVE_UNSTARTED, ValueWithUnit(position + 1, Units.None))
|
||||||
objective.startedOn = 0
|
objective.startedOn = 0
|
||||||
scrollToCurrentObjective()
|
scrollToCurrentObjective()
|
||||||
|
|
|
@ -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
|
||||||
|
@ -74,7 +74,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())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,10 @@ import androidx.work.WorkerParameters
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
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.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.ValueWithUnit
|
import info.nightscout.androidaps.database.entities.UserEntry.*
|
||||||
import info.nightscout.androidaps.database.transactions.SyncNsTemporaryTargetTransaction
|
import info.nightscout.androidaps.database.transactions.SyncNsTemporaryTargetTransaction
|
||||||
import info.nightscout.androidaps.database.transactions.SyncNsTherapyEventTransaction
|
import info.nightscout.androidaps.database.transactions.SyncNsTherapyEventTransaction
|
||||||
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,47 @@ class NSClientAddUpdateWorker(
|
||||||
}
|
}
|
||||||
.blockingGet()
|
.blockingGet()
|
||||||
.also { result ->
|
.also { result ->
|
||||||
result.inserted.forEach {
|
/*result.inserted.forEach { tt ->
|
||||||
uel.log(UserEntry.Action.TT_FROM_NS,
|
uel.log(UserEntry.Action.TT_FROM_NS,
|
||||||
ValueWithUnit(it.reason.text, UserEntry.Units.TherapyEvent),
|
XXXValueWithUnit.TherapyEventTTReason(tt.reason),
|
||||||
ValueWithUnit(it.lowTarget, UserEntry.Units.Mg_Dl, true),
|
XXXValueWithUnit.Mgdl(tt.lowTarget),
|
||||||
ValueWithUnit(it.highTarget, UserEntry.Units.Mg_Dl, it.lowTarget != it.highTarget),
|
XXXValueWithUnit.Mgdl(tt.highTarget).takeIf { tt.lowTarget != tt.highTarget },
|
||||||
ValueWithUnit(it.duration.toInt() / 60000, UserEntry.Units.M, true)
|
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 {
|
/*result.invalidated.forEach { tt ->
|
||||||
uel.log(UserEntry.Action.TT_DELETED_FROM_NS,
|
uel.log(UserEntry.Action.TT_DELETED_FROM_NS,
|
||||||
ValueWithUnit(it.reason.text, UserEntry.Units.TherapyEvent),
|
XXXValueWithUnit.TherapyEventTTReason(tt.reason),
|
||||||
ValueWithUnit(it.lowTarget, UserEntry.Units.Mg_Dl, true),
|
XXXValueWithUnit.Mgdl(tt.lowTarget),
|
||||||
ValueWithUnit(it.highTarget, UserEntry.Units.Mg_Dl, it.lowTarget != it.highTarget),
|
XXXValueWithUnit.Mgdl(tt.highTarget).takeIf { tt.lowTarget != tt.highTarget },
|
||||||
ValueWithUnit(it.duration.toInt() / 60000, UserEntry.Units.M, true)
|
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 {
|
/*result.ended.forEach { tt ->
|
||||||
uel.log(UserEntry.Action.TT_CANCELED_FROM_NS,
|
uel.log(UserEntry.Action.TT_CANCELED_FROM_NS,
|
||||||
ValueWithUnit(it.reason.text, UserEntry.Units.TherapyEvent),
|
XXXValueWithUnit.TherapyEventTTReason(tt.reason),
|
||||||
ValueWithUnit(it.lowTarget, UserEntry.Units.Mg_Dl, true),
|
XXXValueWithUnit.Mgdl(tt.lowTarget),
|
||||||
ValueWithUnit(it.highTarget, UserEntry.Units.Mg_Dl, it.lowTarget != it.highTarget),
|
XXXValueWithUnit.Mgdl(tt.highTarget).takeIf { tt.lowTarget != tt.highTarget },
|
||||||
ValueWithUnit(it.duration.toInt() / 60000, UserEntry.Units.M, true)
|
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 +151,32 @@ 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 ?: "",
|
||||||
ValueWithUnit(it.timestamp, UserEntry.Units.Timestamp, true),
|
XXXValueWithUnit.Timestamp(it.timestamp),
|
||||||
ValueWithUnit(it.type.text, UserEntry.Units.TherapyEvent)
|
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 ?: "",
|
||||||
ValueWithUnit(it.timestamp, UserEntry.Units.Timestamp, true),
|
XXXValueWithUnit.Timestamp(it.timestamp),
|
||||||
ValueWithUnit(it.type.text, UserEntry.Units.TherapyEvent)
|
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)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import dagger.android.HasAndroidInjector;
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.database.entities.UserEntry.*;
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
import info.nightscout.androidaps.events.EventChargingState;
|
import info.nightscout.androidaps.events.EventChargingState;
|
||||||
import info.nightscout.androidaps.events.EventNetworkChange;
|
import info.nightscout.androidaps.events.EventNetworkChange;
|
||||||
|
|
|
@ -6,8 +6,9 @@ import androidx.work.WorkerParameters
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
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.XXXValueWithUnit
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry
|
import info.nightscout.androidaps.database.entities.UserEntry
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.ValueWithUnit
|
import info.nightscout.androidaps.database.entities.UserEntry.*
|
||||||
import info.nightscout.androidaps.database.transactions.SyncNsTemporaryTargetTransaction
|
import info.nightscout.androidaps.database.transactions.SyncNsTemporaryTargetTransaction
|
||||||
import info.nightscout.androidaps.database.transactions.SyncNsTherapyEventTransaction
|
import info.nightscout.androidaps.database.transactions.SyncNsTherapyEventTransaction
|
||||||
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,13 +68,23 @@ class NSClientRemoveWorker(
|
||||||
}
|
}
|
||||||
.blockingGet()
|
.blockingGet()
|
||||||
.also { result ->
|
.also { result ->
|
||||||
result.invalidated.forEach {
|
/*result.invalidated.forEach { tt ->
|
||||||
uel.log(
|
uel.log(
|
||||||
UserEntry.Action.TT_DELETED_FROM_NS,
|
UserEntry.Action.TT_DELETED_FROM_NS,
|
||||||
ValueWithUnit(it.reason.text, UserEntry.Units.TherapyEvent),
|
XXXValueWithUnit.TherapyEventTTReason(tt.reason),
|
||||||
ValueWithUnit(it.lowTarget, UserEntry.Units.Mg_Dl, true),
|
XXXValueWithUnit.Mgdl(tt.lowTarget),
|
||||||
ValueWithUnit(it.highTarget, UserEntry.Units.Mg_Dl, it.lowTarget != it.highTarget),
|
XXXValueWithUnit.Mgdl(tt.highTarget).takeIf { tt.lowTarget != tt.highTarget },
|
||||||
ValueWithUnit(it.duration.toInt() / 60000, UserEntry.Units.M, it.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 +99,17 @@ 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 ?: ""),
|
||||||
ValueWithUnit(it.timestamp, UserEntry.Units.Timestamp, true),
|
XXXValueWithUnit.Timestamp(it.timestamp),
|
||||||
ValueWithUnit(it.type.text, UserEntry.Units.TherapyEvent))
|
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))
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo
|
import info.nightscout.androidaps.data.DetailedBolusInfo
|
||||||
import info.nightscout.androidaps.data.Profile
|
import info.nightscout.androidaps.data.Profile
|
||||||
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.TemporaryTarget
|
import info.nightscout.androidaps.database.entities.TemporaryTarget
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.Action
|
import info.nightscout.androidaps.database.entities.UserEntry.Action
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.Units
|
import info.nightscout.androidaps.database.entities.UserEntry.Units
|
||||||
|
@ -347,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() {
|
||||||
|
@ -371,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"))
|
||||||
|
@ -398,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() {
|
||||||
|
@ -431,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) {
|
||||||
|
@ -515,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) {
|
||||||
|
@ -544,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"))
|
||||||
|
@ -601,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, ValueWithUnit(R.string.profileswitchcreated, Units.R_String))
|
//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))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -623,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), ValueWithUnit(R.string.smscommunicator_tempbasalcanceled, Units.R_String))
|
//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), ValueWithUnit(R.string.smscommunicator_tempbasalcancelfailed, Units.R_String))
|
//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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -657,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), ValueWithUnit(R.string.smscommunicator_tempbasalset_percent, 2), ValueWithUnit(result.percent, Units.Percent), ValueWithUnit(result.duration, Units.M))
|
//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), ValueWithUnit(R.string.smscommunicator_tempbasalset, 2), ValueWithUnit(result.absolute, Units.U_H), ValueWithUnit(result.duration, Units.M))
|
//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), ValueWithUnit(R.string.smscommunicator_tempbasalfailed, Units.R_String))
|
//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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -695,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), ValueWithUnit(R.string.smscommunicator_tempbasalset_percent, 2), ValueWithUnit(result.percent, Units.Percent), ValueWithUnit(result.duration, Units.M))
|
//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), ValueWithUnit(R.string.smscommunicator_tempbasalset, 2), ValueWithUnit(result.absolute, Units.U_H), ValueWithUnit(result.duration, Units.M))
|
//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), ValueWithUnit(R.string.smscommunicator_tempbasalfailed, Units.R_String))
|
//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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -729,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), ValueWithUnit(R.string.smscommunicator_extendedcanceled, Units.R_String))
|
//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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -756,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), ValueWithUnit(R.string.smscommunicator_extendedset, 2), ValueWithUnit(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))
|
||||||
|
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))
|
?: 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), ValueWithUnit(R.string.smscommunicator_extendedset, 2), ValueWithUnit(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))))
|
||||||
|
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))
|
?: 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), ValueWithUnit(R.string.smscommunicator_extendedfailed, Units.R_String))
|
//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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -837,12 +853,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), ValueWithUnit(R.string.smscommunicator_bolusfailed, Units.R_String))
|
//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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -881,13 +898,16 @@ 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), ValueWithUnit(R.string.smscommunicator_carbsset, 1), ValueWithUnit(anInteger
|
//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))
|
?: 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), ValueWithUnit(R.string.smscommunicator_carbsfailed, 1), ValueWithUnit(anInteger
|
//uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_carbsfailed, listOf(XXXValueWithUnit.Gram(anInteger
|
||||||
|
// ?: 0))))
|
||||||
|
uel.log(Action.CARBS, activePlugin.activePump.shortStatus(true), ValueWithUnit(Sources.SMS), ValueWithUnit(R.string.smscommunicator_carbsfailed, 1), ValueWithUnit(anInteger
|
||||||
?: 0, Units.G))
|
?: 0, Units.G))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -897,7 +917,9 @@ 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), ValueWithUnit(R.string.smscommunicator_carbsset, 1), ValueWithUnit(anInteger
|
//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))
|
?: 0, Units.G))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -968,7 +990,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, ValueWithUnit(tt, units), ValueWithUnit(ttDuration, Units.M))
|
//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) {
|
||||||
|
@ -985,7 +1008,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, ValueWithUnit(R.string.smscommunicator_tt_canceled, Units.R_String))
|
//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
|
||||||
|
@ -1004,7 +1028,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, ValueWithUnit(R.string.smscommunicator_stoppedsms, Units.R_String))
|
//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)))
|
||||||
|
@ -1023,9 +1048,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, ValueWithUnit(R.string.smscommunicator_calibrationsent, Units.R_String))
|
//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, ValueWithUnit(R.string.smscommunicator_calibrationfailed, Units.R_String))
|
//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)))
|
||||||
|
|
|
@ -16,6 +16,7 @@ import info.nightscout.androidaps.data.Profile
|
||||||
import info.nightscout.androidaps.database.AppRepository
|
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.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
|
||||||
|
@ -23,6 +24,7 @@ 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.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
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
|
||||||
|
@ -57,7 +59,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,
|
||||||
|
@ -79,6 +81,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
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
@ -89,7 +92,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)
|
||||||
|
@ -101,6 +104,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
|
||||||
|
@ -562,11 +569,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()),
|
||||||
|
@ -579,19 +587,23 @@ class ActionStringHandler @Inject constructor(
|
||||||
}, {
|
}, {
|
||||||
aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it)
|
aapsLogger.error(LTag.DATABASE, "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 { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") }
|
result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") }
|
||||||
}, {
|
}, {
|
||||||
aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it)
|
aapsLogger.error(LTag.DATABASE, "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) {
|
||||||
val detailedBolusInfo = DetailedBolusInfo()
|
val detailedBolusInfo = DetailedBolusInfo()
|
||||||
detailedBolusInfo.insulin = amount
|
detailedBolusInfo.insulin = amount
|
||||||
detailedBolusInfo.bolusType = DetailedBolusInfo.BolusType.PRIMING
|
detailedBolusInfo.bolusType = DetailedBolusInfo.BolusType.PRIMING
|
||||||
|
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) {
|
||||||
|
@ -604,6 +616,7 @@ class ActionStringHandler @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun doECarbs(carbs: Int, time: Long, duration: Int) {
|
private fun doECarbs(carbs: Int, time: Long, duration: Int) {
|
||||||
|
uel.log(if (duration==0) Action.CARBS else Action.EXTENDED_CARBS, ValueWithUnit(Sources.Wear), ValueWithUnit(time, Units.Timestamp), ValueWithUnit(carbs, Units.G), ValueWithUnit(duration, Units.H, duration !=0))
|
||||||
doBolus(0.0, carbs, time, duration)
|
doBolus(0.0, carbs, time, duration)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -616,6 +629,12 @@ class ActionStringHandler @Inject constructor(
|
||||||
detailedBolusInfo.carbsDuration = carbsDuration.toLong()
|
detailedBolusInfo.carbsDuration = carbsDuration.toLong()
|
||||||
val storesCarbs = activePlugin.activePump.pumpDescription.storesCarbInfo
|
val storesCarbs = activePlugin.activePump.pumpDescription.storesCarbInfo
|
||||||
if (detailedBolusInfo.insulin > 0 || (storesCarbs && carbsDuration == 0)) {
|
if (detailedBolusInfo.insulin > 0 || (storesCarbs && carbsDuration == 0)) {
|
||||||
|
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) {
|
||||||
|
|
|
@ -34,7 +34,8 @@ class WearPlugin @Inject constructor(
|
||||||
private val ctx: Context,
|
private val ctx: Context,
|
||||||
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)
|
||||||
|
@ -126,11 +127,13 @@ class WearPlugin @Inject constructor(
|
||||||
ctx.startService(intent)
|
ctx.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
|
||||||
|
|
|
@ -8,6 +8,7 @@ import android.widget.AdapterView
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
import dagger.android.support.DaggerFragment
|
import dagger.android.support.DaggerFragment
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
|
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.databinding.NsprofileFragmentBinding
|
import info.nightscout.androidaps.databinding.NsprofileFragmentBinding
|
||||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
|
@ -62,6 +63,7 @@ class NSProfileFragment : DaggerFragment() {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.nsprofile),
|
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.nsprofile),
|
||||||
resourceHelper.gs(R.string.activate_profile) + ": " + name + " ?", Runnable {
|
resourceHelper.gs(R.string.activate_profile) + ": " + name + " ?", Runnable {
|
||||||
|
//uel.log(Action.PROFILE_SWITCH, XXXValueWithUnit.SimpleString(name), XXXValueWithUnit.Percent(100))
|
||||||
uel.log(Action.PROFILE_SWITCH, ValueWithUnit(name, Units.None), ValueWithUnit(100.toInt(), Units.Percent))
|
uel.log(Action.PROFILE_SWITCH, ValueWithUnit(name, Units.None), ValueWithUnit(100.toInt(), Units.Percent))
|
||||||
treatmentsPlugin.doProfileSwitch(store, name, 0, 100, 0, DateUtil.now())
|
treatmentsPlugin.doProfileSwitch(store, name, 0, 100, 0, DateUtil.now())
|
||||||
})
|
})
|
||||||
|
|
|
@ -10,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||||
import dagger.android.support.DaggerFragment
|
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.XXXValueWithUnit
|
||||||
import info.nightscout.androidaps.database.entities.GlucoseValue
|
import info.nightscout.androidaps.database.entities.GlucoseValue
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.*
|
import info.nightscout.androidaps.database.entities.UserEntry.*
|
||||||
import info.nightscout.androidaps.database.transactions.InvalidateGlucoseValueTransaction
|
import info.nightscout.androidaps.database.transactions.InvalidateGlucoseValueTransaction
|
||||||
|
@ -129,6 +130,7 @@ class BGSourceFragment : DaggerFragment() {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
val text = dateUtil.dateAndTimeString(glucoseValue.timestamp) + "\n" + glucoseValue.valueToUnitsString(profileFunction.getUnits())
|
val text = dateUtil.dateAndTimeString(glucoseValue.timestamp) + "\n" + glucoseValue.valueToUnitsString(profileFunction.getUnits())
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable {
|
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable {
|
||||||
|
//uel.log(Action.BG_REMOVED, XXXValueWithUnit.Timestamp(glucoseValue.timestamp))
|
||||||
uel.log(Action.BG_REMOVED, ValueWithUnit(glucoseValue.timestamp, Units.Timestamp))
|
uel.log(Action.BG_REMOVED, ValueWithUnit(glucoseValue.timestamp, Units.Timestamp))
|
||||||
disposable += repository.runTransaction(InvalidateGlucoseValueTransaction(glucoseValue.id)).subscribe()
|
disposable += repository.runTransaction(InvalidateGlucoseValueTransaction(glucoseValue.id)).subscribe()
|
||||||
})
|
})
|
||||||
|
|
|
@ -10,10 +10,9 @@ import androidx.recyclerview.widget.RecyclerView
|
||||||
import dagger.android.support.DaggerFragment
|
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.XXXValueWithUnit
|
||||||
import info.nightscout.androidaps.database.entities.TherapyEvent
|
import info.nightscout.androidaps.database.entities.TherapyEvent
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.Action
|
import info.nightscout.androidaps.database.entities.UserEntry.*
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.Units
|
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.ValueWithUnit
|
|
||||||
import info.nightscout.androidaps.database.transactions.InvalidateAAPSStartedTherapyEventTransaction
|
import info.nightscout.androidaps.database.transactions.InvalidateAAPSStartedTherapyEventTransaction
|
||||||
import info.nightscout.androidaps.database.transactions.InvalidateTherapyEventTransaction
|
import info.nightscout.androidaps.database.transactions.InvalidateTherapyEventTransaction
|
||||||
import info.nightscout.androidaps.databinding.TreatmentsCareportalFragmentBinding
|
import info.nightscout.androidaps.databinding.TreatmentsCareportalFragmentBinding
|
||||||
|
@ -77,7 +76,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)
|
||||||
|
@ -92,7 +91,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))
|
||||||
repository.runTransactionForResult(InvalidateAAPSStartedTherapyEventTransaction(resourceHelper.gs(R.string.androidaps_start)))
|
repository.runTransactionForResult(InvalidateAAPSStartedTherapyEventTransaction(resourceHelper.gs(R.string.androidaps_start)))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
{ result -> result.invalidated.forEach { aapsLogger.debug(LTag.DATABASE, "Invalidated therapy event $it") } },
|
{ result -> result.invalidated.forEach { aapsLogger.debug(LTag.DATABASE, "Invalidated therapy event $it") } },
|
||||||
|
@ -167,7 +166,7 @@ class TreatmentsCareportalFragment : DaggerFragment() {
|
||||||
holder.binding.date.text = dateUtil.dateAndTimeString(therapyEvent.timestamp)
|
holder.binding.date.text = dateUtil.dateAndTimeString(therapyEvent.timestamp)
|
||||||
holder.binding.duration.text = if (therapyEvent.duration == 0L) "" else DateUtil.niceTimeScalar(therapyEvent.duration, resourceHelper)
|
holder.binding.duration.text = if (therapyEvent.duration == 0L) "" else DateUtil.niceTimeScalar(therapyEvent.duration, resourceHelper)
|
||||||
holder.binding.note.text = therapyEvent.note
|
holder.binding.note.text = therapyEvent.note
|
||||||
holder.binding.type.text = translator.translate(therapyEvent.type.text)
|
holder.binding.type.text = translator.translate(therapyEvent.type)
|
||||||
holder.binding.remove.tag = therapyEvent
|
holder.binding.remove.tag = therapyEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +187,8 @@ class TreatmentsCareportalFragment : DaggerFragment() {
|
||||||
?: "") + "\n" +
|
?: "") + "\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, ValueWithUnit(therapyEvent.timestamp, Units.Timestamp), ValueWithUnit(therapyEvent.type.text, Units.TherapyEvent))
|
//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(
|
||||||
{ result -> result.invalidated.forEach { aapsLogger.debug(LTag.DATABASE, "Invalidated therapy event $it") } },
|
{ result -> result.invalidated.forEach { aapsLogger.debug(LTag.DATABASE, "Invalidated therapy event $it") } },
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -9,6 +9,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import dagger.android.support.DaggerFragment
|
import dagger.android.support.DaggerFragment
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
|
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.databinding.TreatmentsProfileswitchFragmentBinding
|
import info.nightscout.androidaps.databinding.TreatmentsProfileswitchFragmentBinding
|
||||||
import info.nightscout.androidaps.databinding.TreatmentsProfileswitchItemBinding
|
import info.nightscout.androidaps.databinding.TreatmentsProfileswitchItemBinding
|
||||||
|
@ -71,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())
|
||||||
|
@ -148,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, ValueWithUnit(profileSwitch.date, Units.Timestamp))
|
//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)
|
||||||
|
@ -161,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, ValueWithUnit(profileSwitch.date, Units.Timestamp), ValueWithUnit(profileSwitch.profileName, Units.None))
|
//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(".", "_")))
|
||||||
|
|
|
@ -13,6 +13,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.ValueWrapper
|
import info.nightscout.androidaps.database.ValueWrapper
|
||||||
|
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
|
||||||
import info.nightscout.androidaps.database.entities.TemporaryTarget
|
import info.nightscout.androidaps.database.entities.TemporaryTarget
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.Action
|
import info.nightscout.androidaps.database.entities.UserEntry.Action
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.Units
|
import info.nightscout.androidaps.database.entities.UserEntry.Units
|
||||||
|
@ -86,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)
|
||||||
|
@ -170,7 +171,7 @@ class TreatmentsTempTargetFragment : DaggerFragment() {
|
||||||
holder.binding.duration.text = resourceHelper.gs(R.string.format_mins, T.msecs(tempTarget.duration).mins())
|
holder.binding.duration.text = resourceHelper.gs(R.string.format_mins, T.msecs(tempTarget.duration).mins())
|
||||||
holder.binding.low.text = tempTarget.lowValueToUnitsToString(units)
|
holder.binding.low.text = tempTarget.lowValueToUnitsToString(units)
|
||||||
holder.binding.high.text = tempTarget.highValueToUnitsToString(units)
|
holder.binding.high.text = tempTarget.highValueToUnitsToString(units)
|
||||||
holder.binding.reason.text = translator.translate(tempTarget.reason.text)
|
holder.binding.reason.text = translator.translate(tempTarget.reason)
|
||||||
holder.binding.date.setTextColor(
|
holder.binding.date.setTextColor(
|
||||||
when {
|
when {
|
||||||
tempTarget.id == currentlyActiveTarget?.id -> resourceHelper.gc(R.color.colorActive)
|
tempTarget.id == currentlyActiveTarget?.id -> resourceHelper.gc(R.color.colorActive)
|
||||||
|
@ -196,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, 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))
|
//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(
|
||||||
{ aapsLogger.debug(LTag.DATABASE, "Removed temp target $tempTarget") },
|
{ aapsLogger.debug(LTag.DATABASE, "Removed temp target $tempTarget") },
|
||||||
|
|
|
@ -12,6 +12,7 @@ import dagger.android.support.DaggerFragment
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.Intervals
|
import info.nightscout.androidaps.data.Intervals
|
||||||
import info.nightscout.androidaps.data.IobTotal
|
import info.nightscout.androidaps.data.IobTotal
|
||||||
|
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.databinding.TreatmentsTempbasalsFragmentBinding
|
import info.nightscout.androidaps.databinding.TreatmentsTempbasalsFragmentBinding
|
||||||
import info.nightscout.androidaps.databinding.TreatmentsTempbasalsItemBinding
|
import info.nightscout.androidaps.databinding.TreatmentsTempbasalsItemBinding
|
||||||
|
@ -164,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, ValueWithUnit(tempBasal.date, Units.Timestamp))
|
//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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,15 +19,17 @@ 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
|
||||||
import info.nightscout.androidaps.utils.Translator
|
import info.nightscout.androidaps.utils.Translator
|
||||||
|
import info.nightscout.androidaps.utils.UserEntryPresentationHelper
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.extensions.*
|
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.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() {
|
||||||
|
@ -42,6 +44,7 @@ class TreatmentsUserEntryFragment : DaggerFragment() {
|
||||||
@Inject lateinit var translator: Translator
|
@Inject lateinit var translator: Translator
|
||||||
@Inject lateinit var importExportPrefs: ImportExportPrefsInterface
|
@Inject lateinit var importExportPrefs: ImportExportPrefsInterface
|
||||||
@Inject lateinit var uel: UserEntryLogger
|
@Inject lateinit var uel: UserEntryLogger
|
||||||
|
@Inject lateinit var userEntryPresentationHelper: UserEntryPresentationHelper
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -61,20 +64,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() {
|
||||||
|
if (binding.showLoop.isChecked)
|
||||||
disposable.add( repository
|
disposable.add( repository
|
||||||
.getAllUserEntries()
|
.getAllUserEntries()
|
||||||
.observeOn(aapsSchedulers.main)
|
.observeOn(aapsSchedulers.main)
|
||||||
.subscribe { list -> binding.recyclerview.swapAdapter(UserEntryAdapter(list), true) }
|
.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
|
||||||
|
@ -86,6 +98,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
|
||||||
|
@ -111,8 +128,7 @@ 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.name)
|
holder.binding.action.text = userEntryPresentationHelper.actionToColoredString(current.action)
|
||||||
holder.binding.action.setTextColor(resourceHelper.gc(current.action.colorGroup.colorId()))
|
|
||||||
if (current.s != "") {
|
if (current.s != "") {
|
||||||
holder.binding.s.text = current.s
|
holder.binding.s.text = current.s
|
||||||
holder.binding.s.visibility = View.VISIBLE
|
holder.binding.s.visibility = View.VISIBLE
|
||||||
|
@ -120,6 +136,7 @@ class TreatmentsUserEntryFragment : DaggerFragment() {
|
||||||
holder.binding.s.visibility = View.GONE
|
holder.binding.s.visibility = View.GONE
|
||||||
var valuesWithUnitString = ""
|
var valuesWithUnitString = ""
|
||||||
var rStringParam = 0
|
var rStringParam = 0
|
||||||
|
var source = Sources.Unknown
|
||||||
val separator = " "
|
val separator = " "
|
||||||
for(v in current.values) {
|
for(v in current.values) {
|
||||||
if (rStringParam >0)
|
if (rStringParam >0)
|
||||||
|
@ -138,17 +155,21 @@ class TreatmentsUserEntryFragment : DaggerFragment() {
|
||||||
4 -> rStringParam = 0
|
4 -> rStringParam = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Units.Mg_Dl -> valuesWithUnitString += if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue) + translator.translate(Units.Mg_Dl.name) + separator else DecimalFormatter.to1Decimal(v.dValue/Constants.MMOLL_TO_MGDL) + translator.translate(Units.Mmol_L.name) + separator
|
Units.Mg_Dl -> valuesWithUnitString += if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue) + translator.translate(Units.Mg_Dl) + separator else DecimalFormatter.to1Decimal(v.dValue/Constants.MMOLL_TO_MGDL) + translator.translate(Units.Mmol_L) + separator
|
||||||
Units.Mmol_L -> valuesWithUnitString += if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue*Constants.MMOLL_TO_MGDL) + translator.translate(Units.Mg_Dl.name) + separator else DecimalFormatter.to1Decimal(v.dValue) + translator.translate(Units.Mmol_L.name) + separator
|
Units.Mmol_L -> valuesWithUnitString += if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue*Constants.MMOLL_TO_MGDL) + translator.translate(Units.Mg_Dl) + separator else DecimalFormatter.to1Decimal(v.dValue) + translator.translate(Units.Mmol_L) + separator
|
||||||
Units.U_H, Units.U
|
Units.U_H, Units.U
|
||||||
-> valuesWithUnitString += DecimalFormatter.to2Decimal(v.dValue) + translator.translate(v.unit.name) + 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.name) + separator
|
-> valuesWithUnitString += v.iValue.toString() + translator.translate(v.unit) + separator
|
||||||
|
Units.Source -> source = Sources.fromString(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 ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
holder.binding.iconSource.setImageResource(userEntryPresentationHelper.iconId(source))
|
||||||
|
holder.binding.iconSource.visibility = View.VISIBLE
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class UserEntryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
inner class UserEntryViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||||
|
@ -157,6 +178,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
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,6 +12,7 @@ import info.nightscout.androidaps.data.DetailedBolusInfo
|
||||||
import info.nightscout.androidaps.data.Profile
|
import info.nightscout.androidaps.data.Profile
|
||||||
import info.nightscout.androidaps.database.AppRepository
|
import info.nightscout.androidaps.database.AppRepository
|
||||||
import info.nightscout.androidaps.database.entities.BolusCalculatorResult
|
import info.nightscout.androidaps.database.entities.BolusCalculatorResult
|
||||||
|
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
|
||||||
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.InsertOrUpdateBolusCalculatorResultTransaction
|
import info.nightscout.androidaps.database.transactions.InsertOrUpdateBolusCalculatorResultTransaction
|
||||||
|
@ -346,7 +347,8 @@ class BolusWizard @Inject constructor(
|
||||||
carbTime = 0
|
carbTime = 0
|
||||||
bolusCalculatorResult = createBolusCalculatorResult()
|
bolusCalculatorResult = createBolusCalculatorResult()
|
||||||
notes = this@BolusWizard.notes
|
notes = this@BolusWizard.notes
|
||||||
uel.log(Action.BOLUS_ADVISOR, notes, ValueWithUnit(eventType.toDBbEventType(), Units.TherapyEvent), ValueWithUnit(insulinAfterConstraints, Units.U))
|
//uel.log(Action.BOLUS_ADVISOR, notes, XXXValueWithUnit.TherapyEventType(eventType), XXXValueWithUnit.Insulin(insulinAfterConstraints))
|
||||||
|
uel.log(Action.BOLUS_ADVISOR, notes, ValueWithUnit(Sources.WizardDialog), ValueWithUnit(eventType.toDBbEventType(), 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() {
|
||||||
|
@ -369,7 +371,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"))
|
||||||
|
@ -409,13 +411,20 @@ class BolusWizard @Inject constructor(
|
||||||
carbTime = this@BolusWizard.carbTime
|
carbTime = this@BolusWizard.carbTime
|
||||||
bolusCalculatorResult = createBolusCalculatorResult()
|
bolusCalculatorResult = createBolusCalculatorResult()
|
||||||
notes = this@BolusWizard.notes
|
notes = this@BolusWizard.notes
|
||||||
uel.log(Action.BOLUS, notes,
|
if (insulin > 0 || carbs > 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(eventType.toDBbEventType(), Units.TherapyEvent),
|
ValueWithUnit(eventType.toDBbEventType(), Units.TherapyEvent),
|
||||||
ValueWithUnit(insulinAfterConstraints, Units.U),
|
ValueWithUnit(insulinAfterConstraints, Units.U),
|
||||||
ValueWithUnit(this@BolusWizard.carbs, Units.G, this@BolusWizard.carbs != 0),
|
ValueWithUnit(this@BolusWizard.carbs, Units.G, this@BolusWizard.carbs != 0),
|
||||||
ValueWithUnit(carbTime, Units.M, carbTime != 0)
|
ValueWithUnit(carbTime, Units.M, carbTime != 0)
|
||||||
)
|
)
|
||||||
if (insulin > 0 || carbs > 0) {
|
|
||||||
commandQueue.bolus(this, object : Callback() {
|
commandQueue.bolus(this, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
|
|
@ -1,19 +1,45 @@
|
||||||
<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">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<info.nightscout.androidaps.utils.ui.SingleClickButton
|
<info.nightscout.androidaps.utils.ui.SingleClickButton
|
||||||
android:id="@+id/ue_export_to_xml"
|
android:id="@+id/ue_export_to_xml"
|
||||||
style="?android:attr/buttonStyle"
|
style="?android:attr/buttonStyle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:layout_weight="1"
|
||||||
android:drawableStart="@drawable/ic_header_export"
|
android:drawableStart="@drawable/ic_header_export"
|
||||||
android:text="@string/ue_export_to_csv" />
|
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"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -141,7 +141,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>
|
||||||
|
@ -518,7 +517,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
|
||||||
|
@ -37,6 +40,7 @@ class ActionStartTempTarget(injector: HasAndroidInjector) : Action(injector) {
|
||||||
@Inject lateinit var activePlugin: ActivePluginProvider
|
@Inject lateinit var activePlugin: ActivePluginProvider
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
|
@Inject lateinit var uel: UserEntryLogger
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -56,6 +60,7 @@ class ActionStartTempTarget(injector: HasAndroidInjector) : Action(injector) {
|
||||||
.subscribe({ result ->
|
.subscribe({ result ->
|
||||||
result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted temp target $it") }
|
result.inserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted temp target $it") }
|
||||||
result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") }
|
result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $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.DATABASE, "Error while saving temporary target", it)
|
aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it)
|
||||||
|
|
|
@ -4,8 +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.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.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
@ -18,6 +21,7 @@ class ActionStopTempTarget(injector: HasAndroidInjector) : Action(injector) {
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var repository: AppRepository
|
@Inject lateinit var repository: AppRepository
|
||||||
@Inject lateinit var dateUtil: DateUtil
|
@Inject lateinit var dateUtil: DateUtil
|
||||||
|
@Inject lateinit var uel: UserEntryLogger
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -28,6 +32,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 { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") }
|
result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") }
|
||||||
}, {
|
}, {
|
||||||
aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it)
|
aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it)
|
||||||
|
|
|
@ -59,7 +59,7 @@ class TherapyEventDataPoint @Inject constructor(
|
||||||
|
|
||||||
override fun getLabel(): String? =
|
override fun getLabel(): String? =
|
||||||
if (data.note != null) data.note
|
if (data.note != null) data.note
|
||||||
else translator.translate(data.type.text)
|
else translator.translate(data.type)
|
||||||
|
|
||||||
override fun getDuration(): Long = end() - start()
|
override fun getDuration(): Long = end() - start()
|
||||||
override fun getShape(): PointsWithLabelGraphSeries.Shape =
|
override fun getShape(): PointsWithLabelGraphSeries.Shape =
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.androidaps.logging
|
package info.nightscout.androidaps.logging
|
||||||
|
|
||||||
import info.nightscout.androidaps.database.AppRepository
|
import info.nightscout.androidaps.database.AppRepository
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.Action
|
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
|
||||||
import info.nightscout.androidaps.database.entities.UserEntry.ValueWithUnit
|
import info.nightscout.androidaps.database.entities.UserEntry.*
|
||||||
import info.nightscout.androidaps.database.transactions.UserEntryTransaction
|
import info.nightscout.androidaps.database.transactions.UserEntryTransaction
|
||||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
|
@ -38,6 +38,12 @@ class UserEntryLogger @Inject constructor(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//fun log(action: Action, vararg listvalues: XXXValueWithUnit?) = Unit // TODO
|
||||||
|
|
||||||
|
//fun log(action: Action, s: String? = "", values: List<XXXValueWithUnit?>) = Unit
|
||||||
|
|
||||||
|
//fun log(action: Action, s: String? , vararg listvalues: XXXValueWithUnit?) = Unit
|
||||||
|
|
||||||
fun log(action: Action, vararg listValues: ValueWithUnit) {
|
fun log(action: Action, vararg listValues: ValueWithUnit) {
|
||||||
val values = mutableListOf<ValueWithUnit>()
|
val values = mutableListOf<ValueWithUnit>()
|
||||||
for (v in listValues){
|
for (v in listValues){
|
||||||
|
|
|
@ -88,45 +88,81 @@ 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.s) + ";" +
|
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())
|
||||||
}
|
}
|
||||||
} else {
|
formatedString = if (formatedString == "") tempString else formatedString + " / " + tempString
|
||||||
entry.timestamp.toString() + ";" +
|
|
||||||
dateUtil.dateAndTimeAndSecondsString(entry.timestamp) + ";" +
|
|
||||||
dateUtil.timeString(entry.utcOffset) + ";" +
|
|
||||||
csvString(entry.action) + ";" +
|
|
||||||
csvString(entry.s) + ";;"
|
|
||||||
}
|
}
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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) {
|
private fun csvString(action: Action): String = "\"" + translator.translate(action).replace("\"", "\"\"") + "\""
|
||||||
Units.Timestamp -> dateUtil.dateAndTimeAndSecondsString(v.lValue) + ";" + csvString(R.string.date)
|
private fun csvString(unit: Units): String = "\"" + translator.translate(unit).replace("\"", "\"\"") + "\""
|
||||||
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.name).replace("\"", "\"\"") + "\""
|
|
||||||
private fun csvString(unit: Units): String = "\"" + translator.translate(unit.name).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 ""
|
||||||
private fun csvString(s: String): String = if (s != "") "\"" + s.replace("\"", "\"\"") + "\"" else ""
|
private fun csvString(s: String): String = if (s != "") "\"" + s.replace("\"", "\"\"") + "\"" else ""
|
||||||
}
|
}
|
|
@ -241,7 +241,7 @@ public class NSUpload {
|
||||||
/*
|
/*
|
||||||
JSONObject data = new JSONObject();
|
JSONObject data = new JSONObject();
|
||||||
try {
|
try {
|
||||||
data.put("eventType", detailedBolusInfo.eventType);
|
data.put("eventType", detailedBolusInfo.eventType.getText());
|
||||||
if (detailedBolusInfo.insulin != 0d) data.put("insulin", detailedBolusInfo.insulin);
|
if (detailedBolusInfo.insulin != 0d) data.put("insulin", detailedBolusInfo.insulin);
|
||||||
if (detailedBolusInfo.carbs != 0d) data.put("carbs", (int) detailedBolusInfo.carbs);
|
if (detailedBolusInfo.carbs != 0d) data.put("carbs", (int) detailedBolusInfo.carbs);
|
||||||
data.put("created_at", DateUtil.toISOString(detailedBolusInfo.timestamp));
|
data.put("created_at", DateUtil.toISOString(detailedBolusInfo.timestamp));
|
||||||
|
|
|
@ -13,142 +13,155 @@ class Translator @Inject internal constructor(
|
||||||
private val resourceHelper: ResourceHelper
|
private val resourceHelper: ResourceHelper
|
||||||
) {
|
) {
|
||||||
|
|
||||||
fun translate(text: String): String =
|
@Deprecated("use type instead of string")
|
||||||
when (text) {
|
fun translate(text: String): String = ""
|
||||||
TherapyEvent.Type.FINGER_STICK_BG_VALUE.text -> resourceHelper.gs(R.string.careportal_bgcheck)
|
|
||||||
TherapyEvent.Type.SNACK_BOLUS.text -> resourceHelper.gs(R.string.careportal_snackbolus)
|
|
||||||
TherapyEvent.Type.MEAL_BOLUS.text -> resourceHelper.gs(R.string.careportal_mealbolus)
|
|
||||||
TherapyEvent.Type.CORRECTION_BOLUS.text -> resourceHelper.gs(R.string.careportal_correctionbolus)
|
|
||||||
TherapyEvent.Type.CARBS_CORRECTION.text -> resourceHelper.gs(R.string.careportal_carbscorrection)
|
|
||||||
TherapyEvent.Type.BOLUS_WIZARD.text -> resourceHelper.gs(R.string.boluswizard)
|
|
||||||
TherapyEvent.Type.COMBO_BOLUS.text -> resourceHelper.gs(R.string.careportal_combobolus)
|
|
||||||
TherapyEvent.Type.ANNOUNCEMENT.text -> resourceHelper.gs(R.string.careportal_announcement)
|
|
||||||
TherapyEvent.Type.NOTE.text -> resourceHelper.gs(R.string.careportal_note)
|
|
||||||
TherapyEvent.Type.QUESTION.text -> resourceHelper.gs(R.string.careportal_question)
|
|
||||||
TherapyEvent.Type.EXERCISE.text -> resourceHelper.gs(R.string.careportal_exercise)
|
|
||||||
TherapyEvent.Type.CANNULA_CHANGE.text -> resourceHelper.gs(R.string.careportal_pumpsitechange)
|
|
||||||
TherapyEvent.Type.PUMP_BATTERY_CHANGE.text -> resourceHelper.gs(R.string.careportal_pumpbatterychange)
|
|
||||||
TherapyEvent.Type.SENSOR_STARTED.text -> resourceHelper.gs(R.string.careportal_cgmsensorstart)
|
|
||||||
TherapyEvent.Type.SENSOR_STOPPED.text -> resourceHelper.gs(R.string.careportal_cgm_sensor_stop)
|
|
||||||
TherapyEvent.Type.SENSOR_CHANGE.text -> resourceHelper.gs(R.string.careportal_cgmsensorinsert)
|
|
||||||
TherapyEvent.Type.INSULIN_CHANGE.text -> resourceHelper.gs(R.string.careportal_insulincartridgechange)
|
|
||||||
TherapyEvent.Type.DAD_ALERT.text -> resourceHelper.gs(R.string.careportal_dad_alert)
|
|
||||||
TherapyEvent.Type.TEMPORARY_BASAL_START.text -> resourceHelper.gs(R.string.careportal_tempbasalstart)
|
|
||||||
TherapyEvent.Type.TEMPORARY_BASAL_END.text -> resourceHelper.gs(R.string.careportal_tempbasalend)
|
|
||||||
TherapyEvent.Type.PROFILE_SWITCH.text -> resourceHelper.gs(R.string.careportal_profileswitch)
|
|
||||||
TherapyEvent.Type.TEMPORARY_TARGET.text -> resourceHelper.gs(R.string.careportal_temporarytarget)
|
|
||||||
TherapyEvent.Type.TEMPORARY_TARGET_CANCEL.text -> resourceHelper.gs(R.string.careportal_temporarytargetcancel)
|
|
||||||
TherapyEvent.Type.APS_OFFLINE.text -> resourceHelper.gs(R.string.careportal_openapsoffline)
|
|
||||||
TherapyEvent.Type.NS_MBG.text -> resourceHelper.gs(R.string.careportal_mbg)
|
|
||||||
TherapyEvent.MeterType.FINGER.text -> resourceHelper.gs(R.string.glucosetype_finger)
|
|
||||||
TherapyEvent.MeterType.SENSOR.text -> resourceHelper.gs(R.string.glucosetype_sensor)
|
|
||||||
TherapyEvent.MeterType.MANUAL.text -> resourceHelper.gs(R.string.manual)
|
|
||||||
|
|
||||||
TemporaryTarget.Reason.CUSTOM.text -> resourceHelper.gs(R.string.custom)
|
fun translate(action: Action): String = when(action) {
|
||||||
TemporaryTarget.Reason.HYPOGLYCEMIA.text -> resourceHelper.gs(R.string.hypo)
|
Action.BOLUS -> resourceHelper.gs(R.string.uel_bolus)
|
||||||
TemporaryTarget.Reason.EATING_SOON.text -> resourceHelper.gs(R.string.eatingsoon)
|
Action.SMB -> resourceHelper.gs(R.string.smb_shortname)
|
||||||
TemporaryTarget.Reason.ACTIVITY.text -> resourceHelper.gs(R.string.activity)
|
Action.BOLUS_ADVISOR -> resourceHelper.gs(R.string.uel_bolus_advisor)
|
||||||
TemporaryTarget.Reason.AUTOMATION.text -> resourceHelper.gs(R.string.automation)
|
Action.EXTENDED_BOLUS -> resourceHelper.gs(R.string.uel_extended_bolus)
|
||||||
TemporaryTarget.Reason.WEAR.text -> resourceHelper.gs(R.string.wear)
|
Action.SUPERBOLUS_TBR -> resourceHelper.gs(R.string.uel_superbolus_tbr)
|
||||||
|
Action.CARBS -> resourceHelper.gs(R.string.uel_carbs)
|
||||||
|
Action.EXTENDED_CARBS -> resourceHelper.gs(R.string.uel_extended_carbs)
|
||||||
|
Action.TEMP_BASAL -> resourceHelper.gs(R.string.uel_temp_basal)
|
||||||
|
Action.TT -> resourceHelper.gs(R.string.uel_tt)
|
||||||
|
Action.NEW_PROFILE -> resourceHelper.gs(R.string.uel_new_profile)
|
||||||
|
Action.CLONE_PROFILE -> resourceHelper.gs(R.string.uel_clone_profile)
|
||||||
|
Action.STORE_PROFILE -> resourceHelper.gs(R.string.uel_store_profile)
|
||||||
|
Action.PROFILE_SWITCH -> resourceHelper.gs(R.string.uel_profile_switch)
|
||||||
|
Action.PROFILE_SWITCH_CLONED -> resourceHelper.gs(R.string.uel_profile_switch_cloned)
|
||||||
|
Action.CLOSED_LOOP_MODE -> resourceHelper.gs(R.string.uel_closed_loop_mode)
|
||||||
|
Action.LGS_LOOP_MODE -> resourceHelper.gs(R.string.uel_lgs_loop_mode)
|
||||||
|
Action.OPEN_LOOP_MODE -> resourceHelper.gs(R.string.uel_open_loop_mode)
|
||||||
|
Action.LOOP_DISABLED -> resourceHelper.gs(R.string.uel_loop_disabled)
|
||||||
|
Action.LOOP_ENABLED -> resourceHelper.gs(R.string.uel_loop_enabled)
|
||||||
|
Action.RECONNECT -> resourceHelper.gs(R.string.uel_reconnect)
|
||||||
|
Action.DISCONNECT -> resourceHelper.gs(R.string.uel_disconnect)
|
||||||
|
Action.RESUME -> resourceHelper.gs(R.string.uel_resume)
|
||||||
|
Action.SUSPEND -> resourceHelper.gs(R.string.uel_suspend)
|
||||||
|
Action.HW_PUMP_ALLOWED -> resourceHelper.gs(R.string.uel_hw_pump_allowed)
|
||||||
|
Action.CLEAR_PAIRING_KEYS -> resourceHelper.gs(R.string.uel_clear_pairing_keys)
|
||||||
|
Action.ACCEPTS_TEMP_BASAL -> resourceHelper.gs(R.string.uel_accepts_temp_basal)
|
||||||
|
Action.CANCEL_TEMP_BASAL -> resourceHelper.gs(R.string.uel_cancel_temp_basal)
|
||||||
|
Action.CANCEL_EXTENDED_BOLUS -> resourceHelper.gs(R.string.uel_cancel_extended_bolus)
|
||||||
|
Action.CANCEL_TT -> resourceHelper.gs(R.string.uel_cancel_tt)
|
||||||
|
Action.CAREPORTAL -> resourceHelper.gs(R.string.uel_careportal)
|
||||||
|
Action.CALIBRATION -> resourceHelper.gs(R.string.uel_calibration)
|
||||||
|
Action.PRIME_BOLUS -> resourceHelper.gs(R.string.uel_prime_bolus)
|
||||||
|
Action.TREATMENT -> resourceHelper.gs(R.string.uel_treatment)
|
||||||
|
Action.CAREPORTAL_NS_REFRESH -> resourceHelper.gs(R.string.uel_careportal_ns_refresh)
|
||||||
|
Action.PROFILE_SWITCH_NS_REFRESH -> resourceHelper.gs(R.string.uel_profile_switch_ns_refresh)
|
||||||
|
Action.TREATMENTS_NS_REFRESH -> resourceHelper.gs(R.string.uel_treatments_ns_refresh)
|
||||||
|
Action.TT_NS_REFRESH -> resourceHelper.gs(R.string.uel_tt_ns_refresh)
|
||||||
|
Action.AUTOMATION_REMOVED -> resourceHelper.gs(R.string.uel_automation_removed)
|
||||||
|
Action.BG_REMOVED -> resourceHelper.gs(R.string.uel_bg_removed)
|
||||||
|
Action.CAREPORTAL_REMOVED -> resourceHelper.gs(R.string.uel_careportal_removed)
|
||||||
|
Action.EXTENDED_BOLUS_REMOVED -> resourceHelper.gs(R.string.uel_extended_bolus_removed)
|
||||||
|
Action.FOOD -> resourceHelper.gs(R.string.uel_food)
|
||||||
|
Action.FOOD_REMOVED -> resourceHelper.gs(R.string.uel_food_removed)
|
||||||
|
Action.PROFILE_REMOVED -> resourceHelper.gs(R.string.uel_profile_removed)
|
||||||
|
Action.PROFILE_SWITCH_REMOVED -> resourceHelper.gs(R.string.uel_profile_switch_removed)
|
||||||
|
Action.RESTART_EVENTS_REMOVED -> resourceHelper.gs(R.string.uel_restart_events_removed)
|
||||||
|
Action.TREATMENT_REMOVED -> resourceHelper.gs(R.string.uel_treatment_removed)
|
||||||
|
Action.TT_REMOVED -> resourceHelper.gs(R.string.uel_tt_removed)
|
||||||
|
Action.NS_PAUSED -> resourceHelper.gs(R.string.uel_ns_paused)
|
||||||
|
Action.NS_RESUME -> resourceHelper.gs(R.string.uel_ns_resume)
|
||||||
|
Action.NS_QUEUE_CLEARED -> resourceHelper.gs(R.string.uel_ns_queue_cleared)
|
||||||
|
Action.NS_SETTINGS_COPIED -> resourceHelper.gs(R.string.uel_ns_settings_copied)
|
||||||
|
Action.ERROR_DIALOG_OK -> resourceHelper.gs(R.string.uel_error_dialog_ok)
|
||||||
|
Action.ERROR_DIALOG_MUTE -> resourceHelper.gs(R.string.uel_error_dialog_mute)
|
||||||
|
Action.ERROR_DIALOG_MUTE_5MIN -> resourceHelper.gs(R.string.uel_error_dialog_mute_5min)
|
||||||
|
Action.OBJECTIVE_STARTED -> resourceHelper.gs(R.string.uel_objective_started)
|
||||||
|
Action.OBJECTIVE_UNSTARTED -> resourceHelper.gs(R.string.uel_objective_unstarted)
|
||||||
|
Action.OBJECTIVES_SKIPPED -> resourceHelper.gs(R.string.uel_objectives_skipped)
|
||||||
|
Action.STAT_RESET -> resourceHelper.gs(R.string.uel_stat_reset)
|
||||||
|
Action.DELETE_LOGS -> resourceHelper.gs(R.string.uel_delete_logs)
|
||||||
|
Action.DELETE_FUTURE_TREATMENTS -> resourceHelper.gs(R.string.uel_delete_future_treatments)
|
||||||
|
Action.EXPORT_SETTINGS -> resourceHelper.gs(R.string.uel_export_settings)
|
||||||
|
Action.IMPORT_SETTINGS -> resourceHelper.gs(R.string.uel_import_settings)
|
||||||
|
Action.RESET_DATABASES -> resourceHelper.gs(R.string.uel_reset_databases)
|
||||||
|
Action.EXPORT_DATABASES -> resourceHelper.gs(R.string.uel_export_databases)
|
||||||
|
Action.IMPORT_DATABASES -> resourceHelper.gs(R.string.uel_import_databases)
|
||||||
|
Action.OTP_EXPORT -> resourceHelper.gs(R.string.uel_otp_export)
|
||||||
|
Action.OTP_RESET -> resourceHelper.gs(R.string.uel_otp_reset)
|
||||||
|
Action.EXPORT_CSV -> resourceHelper.gs(R.string.uel_export_csv)
|
||||||
|
Action.STOP_SMS -> resourceHelper.gs(R.string.uel_stop_sms)
|
||||||
|
Action.UNKNOWN -> resourceHelper.gs(R.string.unknown)
|
||||||
|
}
|
||||||
|
|
||||||
Action.BOLUS.name -> resourceHelper.gs(R.string.uel_bolus)
|
fun translate(units: Units): String = when(units) {
|
||||||
Action.BOLUS_ADVISOR.name -> resourceHelper.gs(R.string.uel_bolus_advisor)
|
Units.Mg_Dl -> resourceHelper.gs(R.string.mgdl)
|
||||||
Action.BOLUS_RECORD.name -> resourceHelper.gs(R.string.uel_bolus_record)
|
Units.Mmol_L -> resourceHelper.gs(R.string.mmol)
|
||||||
Action.EXTENDED_BOLUS.name -> resourceHelper.gs(R.string.uel_extended_bolus)
|
Units.U -> resourceHelper.gs(R.string.insulin_unit_shortname)
|
||||||
Action.SUPERBOLUS_TBR.name -> resourceHelper.gs(R.string.uel_superbolus_tbr)
|
Units.U_H -> resourceHelper.gs(R.string.profile_ins_units_per_hour)
|
||||||
Action.CARBS.name -> resourceHelper.gs(R.string.uel_carbs)
|
Units.G -> resourceHelper.gs(R.string.shortgram)
|
||||||
Action.EXTENDED_CARBS.name -> resourceHelper.gs(R.string.uel_extended_carbs)
|
Units.M -> resourceHelper.gs(R.string.shortminute)
|
||||||
Action.TEMP_BASAL.name -> resourceHelper.gs(R.string.uel_temp_basal)
|
Units.H -> resourceHelper.gs(R.string.shorthour)
|
||||||
Action.TT.name -> resourceHelper.gs(R.string.uel_tt)
|
Units.Percent -> resourceHelper.gs(R.string.shortpercent)
|
||||||
Action.NEW_PROFILE.name -> resourceHelper.gs(R.string.uel_new_profile)
|
Units.None -> ""
|
||||||
Action.CLONE_PROFILE.name -> resourceHelper.gs(R.string.uel_clone_profile)
|
|
||||||
Action.STORE_PROFILE.name -> resourceHelper.gs(R.string.uel_store_profile)
|
|
||||||
Action.PROFILE_SWITCH.name -> resourceHelper.gs(R.string.uel_profile_switch)
|
|
||||||
Action.PROFILE_SWITCH_CLONED.name -> resourceHelper.gs(R.string.uel_profile_switch_cloned)
|
|
||||||
Action.CLOSED_LOOP_MODE.name -> resourceHelper.gs(R.string.uel_closed_loop_mode)
|
|
||||||
Action.LGS_LOOP_MODE.name -> resourceHelper.gs(R.string.uel_lgs_loop_mode)
|
|
||||||
Action.OPEN_LOOP_MODE.name -> resourceHelper.gs(R.string.uel_open_loop_mode)
|
|
||||||
Action.LOOP_DISABLED.name -> resourceHelper.gs(R.string.uel_loop_disabled)
|
|
||||||
Action.LOOP_ENABLED.name -> resourceHelper.gs(R.string.uel_loop_enabled)
|
|
||||||
Action.RECONNECT.name -> resourceHelper.gs(R.string.uel_reconnect)
|
|
||||||
Action.DISCONNECT.name -> resourceHelper.gs(R.string.uel_disconnect)
|
|
||||||
Action.RESUME.name -> resourceHelper.gs(R.string.uel_resume)
|
|
||||||
Action.SUSPEND.name -> resourceHelper.gs(R.string.uel_suspend)
|
|
||||||
Action.HW_PUMP_ALLOWED.name -> resourceHelper.gs(R.string.uel_hw_pump_allowed)
|
|
||||||
Action.CLEAR_PAIRING_KEYS.name -> resourceHelper.gs(R.string.uel_clear_pairing_keys)
|
|
||||||
Action.ACCEPTS_TEMP_BASAL.name -> resourceHelper.gs(R.string.uel_accepts_temp_basal)
|
|
||||||
Action.CANCEL_TEMP_BASAL.name -> resourceHelper.gs(R.string.uel_cancel_temp_basal)
|
|
||||||
Action.CANCEL_EXTENDED_BOLUS.name -> resourceHelper.gs(R.string.uel_cancel_extended_bolus)
|
|
||||||
Action.CANCEL_TT.name -> resourceHelper.gs(R.string.uel_cancel_tt)
|
|
||||||
Action.CAREPORTAL.name -> resourceHelper.gs(R.string.uel_careportal)
|
|
||||||
Action.CALIBRATION.name -> resourceHelper.gs(R.string.uel_calibration)
|
|
||||||
Action.PRIME_BOLUS.name -> resourceHelper.gs(R.string.uel_prime_bolus)
|
|
||||||
Action.TREATMENT.name -> resourceHelper.gs(R.string.uel_treatment)
|
|
||||||
Action.CAREPORTAL_NS_REFRESH.name -> resourceHelper.gs(R.string.uel_careportal_ns_refresh)
|
|
||||||
Action.PROFILE_SWITCH_NS_REFRESH.name -> resourceHelper.gs(R.string.uel_profile_switch_ns_refresh)
|
|
||||||
Action.TREATMENTS_NS_REFRESH.name -> resourceHelper.gs(R.string.uel_treatments_ns_refresh)
|
|
||||||
Action.TT_NS_REFRESH.name -> resourceHelper.gs(R.string.uel_tt_ns_refresh)
|
|
||||||
Action.AUTOMATION_REMOVED.name -> resourceHelper.gs(R.string.uel_automation_removed)
|
|
||||||
Action.BG_REMOVED.name -> resourceHelper.gs(R.string.uel_bg_removed)
|
|
||||||
Action.CAREPORTAL_REMOVED.name -> resourceHelper.gs(R.string.uel_careportal_removed)
|
|
||||||
Action.EXTENDED_BOLUS_REMOVED.name -> resourceHelper.gs(R.string.uel_extended_bolus_removed)
|
|
||||||
Action.FOOD_REMOVED.name -> resourceHelper.gs(R.string.uel_food_removed)
|
|
||||||
Action.PROFILE_REMOVED.name -> resourceHelper.gs(R.string.uel_profile_removed)
|
|
||||||
Action.PROFILE_SWITCH_REMOVED.name -> resourceHelper.gs(R.string.uel_profile_switch_removed)
|
|
||||||
Action.RESTART_EVENTS_REMOVED.name -> resourceHelper.gs(R.string.uel_restart_events_removed)
|
|
||||||
Action.TREATMENT_REMOVED.name -> resourceHelper.gs(R.string.uel_treatment_removed)
|
|
||||||
Action.TT_REMOVED.name -> resourceHelper.gs(R.string.uel_tt_removed)
|
|
||||||
Action.NS_PAUSED.name -> resourceHelper.gs(R.string.uel_ns_paused)
|
|
||||||
Action.NS_RESUME.name -> resourceHelper.gs(R.string.uel_ns_resume)
|
|
||||||
Action.NS_QUEUE_CLEARED.name -> resourceHelper.gs(R.string.uel_ns_queue_cleared)
|
|
||||||
Action.NS_SETTINGS_COPIED.name -> resourceHelper.gs(R.string.uel_ns_settings_copied)
|
|
||||||
Action.ERROR_DIALOG_OK.name -> resourceHelper.gs(R.string.uel_error_dialog_ok)
|
|
||||||
Action.ERROR_DIALOG_MUTE.name -> resourceHelper.gs(R.string.uel_error_dialog_mute)
|
|
||||||
Action.ERROR_DIALOG_MUTE_5MIN.name -> resourceHelper.gs(R.string.uel_error_dialog_mute_5min)
|
|
||||||
Action.OBJECTIVE_STARTED.name -> resourceHelper.gs(R.string.uel_objective_started)
|
|
||||||
Action.OBJECTIVE_UNSTARTED.name -> resourceHelper.gs(R.string.uel_objective_unstarted)
|
|
||||||
Action.OBJECTIVES_SKIPPED.name -> resourceHelper.gs(R.string.uel_objectives_skipped)
|
|
||||||
Action.STAT_RESET.name -> resourceHelper.gs(R.string.uel_stat_reset)
|
|
||||||
Action.DELETE_LOGS.name -> resourceHelper.gs(R.string.uel_delete_logs)
|
|
||||||
Action.DELETE_FUTURE_TREATMENTS.name -> resourceHelper.gs(R.string.uel_delete_future_treatments)
|
|
||||||
Action.EXPORT_SETTINGS.name -> resourceHelper.gs(R.string.uel_export_settings)
|
|
||||||
Action.IMPORT_SETTINGS.name -> resourceHelper.gs(R.string.uel_import_settings)
|
|
||||||
Action.RESET_DATABASES.name -> resourceHelper.gs(R.string.uel_reset_databases)
|
|
||||||
Action.EXPORT_DATABASES.name -> resourceHelper.gs(R.string.uel_export_databases)
|
|
||||||
Action.IMPORT_DATABASES.name -> resourceHelper.gs(R.string.uel_import_databases)
|
|
||||||
Action.OTP_EXPORT.name -> resourceHelper.gs(R.string.uel_otp_export)
|
|
||||||
Action.OTP_RESET.name -> resourceHelper.gs(R.string.uel_otp_reset)
|
|
||||||
Action.SMS_BASAL.name -> resourceHelper.gs(R.string.uel_sms_basal)
|
|
||||||
Action.SMS_BOLUS.name -> resourceHelper.gs(R.string.uel_sms_bolus)
|
|
||||||
Action.SMS_CAL.name -> resourceHelper.gs(R.string.uel_sms_cal)
|
|
||||||
Action.SMS_CARBS.name -> resourceHelper.gs(R.string.uel_sms_carbs)
|
|
||||||
Action.SMS_EXTENDED_BOLUS.name -> resourceHelper.gs(R.string.uel_sms_extended_bolus)
|
|
||||||
Action.SMS_LOOP_DISABLED.name -> resourceHelper.gs(R.string.uel_sms_loop_disabled)
|
|
||||||
Action.SMS_LOOP_ENABLED.name -> resourceHelper.gs(R.string.uel_sms_loop_enabled)
|
|
||||||
Action.SMS_LOOP_RESUME.name -> resourceHelper.gs(R.string.uel_sms_loop_resume)
|
|
||||||
Action.SMS_LOOP_SUSPEND.name -> resourceHelper.gs(R.string.uel_sms_loop_suspend)
|
|
||||||
Action.SMS_PROFILE.name -> resourceHelper.gs(R.string.uel_sms_profile)
|
|
||||||
Action.SMS_PUMP_CONNECT.name -> resourceHelper.gs(R.string.uel_sms_pump_connect)
|
|
||||||
Action.SMS_PUMP_DISCONNECT.name -> resourceHelper.gs(R.string.uel_sms_pump_disconnect)
|
|
||||||
Action.SMS_SMS.name -> resourceHelper.gs(R.string.uel_sms_sms)
|
|
||||||
Action.SMS_TT.name -> resourceHelper.gs(R.string.uel_sms_tt)
|
|
||||||
Action.TT_DELETED_FROM_NS.name -> resourceHelper.gs(R.string.uel_tt_deleted_from_ns)
|
|
||||||
Action.TT_FROM_NS.name -> resourceHelper.gs(R.string.uel_tt_from_ns)
|
|
||||||
Action.TT_CANCELED_FROM_NS.name -> resourceHelper.gs(R.string.uel_tt_canceleted_from_ns)
|
|
||||||
Action.CAREPORTAL_DELETED_FROM_NS.name -> resourceHelper.gs(R.string.uel_careportal_deleted_from_ns)
|
|
||||||
Action.CAREPORTAL_FROM_NS.name -> resourceHelper.gs(R.string.uel_careportal_from_ns)
|
|
||||||
Action.EXPORT_CSV.name -> resourceHelper.gs(R.string.uel_export_csv)
|
|
||||||
|
|
||||||
Units.Mg_Dl.name -> resourceHelper.gs(R.string.mgdl)
|
|
||||||
Units.Mmol_L.name -> resourceHelper.gs(R.string.mmol)
|
|
||||||
Units.U.name -> resourceHelper.gs(R.string.insulin_unit_shortname)
|
|
||||||
Units.U_H.name -> resourceHelper.gs(R.string.profile_ins_units_per_hour)
|
|
||||||
Units.G.name -> resourceHelper.gs(R.string.shortgram)
|
|
||||||
Units.M.name -> resourceHelper.gs(R.string.shortminute)
|
|
||||||
Units.H.name -> resourceHelper.gs(R.string.shorthour)
|
|
||||||
Units.Percent.name -> resourceHelper.gs(R.string.shortpercent)
|
|
||||||
Units.None.name -> ""
|
|
||||||
|
|
||||||
else -> resourceHelper.gs(R.string.unknown)
|
else -> resourceHelper.gs(R.string.unknown)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun translate(meterType: TherapyEvent.MeterType): String = when(meterType) {
|
||||||
|
TherapyEvent.MeterType.FINGER -> resourceHelper.gs(R.string.glucosetype_finger)
|
||||||
|
TherapyEvent.MeterType.SENSOR -> resourceHelper.gs(R.string.glucosetype_sensor)
|
||||||
|
TherapyEvent.MeterType.MANUAL -> resourceHelper.gs(R.string.manual)
|
||||||
|
|
||||||
|
else -> resourceHelper.gs(R.string.unknown)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun translate(type: TherapyEvent.Type): String = when(type) {
|
||||||
|
TherapyEvent.Type.FINGER_STICK_BG_VALUE -> resourceHelper.gs(R.string.careportal_bgcheck)
|
||||||
|
TherapyEvent.Type.SNACK_BOLUS -> resourceHelper.gs(R.string.careportal_snackbolus)
|
||||||
|
TherapyEvent.Type.MEAL_BOLUS -> resourceHelper.gs(R.string.careportal_mealbolus)
|
||||||
|
TherapyEvent.Type.CORRECTION_BOLUS -> resourceHelper.gs(R.string.careportal_correctionbolus)
|
||||||
|
TherapyEvent.Type.CARBS_CORRECTION -> resourceHelper.gs(R.string.careportal_carbscorrection)
|
||||||
|
TherapyEvent.Type.BOLUS_WIZARD -> resourceHelper.gs(R.string.boluswizard)
|
||||||
|
TherapyEvent.Type.COMBO_BOLUS -> resourceHelper.gs(R.string.careportal_combobolus)
|
||||||
|
TherapyEvent.Type.ANNOUNCEMENT -> resourceHelper.gs(R.string.careportal_announcement)
|
||||||
|
TherapyEvent.Type.NOTE -> resourceHelper.gs(R.string.careportal_note)
|
||||||
|
TherapyEvent.Type.QUESTION -> resourceHelper.gs(R.string.careportal_question)
|
||||||
|
TherapyEvent.Type.EXERCISE -> resourceHelper.gs(R.string.careportal_exercise)
|
||||||
|
TherapyEvent.Type.CANNULA_CHANGE -> resourceHelper.gs(R.string.careportal_pumpsitechange)
|
||||||
|
TherapyEvent.Type.PUMP_BATTERY_CHANGE -> resourceHelper.gs(R.string.careportal_pumpbatterychange)
|
||||||
|
TherapyEvent.Type.SENSOR_STARTED -> resourceHelper.gs(R.string.careportal_cgmsensorstart)
|
||||||
|
TherapyEvent.Type.SENSOR_STOPPED -> resourceHelper.gs(R.string.careportal_cgm_sensor_stop)
|
||||||
|
TherapyEvent.Type.SENSOR_CHANGE -> resourceHelper.gs(R.string.careportal_cgmsensorinsert)
|
||||||
|
TherapyEvent.Type.INSULIN_CHANGE -> resourceHelper.gs(R.string.careportal_insulincartridgechange)
|
||||||
|
TherapyEvent.Type.DAD_ALERT -> resourceHelper.gs(R.string.careportal_dad_alert)
|
||||||
|
TherapyEvent.Type.TEMPORARY_BASAL_START -> resourceHelper.gs(R.string.careportal_tempbasalstart)
|
||||||
|
TherapyEvent.Type.TEMPORARY_BASAL_END -> resourceHelper.gs(R.string.careportal_tempbasalend)
|
||||||
|
TherapyEvent.Type.PROFILE_SWITCH -> resourceHelper.gs(R.string.careportal_profileswitch)
|
||||||
|
TherapyEvent.Type.TEMPORARY_TARGET -> resourceHelper.gs(R.string.careportal_temporarytarget)
|
||||||
|
TherapyEvent.Type.TEMPORARY_TARGET_CANCEL -> resourceHelper.gs(R.string.careportal_temporarytargetcancel)
|
||||||
|
TherapyEvent.Type.APS_OFFLINE -> resourceHelper.gs(R.string.careportal_openapsoffline)
|
||||||
|
TherapyEvent.Type.NS_MBG -> resourceHelper.gs(R.string.careportal_mbg)
|
||||||
|
|
||||||
|
else -> resourceHelper.gs(R.string.unknown)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun translate(reason: TemporaryTarget.Reason): String = when(reason) {
|
||||||
|
TemporaryTarget.Reason.CUSTOM -> resourceHelper.gs(R.string.custom)
|
||||||
|
TemporaryTarget.Reason.HYPOGLYCEMIA -> resourceHelper.gs(R.string.hypo)
|
||||||
|
TemporaryTarget.Reason.EATING_SOON -> resourceHelper.gs(R.string.eatingsoon)
|
||||||
|
TemporaryTarget.Reason.ACTIVITY -> resourceHelper.gs(R.string.activity)
|
||||||
|
TemporaryTarget.Reason.AUTOMATION -> resourceHelper.gs(R.string.automation)
|
||||||
|
TemporaryTarget.Reason.WEAR -> resourceHelper.gs(R.string.wear)
|
||||||
|
|
||||||
|
else -> resourceHelper.gs(R.string.unknown)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun translate(source: Sources): String = when(source) {
|
||||||
|
Sources.Automation -> resourceHelper.gs(R.string.automation)
|
||||||
|
Sources.Loop -> resourceHelper.gs(R.string.loop)
|
||||||
|
Sources.NSClient -> resourceHelper.gs(R.string.ns)
|
||||||
|
Sources.Pump -> resourceHelper.gs(R.string.pump)
|
||||||
|
Sources.SMS -> resourceHelper.gs(R.string.smb_shortname)
|
||||||
|
Sources.Wear -> resourceHelper.gs(R.string.wear)
|
||||||
|
Sources.Unknown -> resourceHelper.gs(R.string.unknown)
|
||||||
|
|
||||||
|
else -> source.name
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,105 @@
|
||||||
|
package info.nightscout.androidaps.utils
|
||||||
|
|
||||||
|
import android.text.Spanned
|
||||||
|
import dagger.Reusable
|
||||||
|
import info.nightscout.androidaps.Constants
|
||||||
|
import info.nightscout.androidaps.core.R
|
||||||
|
import info.nightscout.androidaps.database.entities.UserEntry
|
||||||
|
import info.nightscout.androidaps.database.entities.UserEntry.*
|
||||||
|
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
|
||||||
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@Reusable
|
||||||
|
class UserEntryPresentationHelper @Inject constructor(
|
||||||
|
private val translator: Translator,
|
||||||
|
private val profileFunction: ProfileFunction,
|
||||||
|
private val resourceHelper: ResourceHelper,
|
||||||
|
private val dateUtil: DateUtil
|
||||||
|
) {
|
||||||
|
|
||||||
|
fun colorId(colorGroup: ColorGroup): Int = when (colorGroup) {
|
||||||
|
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 iconId(source: Sources): Int = when (source) {
|
||||||
|
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.Actions -> R.drawable.ic_action
|
||||||
|
Sources.Automation -> R.drawable.ic_automation
|
||||||
|
Sources.LocalProfile -> R.drawable.ic_local_profile
|
||||||
|
Sources.Loop -> R.drawable.ic_loop_closed_white
|
||||||
|
Sources.Maintenance -> R.drawable.ic_maintenance
|
||||||
|
Sources.NSClient -> R.drawable.ic_nightscout_syncs
|
||||||
|
Sources.Pump -> R.drawable.ic_generic_icon
|
||||||
|
Sources.SMS -> R.drawable.ic_sms
|
||||||
|
Sources.Treatments -> R.drawable.ic_treatments
|
||||||
|
Sources.Wear -> R.drawable.ic_watch
|
||||||
|
Sources.Food -> R.drawable.ic_food
|
||||||
|
Sources.Unknown -> R.drawable.ic_generic_icon
|
||||||
|
}
|
||||||
|
|
||||||
|
fun actionToColoredString(action: Action): Spanned = when (action) {
|
||||||
|
Action.TREATMENT -> HtmlHelper.fromHtml(coloredAction(Action.BOLUS) + " + " + coloredAction(Action.CARBS))
|
||||||
|
else -> HtmlHelper.fromHtml(coloredAction(action))
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun coloredAction(action: Action): String = "<font color='${resourceHelper.gc(colorId(action.colorGroup))}'>${translator.translate(action)}</font>"
|
||||||
|
|
||||||
|
fun listToPresentationString(list: List<XXXValueWithUnit>) =
|
||||||
|
list.joinToString(separator = " ", transform = this::toPresentationString)
|
||||||
|
|
||||||
|
private fun toPresentationString(valueWithUnit: XXXValueWithUnit): String = when (valueWithUnit) {
|
||||||
|
is XXXValueWithUnit.Gram -> "${valueWithUnit.value} ${translator.translate(Units.G)}"
|
||||||
|
is XXXValueWithUnit.Hour -> "${valueWithUnit.value} ${translator.translate(Units.H)}"
|
||||||
|
is XXXValueWithUnit.Minute -> "${valueWithUnit.value} ${translator.translate(Units.G)}"
|
||||||
|
is XXXValueWithUnit.Percent -> "${valueWithUnit.value} ${translator.translate(Units.Percent)}"
|
||||||
|
is XXXValueWithUnit.Insulin -> DecimalFormatter.to2Decimal(valueWithUnit.value) + translator.translate(UserEntry.Units.U)
|
||||||
|
is XXXValueWithUnit.UnitPerHour -> DecimalFormatter.to2Decimal(valueWithUnit.value) + translator.translate(UserEntry.Units.U_H)
|
||||||
|
is XXXValueWithUnit.SimpleInt -> valueWithUnit.value.toString()
|
||||||
|
is XXXValueWithUnit.SimpleString -> valueWithUnit.value
|
||||||
|
is XXXValueWithUnit.StringResource -> resourceHelper.gs(valueWithUnit.value, valueWithUnit.params.map(this::toPresentationString))
|
||||||
|
is XXXValueWithUnit.TherapyEventMeterType -> translator.translate(valueWithUnit.value)
|
||||||
|
is XXXValueWithUnit.TherapyEventTTReason -> translator.translate(valueWithUnit.value)
|
||||||
|
is XXXValueWithUnit.TherapyEventType -> translator.translate(valueWithUnit.value)
|
||||||
|
is XXXValueWithUnit.Timestamp -> dateUtil.dateAndTimeAndSecondsString(valueWithUnit.value)
|
||||||
|
|
||||||
|
is XXXValueWithUnit.Mgdl -> {
|
||||||
|
if (profileFunction.getUnits() == Constants.MGDL) DecimalFormatter.to0Decimal(valueWithUnit.value) + translator.translate(Units.Mg_Dl)
|
||||||
|
else DecimalFormatter.to1Decimal(valueWithUnit.value / Constants.MMOLL_TO_MGDL) + translator.translate(Units.Mmol_L)
|
||||||
|
}
|
||||||
|
|
||||||
|
is XXXValueWithUnit.Mmoll -> {
|
||||||
|
if (profileFunction.getUnits() == Constants.MGDL) DecimalFormatter.to0Decimal(valueWithUnit.value) + translator.translate(Units.Mmol_L)
|
||||||
|
else DecimalFormatter.to1Decimal(valueWithUnit.value * Constants.MMOLL_TO_MGDL) + translator.translate(Units.Mg_Dl)
|
||||||
|
}
|
||||||
|
|
||||||
|
XXXValueWithUnit.UNKNOWN -> ""
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,19 +0,0 @@
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
package info.nightscout.androidaps.utils.serialisation
|
||||||
|
|
||||||
|
import com.google.gson.Gson
|
||||||
|
import com.google.gson.GsonBuilder
|
||||||
|
import com.google.gson.TypeAdapter
|
||||||
|
import com.google.gson.TypeAdapterFactory
|
||||||
|
import com.google.gson.reflect.TypeToken
|
||||||
|
import com.google.gson.stream.JsonReader
|
||||||
|
import com.google.gson.stream.JsonWriter
|
||||||
|
import kotlin.jvm.internal.Reflection
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
|
object SealedClassHelper {
|
||||||
|
|
||||||
|
val gson: Gson = GsonBuilder().registerTypeAdapterFactory(
|
||||||
|
object : TypeAdapterFactory {
|
||||||
|
override fun <T : Any> create(gson: Gson, type: TypeToken<T>): TypeAdapter<T> {
|
||||||
|
val kClass = Reflection.getOrCreateKotlinClass(type.rawType)
|
||||||
|
return if (kClass.sealedSubclasses.any()) {
|
||||||
|
SealedClassTypeAdapter(kClass, gson)
|
||||||
|
} else
|
||||||
|
gson.getDelegateAdapter(this, type)
|
||||||
|
}
|
||||||
|
}).create()
|
||||||
|
|
||||||
|
private class SealedClassTypeAdapter<T : Any>(private val kClass: KClass<Any>, val gson: Gson) : TypeAdapter<T>() {
|
||||||
|
|
||||||
|
override fun read(jsonReader: JsonReader): T? {
|
||||||
|
jsonReader.beginObject()
|
||||||
|
val nextName = jsonReader.nextName()
|
||||||
|
val innerClass = kClass.sealedSubclasses.firstOrNull { it.simpleName == nextName }
|
||||||
|
?: throw Exception("$nextName is not a child of the sealed class ${kClass.qualifiedName}")
|
||||||
|
val x = gson.fromJson<T>(jsonReader, innerClass.javaObjectType)
|
||||||
|
jsonReader.endObject()
|
||||||
|
// if there a static object, actually return that
|
||||||
|
return innerClass.objectInstance as T? ?: x
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun write(out: JsonWriter, value: T) {
|
||||||
|
val jsonString = gson.toJson(value)
|
||||||
|
val name = value.javaClass.canonicalName
|
||||||
|
if (name != null) {
|
||||||
|
out.beginObject()
|
||||||
|
out.name(name.splitToSequence(".").last()).jsonValue(jsonString)
|
||||||
|
out.endObject()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun <reified T> Gson.fromJson(json: String): T = fromJson(json, object : TypeToken<T>() {}.type)
|
|
@ -0,0 +1,14 @@
|
||||||
|
package info.nightscout.androidaps.utils.serialisation
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
|
||||||
|
|
||||||
|
object ValueWithUnitSerialiser {
|
||||||
|
|
||||||
|
fun toSealedClassJson(list: List<XXXValueWithUnit>): String = list.map(::ValueWithUnitWrapper)
|
||||||
|
.let(SealedClassHelper.gson::toJson)
|
||||||
|
|
||||||
|
fun fromJson(string: String): List<XXXValueWithUnit> = SealedClassHelper.gson
|
||||||
|
.fromJson<List<ValueWithUnitWrapper>>(string).map { it.wrapped }
|
||||||
|
|
||||||
|
private class ValueWithUnitWrapper(val wrapped: XXXValueWithUnit)
|
||||||
|
}
|
|
@ -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>
|
||||||
|
@ -440,6 +443,7 @@
|
||||||
<string name="uel_bg_removed">BG REMOVED</string>
|
<string name="uel_bg_removed">BG REMOVED</string>
|
||||||
<string name="uel_careportal_removed">CAREPORTAL REMOVED</string>
|
<string name="uel_careportal_removed">CAREPORTAL REMOVED</string>
|
||||||
<string name="uel_extended_bolus_removed">EXTENDED BOLUS REMOVED</string>
|
<string name="uel_extended_bolus_removed">EXTENDED BOLUS REMOVED</string>
|
||||||
|
<string name="uel_food">FOOD</string>
|
||||||
<string name="uel_food_removed">FOOD REMOVED</string>
|
<string name="uel_food_removed">FOOD REMOVED</string>
|
||||||
<string name="uel_profile_removed">PROFILE REMOVED</string>
|
<string name="uel_profile_removed">PROFILE REMOVED</string>
|
||||||
<string name="uel_profile_switch_removed">PROFILE SWITCH REMOVED</string>
|
<string name="uel_profile_switch_removed">PROFILE SWITCH REMOVED</string>
|
||||||
|
@ -466,30 +470,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>
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package info.nightscout.androidaps.utils.serialisation
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
|
||||||
|
import org.junit.Assert
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
internal class ValueWithUnitSerialiserTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testSerialisationDeserization() {
|
||||||
|
|
||||||
|
val list = listOf<XXXValueWithUnit>(
|
||||||
|
XXXValueWithUnit.SimpleString("hello"),
|
||||||
|
XXXValueWithUnit.SimpleInt(5),
|
||||||
|
XXXValueWithUnit.UNKNOWN
|
||||||
|
)
|
||||||
|
|
||||||
|
val serialized = ValueWithUnitSerialiser.toSealedClassJson(list)
|
||||||
|
val deserialized = ValueWithUnitSerialiser.fromJson(serialized)
|
||||||
|
|
||||||
|
Assert.assertEquals(3, list.size)
|
||||||
|
Assert.assertEquals(list, deserialized)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testEmptyList() {
|
||||||
|
|
||||||
|
val list = listOf<XXXValueWithUnit>()
|
||||||
|
|
||||||
|
val serialized = ValueWithUnitSerialiser.toSealedClassJson(list)
|
||||||
|
val deserialized = ValueWithUnitSerialiser.fromJson(serialized)
|
||||||
|
|
||||||
|
Assert.assertEquals(0, list.size)
|
||||||
|
Assert.assertEquals(list, deserialized)
|
||||||
|
}
|
||||||
|
}
|
|
@ -39,4 +39,5 @@ dependencies {
|
||||||
|
|
||||||
implementation "com.google.dagger:dagger-android:$dagger_version"
|
implementation "com.google.dagger:dagger-android:$dagger_version"
|
||||||
implementation "com.google.dagger:dagger-android-support:$dagger_version"
|
implementation "com.google.dagger:dagger-android-support:$dagger_version"
|
||||||
|
api "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.androidaps.database
|
package info.nightscout.androidaps.database
|
||||||
|
|
||||||
import androidx.room.TypeConverter
|
import androidx.room.TypeConverter
|
||||||
|
import com.google.gson.JsonArray
|
||||||
import info.nightscout.androidaps.database.data.Block
|
import info.nightscout.androidaps.database.data.Block
|
||||||
import info.nightscout.androidaps.database.data.TargetBlock
|
import info.nightscout.androidaps.database.data.TargetBlock
|
||||||
import info.nightscout.androidaps.database.embedments.InterfaceIDs
|
import info.nightscout.androidaps.database.embedments.InterfaceIDs
|
||||||
|
@ -18,8 +19,7 @@ class Converters {
|
||||||
fun toAction(action: String?) = action?.let { Action.fromString(it) }
|
fun toAction(action: String?) = action?.let { Action.fromString(it) }
|
||||||
|
|
||||||
@TypeConverter
|
@TypeConverter
|
||||||
fun fromMutableListOfValueWithUnit(values: MutableList<ValueWithUnit>?): String? {
|
fun fromMutableListOfValueWithUnit(values: MutableList<ValueWithUnit>): String {
|
||||||
if (values == null) return null
|
|
||||||
val jsonArray = JSONArray()
|
val jsonArray = JSONArray()
|
||||||
values.forEach {
|
values.forEach {
|
||||||
if (it.condition) {
|
if (it.condition) {
|
||||||
|
@ -32,8 +32,7 @@ class Converters {
|
||||||
}
|
}
|
||||||
|
|
||||||
@TypeConverter
|
@TypeConverter
|
||||||
fun toMutableListOfValueWithUnit(jsonString: String?): MutableList<ValueWithUnit>? {
|
fun toMutableListOfValueWithUnit(jsonString: String): MutableList<ValueWithUnit> {
|
||||||
if (jsonString == null) return null
|
|
||||||
val jsonArray = JSONArray(jsonString)
|
val jsonArray = JSONArray(jsonString)
|
||||||
val list = mutableListOf<ValueWithUnit>()
|
val list = mutableListOf<ValueWithUnit>()
|
||||||
for (i in 0 until jsonArray.length()) {
|
for (i in 0 until jsonArray.length()) {
|
||||||
|
|
|
@ -16,98 +16,81 @@ data class UserEntry(
|
||||||
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 s: String,
|
var s: String,
|
||||||
|
// 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),
|
BOLUS (ColorGroup.InsulinTreatment),
|
||||||
@SerializedName("BOLUS_ADVISOR") BOLUS_ADVISOR (ColorGroup.InsulinTreatment),
|
SMB (ColorGroup.InsulinTreatment),
|
||||||
@SerializedName("BOLUS_RECORD") BOLUS_RECORD (ColorGroup.InsulinTreatment),
|
BOLUS_ADVISOR (ColorGroup.InsulinTreatment),
|
||||||
@SerializedName("EXTENDED_BOLUS") EXTENDED_BOLUS (ColorGroup.InsulinTreatment),
|
EXTENDED_BOLUS (ColorGroup.InsulinTreatment),
|
||||||
@SerializedName("SUPERBOLUS_TBR") SUPERBOLUS_TBR (ColorGroup.InsulinTreatment),
|
SUPERBOLUS_TBR (ColorGroup.InsulinTreatment),
|
||||||
@SerializedName("CARBS") CARBS (ColorGroup.CarbTreatment),
|
CARBS (ColorGroup.CarbTreatment),
|
||||||
@SerializedName("EXTENDED_CARBS") EXTENDED_CARBS (ColorGroup.CarbTreatment),
|
EXTENDED_CARBS (ColorGroup.CarbTreatment),
|
||||||
@SerializedName("TEMP_BASAL") TEMP_BASAL (ColorGroup.InsulinTreatment),
|
TEMP_BASAL (ColorGroup.InsulinTreatment),
|
||||||
@SerializedName("TT") TT (ColorGroup.TT),
|
TT (ColorGroup.TT),
|
||||||
@SerializedName("NEW_PROFILE") NEW_PROFILE (ColorGroup.Profile),
|
NEW_PROFILE (ColorGroup.Profile),
|
||||||
@SerializedName("CLONE_PROFILE") CLONE_PROFILE (ColorGroup.Profile),
|
CLONE_PROFILE (ColorGroup.Profile),
|
||||||
@SerializedName("STORE_PROFILE") STORE_PROFILE (ColorGroup.Profile),
|
STORE_PROFILE (ColorGroup.Profile),
|
||||||
@SerializedName("PROFILE_SWITCH") PROFILE_SWITCH (ColorGroup.Profile),
|
PROFILE_SWITCH (ColorGroup.Profile),
|
||||||
@SerializedName("PROFILE_SWITCH_CLONED") PROFILE_SWITCH_CLONED (ColorGroup.Profile),
|
PROFILE_SWITCH_CLONED (ColorGroup.Profile),
|
||||||
@SerializedName("CLOSED_LOOP_MODE") CLOSED_LOOP_MODE (ColorGroup.Loop),
|
CLOSED_LOOP_MODE (ColorGroup.Loop),
|
||||||
@SerializedName("LGS_LOOP_MODE") LGS_LOOP_MODE (ColorGroup.Loop),
|
LGS_LOOP_MODE (ColorGroup.Loop),
|
||||||
@SerializedName("OPEN_LOOP_MODE") OPEN_LOOP_MODE (ColorGroup.Loop),
|
OPEN_LOOP_MODE (ColorGroup.Loop),
|
||||||
@SerializedName("LOOP_DISABLED") LOOP_DISABLED (ColorGroup.Loop),
|
LOOP_DISABLED (ColorGroup.Loop),
|
||||||
@SerializedName("LOOP_ENABLED") LOOP_ENABLED (ColorGroup.Loop),
|
LOOP_ENABLED (ColorGroup.Loop),
|
||||||
@SerializedName("RECONNECT") RECONNECT (ColorGroup.Pump),
|
RECONNECT (ColorGroup.Pump),
|
||||||
@SerializedName("DISCONNECT") DISCONNECT (ColorGroup.Pump),
|
DISCONNECT (ColorGroup.Pump),
|
||||||
@SerializedName("RESUME") RESUME (ColorGroup.Loop),
|
RESUME (ColorGroup.Loop),
|
||||||
@SerializedName("SUSPEND") SUSPEND (ColorGroup.Loop),
|
SUSPEND (ColorGroup.Loop),
|
||||||
@SerializedName("HW_PUMP_ALLOWED") HW_PUMP_ALLOWED (ColorGroup.Pump),
|
HW_PUMP_ALLOWED (ColorGroup.Pump),
|
||||||
@SerializedName("CLEAR_PAIRING_KEYS") CLEAR_PAIRING_KEYS (ColorGroup.Pump),
|
CLEAR_PAIRING_KEYS (ColorGroup.Pump),
|
||||||
@SerializedName("ACCEPTS_TEMP_BASAL") ACCEPTS_TEMP_BASAL (ColorGroup.InsulinTreatment),
|
ACCEPTS_TEMP_BASAL (ColorGroup.InsulinTreatment),
|
||||||
@SerializedName("CANCEL_TEMP_BASAL") CANCEL_TEMP_BASAL (ColorGroup.InsulinTreatment),
|
CANCEL_TEMP_BASAL (ColorGroup.InsulinTreatment),
|
||||||
@SerializedName("CANCEL_EXTENDED_BOLUS") CANCEL_EXTENDED_BOLUS (ColorGroup.InsulinTreatment),
|
CANCEL_EXTENDED_BOLUS (ColorGroup.InsulinTreatment),
|
||||||
@SerializedName("CANCEL_TT") CANCEL_TT (ColorGroup.TT),
|
CANCEL_TT (ColorGroup.TT),
|
||||||
@SerializedName("CAREPORTAL") CAREPORTAL (ColorGroup.Careportal),
|
CAREPORTAL (ColorGroup.Careportal),
|
||||||
@SerializedName("CALIBRATION") CALIBRATION (ColorGroup.Careportal),
|
CALIBRATION (ColorGroup.Careportal),
|
||||||
@SerializedName("PRIME_BOLUS") PRIME_BOLUS (ColorGroup.Careportal),
|
PRIME_BOLUS (ColorGroup.Careportal),
|
||||||
@SerializedName("TREATMENT") TREATMENT (ColorGroup.InsulinTreatment),
|
TREATMENT (ColorGroup.InsulinTreatment),
|
||||||
@SerializedName("CAREPORTAL_NS_REFRESH") CAREPORTAL_NS_REFRESH (ColorGroup.Aaps),
|
CAREPORTAL_NS_REFRESH (ColorGroup.Aaps),
|
||||||
@SerializedName("PROFILE_SWITCH_NS_REFRESH") PROFILE_SWITCH_NS_REFRESH (ColorGroup.Aaps),
|
PROFILE_SWITCH_NS_REFRESH (ColorGroup.Aaps),
|
||||||
@SerializedName("TREATMENTS_NS_REFRESH") TREATMENTS_NS_REFRESH (ColorGroup.Aaps),
|
TREATMENTS_NS_REFRESH (ColorGroup.Aaps),
|
||||||
@SerializedName("TT_NS_REFRESH") TT_NS_REFRESH (ColorGroup.Aaps),
|
TT_NS_REFRESH (ColorGroup.Aaps),
|
||||||
@SerializedName("AUTOMATION_REMOVED") AUTOMATION_REMOVED (ColorGroup.Aaps),
|
AUTOMATION_REMOVED (ColorGroup.Aaps),
|
||||||
@SerializedName("BG_REMOVED") BG_REMOVED (ColorGroup.Careportal),
|
BG_REMOVED (ColorGroup.Careportal),
|
||||||
@SerializedName("CAREPORTAL_REMOVED") CAREPORTAL_REMOVED (ColorGroup.Careportal),
|
CAREPORTAL_REMOVED (ColorGroup.Careportal),
|
||||||
@SerializedName("EXTENDED_BOLUS_REMOVED") EXTENDED_BOLUS_REMOVED (ColorGroup.InsulinTreatment),
|
EXTENDED_BOLUS_REMOVED (ColorGroup.InsulinTreatment),
|
||||||
@SerializedName("FOOD_REMOVED") FOOD_REMOVED (ColorGroup.Careportal),
|
FOOD_REMOVED (ColorGroup.Careportal),
|
||||||
@SerializedName("PROFILE_REMOVED") PROFILE_REMOVED (ColorGroup.Profile),
|
PROFILE_REMOVED (ColorGroup.Profile),
|
||||||
@SerializedName("PROFILE_SWITCH_REMOVED") PROFILE_SWITCH_REMOVED (ColorGroup.Profile),
|
PROFILE_SWITCH_REMOVED (ColorGroup.Profile),
|
||||||
@SerializedName("RESTART_EVENTS_REMOVED") RESTART_EVENTS_REMOVED (ColorGroup.Aaps),
|
RESTART_EVENTS_REMOVED (ColorGroup.Aaps),
|
||||||
@SerializedName("TREATMENT_REMOVED") TREATMENT_REMOVED (ColorGroup.InsulinTreatment),
|
TREATMENT_REMOVED (ColorGroup.InsulinTreatment),
|
||||||
@SerializedName("TT_REMOVED") TT_REMOVED (ColorGroup.TT),
|
TT_REMOVED (ColorGroup.TT),
|
||||||
@SerializedName("NS_PAUSED") NS_PAUSED (ColorGroup.Aaps),
|
NS_PAUSED (ColorGroup.Aaps),
|
||||||
@SerializedName("NS_RESUME") NS_RESUME (ColorGroup.Aaps),
|
NS_RESUME (ColorGroup.Aaps),
|
||||||
@SerializedName("NS_QUEUE_CLEARED") NS_QUEUE_CLEARED (ColorGroup.Aaps),
|
NS_QUEUE_CLEARED (ColorGroup.Aaps),
|
||||||
@SerializedName("NS_SETTINGS_COPIED") NS_SETTINGS_COPIED (ColorGroup.Aaps),
|
NS_SETTINGS_COPIED (ColorGroup.Aaps),
|
||||||
@SerializedName("ERROR_DIALOG_OK") ERROR_DIALOG_OK (ColorGroup.Aaps),
|
ERROR_DIALOG_OK (ColorGroup.Aaps),
|
||||||
@SerializedName("ERROR_DIALOG_MUTE") ERROR_DIALOG_MUTE (ColorGroup.Aaps),
|
ERROR_DIALOG_MUTE (ColorGroup.Aaps),
|
||||||
@SerializedName("ERROR_DIALOG_MUTE_5MIN") ERROR_DIALOG_MUTE_5MIN (ColorGroup.Aaps),
|
ERROR_DIALOG_MUTE_5MIN (ColorGroup.Aaps),
|
||||||
@SerializedName("OBJECTIVE_STARTED") OBJECTIVE_STARTED (ColorGroup.Aaps),
|
OBJECTIVE_STARTED (ColorGroup.Aaps),
|
||||||
@SerializedName("OBJECTIVE_UNSTARTED") OBJECTIVE_UNSTARTED (ColorGroup.Aaps),
|
OBJECTIVE_UNSTARTED (ColorGroup.Aaps),
|
||||||
@SerializedName("OBJECTIVES_SKIPPED") OBJECTIVES_SKIPPED (ColorGroup.Aaps),
|
OBJECTIVES_SKIPPED (ColorGroup.Aaps),
|
||||||
@SerializedName("STAT_RESET") STAT_RESET (ColorGroup.Aaps),
|
STAT_RESET (ColorGroup.Aaps),
|
||||||
@SerializedName("DELETE_LOGS") DELETE_LOGS (ColorGroup.Aaps),
|
DELETE_LOGS (ColorGroup.Aaps),
|
||||||
@SerializedName("DELETE_FUTURE_TREATMENTS") DELETE_FUTURE_TREATMENTS (ColorGroup.Aaps),
|
DELETE_FUTURE_TREATMENTS (ColorGroup.Aaps),
|
||||||
@SerializedName("EXPORT_SETTINGS") EXPORT_SETTINGS (ColorGroup.Aaps),
|
EXPORT_SETTINGS (ColorGroup.Aaps),
|
||||||
@SerializedName("IMPORT_SETTINGS") IMPORT_SETTINGS (ColorGroup.Aaps),
|
IMPORT_SETTINGS (ColorGroup.Aaps),
|
||||||
@SerializedName("RESET_DATABASES") RESET_DATABASES (ColorGroup.Aaps),
|
RESET_DATABASES (ColorGroup.Aaps),
|
||||||
@SerializedName("EXPORT_DATABASES") EXPORT_DATABASES (ColorGroup.Aaps),
|
EXPORT_DATABASES (ColorGroup.Aaps),
|
||||||
@SerializedName("IMPORT_DATABASES") IMPORT_DATABASES (ColorGroup.Aaps),
|
IMPORT_DATABASES (ColorGroup.Aaps),
|
||||||
@SerializedName("OTP_EXPORT") OTP_EXPORT (ColorGroup.Aaps),
|
OTP_EXPORT (ColorGroup.Aaps),
|
||||||
@SerializedName("OTP_RESET") OTP_RESET (ColorGroup.Aaps),
|
OTP_RESET (ColorGroup.Aaps),
|
||||||
@SerializedName("SMS_BASAL") SMS_BASAL (ColorGroup.InsulinTreatment),
|
STOP_SMS (ColorGroup.Aaps),
|
||||||
@SerializedName("SMS_BOLUS") SMS_BOLUS (ColorGroup.InsulinTreatment),
|
FOOD (ColorGroup.Careportal),
|
||||||
@SerializedName("SMS_CAL") SMS_CAL (ColorGroup.Careportal),
|
EXPORT_CSV (ColorGroup.Aaps),
|
||||||
@SerializedName("SMS_CARBS") SMS_CARBS (ColorGroup.CarbTreatment),
|
UNKNOWN (ColorGroup.Aaps)
|
||||||
@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("UNKNOWN") UNKNOWN (ColorGroup.Aaps)
|
|
||||||
;
|
;
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -119,8 +102,8 @@ data class UserEntry(
|
||||||
constructor(ivalue: Int, unit: Units, condition:Boolean = true) : this(0.0, ivalue, 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(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(svalue: String, unit:Units) : this(0.0,0, 0, svalue, unit, svalue != "")
|
||||||
constructor(svalue: TherapyEvent.Type, unit:Units) : this(0.0,0, 0, svalue.text, unit)
|
constructor(source: Sources) : this(0.0,0, 0, source.name, Units.Source, true)
|
||||||
constructor(dvalue: Double, unit:String) : this(dvalue,0, 0, "", Units.fromText(unit))
|
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
|
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 {
|
||||||
|
@ -131,18 +114,20 @@ data class UserEntry(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
enum class Units(val text: String) {
|
enum class Units(val text: String) {
|
||||||
@SerializedName("None") None (""), //Int or String
|
None (""), //Int or String
|
||||||
@SerializedName("Mg_Dl") Mg_Dl ("mg/dl"), //Double
|
Mg_Dl ("mg/dl"), //Double
|
||||||
@SerializedName("Mmol_L") Mmol_L ("mmol"), //Double
|
Mmol_L ("mmol"), //Double
|
||||||
@SerializedName("Timestamp") Timestamp("Timestamp"), //long
|
Timestamp("Timestamp"), //long
|
||||||
@SerializedName("U") U ("U"), //Double
|
U ("U"), //Double
|
||||||
@SerializedName("U_H") U_H ("U/h"), //Double
|
U_H ("U/h"), //Double
|
||||||
@SerializedName("G") G ("g"), //Int
|
G ("g"), //Int
|
||||||
@SerializedName("M") M ("m"), //Int
|
M ("m"), //Int
|
||||||
@SerializedName("H") H ("h"), //Int
|
H ("h"), //Int
|
||||||
@SerializedName("Percent") Percent ("%"), //Int
|
Percent ("%"), //Int
|
||||||
@SerializedName("TherapyEvent") TherapyEvent ("TherapyEvent"), //String (All enum key translated by Translator function, mainly TherapyEvent)
|
TherapyEvent ("TherapyEvent"), //String (All enum key translated by Translator function, mainly The
|
||||||
@SerializedName("R_String") R_String ("R.string") //Int
|
R_String ("R.string"), //Int
|
||||||
|
Source ("Source") //String
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -150,6 +135,44 @@ 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() {
|
||||||
|
TreatmentDialog,
|
||||||
|
InsulinDialog,
|
||||||
|
CarbDialog,
|
||||||
|
WizardDialog,
|
||||||
|
QuickWizard,
|
||||||
|
ExtendedBolusDialog,
|
||||||
|
TTDialog,
|
||||||
|
ProfileSwitchDialog,
|
||||||
|
LoopDialog,
|
||||||
|
TempBasalDialog,
|
||||||
|
CalibrationDialog,
|
||||||
|
FillDialog,
|
||||||
|
BgCheck,
|
||||||
|
SensorInsert,
|
||||||
|
BatteryChange,
|
||||||
|
Note,
|
||||||
|
Exercise,
|
||||||
|
Question,
|
||||||
|
Announcement,
|
||||||
|
Actions, //From Actions plugin
|
||||||
|
Automation, //From Automation plugin
|
||||||
|
LocalProfile, //From LocalProfile plugin
|
||||||
|
Loop, //From Loop plugin
|
||||||
|
Maintenance, //From Maintenance plugin
|
||||||
|
NSClient, //From NSClient plugin
|
||||||
|
Pump, //From Pump plugin
|
||||||
|
SMS, //From SMS plugin
|
||||||
|
Treatments, //From Treatments plugin
|
||||||
|
Wear, //From Wear plugin
|
||||||
|
Food, //From Food plugin
|
||||||
|
Unknown //if necessary
|
||||||
|
;
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun fromString(source: String?) = values().firstOrNull { it.name == source } ?: Unknown
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enum class ColorGroup() {
|
enum class ColorGroup() {
|
||||||
InsulinTreatment,
|
InsulinTreatment,
|
||||||
|
@ -161,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.fromString(v.sValue).equals(Sources.Loop)) result = true
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
package info.nightscout.androidaps.database.entities
|
||||||
|
|
||||||
|
import androidx.annotation.StringRes
|
||||||
|
|
||||||
|
sealed class XXXValueWithUnit {
|
||||||
|
|
||||||
|
object UNKNOWN : XXXValueWithUnit() // formerly None used as fallback
|
||||||
|
|
||||||
|
data class SimpleString(val value: String) : XXXValueWithUnit() // formerly one usage of None
|
||||||
|
|
||||||
|
data class SimpleInt(val value: Int) : XXXValueWithUnit() // formerly one usage of None
|
||||||
|
|
||||||
|
class Mgdl(val value: Double) : XXXValueWithUnit()
|
||||||
|
|
||||||
|
class Mmoll(val value: Double) : XXXValueWithUnit()
|
||||||
|
|
||||||
|
class Timestamp(val value: Long) : XXXValueWithUnit()
|
||||||
|
|
||||||
|
class Insulin(val value: Double) : XXXValueWithUnit()
|
||||||
|
|
||||||
|
class UnitPerHour(val value: Double) : XXXValueWithUnit()
|
||||||
|
|
||||||
|
class Gram(val value: Int) : XXXValueWithUnit()
|
||||||
|
|
||||||
|
class Minute(val value: Int) : XXXValueWithUnit()
|
||||||
|
|
||||||
|
class Hour(val value: Int) : XXXValueWithUnit()
|
||||||
|
|
||||||
|
class Percent(val value: Int) : XXXValueWithUnit()
|
||||||
|
|
||||||
|
class TherapyEventType(val value: TherapyEvent.Type) : XXXValueWithUnit()
|
||||||
|
|
||||||
|
class TherapyEventMeterType(val value: TherapyEvent.MeterType) : XXXValueWithUnit()
|
||||||
|
|
||||||
|
class TherapyEventTTReason(val value: TemporaryTarget.Reason) : XXXValueWithUnit()
|
||||||
|
|
||||||
|
class StringResource(@StringRes val value: Int, val params: List<XXXValueWithUnit> = listOf()) : XXXValueWithUnit()
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
fun fromGlucoseUnit(value: Double, string: String): XXXValueWithUnit? = when (string) {
|
||||||
|
"mg/dl", "mgdl" -> Mgdl(value)
|
||||||
|
"mmol", "mmol/l" -> Mmoll(value)
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
* Idea: Leverage sealed classes for units
|
||||||
|
* Advantage: it is clear what type of data a Unit contains. Still we are exhaustive on when
|
||||||
|
*
|
||||||
|
* The condition "condition" that is used to check if an item should be logged can be replaced by .takeIf { condition }.
|
||||||
|
* The value then would not have to be handled but the logging could simply discard null value.
|
||||||
|
*
|
||||||
|
* [x] new sealed classes
|
||||||
|
* [x] use entry type directly, not String
|
||||||
|
* [ ] database
|
||||||
|
* [x] generate presentation string
|
||||||
|
* [ ] update fragment
|
||||||
|
* [ ] generate csv
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
// just do develop in this file. Remove when done.
|
||||||
|
/*
|
||||||
|
interface Translator {
|
||||||
|
|
||||||
|
fun translate(units: UserEntry.Units): String
|
||||||
|
fun translate(meterType: TherapyEvent.MeterType): String
|
||||||
|
fun translate(type: TherapyEvent.Type): String
|
||||||
|
fun translate(reason: TemporaryTarget.Reason): String
|
||||||
|
}
|
||||||
|
*/
|
Loading…
Reference in a new issue