idea: value with unit as sealed class

This commit is contained in:
AdrianLxM 2021-03-25 02:24:26 +01:00
parent 906fc35da5
commit 2da872bbfe
33 changed files with 535 additions and 247 deletions

View file

@ -2,6 +2,22 @@
<code_scheme name="Project" version="173">
<option name="AUTODETECT_INDENTS" value="false" />
<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="NAME_COUNT_TO_USE_STAR_IMPORT" value="6" />
<option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" value="6" />

View file

@ -9,6 +9,7 @@ import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.DialogCalibrationBinding
import info.nightscout.androidaps.interfaces.ProfileFunction
@ -79,7 +80,7 @@ class CalibrationDialog : DialogFragmentWithDate() {
if (bg > 0) {
activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_calibration), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
uel.log(Action.CALIBRATION, ValueWithUnit(bg, units))
uel.log(Action.CALIBRATION, XXXValueWithUnit.fromGlucoseUnit(bg, units))
xdripCalibrations.sendIntent(bg)
})
}

View file

@ -12,6 +12,7 @@ import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.Profile
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.TherapyEvent
import info.nightscout.androidaps.database.entities.UserEntry.*
@ -222,7 +223,7 @@ class CarbsDialog : DialogFragmentWithDate() {
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.carbs), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
when {
activitySelected -> {
uel.log(Action.TT, ValueWithUnit(TemporaryTarget.Reason.ACTIVITY.text, Units.TherapyEvent), ValueWithUnit(activityTT, units) , ValueWithUnit(activityTTDuration, Units.M))
uel.log(Action.TT, XXXValueWithUnit.TherapyEvent(TemporaryTarget.Reason.ACTIVITY.text), XXXValueWithUnit.fromGlucoseUnit(activityTT, units) , XXXValueWithUnit.Minute(activityTTDuration))
disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
timestamp = System.currentTimeMillis(),
duration = TimeUnit.MINUTES.toMillis(activityTTDuration.toLong()),
@ -238,7 +239,7 @@ class CarbsDialog : DialogFragmentWithDate() {
}
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.TherapyEvent(TemporaryTarget.Reason.EATING_SOON.text), XXXValueWithUnit.fromGlucoseUnit(eatingSoonTT, units) , XXXValueWithUnit.Minute(eatingSoonTTDuration))
disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
timestamp = System.currentTimeMillis(),
duration = TimeUnit.MINUTES.toMillis(eatingSoonTTDuration.toLong()),
@ -254,7 +255,7 @@ class CarbsDialog : DialogFragmentWithDate() {
}
hypoSelected -> {
uel.log(Action.TT, ValueWithUnit(TemporaryTarget.Reason.HYPOGLYCEMIA.text, Units.TherapyEvent), ValueWithUnit(hypoTT, units) , ValueWithUnit(hypoTTDuration, Units.M))
uel.log(Action.TT, XXXValueWithUnit.TherapyEvent(TemporaryTarget.Reason.HYPOGLYCEMIA.text), XXXValueWithUnit.fromGlucoseUnit(hypoTT, units) , XXXValueWithUnit.Minute(hypoTTDuration))
disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
timestamp = System.currentTimeMillis(),
duration = TimeUnit.MINUTES.toMillis(hypoTTDuration.toLong()),
@ -276,7 +277,7 @@ class CarbsDialog : DialogFragmentWithDate() {
carbsGenerator.generateCarbs(carbsAfterConstraints, time, duration, notes)
nsUpload.uploadEvent(TherapyEvent.Type.NOTE.text, DateUtil.now() - 2000, resourceHelper.gs(R.string.generated_ecarbs_note, carbsAfterConstraints, duration, timeOffset))
}
uel.log(Action.CARBS, notes, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged), ValueWithUnit(carbsAfterConstraints, Units.G), ValueWithUnit(timeOffset, Units.M, timeOffset != 0), ValueWithUnit(duration, Units.H, duration != 0))
uel.log(Action.CARBS, notes, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, XXXValueWithUnit.Gram(carbsAfterConstraints), XXXValueWithUnit.Minute(timeOffset).takeIf { timeOffset != 0 }, XXXValueWithUnit.Hour(duration).takeIf { duration != 0 })
}
if (useAlarm && carbs > 0 && timeOffset > 0) {
carbTimer.scheduleReminder(dateUtil._now() + T.mins(timeOffset.toLong()).msecs())

View file

@ -14,6 +14,7 @@ import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.Profile
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.transactions.InsertTherapyEventIfNewTransaction
import info.nightscout.androidaps.database.entities.UserEntry.*
@ -60,7 +61,7 @@ class CareDialog : DialogFragmentWithDate() {
}
private var options: EventType = EventType.BGCHECK
private var valuesWithUnit = mutableListOf<ValueWithUnit>()
private var valuesWithUnit = mutableListOf<XXXValueWithUnit?>()
@StringRes
private var event: Int = R.string.none
@ -198,17 +199,17 @@ class CareDialog : DialogFragmentWithDate() {
binding.sensor.isChecked -> TherapyEvent.MeterType.SENSOR
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))
therapyEvent.glucoseType = meterType
therapyEvent.glucose = binding.bg.value
valuesWithUnit.add(ValueWithUnit(binding.bg.value.toDouble(), profileFunction.getUnits()))
valuesWithUnit.add(ValueWithUnit(meterType.text, Units.TherapyEvent))
valuesWithUnit.add(XXXValueWithUnit.fromGlucoseUnit(binding.bg.value.toDouble(), profileFunction.getUnits()))
valuesWithUnit.add(XXXValueWithUnit.TherapyEvent(meterType.text))
}
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()))
therapyEvent.duration = T.mins(binding.duration.value.toLong()).msecs()
valuesWithUnit.add(ValueWithUnit(binding.duration.value.toInt(), Units.M, !binding.duration.value.equals(0.0)))
valuesWithUnit.add(XXXValueWithUnit.Minute(binding.duration.value.toInt()).takeIf { !binding.duration.value.equals(0.0) })
}
val notes = binding.notesLayout.notes.text.toString()
if (notes.isNotEmpty()) {
@ -227,8 +228,8 @@ class CareDialog : DialogFragmentWithDate() {
}, {
aapsLogger.error(LTag.BGSOURCE, "Error while saving therapy event", it)
})
valuesWithUnit.add(0, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged))
valuesWithUnit.add(1, ValueWithUnit(therapyEvent.type.text, Units.TherapyEvent))
valuesWithUnit.add(0, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged })
valuesWithUnit.add(1, XXXValueWithUnit.TherapyEvent(therapyEvent.type.text))
uel.log(Action.CAREPORTAL, notes, valuesWithUnit)
}, null)
}

View file

@ -8,6 +8,7 @@ import android.view.ViewGroup
import com.google.common.base.Joiner
import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.DialogExtendedbolusBinding
import info.nightscout.androidaps.interfaces.ActivePluginProvider
@ -88,7 +89,7 @@ class ExtendedBolusDialog : DialogFragmentWithDate() {
activity?.let { activity ->
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))
commandQueue.extendedBolus(insulinAfterConstraint, durationInMinutes, object : Callback() {
override fun run() {
if (!result.success) {

View file

@ -10,6 +10,7 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
import info.nightscout.androidaps.database.entities.TherapyEvent
import info.nightscout.androidaps.database.transactions.InsertTherapyEventIfNewTransaction
import info.nightscout.androidaps.database.entities.UserEntry.*
@ -124,7 +125,7 @@ class FillDialog : DialogFragmentWithDate() {
val insulinChange = binding.fillCartridgeChange.isChecked
if (insulinChange)
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())
actions.add(resourceHelper.gs(R.string.notes_label) + ": " + notes)
eventTime -= eventTime % 1000
@ -136,11 +137,11 @@ class FillDialog : DialogFragmentWithDate() {
activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.primefill), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
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 })
requestPrimeBolus(insulinAfterConstraints, notes)
}
if (siteChange) {
uel.log(Action.CAREPORTAL, notes, ValueWithUnit(TherapyEvent.Type.CANNULA_CHANGE.text, Units.TherapyEvent))
uel.log(Action.CAREPORTAL, notes, XXXValueWithUnit.TherapyEvent(TherapyEvent.Type.CANNULA_CHANGE.text))
disposable += repository.runTransactionForResult(InsertTherapyEventIfNewTransaction(
timestamp = eventTime,
type = TherapyEvent.Type.CANNULA_CHANGE,
@ -154,7 +155,7 @@ class FillDialog : DialogFragmentWithDate() {
}
if (insulinChange) {
// 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.TherapyEvent(TherapyEvent.Type.INSULIN_CHANGE.text))
disposable += repository.runTransactionForResult(InsertTherapyEventIfNewTransaction(
timestamp = eventTime + 1000,
type = TherapyEvent.Type.INSULIN_CHANGE,

View file

@ -15,6 +15,7 @@ import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
import info.nightscout.androidaps.database.entities.TemporaryTarget
import info.nightscout.androidaps.database.entities.TherapyEvent
import info.nightscout.androidaps.database.entities.UserEntry.*
@ -189,7 +190,7 @@ class InsulinDialog : DialogFragmentWithDate() {
activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.bolus), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
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.TherapyEvent(TemporaryTarget.Reason.EATING_SOON.text), XXXValueWithUnit.fromGlucoseUnit(eatingSoonTT, units), XXXValueWithUnit.Minute(eatingSoonTTDuration))
disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
timestamp = System.currentTimeMillis(),
duration = TimeUnit.MINUTES.toMillis(eatingSoonTTDuration.toLong()),
@ -211,11 +212,11 @@ class InsulinDialog : DialogFragmentWithDate() {
detailedBolusInfo.source = Source.USER
detailedBolusInfo.notes = notes
if (recordOnlyChecked) {
uel.log(Action.BOLUS_RECORD, notes, ValueWithUnit(insulinAfterConstraints, Units.U), ValueWithUnit(timeOffset, Units.M, timeOffset!= 0))
uel.log(Action.BOLUS_RECORD, notes, XXXValueWithUnit.Insulin(insulinAfterConstraints), XXXValueWithUnit.Minute(timeOffset).takeIf { timeOffset!= 0 })
detailedBolusInfo.date = time
activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false)
} else {
uel.log(Action.BOLUS, notes, ValueWithUnit(insulinAfterConstraints, Units.U))
uel.log(Action.BOLUS, notes, XXXValueWithUnit.Insulin(insulinAfterConstraints))
detailedBolusInfo.date = DateUtil.now()
commandQueue.bolus(detailedBolusInfo, object : Callback() {
override fun run() {

View file

@ -12,6 +12,7 @@ import androidx.fragment.app.FragmentManager
import dagger.android.support.DaggerDialogFragment
import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.DialogLoopBinding
import info.nightscout.androidaps.events.EventPreferenceChange
@ -287,7 +288,7 @@ class LoopDialog : DaggerDialogFragment() {
}
R.id.overview_resume, R.id.overview_reconnect -> {
uel.log(if (v.id==R.id.overview_resume) Action.RESUME else Action.RECONNECT )
uel.log(if (v.id == R.id.overview_resume) Action.RESUME else Action.RECONNECT )
loopPlugin.suspendTo(0L)
rxBus.send(EventRefreshOverview("suspendmenu"))
commandQueue.cancelTempBasal(true, object : Callback() {
@ -303,49 +304,49 @@ class LoopDialog : DaggerDialogFragment() {
}
R.id.overview_suspend_1h -> {
uel.log(Action.SUSPEND, ValueWithUnit(1, Units.H))
uel.log(Action.SUSPEND, XXXValueWithUnit.Hour(1))
loopPlugin.suspendLoop(60)
rxBus.send(EventRefreshOverview("suspendmenu"))
return true
}
R.id.overview_suspend_2h -> {
uel.log(Action.SUSPEND, ValueWithUnit(2, Units.H))
uel.log(Action.SUSPEND, XXXValueWithUnit.Hour(2))
loopPlugin.suspendLoop(120)
rxBus.send(EventRefreshOverview("suspendmenu"))
return true
}
R.id.overview_suspend_3h -> {
uel.log(Action.SUSPEND, ValueWithUnit(3, Units.H))
uel.log(Action.SUSPEND, XXXValueWithUnit.Hour(3))
loopPlugin.suspendLoop(180)
rxBus.send(EventRefreshOverview("suspendmenu"))
return true
}
R.id.overview_suspend_10h -> {
uel.log(Action.SUSPEND, ValueWithUnit(10, Units.H))
uel.log(Action.SUSPEND, XXXValueWithUnit.Hour(10))
loopPlugin.suspendLoop(600)
rxBus.send(EventRefreshOverview("suspendmenu"))
return true
}
R.id.overview_disconnect_15m -> {
uel.log(Action.DISCONNECT, ValueWithUnit(15, Units.M))
uel.log(Action.DISCONNECT, XXXValueWithUnit.Minute(15))
loopPlugin.disconnectPump(15, profile)
rxBus.send(EventRefreshOverview("suspendmenu"))
return true
}
R.id.overview_disconnect_30m -> {
uel.log(Action.DISCONNECT, ValueWithUnit(30, Units.M))
uel.log(Action.DISCONNECT, XXXValueWithUnit.Minute(30))
loopPlugin.disconnectPump(30, profile)
rxBus.send(EventRefreshOverview("suspendmenu"))
return true
}
R.id.overview_disconnect_1h -> {
uel.log(Action.DISCONNECT, ValueWithUnit(1, Units.H))
uel.log(Action.DISCONNECT, XXXValueWithUnit.Hour(1))
loopPlugin.disconnectPump(60, profile)
sp.putBoolean(R.string.key_objectiveusedisconnect, true)
rxBus.send(EventRefreshOverview("suspendmenu"))
@ -353,14 +354,14 @@ class LoopDialog : DaggerDialogFragment() {
}
R.id.overview_disconnect_2h -> {
uel.log(Action.DISCONNECT, ValueWithUnit(2, Units.H))
uel.log(Action.DISCONNECT, XXXValueWithUnit.Hour(2))
loopPlugin.disconnectPump(120, profile)
rxBus.send(EventRefreshOverview("suspendmenu"))
return true
}
R.id.overview_disconnect_3h -> {
uel.log(Action.DISCONNECT, ValueWithUnit(3, Units.H))
uel.log(Action.DISCONNECT, XXXValueWithUnit.Hour(3))
loopPlugin.disconnectPump(180, profile)
rxBus.send(EventRefreshOverview("suspendmenu"))
return true

View file

@ -8,6 +8,7 @@ import android.widget.ArrayAdapter
import com.google.common.base.Joiner
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.DialogProfileswitchBinding
import info.nightscout.androidaps.interfaces.ActivePluginProvider
@ -125,7 +126,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
activity?.let { activity ->
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 })
treatmentsPlugin.doProfileSwitch(profileStore, profile, duration, percent, timeShift, eventTime)
})
}

View file

@ -8,6 +8,7 @@ import android.view.ViewGroup
import com.google.common.base.Joiner
import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.DialogTempbasalBinding
import info.nightscout.androidaps.interfaces.ActivePluginProvider
@ -126,10 +127,10 @@ class TempBasalDialog : DialogFragmentWithDate() {
}
}
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))
commandQueue.tempBasalPercent(percent, durationInMinutes, true, profile, callback)
} 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))
commandQueue.tempBasalAbsolute(absolute, durationInMinutes, true, profile, callback)
}
})

View file

@ -12,6 +12,7 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.database.AppRepository
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.UserEntry.*
import info.nightscout.androidaps.database.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
@ -181,11 +182,11 @@ class TempTargetDialog : DialogFragmentWithDate() {
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
val units = profileFunction.getUnits()
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.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.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.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.stoptemptarget) -> uel.log(Action.CANCEL_TT, ValueWithUnit(eventTime, Units.Timestamp, eventTimeChanged))
resourceHelper.gs(R.string.eatingsoon) -> uel.log(Action.TT, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, XXXValueWithUnit.TherapyEvent(TemporaryTarget.Reason.EATING_SOON.text), XXXValueWithUnit.fromGlucoseUnit(target, units), XXXValueWithUnit.Minute(duration))
resourceHelper.gs(R.string.activity) -> uel.log(Action.TT, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, XXXValueWithUnit.TherapyEvent(TemporaryTarget.Reason.ACTIVITY.text), XXXValueWithUnit.fromGlucoseUnit(target, units), XXXValueWithUnit.Minute(duration))
resourceHelper.gs(R.string.hypo) -> uel.log(Action.TT, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, XXXValueWithUnit.TherapyEvent(TemporaryTarget.Reason.HYPOGLYCEMIA.text), XXXValueWithUnit.fromGlucoseUnit(target, units), XXXValueWithUnit.Minute(duration))
resourceHelper.gs(R.string.manual) -> uel.log(Action.TT, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged }, XXXValueWithUnit.TherapyEvent(TemporaryTarget.Reason.CUSTOM.text), XXXValueWithUnit.fromGlucoseUnit(target, units), XXXValueWithUnit.Minute(duration))
resourceHelper.gs(R.string.stoptemptarget) -> uel.log(Action.CANCEL_TT, XXXValueWithUnit.Timestamp(eventTime).takeIf { eventTimeChanged })
}
if (target == 0.0 || duration == 0) {
disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(eventTime))

View file

@ -12,6 +12,7 @@ import info.nightscout.androidaps.Config
import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
import info.nightscout.androidaps.database.entities.TherapyEvent
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.DialogTreatmentBinding
@ -130,7 +131,7 @@ class TreatmentDialog : DialogFragmentWithDate() {
if (insulinAfterConstraints > 0 || carbsAfterConstraints > 0) {
activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_treatment_label), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), {
uel.log(Action.TREATMENT, ValueWithUnit(insulin, Units.U, insulin != 0.0), ValueWithUnit(carbs, Units.G, carbs != 0))
uel.log(Action.TREATMENT, XXXValueWithUnit.Insulin(insulin ).takeIf { insulin != 0.0 }, XXXValueWithUnit.Gram(carbs).takeIf { carbs != 0 })
val detailedBolusInfo = DetailedBolusInfo()
if (insulinAfterConstraints == 0.0) detailedBolusInfo.eventType = TherapyEvent.Type.CARBS_CORRECTION.text
if (carbsAfterConstraints == 0) detailedBolusInfo.eventType = TherapyEvent.Type.CORRECTION_BOLUS.text

View file

@ -17,7 +17,8 @@ import androidx.recyclerview.widget.LinearSmoothScroller
import androidx.recyclerview.widget.RecyclerView
import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
import info.nightscout.androidaps.database.entities.UserEntry.Action
import info.nightscout.androidaps.databinding.ObjectivesFragmentBinding
import info.nightscout.androidaps.databinding.ObjectivesItemBinding
import info.nightscout.androidaps.dialogs.NtpProgressDialog
@ -35,11 +36,11 @@ import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.HtmlHelper
import info.nightscout.androidaps.utils.SntpClient
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import io.reactivex.rxkotlin.plusAssign
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.rx.AapsSchedulers
import info.nightscout.androidaps.utils.sharedPreferences.SP
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.rxkotlin.plusAssign
import javax.inject.Inject
class ObjectivesFragment : DaggerFragment() {
@ -308,7 +309,7 @@ class ObjectivesFragment : DaggerFragment() {
holder.binding.unstart.setOnClickListener {
activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.objectives), resourceHelper.gs(R.string.doyouwantresetstart), Runnable {
uel.log(Action.OBJECTIVE_UNSTARTED, ValueWithUnit(position + 1, Units.None))
uel.log(Action.OBJECTIVE_UNSTARTED, XXXValueWithUnit.SimpleInt(position + 1))
objective.startedOn = 0
scrollToCurrentObjective()
rxBus.send(EventObjectivesUpdateGui())

View file

@ -6,9 +6,9 @@ import androidx.work.WorkerParameters
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
import info.nightscout.androidaps.database.entities.TherapyEvent
import info.nightscout.androidaps.database.entities.UserEntry
import info.nightscout.androidaps.database.entities.UserEntry.ValueWithUnit
import info.nightscout.androidaps.database.transactions.SyncTemporaryTargetTransaction
import info.nightscout.androidaps.database.transactions.SyncTherapyEventTransaction
import info.nightscout.androidaps.events.EventNsTreatment
@ -85,28 +85,28 @@ class NSClientAddUpdateWorker(
}
.blockingGet()
.also { result ->
result.inserted.forEach {
result.inserted.forEach { tt ->
uel.log(UserEntry.Action.TT_FROM_NS,
ValueWithUnit(it.reason.text, UserEntry.Units.TherapyEvent),
ValueWithUnit(it.lowTarget, UserEntry.Units.Mg_Dl, true),
ValueWithUnit(it.highTarget, UserEntry.Units.Mg_Dl, it.lowTarget != it.highTarget),
ValueWithUnit(it.duration.toInt() / 60000, UserEntry.Units.M, true)
XXXValueWithUnit.TherapyEvent(tt.reason.text),
XXXValueWithUnit.Mgdl(tt.lowTarget),
XXXValueWithUnit.Mgdl(tt.highTarget).takeIf { tt.lowTarget != tt.highTarget },
XXXValueWithUnit.Minute(tt.duration.toInt() / 60000)
)
}
result.invalidated.forEach {
result.invalidated.forEach { tt ->
uel.log(UserEntry.Action.TT_DELETED_FROM_NS,
ValueWithUnit(it.reason.text, UserEntry.Units.TherapyEvent),
ValueWithUnit(it.lowTarget, UserEntry.Units.Mg_Dl, true),
ValueWithUnit(it.highTarget, UserEntry.Units.Mg_Dl, it.lowTarget != it.highTarget),
ValueWithUnit(it.duration.toInt() / 60000, UserEntry.Units.M, true)
XXXValueWithUnit.TherapyEvent(tt.reason.text),
XXXValueWithUnit.Mgdl(tt.lowTarget),
XXXValueWithUnit.Mgdl(tt.highTarget).takeIf { tt.lowTarget != tt.highTarget },
XXXValueWithUnit.Minute(tt.duration.toInt() / 60000)
)
}
result.ended.forEach {
result.ended.forEach { tt ->
uel.log(UserEntry.Action.TT_CANCELED_FROM_NS,
ValueWithUnit(it.reason.text, UserEntry.Units.TherapyEvent),
ValueWithUnit(it.lowTarget, UserEntry.Units.Mg_Dl, true),
ValueWithUnit(it.highTarget, UserEntry.Units.Mg_Dl, it.lowTarget != it.highTarget),
ValueWithUnit(it.duration.toInt() / 60000, UserEntry.Units.M, true)
XXXValueWithUnit.TherapyEvent(tt.reason.text),
XXXValueWithUnit.Mgdl(tt.lowTarget),
XXXValueWithUnit.Mgdl(tt.highTarget).takeIf { tt.lowTarget != tt.highTarget },
XXXValueWithUnit.Minute(tt.duration.toInt() / 60000)
)
}
}
@ -133,15 +133,15 @@ class NSClientAddUpdateWorker(
result.inserted.forEach {
uel.log(UserEntry.Action.CAREPORTAL_FROM_NS,
it.note ?: "",
ValueWithUnit(it.timestamp, UserEntry.Units.Timestamp, true),
ValueWithUnit(it.type.text, UserEntry.Units.TherapyEvent)
XXXValueWithUnit.Timestamp(it.timestamp),
XXXValueWithUnit.TherapyEvent(it.type.text)
)
}
result.invalidated.forEach {
uel.log(UserEntry.Action.CAREPORTAL_DELETED_FROM_NS,
it.note ?: "",
ValueWithUnit(it.timestamp, UserEntry.Units.Timestamp, true),
ValueWithUnit(it.type.text, UserEntry.Units.TherapyEvent)
XXXValueWithUnit.Timestamp(it.timestamp),
XXXValueWithUnit.TherapyEvent(it.type.text)
)
}
}

View file

@ -33,7 +33,6 @@ import info.nightscout.androidaps.database.entities.TemporaryTarget;
import info.nightscout.androidaps.database.entities.TherapyEvent;
import info.nightscout.androidaps.database.entities.UserEntry.Action;
import info.nightscout.androidaps.database.entities.UserEntry.Units;
import info.nightscout.androidaps.database.entities.UserEntry.ValueWithUnit;
import info.nightscout.androidaps.database.transactions.SyncTemporaryTargetTransaction;
import info.nightscout.androidaps.database.transactions.SyncTherapyEventTransaction;
import info.nightscout.androidaps.events.EventAppExit;

View file

@ -6,8 +6,8 @@ import androidx.work.WorkerParameters
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
import info.nightscout.androidaps.database.entities.UserEntry
import info.nightscout.androidaps.database.entities.UserEntry.ValueWithUnit
import info.nightscout.androidaps.database.transactions.SyncTemporaryTargetTransaction
import info.nightscout.androidaps.database.transactions.SyncTherapyEventTransaction
import info.nightscout.androidaps.events.EventNsTreatment
@ -66,13 +66,13 @@ class NSClientRemoveWorker(
}
.blockingGet()
.also { result ->
result.invalidated.forEach {
result.invalidated.forEach { tt ->
uel.log(
UserEntry.Action.TT_DELETED_FROM_NS,
ValueWithUnit(it.reason.text, UserEntry.Units.TherapyEvent),
ValueWithUnit(it.lowTarget, UserEntry.Units.Mg_Dl, true),
ValueWithUnit(it.highTarget, UserEntry.Units.Mg_Dl, it.lowTarget != it.highTarget),
ValueWithUnit(it.duration.toInt() / 60000, UserEntry.Units.M, it.duration != 0L)
XXXValueWithUnit.TherapyEvent(tt.reason.text),
XXXValueWithUnit.Mgdl(tt.lowTarget),
XXXValueWithUnit.Mgdl(tt.highTarget).takeIf { tt.lowTarget != tt.highTarget },
XXXValueWithUnit.Minute(tt.duration.toInt() / 60000).takeIf { tt.duration != 0L }
)
}
}
@ -89,8 +89,8 @@ class NSClientRemoveWorker(
result.invalidated.forEach {
uel.log(
UserEntry.Action.CAREPORTAL_DELETED_FROM_NS, (it.note ?: ""),
ValueWithUnit(it.timestamp, UserEntry.Units.Timestamp, true),
ValueWithUnit(it.type.text, UserEntry.Units.TherapyEvent))
XXXValueWithUnit.Timestamp(it.timestamp),
XXXValueWithUnit.TherapyEvent(it.type.text))
}
}

View file

@ -16,6 +16,7 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.data.Profile
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.UserEntry.*
import info.nightscout.androidaps.database.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
@ -40,7 +41,6 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProv
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.receivers.DataWorker
import info.nightscout.androidaps.receivers.DataReceiver
import info.nightscout.androidaps.utils.*
import info.nightscout.androidaps.utils.extensions.valueToUnitsString
import info.nightscout.androidaps.utils.resources.ResourceHelper
@ -602,7 +602,7 @@ class SmsCommunicatorPlugin @Inject constructor(
activePlugin.activeTreatments.doProfileSwitch(store, list[pIndex - 1] as String, 0, finalPercentage, 0, DateUtil.now())
val replyText = resourceHelper.gs(R.string.profileswitchcreated)
sendSMS(Sms(receivedSms.phoneNumber, replyText))
uel.log(Action.SMS_PROFILE, ValueWithUnit(R.string.profileswitchcreated, Units.R_String))
uel.log(Action.SMS_PROFILE, XXXValueWithUnit.StringResource(R.string.profileswitchcreated))
}
})
}
@ -624,12 +624,12 @@ class SmsCommunicatorPlugin @Inject constructor(
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalcanceled)
replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
uel.log(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))
} else {
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalcancelfailed)
replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText))
uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalcancelfailed, Units.R_String))
uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_tempbasalcancelfailed))
}
}
})
@ -658,14 +658,14 @@ class SmsCommunicatorPlugin @Inject constructor(
replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
if (result.isPercent)
uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalset_percent, 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))) )
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))))
} else {
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed)
replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText))
uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalfailed, Units.R_String))
uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_tempbasalfailed))
}
}
})
@ -696,14 +696,14 @@ class SmsCommunicatorPlugin @Inject constructor(
replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
if (result.isPercent)
uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalset_percent, 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))))
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))))
} else {
var replyText = resourceHelper.gs(R.string.smscommunicator_tempbasalfailed)
replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText))
uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_tempbasalfailed, Units.R_String))
uel.log(Action.SMS_BASAL, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_tempbasalfailed))
}
}
})
@ -730,7 +730,7 @@ class SmsCommunicatorPlugin @Inject constructor(
var replyText = resourceHelper.gs(R.string.smscommunicator_extendedcancelfailed)
replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText))
uel.log(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))
}
}
})
@ -757,16 +757,16 @@ class SmsCommunicatorPlugin @Inject constructor(
replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
if (config.APS)
uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_extendedset, 2), ValueWithUnit(aDouble
?: 0.0, Units.U), ValueWithUnit(duration, Units.M), ValueWithUnit(R.string.loopsuspended, Units.R_String))
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))
else
uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_extendedset, 2), ValueWithUnit(aDouble
?: 0.0, Units.U), ValueWithUnit(duration, Units.M))
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))))
} else {
var replyText = resourceHelper.gs(R.string.smscommunicator_extendedfailed)
replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText))
uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_extendedfailed, Units.R_String))
uel.log(Action.SMS_EXTENDED_BOLUS, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_extendedfailed))
}
}
})
@ -844,7 +844,7 @@ class SmsCommunicatorPlugin @Inject constructor(
var replyText = resourceHelper.gs(R.string.smscommunicator_bolusfailed)
replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText))
uel.log(Action.SMS_BOLUS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_bolusfailed, Units.R_String))
uel.log(Action.SMS_BOLUS, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_bolusfailed))
}
}
})
@ -884,14 +884,13 @@ class SmsCommunicatorPlugin @Inject constructor(
var replyText = String.format(resourceHelper.gs(R.string.smscommunicator_carbsset), anInteger)
replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_carbsset, 1), ValueWithUnit(anInteger
?: 0, Units.G))
uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_carbsset, listOf(XXXValueWithUnit.Gram(anInteger ?: 0))))
} else {
var replyText = resourceHelper.gs(R.string.smscommunicator_carbsfailed, anInteger)
replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText))
uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_carbsfailed, 1), ValueWithUnit(anInteger
?: 0, Units.G))
uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_carbsfailed, listOf(XXXValueWithUnit.Gram(anInteger
?: 0))))
}
}
})
@ -900,8 +899,8 @@ class SmsCommunicatorPlugin @Inject constructor(
var replyText = String.format(resourceHelper.gs(R.string.smscommunicator_carbsset), anInteger)
replyText += "\n" + activePlugin.activePump.shortStatus(true)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), ValueWithUnit(R.string.smscommunicator_carbsset, 1), ValueWithUnit(anInteger
?: 0, Units.G))
uel.log(Action.SMS_CARBS, activePlugin.activePump.shortStatus(true), XXXValueWithUnit.StringResource(R.string.smscommunicator_carbsset, listOf(XXXValueWithUnit.Gram(anInteger
?: 0))))
}
}
})
@ -971,7 +970,7 @@ class SmsCommunicatorPlugin @Inject constructor(
val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_tt_set), ttString, ttDuration)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
//uel.log(Action.SMS_TT, ValueWithUnit(R.string.smscommunicator_tt_set, 2), ValueWithUnit(tt, units), ValueWithUnit(ttDuration, Units.M))
uel.log(Action.SMS_TT, ValueWithUnit(tt, units), ValueWithUnit(ttDuration, Units.M))
uel.log(Action.SMS_TT, XXXValueWithUnit.fromGlucoseUnit(tt, units), XXXValueWithUnit.Minute(ttDuration))
}
})
} else if (isStop) {
@ -988,7 +987,7 @@ class SmsCommunicatorPlugin @Inject constructor(
})
val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_tt_canceled))
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
uel.log(Action.SMS_TT, ValueWithUnit(R.string.smscommunicator_tt_canceled, Units.R_String))
uel.log(Action.SMS_TT, XXXValueWithUnit.StringResource(R.string.smscommunicator_tt_canceled))
}
})
} else
@ -1007,7 +1006,7 @@ class SmsCommunicatorPlugin @Inject constructor(
sp.putBoolean(R.string.key_smscommunicator_remotecommandsallowed, false)
val replyText = String.format(resourceHelper.gs(R.string.smscommunicator_stoppedsms))
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
uel.log(Action.SMS_SMS, ValueWithUnit(R.string.smscommunicator_stoppedsms, Units.R_String))
uel.log(Action.SMS_SMS, XXXValueWithUnit.StringResource(R.string.smscommunicator_stoppedsms))
}
})
} else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat)))
@ -1026,9 +1025,9 @@ class SmsCommunicatorPlugin @Inject constructor(
if (result) resourceHelper.gs(R.string.smscommunicator_calibrationsent) else resourceHelper.gs(R.string.smscommunicator_calibrationfailed)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
if (result)
uel.log(Action.SMS_CAL, ValueWithUnit(R.string.smscommunicator_calibrationsent, Units.R_String))
uel.log(Action.SMS_CAL, XXXValueWithUnit.StringResource(R.string.smscommunicator_calibrationsent))
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))
}
})
} else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat)))

View file

@ -8,6 +8,7 @@ import android.widget.AdapterView
import android.widget.ArrayAdapter
import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.NsprofileFragmentBinding
import info.nightscout.androidaps.interfaces.ProfileFunction
@ -62,7 +63,7 @@ class NSProfileFragment : DaggerFragment() {
activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.nsprofile),
resourceHelper.gs(R.string.activate_profile) + ": " + name + " ?", Runnable {
uel.log(Action.PROFILE_SWITCH, ValueWithUnit(name, Units.None), ValueWithUnit(100.toInt(), Units.Percent))
uel.log(Action.PROFILE_SWITCH, XXXValueWithUnit.SimpleString(name), XXXValueWithUnit.Percent(100))
treatmentsPlugin.doProfileSwitch(store, name, 0, 100, 0, DateUtil.now())
})
}

View file

@ -10,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView
import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R
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.UserEntry.*
import info.nightscout.androidaps.database.transactions.InvalidateGlucoseValueTransaction
@ -129,7 +130,7 @@ class BGSourceFragment : DaggerFragment() {
activity?.let { activity ->
val text = dateUtil.dateAndTimeString(glucoseValue.timestamp) + "\n" + glucoseValue.valueToUnitsString(profileFunction.getUnits())
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable {
uel.log(Action.BG_REMOVED, ValueWithUnit(glucoseValue.timestamp, Units.Timestamp))
uel.log(Action.BG_REMOVED, XXXValueWithUnit.Timestamp(glucoseValue.timestamp))
disposable += repository.runTransaction(InvalidateGlucoseValueTransaction(glucoseValue.id)).subscribe()
})
}

View file

@ -9,6 +9,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.TreatmentsBolusFragmentBinding
import info.nightscout.androidaps.databinding.TreatmentsBolusItemBinding
@ -175,7 +176,7 @@ class TreatmentsBolusFragment : DaggerFragment() {
resourceHelper.gs(R.string.carbs) + ": " + resourceHelper.gs(R.string.format_carbs, treatment.carbs.toInt()) + "\n" +
resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(treatment.date)
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable {
uel.log(Action.TREATMENT_REMOVED, ValueWithUnit(treatment.date, Units.Timestamp), ValueWithUnit(treatment.insulin, Units.U, treatment.insulin != 0.0), ValueWithUnit(treatment.carbs.toInt(), Units.G, treatment.carbs != 0.0))
uel.log(Action.TREATMENT_REMOVED, XXXValueWithUnit.Timestamp(treatment.date), XXXValueWithUnit.Insulin(treatment.insulin).takeIf { treatment.insulin != 0.0 }, XXXValueWithUnit.Gram(treatment.carbs.toInt()).takeIf { treatment.carbs != 0.0 })
if (treatment.source == Source.PUMP) {
treatment.isValid = false
treatmentsPlugin.service.update(treatment)

View file

@ -10,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView
import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R
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.transactions.InvalidateAAPSStartedTherapyEventTransaction
import info.nightscout.androidaps.database.transactions.InvalidateTherapyEventTransaction
@ -176,7 +177,7 @@ class TreatmentsCareportalFragment : DaggerFragment() {
holder.binding.date.text = dateUtil.dateAndTimeString(therapyEvent.timestamp)
holder.binding.duration.text = if (therapyEvent.duration == 0L) "" else DateUtil.niceTimeScalar(therapyEvent.duration, resourceHelper)
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
}
@ -192,11 +193,11 @@ class TreatmentsCareportalFragment : DaggerFragment() {
binding.remove.setOnClickListener { v: View ->
val therapyEvent = v.tag as TherapyEvent
activity?.let { activity ->
val text = resourceHelper.gs(R.string.eventtype) + ": " + translator.translate(therapyEvent.type.text) + "\n" +
val text = resourceHelper.gs(R.string.eventtype) + ": " + translator.translate(therapyEvent.type) + "\n" +
resourceHelper.gs(R.string.notes_label) + ": " + (therapyEvent.note ?: "") + "\n" +
resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(therapyEvent.timestamp)
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable {
uel.log(Action.CAREPORTAL_REMOVED, therapyEvent.note , ValueWithUnit(therapyEvent.timestamp, Units.Timestamp), ValueWithUnit(therapyEvent.type.text, Units.TherapyEvent))
uel.log(Action.CAREPORTAL_REMOVED, therapyEvent.note , XXXValueWithUnit.Timestamp(therapyEvent.timestamp), XXXValueWithUnit.TherapyEvent(therapyEvent.type.text))
disposable += repository.runTransactionForResult(InvalidateTherapyEventTransaction(therapyEvent.id))
.subscribe({
val id = therapyEvent.interfaceIDs.nightscoutId

View file

@ -9,6 +9,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.TreatmentsProfileswitchFragmentBinding
import info.nightscout.androidaps.databinding.TreatmentsProfileswitchItemBinding
@ -148,7 +149,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() {
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord),
resourceHelper.gs(R.string.careportal_profileswitch) + ": " + profileSwitch.profileName +
"\n" + resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(profileSwitch.date), Runnable {
uel.log(Action.PROFILE_SWITCH_REMOVED, profileSwitch.profileName, ValueWithUnit(profileSwitch.date, Units.Timestamp))
uel.log(Action.PROFILE_SWITCH_REMOVED, profileSwitch.profileName, XXXValueWithUnit.Timestamp(profileSwitch.date))
val id = profileSwitch._id
if (NSUpload.isIdValid(id)) nsUpload.removeCareportalEntryFromNS(id)
else uploadQueue.removeByMongoId("dbAdd", id)
@ -161,7 +162,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() {
val profileSwitch = it.tag as ProfileSwitch
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), resourceHelper.gs(R.string.copytolocalprofile) + "\n" + profileSwitch.customizedName + "\n" + dateUtil.dateAndTimeString(profileSwitch.date), Runnable {
profileSwitch.profileObject?.let {
uel.log(Action.PROFILE_SWITCH_CLONED, ValueWithUnit(profileSwitch.date, Units.Timestamp), ValueWithUnit(profileSwitch.profileName, Units.None))
uel.log(Action.PROFILE_SWITCH_CLONED, XXXValueWithUnit.Timestamp(profileSwitch.date), XXXValueWithUnit.SimpleString(profileSwitch.profileName))
val nonCustomized = it.convertToNonCustomizedProfile()
if (nonCustomized.isValid(resourceHelper.gs(R.string.careportal_profileswitch, false))) {
localProfilePlugin.addProfile(localProfilePlugin.copyFrom(nonCustomized, profileSwitch.customizedName + " " + dateUtil.dateAndTimeString(profileSwitch.date).replace(".", "_")))

View file

@ -13,6 +13,7 @@ import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.AppRepository
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.UserEntry.*
import info.nightscout.androidaps.database.interfaces.end
@ -170,7 +171,7 @@ class TreatmentsTempTargetFragment : DaggerFragment() {
holder.binding.duration.text = resourceHelper.gs(R.string.format_mins, T.msecs(tempTarget.duration).mins())
holder.binding.low.text = tempTarget.lowValueToUnitsToString(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(
when {
tempTarget.id == currentlyActiveTarget?.id -> resourceHelper.gc(R.color.colorActive)
@ -196,7 +197,7 @@ class TreatmentsTempTargetFragment : DaggerFragment() {
${dateUtil.dateAndTimeString(tempTarget.timestamp)}
""".trimIndent(),
{ _: 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.TherapyEvent(tempTarget.reason.text), XXXValueWithUnit.Mgdl(tempTarget.lowTarget), XXXValueWithUnit.Mgdl(tempTarget.highTarget).takeIf { tempTarget.lowTarget != tempTarget.highTarget }, XXXValueWithUnit.Minute(tempTarget.duration.toInt()))
disposable += repository.runTransactionForResult(InvalidateTemporaryTargetTransaction(tempTarget.id))
.subscribe({
val id = tempTarget.interfaceIDs.nightscoutId

View file

@ -12,6 +12,7 @@ import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.Intervals
import info.nightscout.androidaps.data.IobTotal
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.databinding.TreatmentsTempbasalsFragmentBinding
import info.nightscout.androidaps.databinding.TreatmentsTempbasalsItemBinding
@ -164,7 +165,7 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() {
${resourceHelper.gs(R.string.date)}: ${dateUtil.dateAndTimeString(tempBasal.date)}
""".trimIndent(),
{ _: DialogInterface?, _: Int ->
uel.log(Action.TT_REMOVED, ValueWithUnit(tempBasal.date, Units.Timestamp))
uel.log(Action.TT_REMOVED, XXXValueWithUnit.Timestamp(tempBasal.date))
activePlugin.activeTreatments.removeTempBasal(tempBasal)
}, null)
}

View file

@ -111,7 +111,7 @@ class TreatmentsUserEntryFragment : DaggerFragment() {
override fun onBindViewHolder(holder: UserEntryViewHolder, position: Int) {
val current = entries[position]
holder.binding.date.text = dateUtil.dateAndTimeAndSecondsString(current.timestamp)
holder.binding.action.text = translator.translate(current.action.name)
holder.binding.action.text = translator.translate(current.action)
holder.binding.action.setTextColor(resourceHelper.gc(current.action.colorGroup.colorId()))
if (current.s != "") {
holder.binding.s.text = current.s
@ -138,12 +138,12 @@ class TreatmentsUserEntryFragment : DaggerFragment() {
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.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.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) + separator else DecimalFormatter.to1Decimal(v.dValue) + translator.translate(Units.Mmol_L) + separator
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
-> valuesWithUnitString += v.iValue.toString() + translator.translate(v.unit.name) + separator
-> valuesWithUnitString += v.iValue.toString() + translator.translate(v.unit) + separator
else -> valuesWithUnitString += if (v.iValue != 0 || v.sValue != "") { v.value().toString() + separator } else ""
}
}

View file

@ -10,6 +10,7 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
import info.nightscout.androidaps.database.entities.TemporaryTarget
import info.nightscout.androidaps.database.entities.TherapyEvent
import info.nightscout.androidaps.database.entities.UserEntry.*
@ -349,7 +350,7 @@ class BolusWizard @Inject constructor(
boluscalc = nsJSON()
source = Source.USER
notes = this@BolusWizard.notes
uel.log(Action.BOLUS_ADVISOR, notes, ValueWithUnit(eventType, Units.TherapyEvent), ValueWithUnit(insulinAfterConstraints, Units.U))
uel.log(Action.BOLUS_ADVISOR, notes, XXXValueWithUnit.TherapyEvent(eventType), XXXValueWithUnit.Insulin(insulinAfterConstraints))
if (insulin > 0) {
commandQueue.bolus(this, object : Callback() {
override fun run() {
@ -413,7 +414,7 @@ class BolusWizard @Inject constructor(
boluscalc = nsJSON()
source = Source.USER
notes = this@BolusWizard.notes
uel.log(Action.BOLUS, notes, ValueWithUnit(eventType,Units.TherapyEvent), ValueWithUnit(insulinAfterConstraints, Units.U), ValueWithUnit(this@BolusWizard.carbs, Units.G, this@BolusWizard.carbs != 0), ValueWithUnit(carbTime, Units.M, carbTime != 0))
uel.log(Action.BOLUS, notes, XXXValueWithUnit.TherapyEvent(eventType), XXXValueWithUnit.Insulin(insulinAfterConstraints), XXXValueWithUnit.Gram(this@BolusWizard.carbs).takeIf { this@BolusWizard.carbs != 0 }, XXXValueWithUnit.Minute(carbTime).takeIf { carbTime != 0 })
if (insulin > 0 || pump.pumpDescription.storesCarbInfo) {
commandQueue.bolus(this, object : Callback() {
override fun run() {

View file

@ -59,7 +59,7 @@ class TherapyEventDataPoint @Inject constructor(
override fun getLabel(): String? =
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 getShape(): PointsWithLabelGraphSeries.Shape =

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.logging
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.XXXValueWithUnit
import info.nightscout.androidaps.database.entities.UserEntry.*
import info.nightscout.androidaps.database.transactions.UserEntryTransaction
import info.nightscout.androidaps.utils.rx.AapsSchedulers
@ -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) {
val values = mutableListOf<ValueWithUnit>()
for (v in listvalues){
@ -69,17 +75,17 @@ class UserEntryLogger @Inject constructor(
)
}
fun log(action: Action, s: String? = "", values: MutableList<ValueWithUnit>) {
compositeDisposable += repository.runTransaction(UserEntryTransaction(
action = action,
s = s ?:"",
values = values
))
.subscribeOn(aapsSchedulers.io)
.observeOn(aapsSchedulers.io)
.subscribeBy(
onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $s $values") },
onComplete = { aapsLogger.debug("USER ENTRY: $action $s $values") }
)
}
// fun log(action: Action, s: String? = "", values: List<ValueWithUnit>) { // TODO re-enable with new signature
// compositeDisposable += repository.runTransaction(UserEntryTransaction(
// action = action,
// s = s ?:"",
// values = values
// ))
// .subscribeOn(aapsSchedulers.io)
// .observeOn(aapsSchedulers.io)
// .subscribeBy(
// onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $s $values") },
// onComplete = { aapsLogger.debug("USER ENTRY: $action $s $values") }
// )
// }
}

View file

@ -125,8 +125,8 @@ class ClassicPrefsFormat @Inject constructor(
}
}
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(action: Action): String = "\"" + translator.translate(action).replace("\"", "\"\"") + "\""
private fun csvString(unit: Units): String = "\"" + translator.translate(unit).replace("\"", "\"\"") + "\""
private fun csvString(id: Int): String = if (id != 0) "\"" + resourceHelper.gs(id).replace("\"", "\"\"") + "\"" else ""
private fun csvString(s: String): String = if (s != "") "\"" + s.replace("\"", "\"\"") + "\"" else ""
}

View file

@ -13,6 +13,7 @@ class Translator @Inject internal constructor(
private val resourceHelper: ResourceHelper
) {
@Deprecated("use type instead of string")
fun translate(text: String): String =
when (text) {
TherapyEvent.Type.FINGER_STICK_BG_VALUE.text -> resourceHelper.gs(R.string.careportal_bgcheck)
@ -44,111 +45,162 @@ class Translator @Inject internal constructor(
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)
TemporaryTarget.Reason.HYPOGLYCEMIA.text -> resourceHelper.gs(R.string.hypo)
TemporaryTarget.Reason.EATING_SOON.text -> resourceHelper.gs(R.string.eatingsoon)
TemporaryTarget.Reason.ACTIVITY.text -> resourceHelper.gs(R.string.activity)
TemporaryTarget.Reason.AUTOMATION.text -> resourceHelper.gs(R.string.automation)
TemporaryTarget.Reason.WEAR.text -> resourceHelper.gs(R.string.wear)
Action.BOLUS.name -> resourceHelper.gs(R.string.uel_bolus)
Action.BOLUS_ADVISOR.name -> resourceHelper.gs(R.string.uel_bolus_advisor)
Action.BOLUS_RECORD.name -> resourceHelper.gs(R.string.uel_bolus_record)
Action.EXTENDED_BOLUS.name -> resourceHelper.gs(R.string.uel_extended_bolus)
Action.SUPERBOLUS_TBR.name -> resourceHelper.gs(R.string.uel_superbolus_tbr)
Action.CARBS.name -> resourceHelper.gs(R.string.uel_carbs)
Action.EXTENDED_CARBS.name -> resourceHelper.gs(R.string.uel_extended_carbs)
Action.TEMP_BASAL.name -> resourceHelper.gs(R.string.uel_temp_basal)
Action.TT.name -> resourceHelper.gs(R.string.uel_tt)
Action.NEW_PROFILE.name -> resourceHelper.gs(R.string.uel_new_profile)
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)
}
fun translate(action: Action): String = when(action) {
Action.BOLUS -> resourceHelper.gs(R.string.uel_bolus)
Action.BOLUS_ADVISOR -> resourceHelper.gs(R.string.uel_bolus_advisor)
Action.BOLUS_RECORD -> resourceHelper.gs(R.string.uel_bolus_record)
Action.EXTENDED_BOLUS -> resourceHelper.gs(R.string.uel_extended_bolus)
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_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.SMS_BASAL -> resourceHelper.gs(R.string.uel_sms_basal)
Action.SMS_BOLUS -> resourceHelper.gs(R.string.uel_sms_bolus)
Action.SMS_CAL -> resourceHelper.gs(R.string.uel_sms_cal)
Action.SMS_CARBS -> resourceHelper.gs(R.string.uel_sms_carbs)
Action.SMS_EXTENDED_BOLUS -> resourceHelper.gs(R.string.uel_sms_extended_bolus)
Action.SMS_LOOP_DISABLED -> resourceHelper.gs(R.string.uel_sms_loop_disabled)
Action.SMS_LOOP_ENABLED -> resourceHelper.gs(R.string.uel_sms_loop_enabled)
Action.SMS_LOOP_RESUME -> resourceHelper.gs(R.string.uel_sms_loop_resume)
Action.SMS_LOOP_SUSPEND -> resourceHelper.gs(R.string.uel_sms_loop_suspend)
Action.SMS_PROFILE -> resourceHelper.gs(R.string.uel_sms_profile)
Action.SMS_PUMP_CONNECT -> resourceHelper.gs(R.string.uel_sms_pump_connect)
Action.SMS_PUMP_DISCONNECT -> resourceHelper.gs(R.string.uel_sms_pump_disconnect)
Action.SMS_SMS -> resourceHelper.gs(R.string.uel_sms_sms)
Action.SMS_TT -> resourceHelper.gs(R.string.uel_sms_tt)
Action.TT_DELETED_FROM_NS -> resourceHelper.gs(R.string.uel_tt_deleted_from_ns)
Action.TT_FROM_NS -> resourceHelper.gs(R.string.uel_tt_from_ns)
Action.TT_CANCELED_FROM_NS -> resourceHelper.gs(R.string.uel_tt_canceleted_from_ns)
Action.CAREPORTAL_DELETED_FROM_NS -> resourceHelper.gs(R.string.uel_careportal_deleted_from_ns)
Action.CAREPORTAL_FROM_NS -> resourceHelper.gs(R.string.uel_careportal_from_ns)
Action.EXPORT_CSV -> resourceHelper.gs(R.string.uel_export_csv)
Action.FOOD_FROM_NS -> resourceHelper.gs(R.string.unknown) // TODO?
Action.UNKNOWN -> resourceHelper.gs(R.string.unknown)
}
fun translate(units: Units): String = when(units) {
Units.Mg_Dl -> resourceHelper.gs(R.string.mgdl)
Units.Mmol_L -> resourceHelper.gs(R.string.mmol)
Units.U -> resourceHelper.gs(R.string.insulin_unit_shortname)
Units.U_H -> resourceHelper.gs(R.string.profile_ins_units_per_hour)
Units.G -> resourceHelper.gs(R.string.shortgram)
Units.M -> resourceHelper.gs(R.string.shortminute)
Units.H -> resourceHelper.gs(R.string.shorthour)
Units.Percent -> resourceHelper.gs(R.string.shortpercent)
Units.None -> ""
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)
}
}

View file

@ -115,17 +115,10 @@ data class UserEntry(
}
}
data class ValueWithUnit (val dValue: Double=0.0, val iValue: Int=0, val lValue: Long=0, val sValue: String="", val unit: Units=Units.None, val condition:Boolean=true){
constructor(dvalue: Double, unit: Units, condition:Boolean = true) : this(dvalue, 0, 0, "", unit, condition)
constructor(ivalue: Int, unit: Units, condition:Boolean = true) : this(0.0, ivalue, 0, "", unit, condition)
constructor(lvalue: Long, unit: Units, condition:Boolean = true) : this(0.0,0, lvalue, "", unit, condition)
constructor(svalue: String, unit:Units) : this(0.0,0, 0, svalue, unit, svalue != "")
constructor(dvalue: Double, unit:String) : this(dvalue,0, 0, "", Units.fromText(unit))
constructor(rStringRef: Int, nbParam: Long) : this(0.0, rStringRef, nbParam, "", Units.R_String, !rStringRef.equals(0)) // additionnal constructors for formated strings with additional values as parameters (define number of parameters as long
fun value() : Any {
if (sValue != "") return sValue
if (!dValue.equals(0.0)) return dValue
if (!iValue.equals(0)) return iValue
if (iValue != 0) return iValue
return lValue
}
}

View file

@ -0,0 +1,59 @@
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 TherapyEvent(val value: String) : XXXValueWithUnit()
class TherapyEventType(val value: info.nightscout.androidaps.database.entities.TherapyEvent.Type) : XXXValueWithUnit()
class TherapyEventMeterType(val value: info.nightscout.androidaps.database.entities.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.
*/

View file

@ -0,0 +1,144 @@
import com.google.gson.annotations.SerializedName
import info.nightscout.androidaps.database.entities.GlucoseValue
enum class SourceSensorDomain(val text : String) {
@SerializedName("AndroidAPS-Dexcom")
DEXCOM_NATIVE_UNKNOWN("AndroidAPS-Dexcom"),
@SerializedName("AndroidAPS-DexcomG6")
DEXCOM_G6_NATIVE("AndroidAPS-DexcomG6"),
@SerializedName("AndroidAPS-DexcomG5")
DEXCOM_G5_NATIVE("AndroidAPS-DexcomG5"),
@SerializedName("Bluetooth Wixel")
DEXCOM_G4_WIXEL("Bluetooth Wixel"),
@SerializedName("xBridge Wixel")
DEXCOM_G4_XBRIDGE("xBridge Wixel"),
@SerializedName("G4 Share Receiver")
DEXCOM_G4_NATIVE("G4 Share Receiver"),
@SerializedName("Medtrum A6")
MEDTRUM_A6("Medtrum A6"),
@SerializedName("Network G4")
DEXCOM_G4_NET("Network G4"),
@SerializedName("Network G4 and xBridge")
DEXCOM_G4_NET_XBRIDGE("Network G4 and xBridge"),
@SerializedName("Network G4 and Classic xDrip")
DEXCOM_G4_NET_CLASSIC("Network G4 and Classic xDrip"),
@SerializedName("DexcomG5")
DEXCOM_G5_XDRIP("DexcomG5"),
@SerializedName("G6 Native")
DEXCOM_G6_NATIVE_XDRIP("G6 Native"),
@SerializedName("G5 Native")
DEXCOM_G5_NATIVE_XDRIP("G5 Native"),
@SerializedName("G6 Native / G5 Native")
DEXCOM_G6_G5_NATIVE_XDRIP("G6 Native / G5 Native"),
@SerializedName("Network libre")
LIBRE_1_NET("Network libre"),
@SerializedName("BlueReader")
LIBRE_1_BLUE("BlueReader"),
@SerializedName("Transmiter PL")
LIBRE_1_PL("Transmiter PL"),
@SerializedName("Blucon")
LIBRE_1_BLUCON("Blucon"),
@SerializedName("Tomato")
LIBRE_1_TOMATO("Tomato"),
@SerializedName("Rfduino")
LIBRE_1_RF("Rfduino"),
@SerializedName("LimiTTer")
LIBRE_1_LIMITTER("LimiTTer"),
@SerializedName("Glimp")
GLIMP("Glimp"),
@SerializedName("Libre2")
LIBRE_2_NATIVE("Libre2"),
@SerializedName("Poctech")
POCTECH_NATIVE("Poctech"),
@SerializedName("MM600Series")
MM_600_SERIES("MM600Series"),
@SerializedName("Eversense")
EVERSENSE("Eversense"),
@SerializedName("Random")
RANDOM("Random"),
@SerializedName("Unknown")
UNKNOWN("Unknown"),
@SerializedName("IOBPrediction")
IOB_PREDICTION("IOBPrediction"),
@SerializedName("aCOBPrediction")
aCOB_PREDICTION("aCOBPrediction"),
@SerializedName("COBPrediction")
COB_PREDICTION("COBPrediction"),
@SerializedName("UAMPrediction")
UAM_PREDICTION("UAMPrediction"),
@SerializedName("ZTPrediction")
ZT_PREDICTION("ZTPrediction")
}
fun GlucoseValue.SourceSensor.toDomain(): SourceSensorDomain = when(this) {
GlucoseValue.SourceSensor.DEXCOM_NATIVE_UNKNOWN -> SourceSensorDomain.DEXCOM_NATIVE_UNKNOWN
GlucoseValue.SourceSensor.DEXCOM_G6_NATIVE -> SourceSensorDomain.DEXCOM_G6_NATIVE
GlucoseValue.SourceSensor.DEXCOM_G5_NATIVE -> SourceSensorDomain.DEXCOM_G5_NATIVE
GlucoseValue.SourceSensor.DEXCOM_G4_WIXEL -> SourceSensorDomain.DEXCOM_G4_WIXEL
GlucoseValue.SourceSensor.DEXCOM_G4_XBRIDGE -> SourceSensorDomain.DEXCOM_G4_XBRIDGE
GlucoseValue.SourceSensor.DEXCOM_G4_NATIVE -> SourceSensorDomain.DEXCOM_G4_NATIVE
GlucoseValue.SourceSensor.MEDTRUM_A6 -> SourceSensorDomain.MEDTRUM_A6
GlucoseValue.SourceSensor.DEXCOM_G4_NET -> SourceSensorDomain.DEXCOM_G4_NET
GlucoseValue.SourceSensor.DEXCOM_G4_NET_XBRIDGE -> SourceSensorDomain.DEXCOM_G4_NET_XBRIDGE
GlucoseValue.SourceSensor.DEXCOM_G4_NET_CLASSIC -> SourceSensorDomain.DEXCOM_G4_NET_CLASSIC
GlucoseValue.SourceSensor.DEXCOM_G5_XDRIP -> SourceSensorDomain.DEXCOM_G5_XDRIP
GlucoseValue.SourceSensor.DEXCOM_G6_NATIVE_XDRIP -> SourceSensorDomain.DEXCOM_G6_NATIVE_XDRIP
GlucoseValue.SourceSensor.DEXCOM_G5_NATIVE_XDRIP -> SourceSensorDomain.DEXCOM_G5_NATIVE_XDRIP
GlucoseValue.SourceSensor.DEXCOM_G6_G5_NATIVE_XDRIP -> SourceSensorDomain.DEXCOM_G6_G5_NATIVE_XDRIP
GlucoseValue.SourceSensor.LIBRE_1_NET -> SourceSensorDomain.LIBRE_1_NET
GlucoseValue.SourceSensor.LIBRE_1_BLUE -> SourceSensorDomain.LIBRE_1_BLUE
GlucoseValue.SourceSensor.LIBRE_1_PL -> SourceSensorDomain.LIBRE_1_PL
GlucoseValue.SourceSensor.LIBRE_1_BLUCON -> SourceSensorDomain.LIBRE_1_BLUCON
GlucoseValue.SourceSensor.LIBRE_1_TOMATO -> SourceSensorDomain.LIBRE_1_TOMATO
GlucoseValue.SourceSensor.LIBRE_1_RF -> SourceSensorDomain.LIBRE_1_LIMITTER
GlucoseValue.SourceSensor.LIBRE_1_LIMITTER -> SourceSensorDomain.LIBRE_1_LIMITTER
GlucoseValue.SourceSensor.GLIMP -> SourceSensorDomain.GLIMP
GlucoseValue.SourceSensor.LIBRE_2_NATIVE -> SourceSensorDomain.LIBRE_2_NATIVE
GlucoseValue.SourceSensor.POCTECH_NATIVE -> SourceSensorDomain.POCTECH_NATIVE
GlucoseValue.SourceSensor.MM_600_SERIES -> SourceSensorDomain.MM_600_SERIES
GlucoseValue.SourceSensor.EVERSENSE -> SourceSensorDomain.EVERSENSE
GlucoseValue.SourceSensor.RANDOM -> SourceSensorDomain.RANDOM
GlucoseValue.SourceSensor.UNKNOWN -> SourceSensorDomain.UNKNOWN
GlucoseValue.SourceSensor.IOB_PREDICTION -> SourceSensorDomain.IOB_PREDICTION
GlucoseValue.SourceSensor.aCOB_PREDICTION -> SourceSensorDomain.aCOB_PREDICTION
GlucoseValue.SourceSensor.COB_PREDICTION -> SourceSensorDomain.COB_PREDICTION
GlucoseValue.SourceSensor.UAM_PREDICTION -> SourceSensorDomain.UAM_PREDICTION
GlucoseValue.SourceSensor.ZT_PREDICTION -> SourceSensorDomain.ZT_PREDICTION
}
fun SourceSensorDomain.toPersistence(): GlucoseValue.SourceSensor = when(this) {
SourceSensorDomain.DEXCOM_NATIVE_UNKNOWN -> GlucoseValue.SourceSensor.DEXCOM_NATIVE_UNKNOWN
SourceSensorDomain.DEXCOM_G6_NATIVE -> GlucoseValue.SourceSensor.DEXCOM_G6_NATIVE
SourceSensorDomain.DEXCOM_G5_NATIVE -> GlucoseValue.SourceSensor.DEXCOM_G5_NATIVE
SourceSensorDomain.DEXCOM_G4_WIXEL -> GlucoseValue.SourceSensor.DEXCOM_G4_WIXEL
SourceSensorDomain.DEXCOM_G4_XBRIDGE -> GlucoseValue.SourceSensor.DEXCOM_G4_XBRIDGE
SourceSensorDomain.DEXCOM_G4_NATIVE -> GlucoseValue.SourceSensor.DEXCOM_G4_NATIVE
SourceSensorDomain.MEDTRUM_A6 -> GlucoseValue.SourceSensor.MEDTRUM_A6
SourceSensorDomain.DEXCOM_G4_NET -> GlucoseValue.SourceSensor.DEXCOM_G4_NET
SourceSensorDomain.DEXCOM_G4_NET_XBRIDGE -> GlucoseValue.SourceSensor.DEXCOM_G4_NET_XBRIDGE
SourceSensorDomain.DEXCOM_G4_NET_CLASSIC -> GlucoseValue.SourceSensor.DEXCOM_G4_NET_CLASSIC
SourceSensorDomain.DEXCOM_G5_XDRIP -> GlucoseValue.SourceSensor.DEXCOM_G5_XDRIP
SourceSensorDomain.DEXCOM_G6_NATIVE_XDRIP -> GlucoseValue.SourceSensor.DEXCOM_G6_NATIVE_XDRIP
SourceSensorDomain.DEXCOM_G5_NATIVE_XDRIP -> GlucoseValue.SourceSensor.DEXCOM_G5_NATIVE_XDRIP
SourceSensorDomain.DEXCOM_G6_G5_NATIVE_XDRIP -> GlucoseValue.SourceSensor.DEXCOM_G6_G5_NATIVE_XDRIP
SourceSensorDomain.LIBRE_1_NET -> GlucoseValue.SourceSensor.LIBRE_1_NET
SourceSensorDomain.LIBRE_1_BLUE -> GlucoseValue.SourceSensor.LIBRE_1_BLUE
SourceSensorDomain.LIBRE_1_PL -> GlucoseValue.SourceSensor.LIBRE_1_PL
SourceSensorDomain.LIBRE_1_BLUCON -> GlucoseValue.SourceSensor.LIBRE_1_BLUCON
SourceSensorDomain.LIBRE_1_TOMATO -> GlucoseValue.SourceSensor.LIBRE_1_TOMATO
SourceSensorDomain.LIBRE_1_RF -> GlucoseValue.SourceSensor.LIBRE_1_LIMITTER
SourceSensorDomain.LIBRE_1_LIMITTER -> GlucoseValue.SourceSensor.LIBRE_1_LIMITTER
SourceSensorDomain.GLIMP -> GlucoseValue.SourceSensor.GLIMP
SourceSensorDomain.LIBRE_2_NATIVE -> GlucoseValue.SourceSensor.LIBRE_2_NATIVE
SourceSensorDomain.POCTECH_NATIVE -> GlucoseValue.SourceSensor.POCTECH_NATIVE
SourceSensorDomain.MM_600_SERIES -> GlucoseValue.SourceSensor.MM_600_SERIES
SourceSensorDomain.EVERSENSE -> GlucoseValue.SourceSensor.EVERSENSE
SourceSensorDomain.RANDOM -> GlucoseValue.SourceSensor.RANDOM
SourceSensorDomain.UNKNOWN -> GlucoseValue.SourceSensor.UNKNOWN
SourceSensorDomain.IOB_PREDICTION -> GlucoseValue.SourceSensor.IOB_PREDICTION
SourceSensorDomain.aCOB_PREDICTION -> GlucoseValue.SourceSensor.aCOB_PREDICTION
SourceSensorDomain.COB_PREDICTION -> GlucoseValue.SourceSensor.COB_PREDICTION
SourceSensorDomain.UAM_PREDICTION -> GlucoseValue.SourceSensor.UAM_PREDICTION
SourceSensorDomain.ZT_PREDICTION -> GlucoseValue.SourceSensor.ZT_PREDICTION
}