Merge branch 'User_Entry_ValueWithUnits' into UE_ExportXML

# Conflicts:
#	core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt
#	database/src/main/java/info/nightscout/androidaps/database/entities/UserEntry.kt
This commit is contained in:
Philoul 2021-03-06 22:31:39 +01:00
commit cf83d20e13
6 changed files with 352 additions and 319 deletions

View file

@ -272,12 +272,12 @@ class CarbsDialog : DialogFragmentWithDate() {
if (carbsAfterConstraints > 0) { if (carbsAfterConstraints > 0) {
if (duration == 0) { if (duration == 0) {
if (eventTimeChanged) if (eventTimeChanged)
uel.log(Action.CARBS, notes, ValueWithUnit(eventTime, Units.Timestamp), ValueWithUnit(carbsAfterConstraints.toDouble(), Units.G), ValueWithUnit(timeOffset, Units.M)) uel.log(Action.CARBS, notes, ValueWithUnit(eventTime, Units.Timestamp), ValueWithUnit(carbsAfterConstraints, Units.G), ValueWithUnit(timeOffset, Units.M))
else else
uel.log(Action.CARBS, notes, ValueWithUnit(carbsAfterConstraints.toDouble(), Units.G), ValueWithUnit(timeOffset, Units.M)) uel.log(Action.CARBS, notes, ValueWithUnit(carbsAfterConstraints, Units.G), ValueWithUnit(timeOffset, Units.M))
carbsGenerator.createCarb(carbsAfterConstraints, time, CareportalEvent.CARBCORRECTION, notes) carbsGenerator.createCarb(carbsAfterConstraints, time, CareportalEvent.CARBCORRECTION, notes)
} else { } else {
uel.log(Action.CARBS, notes, ValueWithUnit(carbsAfterConstraints.toDouble(), Units.G), ValueWithUnit(timeOffset,Units.M), ValueWithUnit(duration, Units.H)) uel.log(Action.CARBS, notes, ValueWithUnit(carbsAfterConstraints, Units.G), ValueWithUnit(timeOffset,Units.M), ValueWithUnit(duration, Units.H))
carbsGenerator.generateCarbs(carbsAfterConstraints, time, duration, notes) carbsGenerator.generateCarbs(carbsAfterConstraints, time, duration, notes)
nsUpload.uploadEvent(CareportalEvent.NOTE, DateUtil.now() - 2000, resourceHelper.gs(R.string.generated_ecarbs_note, carbsAfterConstraints, duration, timeOffset)) nsUpload.uploadEvent(CareportalEvent.NOTE, DateUtil.now() - 2000, resourceHelper.gs(R.string.generated_ecarbs_note, carbsAfterConstraints, duration, timeOffset))
} }

View file

@ -54,6 +54,7 @@ class CareDialog : DialogFragmentWithDate() {
} }
private var options: EventType = EventType.BGCHECK private var options: EventType = EventType.BGCHECK
private var valuesWithUnit = mutableListOf<ValueWithUnit>()
@StringRes @StringRes
private var event: Int = R.string.none private var event: Int = R.string.none
@ -178,11 +179,14 @@ class CareDialog : DialogFragmentWithDate() {
} }
actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_glucosetype) + ": " + translator.translate(type)) actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_glucosetype) + ": " + translator.translate(type))
actions.add(resourceHelper.gs(R.string.treatments_wizard_bg_label) + ": " + Profile.toCurrentUnitsString(profileFunction, binding.bg.value) + " " + resourceHelper.gs(unitResId)) actions.add(resourceHelper.gs(R.string.treatments_wizard_bg_label) + ": " + Profile.toCurrentUnitsString(profileFunction, binding.bg.value) + " " + resourceHelper.gs(unitResId))
valuesWithUnit.add(ValueWithUnit(binding.bg.value.toDouble(), profileFunction.getUnits()))
valuesWithUnit.add(ValueWithUnit(type,Units.CPEvent))
json.put("glucose", binding.bg.value) json.put("glucose", binding.bg.value)
json.put("glucoseType", type) json.put("glucoseType", type)
} }
if (options == EventType.NOTE || options == EventType.EXERCISE) { if (options == EventType.NOTE || options == EventType.EXERCISE) {
actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_duration_label) + ": " + resourceHelper.gs(R.string.format_mins, binding.duration.value.toInt())) actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_duration_label) + ": " + resourceHelper.gs(R.string.format_mins, binding.duration.value.toInt()))
valuesWithUnit.add(ValueWithUnit(binding.duration.value.toInt(), Units.M))
json.put("duration", binding.duration.value.toInt()) json.put("duration", binding.duration.value.toInt())
} }
val notes = binding.notesLayout.notes.text.toString() val notes = binding.notesLayout.notes.text.toString()
@ -192,8 +196,10 @@ class CareDialog : DialogFragmentWithDate() {
} }
eventTime -= eventTime % 1000 eventTime -= eventTime % 1000
if (eventTimeChanged) if (eventTimeChanged) {
actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime)) actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime))
valuesWithUnit.add(0, ValueWithUnit(eventTime, Units.Timestamp))
}
json.put("created_at", DateUtil.toISOString(eventTime)) json.put("created_at", DateUtil.toISOString(eventTime))
json.put("mills", eventTime) json.put("mills", eventTime)
@ -224,11 +230,9 @@ class CareDialog : DialogFragmentWithDate() {
EventType.QUESTION -> CareportalEvent.QUESTION EventType.QUESTION -> CareportalEvent.QUESTION
EventType.ANNOUNCEMENT -> CareportalEvent.ANNOUNCEMENT EventType.ANNOUNCEMENT -> CareportalEvent.ANNOUNCEMENT
} }
valuesWithUnit.add(if (eventTimeChanged) 1 else 0, ValueWithUnit(careportalEvent.eventType, Units.CPEvent))
careportalEvent.json = json.toString() careportalEvent.json = json.toString()
if (eventTimeChanged) uel.log(Action.CAREPORTAL, notes, valuesWithUnit)
uel.log(Action.CAREPORTAL, notes, ValueWithUnit(eventTime, Units.Timestamp), ValueWithUnit(careportalEvent.eventType, Units.CPEvent))
else
uel.log(Action.CAREPORTAL, notes, ValueWithUnit(careportalEvent.eventType, Units.CPEvent))
databaseHelper.createOrUpdate(careportalEvent) databaseHelper.createOrUpdate(careportalEvent)
nsUpload.uploadCareportalEntryToNS(json, eventTime) nsUpload.uploadCareportalEntryToNS(json, eventTime)
}, null) }, null)

View file

@ -92,7 +92,7 @@ class TreatmentsUserEntryFragment : DaggerFragment() {
val current = entries[position] val current = entries[position]
holder.binding.date.text = dateUtil.dateAndTimeAndSecondsString(current.timestamp) holder.binding.date.text = dateUtil.dateAndTimeAndSecondsString(current.timestamp)
holder.binding.action.text = resourceHelper.gs(current.action.stringId()) holder.binding.action.text = resourceHelper.gs(current.action.stringId())
holder.binding.action.setTextColor(resourceHelper.gc(current.action.colorId())) holder.binding.action.setTextColor(resourceHelper.gc(current.action.colorGroup.colorId()))
if (current.s != "") holder.binding.s.text = current.s else holder.binding.s.visibility = View.GONE if (current.s != "") holder.binding.s.text = current.s else holder.binding.s.visibility = View.GONE
//holder.binding.s.text = current.toString() //for debug //holder.binding.s.text = current.toString() //for debug
var valuesWithUnitString = "" var valuesWithUnitString = ""
@ -117,7 +117,7 @@ class TreatmentsUserEntryFragment : DaggerFragment() {
} }
Units.Mg_Dl -> valuesWithUnitString += if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue) + resourceHelper.gs(Units.Mg_Dl.stringId()) + separator else DecimalFormatter.to1Decimal(v.dValue/Constants.MMOLL_TO_MGDL) + resourceHelper.gs(Units.Mmol_L.stringId()) + separator Units.Mg_Dl -> valuesWithUnitString += if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue) + resourceHelper.gs(Units.Mg_Dl.stringId()) + separator else DecimalFormatter.to1Decimal(v.dValue/Constants.MMOLL_TO_MGDL) + resourceHelper.gs(Units.Mmol_L.stringId()) + separator
Units.Mmol_L -> valuesWithUnitString += if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue*Constants.MMOLL_TO_MGDL) + resourceHelper.gs(Units.Mg_Dl.stringId()) + separator else DecimalFormatter.to1Decimal(v.dValue) + resourceHelper.gs(Units.Mmol_L.stringId()) + separator Units.Mmol_L -> valuesWithUnitString += if (profileFunction.getUnits()==Constants.MGDL) DecimalFormatter.to0Decimal(v.dValue*Constants.MMOLL_TO_MGDL) + resourceHelper.gs(Units.Mg_Dl.stringId()) + separator else DecimalFormatter.to1Decimal(v.dValue) + resourceHelper.gs(Units.Mmol_L.stringId()) + separator
Units.G -> valuesWithUnitString += DecimalFormatter.to0Decimal(v.dValue) + resourceHelper.gs(Units.G.stringId()) + separator Units.G -> valuesWithUnitString += v.iValue.toString() + resourceHelper.gs(Units.G.stringId()) + separator
Units.U_H -> valuesWithUnitString += DecimalFormatter.to2Decimal(v.dValue) + resourceHelper.gs(Units.U_H.stringId()) + separator Units.U_H -> valuesWithUnitString += DecimalFormatter.to2Decimal(v.dValue) + resourceHelper.gs(Units.U_H.stringId()) + separator
else -> valuesWithUnitString += if (v.dValue != 0.0 || v.iValue != 0 || v.sValue != "") { v.value().toString() + if (!v.unit.stringId().equals(0)) resourceHelper.gs(v.unit.stringId()) + separator else separator } else "" else -> valuesWithUnitString += if (v.dValue != 0.0 || v.iValue != 0 || v.sValue != "") { v.value().toString() + if (!v.unit.stringId().equals(0)) resourceHelper.gs(v.unit.stringId()) + separator else separator } else ""
} }

View file

@ -68,4 +68,18 @@ class UserEntryLogger @Inject constructor(
onComplete = { aapsLogger.debug("USER ENTRY: $action") } onComplete = { aapsLogger.debug("USER ENTRY: $action") }
) )
} }
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") }
)
}
} }

View file

@ -1,225 +1,230 @@
package info.nightscout.androidaps.utils.extensions package info.nightscout.androidaps.utils.extensions
import com.google.gson.annotations.SerializedName
import info.nightscout.androidaps.core.R import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.database.entities.UserEntry.*
fun UserEntry.Action.stringId(): Int { fun Action.stringId(): Int {
return when (this) { return when (this) {
UserEntry.Action.BOLUS -> R.string.uel_bolus Action.BOLUS -> R.string.uel_bolus
UserEntry.Action.BOLUS_WIZARD -> R.string.uel_bolus_wizard Action.BOLUS_WIZARD -> R.string.uel_bolus_wizard
UserEntry.Action.BOLUS_ADVISOR -> R.string.uel_bolus_advisor Action.BOLUS_ADVISOR -> R.string.uel_bolus_advisor
UserEntry.Action.BOLUS_RECORD -> R.string.uel_bolus_record Action.BOLUS_RECORD -> R.string.uel_bolus_record
UserEntry.Action.EXTENDED_BOLUS -> R.string.uel_extended_bolus Action.EXTENDED_BOLUS -> R.string.uel_extended_bolus
UserEntry.Action.SUPERBOLUS_TBR -> R.string.uel_superbolus_tbr Action.SUPERBOLUS_TBR -> R.string.uel_superbolus_tbr
UserEntry.Action.CARBS -> R.string.uel_carbs Action.CARBS -> R.string.uel_carbs
UserEntry.Action.EXTENDED_CARBS -> R.string.uel_extended_carbs Action.EXTENDED_CARBS -> R.string.uel_extended_carbs
UserEntry.Action.TEMP_BASAL -> R.string.uel_temp_basal Action.TEMP_BASAL -> R.string.uel_temp_basal
UserEntry.Action.TT -> R.string.uel_tt Action.TT -> R.string.uel_tt
UserEntry.Action.TT_ACTIVITY -> R.string.uel_tt_activity Action.TT_ACTIVITY -> R.string.uel_tt_activity
UserEntry.Action.TT_EATING_SOON -> R.string.uel_tt_eating_soon Action.TT_EATING_SOON -> R.string.uel_tt_eating_soon
UserEntry.Action.TT_HYPO -> R.string.uel_tt_hypo Action.TT_HYPO -> R.string.uel_tt_hypo
UserEntry.Action.NEW_PROFILE -> R.string.uel_new_profile Action.NEW_PROFILE -> R.string.uel_new_profile
UserEntry.Action.CLONE_PROFILE -> R.string.uel_clone_profile Action.CLONE_PROFILE -> R.string.uel_clone_profile
UserEntry.Action.STORE_PROFILE -> R.string.uel_store_profile Action.STORE_PROFILE -> R.string.uel_store_profile
UserEntry.Action.PROFILE_SWITCH -> R.string.uel_profile_switch Action.PROFILE_SWITCH -> R.string.uel_profile_switch
UserEntry.Action.PROFILE_SWITCH_CLONED -> R.string.uel_profile_switch_cloned Action.PROFILE_SWITCH_CLONED -> R.string.uel_profile_switch_cloned
UserEntry.Action.CLOSED_LOOP_MODE -> R.string.uel_closed_loop_mode Action.CLOSED_LOOP_MODE -> R.string.uel_closed_loop_mode
UserEntry.Action.LGS_LOOP_MODE -> R.string.uel_lgs_loop_mode Action.LGS_LOOP_MODE -> R.string.uel_lgs_loop_mode
UserEntry.Action.OPEN_LOOP_MODE -> R.string.uel_open_loop_mode Action.OPEN_LOOP_MODE -> R.string.uel_open_loop_mode
UserEntry.Action.LOOP_DISABLED -> R.string.uel_loop_disabled Action.LOOP_DISABLED -> R.string.uel_loop_disabled
UserEntry.Action.LOOP_ENABLED -> R.string.uel_loop_enabled Action.LOOP_ENABLED -> R.string.uel_loop_enabled
UserEntry.Action.RECONNECT -> R.string.uel_reconnect Action.RECONNECT -> R.string.uel_reconnect
UserEntry.Action.DISCONNECT_15M -> R.string.uel_disconnect_15m Action.DISCONNECT_15M -> R.string.uel_disconnect_15m
UserEntry.Action.DISCONNECT_30M -> R.string.uel_disconnect_30m Action.DISCONNECT_30M -> R.string.uel_disconnect_30m
UserEntry.Action.DISCONNECT_1H -> R.string.uel_disconnect_1h Action.DISCONNECT_1H -> R.string.uel_disconnect_1h
UserEntry.Action.DISCONNECT_2H -> R.string.uel_disconnect_2h Action.DISCONNECT_2H -> R.string.uel_disconnect_2h
UserEntry.Action.DISCONNECT_3H -> R.string.uel_disconnect_3h Action.DISCONNECT_3H -> R.string.uel_disconnect_3h
UserEntry.Action.RESUME -> R.string.uel_resume Action.RESUME -> R.string.uel_resume
UserEntry.Action.SUSPEND_1H -> R.string.uel_suspend_1h Action.SUSPEND_1H -> R.string.uel_suspend_1h
UserEntry.Action.SUSPEND_2H -> R.string.uel_suspend_2h Action.SUSPEND_2H -> R.string.uel_suspend_2h
UserEntry.Action.SUSPEND_3H -> R.string.uel_suspend_3h Action.SUSPEND_3H -> R.string.uel_suspend_3h
UserEntry.Action.SUSPEND_10H -> R.string.uel_suspend_10h Action.SUSPEND_10H -> R.string.uel_suspend_10h
UserEntry.Action.HW_PUMP_ALLOWED -> R.string.uel_hw_pump_allowed Action.HW_PUMP_ALLOWED -> R.string.uel_hw_pump_allowed
UserEntry.Action.CLEAR_PAIRING_KEYS -> R.string.uel_clear_pairing_keys Action.CLEAR_PAIRING_KEYS -> R.string.uel_clear_pairing_keys
UserEntry.Action.ACCEPTS_TEMP_BASAL -> R.string.uel_accepts_temp_basal Action.ACCEPTS_TEMP_BASAL -> R.string.uel_accepts_temp_basal
UserEntry.Action.CANCEL_TEMP_BASAL -> R.string.uel_cancel_temp_basal Action.CANCEL_TEMP_BASAL -> R.string.uel_cancel_temp_basal
UserEntry.Action.CANCEL_EXTENDED_BOLUS -> R.string.uel_cancel_extended_bolus Action.CANCEL_EXTENDED_BOLUS -> R.string.uel_cancel_extended_bolus
UserEntry.Action.CANCEL_TT -> R.string.uel_cancel_tt Action.CANCEL_TT -> R.string.uel_cancel_tt
UserEntry.Action.CAREPORTAL -> R.string.uel_careportal Action.CAREPORTAL -> R.string.uel_careportal
UserEntry.Action.CALIBRATION -> R.string.uel_calibration Action.CALIBRATION -> R.string.uel_calibration
UserEntry.Action.INSULIN_CHANGE -> R.string.uel_insulin_change Action.INSULIN_CHANGE -> R.string.uel_insulin_change
UserEntry.Action.PRIME_BOLUS -> R.string.uel_prime_bolus Action.PRIME_BOLUS -> R.string.uel_prime_bolus
UserEntry.Action.SITE_CHANGE -> R.string.uel_site_change Action.SITE_CHANGE -> R.string.uel_site_change
UserEntry.Action.TREATMENT -> R.string.uel_treatment Action.TREATMENT -> R.string.uel_treatment
UserEntry.Action.CAREPORTAL_NS_REFRESH -> R.string.uel_careportal_ns_refresh Action.CAREPORTAL_NS_REFRESH -> R.string.uel_careportal_ns_refresh
UserEntry.Action.PROFILE_SWITCH_NS_REFRESH -> R.string.uel_profile_switch_ns_refresh Action.PROFILE_SWITCH_NS_REFRESH -> R.string.uel_profile_switch_ns_refresh
UserEntry.Action.TREATMENTS_NS_REFRESH -> R.string.uel_treatments_ns_refresh Action.TREATMENTS_NS_REFRESH -> R.string.uel_treatments_ns_refresh
UserEntry.Action.TT_NS_REFRESH -> R.string.uel_tt_ns_refresh Action.TT_NS_REFRESH -> R.string.uel_tt_ns_refresh
UserEntry.Action.AUTOMATION_REMOVED -> R.string.uel_automation_removed Action.AUTOMATION_REMOVED -> R.string.uel_automation_removed
UserEntry.Action.BG_REMOVED -> R.string.uel_bg_removed Action.BG_REMOVED -> R.string.uel_bg_removed
UserEntry.Action.CAREPORTAL_REMOVED -> R.string.uel_careportal_removed Action.CAREPORTAL_REMOVED -> R.string.uel_careportal_removed
UserEntry.Action.EXTENDED_BOLUS_REMOVED -> R.string.uel_extended_bolus_removed Action.EXTENDED_BOLUS_REMOVED -> R.string.uel_extended_bolus_removed
UserEntry.Action.FOOD_REMOVED -> R.string.uel_food_removed Action.FOOD_REMOVED -> R.string.uel_food_removed
UserEntry.Action.PROFILE_REMOVED -> R.string.uel_profile_removed Action.PROFILE_REMOVED -> R.string.uel_profile_removed
UserEntry.Action.PROFILE_SWITCH_REMOVED -> R.string.uel_profile_switch_removed Action.PROFILE_SWITCH_REMOVED -> R.string.uel_profile_switch_removed
UserEntry.Action.RESTART_EVENTS_REMOVED -> R.string.uel_restart_events_removed Action.RESTART_EVENTS_REMOVED -> R.string.uel_restart_events_removed
UserEntry.Action.TREATMENT_REMOVED -> R.string.uel_treatment_removed Action.TREATMENT_REMOVED -> R.string.uel_treatment_removed
UserEntry.Action.TT_REMOVED -> R.string.uel_tt_removed Action.TT_REMOVED -> R.string.uel_tt_removed
UserEntry.Action.NS_PAUSED -> R.string.uel_ns_paused Action.NS_PAUSED -> R.string.uel_ns_paused
UserEntry.Action.NS_QUEUE_CLEARED -> R.string.uel_ns_queue_cleared Action.NS_QUEUE_CLEARED -> R.string.uel_ns_queue_cleared
UserEntry.Action.NS_SETTINGS_COPIED -> R.string.uel_ns_settings_copied Action.NS_SETTINGS_COPIED -> R.string.uel_ns_settings_copied
UserEntry.Action.ERROR_DIALOG_OK -> R.string.uel_error_dialog_ok Action.ERROR_DIALOG_OK -> R.string.uel_error_dialog_ok
UserEntry.Action.ERROR_DIALOG_MUTE -> R.string.uel_error_dialog_mute Action.ERROR_DIALOG_MUTE -> R.string.uel_error_dialog_mute
UserEntry.Action.ERROR_DIALOG_MUTE_5MIN -> R.string.uel_error_dialog_mute_5min Action.ERROR_DIALOG_MUTE_5MIN -> R.string.uel_error_dialog_mute_5min
UserEntry.Action.OBJECTIVE_STARTED -> R.string.uel_objective_started Action.OBJECTIVE_STARTED -> R.string.uel_objective_started
UserEntry.Action.OBJECTIVE_UNSTARTED -> R.string.uel_objective_unstarted Action.OBJECTIVE_UNSTARTED -> R.string.uel_objective_unstarted
UserEntry.Action.OBJECTIVES_SKIPPED -> R.string.uel_objectives_skipped Action.OBJECTIVES_SKIPPED -> R.string.uel_objectives_skipped
UserEntry.Action.STAT_RESET -> R.string.uel_stat_reset Action.STAT_RESET -> R.string.uel_stat_reset
UserEntry.Action.DELETE_LOGS -> R.string.uel_delete_logs Action.DELETE_LOGS -> R.string.uel_delete_logs
UserEntry.Action.DELETE_FUTURE_TREATMENTS -> R.string.uel_delete_future_treatments Action.DELETE_FUTURE_TREATMENTS -> R.string.uel_delete_future_treatments
UserEntry.Action.EXPORT_SETTINGS -> R.string.uel_export_settings Action.EXPORT_SETTINGS -> R.string.uel_export_settings
UserEntry.Action.IMPORT_SETTINGS -> R.string.uel_import_settings Action.IMPORT_SETTINGS -> R.string.uel_import_settings
UserEntry.Action.RESET_DATABASES -> R.string.uel_reset_databases Action.RESET_DATABASES -> R.string.uel_reset_databases
UserEntry.Action.EXPORT_DATABASES -> R.string.uel_export_databases Action.EXPORT_DATABASES -> R.string.uel_export_databases
UserEntry.Action.IMPORT_DATABASES -> R.string.uel_import_databases Action.IMPORT_DATABASES -> R.string.uel_import_databases
UserEntry.Action.OTP_EXPORT -> R.string.uel_otp_export Action.OTP_EXPORT -> R.string.uel_otp_export
UserEntry.Action.OTP_RESET -> R.string.uel_otp_reset Action.OTP_RESET -> R.string.uel_otp_reset
UserEntry.Action.SMS_BASAL -> R.string.uel_sms_basal Action.SMS_BASAL -> R.string.uel_sms_basal
UserEntry.Action.SMS_BOLUS -> R.string.uel_sms_bolus Action.SMS_BOLUS -> R.string.uel_sms_bolus
UserEntry.Action.SMS_CAL -> R.string.uel_sms_cal Action.SMS_CAL -> R.string.uel_sms_cal
UserEntry.Action.SMS_CARBS -> R.string.uel_sms_carbs Action.SMS_CARBS -> R.string.uel_sms_carbs
UserEntry.Action.SMS_EXTENDED_BOLUS -> R.string.uel_sms_extended_bolus Action.SMS_EXTENDED_BOLUS -> R.string.uel_sms_extended_bolus
UserEntry.Action.SMS_LOOP_DISABLED -> R.string.uel_sms_loop_disabled Action.SMS_LOOP_DISABLED -> R.string.uel_sms_loop_disabled
UserEntry.Action.SMS_LOOP_ENABLED -> R.string.uel_sms_loop_enabled Action.SMS_LOOP_ENABLED -> R.string.uel_sms_loop_enabled
UserEntry.Action.SMS_LOOP_RESUME -> R.string.uel_sms_loop_resume Action.SMS_LOOP_RESUME -> R.string.uel_sms_loop_resume
UserEntry.Action.SMS_LOOP_SUSPEND -> R.string.uel_sms_loop_suspend Action.SMS_LOOP_SUSPEND -> R.string.uel_sms_loop_suspend
UserEntry.Action.SMS_PROFILE -> R.string.uel_sms_profile Action.SMS_PROFILE -> R.string.uel_sms_profile
UserEntry.Action.SMS_PUMP_CONNECT -> R.string.uel_sms_pump_connect Action.SMS_PUMP_CONNECT -> R.string.uel_sms_pump_connect
UserEntry.Action.SMS_PUMP_DISCONNECT -> R.string.uel_sms_pump_disconnect Action.SMS_PUMP_DISCONNECT -> R.string.uel_sms_pump_disconnect
UserEntry.Action.SMS_SMS -> R.string.uel_sms_sms Action.SMS_SMS -> R.string.uel_sms_sms
UserEntry.Action.SMS_TT -> R.string.uel_sms_tt Action.SMS_TT -> R.string.uel_sms_tt
UserEntry.Action.TT_DELETED_FROM_NS -> R.string.uel_tt_deleted_from_ns Action.TT_DELETED_FROM_NS -> R.string.uel_tt_deleted_from_ns
UserEntry.Action.TT_FROM_NS -> R.string.uel_tt_from_ns Action.TT_FROM_NS -> R.string.uel_tt_from_ns
UserEntry.Action.TT_CANCELED_FROM_NS -> R.string.uel_tt_canceleted_from_ns Action.TT_CANCELED_FROM_NS -> R.string.uel_tt_canceleted_from_ns
UserEntry.Action.UE_EXPORT_TO_XML -> R.string.ue_export_to_xml
else -> R.string.uel_unknown else -> R.string.uel_unknown
} }
} }
fun UserEntry.Action.colorId(): Int { fun Action.colorId(): Int {
return when (this) { return when (this) {
UserEntry.Action.BOLUS -> R.color.iob Action.EXTENDED_CARBS -> R.color.carbs
UserEntry.Action.BOLUS_WIZARD -> R.color.iob Action.TEMP_BASAL -> R.color.basal
UserEntry.Action.BOLUS_ADVISOR -> R.color.iob Action.TT -> R.color.tempTargetConfirmation
UserEntry.Action.BOLUS_RECORD -> R.color.iob Action.TT_ACTIVITY -> R.color.tempTargetConfirmation
UserEntry.Action.EXTENDED_BOLUS -> R.color.extendedBolus Action.TT_EATING_SOON -> R.color.tempTargetConfirmation
UserEntry.Action.SUPERBOLUS_TBR -> R.color.carbs Action.TT_HYPO -> R.color.tempTargetConfirmation
UserEntry.Action.CARBS -> R.color.carbs Action.NEW_PROFILE -> R.color.white
UserEntry.Action.EXTENDED_CARBS -> R.color.carbs Action.CLONE_PROFILE -> R.color.white
UserEntry.Action.TEMP_BASAL -> R.color.basal Action.STORE_PROFILE -> R.color.white
UserEntry.Action.TT -> R.color.tempTargetConfirmation Action.PROFILE_SWITCH -> R.color.white
UserEntry.Action.TT_ACTIVITY -> R.color.tempTargetConfirmation Action.PROFILE_SWITCH_CLONED -> R.color.white
UserEntry.Action.TT_EATING_SOON -> R.color.tempTargetConfirmation Action.CLOSED_LOOP_MODE -> R.color.loopClosed
UserEntry.Action.TT_HYPO -> R.color.tempTargetConfirmation Action.LGS_LOOP_MODE -> R.color.loopClosed
UserEntry.Action.NEW_PROFILE -> R.color.white Action.OPEN_LOOP_MODE -> R.color.loopOpened
UserEntry.Action.CLONE_PROFILE -> R.color.white Action.LOOP_DISABLED -> R.color.loopDisabled
UserEntry.Action.STORE_PROFILE -> R.color.white Action.LOOP_ENABLED -> R.color.loopClosed
UserEntry.Action.PROFILE_SWITCH -> R.color.white Action.RECONNECT -> R.color.loopDisconnected
UserEntry.Action.PROFILE_SWITCH_CLONED -> R.color.white Action.DISCONNECT_15M -> R.color.loopDisconnected
UserEntry.Action.CLOSED_LOOP_MODE -> R.color.loopClosed Action.DISCONNECT_30M -> R.color.loopDisconnected
UserEntry.Action.LGS_LOOP_MODE -> R.color.loopClosed Action.DISCONNECT_1H -> R.color.loopDisconnected
UserEntry.Action.OPEN_LOOP_MODE -> R.color.loopOpened Action.DISCONNECT_2H -> R.color.loopDisconnected
UserEntry.Action.LOOP_DISABLED -> R.color.loopDisabled Action.DISCONNECT_3H -> R.color.loopDisconnected
UserEntry.Action.LOOP_ENABLED -> R.color.loopClosed Action.RESUME -> R.color.loopClosed
UserEntry.Action.RECONNECT -> R.color.loopDisconnected Action.SUSPEND_1H -> R.color.loopSuspended
UserEntry.Action.DISCONNECT_15M -> R.color.loopDisconnected Action.SUSPEND_2H -> R.color.loopSuspended
UserEntry.Action.DISCONNECT_30M -> R.color.loopDisconnected Action.SUSPEND_3H -> R.color.loopSuspended
UserEntry.Action.DISCONNECT_1H -> R.color.loopDisconnected Action.SUSPEND_10H -> R.color.loopSuspended
UserEntry.Action.DISCONNECT_2H -> R.color.loopDisconnected Action.HW_PUMP_ALLOWED -> R.color.defaulttext
UserEntry.Action.DISCONNECT_3H -> R.color.loopDisconnected Action.CLEAR_PAIRING_KEYS -> R.color.defaulttext
UserEntry.Action.RESUME -> R.color.loopClosed Action.ACCEPTS_TEMP_BASAL -> R.color.basal
UserEntry.Action.SUSPEND_1H -> R.color.loopSuspended Action.CANCEL_TEMP_BASAL -> R.color.basal
UserEntry.Action.SUSPEND_2H -> R.color.loopSuspended Action.CANCEL_EXTENDED_BOLUS -> R.color.extendedBolus
UserEntry.Action.SUSPEND_3H -> R.color.loopSuspended Action.CANCEL_TT -> R.color.tempTargetConfirmation
UserEntry.Action.SUSPEND_10H -> R.color.loopSuspended Action.CAREPORTAL -> R.color.notificationAnnouncement
UserEntry.Action.HW_PUMP_ALLOWED -> R.color.defaulttext Action.CALIBRATION -> R.color.calibration
UserEntry.Action.CLEAR_PAIRING_KEYS -> R.color.defaulttext Action.INSULIN_CHANGE -> R.color.iob
UserEntry.Action.ACCEPTS_TEMP_BASAL -> R.color.basal Action.PRIME_BOLUS -> R.color.defaulttext
UserEntry.Action.CANCEL_TEMP_BASAL -> R.color.basal Action.SITE_CHANGE -> R.color.defaulttext
UserEntry.Action.CANCEL_EXTENDED_BOLUS -> R.color.extendedBolus Action.TREATMENT -> R.color.defaulttext
UserEntry.Action.CANCEL_TT -> R.color.tempTargetConfirmation Action.CAREPORTAL_NS_REFRESH -> R.color.notificationAnnouncement
UserEntry.Action.CAREPORTAL -> R.color.notificationAnnouncement Action.PROFILE_SWITCH_NS_REFRESH -> R.color.white
UserEntry.Action.CALIBRATION -> R.color.calibration Action.TREATMENTS_NS_REFRESH -> R.color.defaulttext
UserEntry.Action.INSULIN_CHANGE -> R.color.iob Action.TT_NS_REFRESH -> R.color.tempTargetConfirmation
UserEntry.Action.PRIME_BOLUS -> R.color.defaulttext Action.AUTOMATION_REMOVED -> R.color.defaulttext
UserEntry.Action.SITE_CHANGE -> R.color.defaulttext Action.BG_REMOVED -> R.color.calibration
UserEntry.Action.TREATMENT -> R.color.defaulttext Action.CAREPORTAL_REMOVED -> R.color.notificationAnnouncement
UserEntry.Action.CAREPORTAL_NS_REFRESH -> R.color.notificationAnnouncement Action.EXTENDED_BOLUS_REMOVED -> R.color.extendedBolus
UserEntry.Action.PROFILE_SWITCH_NS_REFRESH -> R.color.white Action.FOOD_REMOVED -> R.color.carbs
UserEntry.Action.TREATMENTS_NS_REFRESH -> R.color.defaulttext Action.PROFILE_REMOVED -> R.color.white
UserEntry.Action.TT_NS_REFRESH -> R.color.tempTargetConfirmation Action.PROFILE_SWITCH_REMOVED -> R.color.white
UserEntry.Action.AUTOMATION_REMOVED -> R.color.defaulttext Action.RESTART_EVENTS_REMOVED -> R.color.defaulttext
UserEntry.Action.BG_REMOVED -> R.color.calibration Action.TREATMENT_REMOVED -> R.color.defaulttext
UserEntry.Action.CAREPORTAL_REMOVED -> R.color.notificationAnnouncement Action.TT_REMOVED -> R.color.tempTargetConfirmation
UserEntry.Action.EXTENDED_BOLUS_REMOVED -> R.color.extendedBolus Action.NS_PAUSED -> R.color.defaulttext
UserEntry.Action.FOOD_REMOVED -> R.color.carbs Action.NS_QUEUE_CLEARED -> R.color.defaulttext
UserEntry.Action.PROFILE_REMOVED -> R.color.white Action.NS_SETTINGS_COPIED -> R.color.defaulttext
UserEntry.Action.PROFILE_SWITCH_REMOVED -> R.color.white Action.ERROR_DIALOG_OK -> R.color.defaulttext
UserEntry.Action.RESTART_EVENTS_REMOVED -> R.color.defaulttext Action.ERROR_DIALOG_MUTE -> R.color.defaulttext
UserEntry.Action.TREATMENT_REMOVED -> R.color.defaulttext Action.ERROR_DIALOG_MUTE_5MIN -> R.color.defaulttext
UserEntry.Action.TT_REMOVED -> R.color.tempTargetConfirmation Action.OBJECTIVE_STARTED -> R.color.defaulttext
UserEntry.Action.NS_PAUSED -> R.color.defaulttext Action.OBJECTIVE_UNSTARTED -> R.color.defaulttext
UserEntry.Action.NS_QUEUE_CLEARED -> R.color.defaulttext Action.OBJECTIVES_SKIPPED -> R.color.defaulttext
UserEntry.Action.NS_SETTINGS_COPIED -> R.color.defaulttext Action.STAT_RESET -> R.color.defaulttext
UserEntry.Action.ERROR_DIALOG_OK -> R.color.defaulttext Action.DELETE_LOGS -> R.color.defaulttext
UserEntry.Action.ERROR_DIALOG_MUTE -> R.color.defaulttext Action.DELETE_FUTURE_TREATMENTS -> R.color.defaulttext
UserEntry.Action.ERROR_DIALOG_MUTE_5MIN -> R.color.defaulttext Action.EXPORT_SETTINGS -> R.color.defaulttext
UserEntry.Action.OBJECTIVE_STARTED -> R.color.defaulttext Action.IMPORT_SETTINGS -> R.color.defaulttext
UserEntry.Action.OBJECTIVE_UNSTARTED -> R.color.defaulttext Action.RESET_DATABASES -> R.color.defaulttext
UserEntry.Action.OBJECTIVES_SKIPPED -> R.color.defaulttext Action.EXPORT_DATABASES -> R.color.defaulttext
UserEntry.Action.STAT_RESET -> R.color.defaulttext Action.IMPORT_DATABASES -> R.color.defaulttext
UserEntry.Action.DELETE_LOGS -> R.color.defaulttext Action.OTP_EXPORT -> R.color.defaulttext
UserEntry.Action.DELETE_FUTURE_TREATMENTS -> R.color.defaulttext Action.OTP_RESET -> R.color.defaulttext
UserEntry.Action.EXPORT_SETTINGS -> R.color.defaulttext Action.SMS_BASAL -> R.color.basal
UserEntry.Action.IMPORT_SETTINGS -> R.color.defaulttext Action.SMS_BOLUS -> R.color.iob
UserEntry.Action.RESET_DATABASES -> R.color.defaulttext Action.SMS_CAL -> R.color.calibration
UserEntry.Action.EXPORT_DATABASES -> R.color.defaulttext Action.SMS_CARBS -> R.color.carbs
UserEntry.Action.IMPORT_DATABASES -> R.color.defaulttext Action.SMS_EXTENDED_BOLUS -> R.color.extendedBolus
UserEntry.Action.OTP_EXPORT -> R.color.defaulttext Action.SMS_LOOP_DISABLED -> R.color.loopDisabled
UserEntry.Action.OTP_RESET -> R.color.defaulttext Action.SMS_LOOP_ENABLED -> R.color.loopClosed
UserEntry.Action.SMS_BASAL -> R.color.basal Action.SMS_LOOP_RESUME -> R.color.loopClosed
UserEntry.Action.SMS_BOLUS -> R.color.iob Action.SMS_LOOP_SUSPEND -> R.color.loopSuspended
UserEntry.Action.SMS_CAL -> R.color.calibration Action.SMS_PROFILE -> R.color.white
UserEntry.Action.SMS_CARBS -> R.color.carbs Action.SMS_PUMP_CONNECT -> R.color.loopDisconnected
UserEntry.Action.SMS_EXTENDED_BOLUS -> R.color.extendedBolus Action.SMS_PUMP_DISCONNECT -> R.color.loopDisconnected
UserEntry.Action.SMS_LOOP_DISABLED -> R.color.loopDisabled Action.SMS_SMS -> R.color.defaulttext
UserEntry.Action.SMS_LOOP_ENABLED -> R.color.loopClosed Action.SMS_TT -> R.color.tempTargetConfirmation
UserEntry.Action.SMS_LOOP_RESUME -> R.color.loopClosed Action.TT_DELETED_FROM_NS -> R.color.tempTargetConfirmation
UserEntry.Action.SMS_LOOP_SUSPEND -> R.color.loopSuspended Action.TT_FROM_NS -> R.color.tempTargetConfirmation
UserEntry.Action.SMS_PROFILE -> R.color.white Action.TT_CANCELED_FROM_NS -> R.color.tempTargetConfirmation
UserEntry.Action.SMS_PUMP_CONNECT -> R.color.loopDisconnected else -> R.color.defaulttext
UserEntry.Action.SMS_PUMP_DISCONNECT -> R.color.loopDisconnected
UserEntry.Action.SMS_SMS -> R.color.defaulttext
UserEntry.Action.SMS_TT -> R.color.tempTargetConfirmation
UserEntry.Action.TT_DELETED_FROM_NS -> R.color.tempTargetConfirmation
UserEntry.Action.TT_FROM_NS -> R.color.tempTargetConfirmation
UserEntry.Action.TT_CANCELED_FROM_NS -> R.color.tempTargetConfirmation
else -> R.color.defaulttext
} }
} }
fun UserEntry.Units.stringId(): Int { fun ColorGroup.colorId(): Int {
return when { return when (this) {
this == UserEntry.Units.Mg_Dl -> R.string.mgdl ColorGroup.InsulinTreatment -> R.color.basal
this == UserEntry.Units.Mmol_L -> R.string.mmol ColorGroup.CarbTreatment -> R.color.carbs
this == UserEntry.Units.U -> R.string.insulin_unit_shortname ColorGroup.TT -> R.color.tempTargetConfirmation
this == UserEntry.Units.U_H -> R.string.profile_ins_units_per_hour ColorGroup.Profile -> R.color.white
this == UserEntry.Units.G -> R.string.shortgram ColorGroup.Loop -> R.color.loopClosed
this == UserEntry.Units.M -> R.string.shortminute ColorGroup.Careportal -> R.color.high
this == UserEntry.Units.H -> R.string.shorthour ColorGroup.Pump -> R.color.iob
this == UserEntry.Units.Percent -> R.string.shortpercent ColorGroup.Aaps -> R.color.defaulttext
this == UserEntry.Units.R_String -> R.string.formated_string else -> R.color.defaulttext
}
}
fun Units.stringId(): Int {
return when (this) {
Units.Mg_Dl -> R.string.mgdl
Units.Mmol_L -> R.string.mmol
Units.U -> R.string.insulin_unit_shortname
Units.U_H -> R.string.profile_ins_units_per_hour
Units.G -> R.string.shortgram
Units.M -> R.string.shortminute
Units.H -> R.string.shorthour
Units.Percent -> R.string.shortpercent
Units.R_String -> R.string.formated_string
else -> 0 else -> 0
} }
} }

View file

@ -18,109 +18,108 @@ data class UserEntry(
var s: String, var s: String,
var values: MutableList<ValueWithUnit> var values: MutableList<ValueWithUnit>
) : DBEntry, DBEntryWithTime { ) : DBEntry, DBEntryWithTime {
enum class Action () { enum class Action (val colorGroup: ColorGroup) {
@SerializedName("BOLUS") BOLUS, @SerializedName("BOLUS") BOLUS (ColorGroup.InsulinTreatment),
@SerializedName("BOLUS_WIZARD") BOLUS_WIZARD, @SerializedName("BOLUS_WIZARD") BOLUS_WIZARD (ColorGroup.InsulinTreatment),
@SerializedName("BOLUS_ADVISOR") BOLUS_ADVISOR, @SerializedName("BOLUS_ADVISOR") BOLUS_ADVISOR (ColorGroup.InsulinTreatment),
@SerializedName("BOLUS_RECORD") BOLUS_RECORD, @SerializedName("BOLUS_RECORD") BOLUS_RECORD (ColorGroup.InsulinTreatment),
@SerializedName("EXTENDED_BOLUS") EXTENDED_BOLUS, @SerializedName("EXTENDED_BOLUS") EXTENDED_BOLUS (ColorGroup.InsulinTreatment),
@SerializedName("SUPERBOLUS_TBR") SUPERBOLUS_TBR, @SerializedName("SUPERBOLUS_TBR") SUPERBOLUS_TBR (ColorGroup.InsulinTreatment),
@SerializedName("CARBS") CARBS, @SerializedName("CARBS") CARBS (ColorGroup.CarbTreatment),
@SerializedName("EXTENDED_CARBS") EXTENDED_CARBS, @SerializedName("EXTENDED_CARBS") EXTENDED_CARBS (ColorGroup.CarbTreatment),
@SerializedName("TEMP_BASAL") TEMP_BASAL, @SerializedName("TEMP_BASAL") TEMP_BASAL (ColorGroup.TT),
@SerializedName("TT") TT, @SerializedName("TT") TT (ColorGroup.TT),
@SerializedName("TT_ACTIVITY") TT_ACTIVITY, @SerializedName("TT_ACTIVITY") TT_ACTIVITY (ColorGroup.TT),
@SerializedName("TT_EATING_SOON") TT_EATING_SOON, @SerializedName("TT_EATING_SOON") TT_EATING_SOON (ColorGroup.TT),
@SerializedName("TT_HYPO") TT_HYPO, @SerializedName("TT_HYPO") TT_HYPO (ColorGroup.TT),
@SerializedName("NEW_PROFILE") NEW_PROFILE, @SerializedName("NEW_PROFILE") NEW_PROFILE (ColorGroup.Profile),
@SerializedName("CLONE_PROFILE") CLONE_PROFILE, @SerializedName("CLONE_PROFILE") CLONE_PROFILE (ColorGroup.Profile),
@SerializedName("STORE_PROFILE") STORE_PROFILE, @SerializedName("STORE_PROFILE") STORE_PROFILE (ColorGroup.Profile),
@SerializedName("PROFILE_SWITCH") PROFILE_SWITCH, @SerializedName("PROFILE_SWITCH") PROFILE_SWITCH (ColorGroup.Profile),
@SerializedName("PROFILE_SWITCH_CLONED") PROFILE_SWITCH_CLONED, @SerializedName("PROFILE_SWITCH_CLONED") PROFILE_SWITCH_CLONED (ColorGroup.Profile),
@SerializedName("CLOSED_LOOP_MODE") CLOSED_LOOP_MODE, @SerializedName("CLOSED_LOOP_MODE") CLOSED_LOOP_MODE (ColorGroup.Loop),
@SerializedName("LGS_LOOP_MODE") LGS_LOOP_MODE, @SerializedName("LGS_LOOP_MODE") LGS_LOOP_MODE (ColorGroup.Loop),
@SerializedName("OPEN_LOOP_MODE") OPEN_LOOP_MODE, @SerializedName("OPEN_LOOP_MODE") OPEN_LOOP_MODE (ColorGroup.Loop),
@SerializedName("LOOP_DISABLED") LOOP_DISABLED, @SerializedName("LOOP_DISABLED") LOOP_DISABLED (ColorGroup.Loop),
@SerializedName("LOOP_ENABLED") LOOP_ENABLED, @SerializedName("LOOP_ENABLED") LOOP_ENABLED (ColorGroup.Loop),
@SerializedName("RECONNECT") RECONNECT, @SerializedName("RECONNECT") RECONNECT (ColorGroup.Pump),
@SerializedName("DISCONNECT_15M") DISCONNECT_15M, @SerializedName("DISCONNECT_15M") DISCONNECT_15M (ColorGroup.Pump),
@SerializedName("DISCONNECT_30M") DISCONNECT_30M, @SerializedName("DISCONNECT_30M") DISCONNECT_30M (ColorGroup.Pump),
@SerializedName("DISCONNECT_1H") DISCONNECT_1H, @SerializedName("DISCONNECT_1H") DISCONNECT_1H (ColorGroup.Pump),
@SerializedName("DISCONNECT_2H") DISCONNECT_2H, @SerializedName("DISCONNECT_2H") DISCONNECT_2H (ColorGroup.Pump),
@SerializedName("DISCONNECT_3H") DISCONNECT_3H, @SerializedName("DISCONNECT_3H") DISCONNECT_3H (ColorGroup.Pump),
@SerializedName("RESUME") RESUME, @SerializedName("RESUME") RESUME (ColorGroup.Loop),
@SerializedName("SUSPEND_1H") SUSPEND_1H, @SerializedName("SUSPEND_1H") SUSPEND_1H (ColorGroup.Loop),
@SerializedName("SUSPEND_2H") SUSPEND_2H, @SerializedName("SUSPEND_2H") SUSPEND_2H (ColorGroup.Loop),
@SerializedName("SUSPEND_3H") SUSPEND_3H, @SerializedName("SUSPEND_3H") SUSPEND_3H (ColorGroup.Loop),
@SerializedName("SUSPEND_10H") SUSPEND_10H, @SerializedName("SUSPEND_10H") SUSPEND_10H (ColorGroup.Loop),
@SerializedName("HW_PUMP_ALLOWED") HW_PUMP_ALLOWED, @SerializedName("HW_PUMP_ALLOWED") HW_PUMP_ALLOWED (ColorGroup.Pump),
@SerializedName("CLEAR_PAIRING_KEYS") CLEAR_PAIRING_KEYS, @SerializedName("CLEAR_PAIRING_KEYS") CLEAR_PAIRING_KEYS (ColorGroup.Pump),
@SerializedName("ACCEPTS_TEMP_BASAL") ACCEPTS_TEMP_BASAL, @SerializedName("ACCEPTS_TEMP_BASAL") ACCEPTS_TEMP_BASAL (ColorGroup.InsulinTreatment),
@SerializedName("CANCEL_TEMP_BASAL") CANCEL_TEMP_BASAL, @SerializedName("CANCEL_TEMP_BASAL") CANCEL_TEMP_BASAL (ColorGroup.InsulinTreatment),
@SerializedName("CANCEL_EXTENDED_BOLUS") CANCEL_EXTENDED_BOLUS, @SerializedName("CANCEL_EXTENDED_BOLUS") CANCEL_EXTENDED_BOLUS (ColorGroup.InsulinTreatment),
@SerializedName("CANCEL_TT") CANCEL_TT, @SerializedName("CANCEL_TT") CANCEL_TT (ColorGroup.TT),
@SerializedName("CAREPORTAL") CAREPORTAL, @SerializedName("CAREPORTAL") CAREPORTAL (ColorGroup.Careportal),
@SerializedName("CALIBRATION") CALIBRATION, @SerializedName("CALIBRATION") CALIBRATION (ColorGroup.Careportal),
@SerializedName("INSULIN_CHANGE") INSULIN_CHANGE, @SerializedName("INSULIN_CHANGE") INSULIN_CHANGE (ColorGroup.InsulinTreatment),
@SerializedName("PRIME_BOLUS") PRIME_BOLUS, @SerializedName("PRIME_BOLUS") PRIME_BOLUS (ColorGroup.Careportal),
@SerializedName("SITE_CHANGE") SITE_CHANGE, @SerializedName("SITE_CHANGE") SITE_CHANGE (ColorGroup.Careportal),
@SerializedName("TREATMENT") TREATMENT, @SerializedName("TREATMENT") TREATMENT (ColorGroup.InsulinTreatment),
@SerializedName("CAREPORTAL_NS_REFRESH") CAREPORTAL_NS_REFRESH, @SerializedName("CAREPORTAL_NS_REFRESH") CAREPORTAL_NS_REFRESH (ColorGroup.Careportal),
@SerializedName("PROFILE_SWITCH_NS_REFRESH") PROFILE_SWITCH_NS_REFRESH, @SerializedName("PROFILE_SWITCH_NS_REFRESH") PROFILE_SWITCH_NS_REFRESH (ColorGroup.Profile),
@SerializedName("TREATMENTS_NS_REFRESH") TREATMENTS_NS_REFRESH, @SerializedName("TREATMENTS_NS_REFRESH") TREATMENTS_NS_REFRESH (ColorGroup.InsulinTreatment),
@SerializedName("TT_NS_REFRESH") TT_NS_REFRESH, @SerializedName("TT_NS_REFRESH") TT_NS_REFRESH (ColorGroup.TT),
@SerializedName("AUTOMATION_REMOVED") AUTOMATION_REMOVED, @SerializedName("AUTOMATION_REMOVED") AUTOMATION_REMOVED (ColorGroup.Aaps),
@SerializedName("BG_REMOVED") BG_REMOVED, @SerializedName("BG_REMOVED") BG_REMOVED (ColorGroup.Careportal),
@SerializedName("CAREPORTAL_REMOVED") CAREPORTAL_REMOVED, @SerializedName("CAREPORTAL_REMOVED") CAREPORTAL_REMOVED (ColorGroup.Careportal),
@SerializedName("EXTENDED_BOLUS_REMOVED") EXTENDED_BOLUS_REMOVED, @SerializedName("EXTENDED_BOLUS_REMOVED") EXTENDED_BOLUS_REMOVED (ColorGroup.InsulinTreatment),
@SerializedName("FOOD_REMOVED") FOOD_REMOVED, @SerializedName("FOOD_REMOVED") FOOD_REMOVED (ColorGroup.Careportal),
@SerializedName("PROFILE_REMOVED") PROFILE_REMOVED, @SerializedName("PROFILE_REMOVED") PROFILE_REMOVED (ColorGroup.Profile),
@SerializedName("PROFILE_SWITCH_REMOVED") PROFILE_SWITCH_REMOVED, @SerializedName("PROFILE_SWITCH_REMOVED") PROFILE_SWITCH_REMOVED (ColorGroup.Profile),
@SerializedName("RESTART_EVENTS_REMOVED") RESTART_EVENTS_REMOVED, @SerializedName("RESTART_EVENTS_REMOVED") RESTART_EVENTS_REMOVED (ColorGroup.Aaps),
@SerializedName("TREATMENT_REMOVED") TREATMENT_REMOVED, @SerializedName("TREATMENT_REMOVED") TREATMENT_REMOVED (ColorGroup.InsulinTreatment),
@SerializedName("TT_REMOVED") TT_REMOVED, @SerializedName("TT_REMOVED") TT_REMOVED (ColorGroup.TT),
@SerializedName("NS_PAUSED") NS_PAUSED, @SerializedName("NS_PAUSED") NS_PAUSED (ColorGroup.Aaps),
@SerializedName("NS_QUEUE_CLEARED") NS_QUEUE_CLEARED, @SerializedName("NS_QUEUE_CLEARED") NS_QUEUE_CLEARED (ColorGroup.Aaps),
@SerializedName("NS_SETTINGS_COPIED") NS_SETTINGS_COPIED, @SerializedName("NS_SETTINGS_COPIED") NS_SETTINGS_COPIED (ColorGroup.Aaps),
@SerializedName("ERROR_DIALOG_OK") ERROR_DIALOG_OK, @SerializedName("ERROR_DIALOG_OK") ERROR_DIALOG_OK (ColorGroup.Aaps),
@SerializedName("ERROR_DIALOG_MUTE") ERROR_DIALOG_MUTE, @SerializedName("ERROR_DIALOG_MUTE") ERROR_DIALOG_MUTE (ColorGroup.Aaps),
@SerializedName("ERROR_DIALOG_MUTE_5MIN") ERROR_DIALOG_MUTE_5MIN, @SerializedName("ERROR_DIALOG_MUTE_5MIN") ERROR_DIALOG_MUTE_5MIN (ColorGroup.Aaps),
@SerializedName("OBJECTIVE_STARTED") OBJECTIVE_STARTED, @SerializedName("OBJECTIVE_STARTED") OBJECTIVE_STARTED (ColorGroup.Aaps),
@SerializedName("OBJECTIVE_UNSTARTED") OBJECTIVE_UNSTARTED, @SerializedName("OBJECTIVE_UNSTARTED") OBJECTIVE_UNSTARTED (ColorGroup.Aaps),
@SerializedName("OBJECTIVES_SKIPPED") OBJECTIVES_SKIPPED, @SerializedName("OBJECTIVES_SKIPPED") OBJECTIVES_SKIPPED (ColorGroup.Aaps),
@SerializedName("STAT_RESET") STAT_RESET, @SerializedName("STAT_RESET") STAT_RESET (ColorGroup.Aaps),
@SerializedName("DELETE_LOGS") DELETE_LOGS, @SerializedName("DELETE_LOGS") DELETE_LOGS (ColorGroup.Aaps),
@SerializedName("DELETE_FUTURE_TREATMENTS") DELETE_FUTURE_TREATMENTS, @SerializedName("DELETE_FUTURE_TREATMENTS") DELETE_FUTURE_TREATMENTS (ColorGroup.Aaps),
@SerializedName("EXPORT_SETTINGS") EXPORT_SETTINGS, @SerializedName("EXPORT_SETTINGS") EXPORT_SETTINGS (ColorGroup.Aaps),
@SerializedName("IMPORT_SETTINGS") IMPORT_SETTINGS, @SerializedName("IMPORT_SETTINGS") IMPORT_SETTINGS (ColorGroup.Aaps),
@SerializedName("RESET_DATABASES") RESET_DATABASES, @SerializedName("RESET_DATABASES") RESET_DATABASES (ColorGroup.Aaps),
@SerializedName("EXPORT_DATABASES") EXPORT_DATABASES, @SerializedName("EXPORT_DATABASES") EXPORT_DATABASES (ColorGroup.Aaps),
@SerializedName("IMPORT_DATABASES") IMPORT_DATABASES, @SerializedName("IMPORT_DATABASES") IMPORT_DATABASES (ColorGroup.Aaps),
@SerializedName("OTP_EXPORT") OTP_EXPORT, @SerializedName("OTP_EXPORT") OTP_EXPORT (ColorGroup.Aaps),
@SerializedName("OTP_RESET") OTP_RESET, @SerializedName("OTP_RESET") OTP_RESET (ColorGroup.Aaps),
@SerializedName("SMS_BASAL") SMS_BASAL, @SerializedName("SMS_BASAL") SMS_BASAL (ColorGroup.InsulinTreatment),
@SerializedName("SMS_BOLUS") SMS_BOLUS, @SerializedName("SMS_BOLUS") SMS_BOLUS (ColorGroup.InsulinTreatment),
@SerializedName("SMS_CAL") SMS_CAL, @SerializedName("SMS_CAL") SMS_CAL (ColorGroup.Careportal),
@SerializedName("SMS_CARBS") SMS_CARBS, @SerializedName("SMS_CARBS") SMS_CARBS (ColorGroup.CarbTreatment),
@SerializedName("SMS_EXTENDED_BOLUS") SMS_EXTENDED_BOLUS, @SerializedName("SMS_EXTENDED_BOLUS") SMS_EXTENDED_BOLUS (ColorGroup.InsulinTreatment),
@SerializedName("SMS_LOOP_DISABLED") SMS_LOOP_DISABLED, @SerializedName("SMS_LOOP_DISABLED") SMS_LOOP_DISABLED (ColorGroup.Loop),
@SerializedName("SMS_LOOP_ENABLED") SMS_LOOP_ENABLED, @SerializedName("SMS_LOOP_ENABLED") SMS_LOOP_ENABLED (ColorGroup.Loop),
@SerializedName("SMS_LOOP_RESUME") SMS_LOOP_RESUME, @SerializedName("SMS_LOOP_RESUME") SMS_LOOP_RESUME (ColorGroup.Loop),
@SerializedName("SMS_LOOP_SUSPEND") SMS_LOOP_SUSPEND, @SerializedName("SMS_LOOP_SUSPEND") SMS_LOOP_SUSPEND (ColorGroup.Loop),
@SerializedName("SMS_PROFILE") SMS_PROFILE, @SerializedName("SMS_PROFILE") SMS_PROFILE (ColorGroup.Profile),
@SerializedName("SMS_PUMP_CONNECT") SMS_PUMP_CONNECT, @SerializedName("SMS_PUMP_CONNECT") SMS_PUMP_CONNECT (ColorGroup.Pump),
@SerializedName("SMS_PUMP_DISCONNECT") SMS_PUMP_DISCONNECT, @SerializedName("SMS_PUMP_DISCONNECT") SMS_PUMP_DISCONNECT (ColorGroup.Pump),
@SerializedName("SMS_SMS") SMS_SMS, @SerializedName("SMS_SMS") SMS_SMS (ColorGroup.Aaps),
@SerializedName("SMS_TT") SMS_TT, @SerializedName("SMS_TT") SMS_TT (ColorGroup.TT),
@SerializedName("TT_DELETED_FROM_NS") TT_DELETED_FROM_NS, @SerializedName("TT_DELETED_FROM_NS") TT_DELETED_FROM_NS (ColorGroup.TT),
@SerializedName("TT_FROM_NS") TT_FROM_NS, @SerializedName("TT_FROM_NS") TT_FROM_NS (ColorGroup.TT),
@SerializedName("TT_CANCELED_FROM_NS") TT_CANCELED_FROM_NS, @SerializedName("TT_CANCELED_FROM_NS") TT_CANCELED_FROM_NS (ColorGroup.TT),
@SerializedName("UE_EXPORT_TO_XML") UE_EXPORT_TO_XML, @SerializedName("UNKNOWN") UNKNOWN (ColorGroup.Aaps)
@SerializedName("UNKNOWN") UNKNOWN
; ;
companion object { companion object {
fun fromString(source: String?) = UserEntry.Action.values().firstOrNull { it.name == source } ?: UserEntry.Action.UNKNOWN fun fromString(source: String?) = values().firstOrNull { it.name == source } ?: UNKNOWN
} }
} }
data class ValueWithUnit (val dValue: Double, val iValue: Int, val lValue: Long, val sValue: String, val unit: Units) { data class ValueWithUnit (val dValue: Double, val iValue: Int, val lValue: Long, val sValue: String, val unit: Units) {
@ -159,4 +158,15 @@ data class UserEntry(
fun fromText(unit: String?) = values().firstOrNull { it.text == unit } ?: None fun fromText(unit: String?) = values().firstOrNull { it.text == unit } ?: None
} }
} }
enum class ColorGroup() {
InsulinTreatment,
CarbTreatment,
TT,
Profile,
Loop,
Careportal,
Pump,
Aaps
}
} }