diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt index e7d6698819..a1e78070f3 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CarbsDialog.kt @@ -272,12 +272,12 @@ class CarbsDialog : DialogFragmentWithDate() { if (carbsAfterConstraints > 0) { if (duration == 0) { 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 - 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) } 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) nsUpload.uploadEvent(CareportalEvent.NOTE, DateUtil.now() - 2000, resourceHelper.gs(R.string.generated_ecarbs_note, carbsAfterConstraints, duration, timeOffset)) } diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt index 80df9ce2c3..96bab1b369 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/CareDialog.kt @@ -54,6 +54,7 @@ class CareDialog : DialogFragmentWithDate() { } private var options: EventType = EventType.BGCHECK + private var valuesWithUnit = mutableListOf() @StringRes 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.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("glucoseType", type) } 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())) + valuesWithUnit.add(ValueWithUnit(binding.duration.value.toInt(), Units.M)) json.put("duration", binding.duration.value.toInt()) } val notes = binding.notesLayout.notes.text.toString() @@ -192,8 +196,10 @@ class CareDialog : DialogFragmentWithDate() { } eventTime -= eventTime % 1000 - if (eventTimeChanged) + if (eventTimeChanged) { 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("mills", eventTime) @@ -224,11 +230,9 @@ class CareDialog : DialogFragmentWithDate() { EventType.QUESTION -> CareportalEvent.QUESTION EventType.ANNOUNCEMENT -> CareportalEvent.ANNOUNCEMENT } + valuesWithUnit.add(if (eventTimeChanged) 1 else 0, ValueWithUnit(careportalEvent.eventType, Units.CPEvent)) careportalEvent.json = json.toString() - if (eventTimeChanged) - 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)) + uel.log(Action.CAREPORTAL, notes, valuesWithUnit) databaseHelper.createOrUpdate(careportalEvent) nsUpload.uploadCareportalEntryToNS(json, eventTime) }, null) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsUserEntryFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsUserEntryFragment.kt index 5bc75ec354..9442a069e3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsUserEntryFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/treatments/fragments/TreatmentsUserEntryFragment.kt @@ -92,7 +92,7 @@ class TreatmentsUserEntryFragment : DaggerFragment() { val current = entries[position] holder.binding.date.text = dateUtil.dateAndTimeAndSecondsString(current.timestamp) 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 //holder.binding.s.text = current.toString() //for debug 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.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 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 "" } diff --git a/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt b/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt index 1cc1895c48..1ddbca4d7f 100644 --- a/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt +++ b/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt @@ -68,4 +68,18 @@ class UserEntryLogger @Inject constructor( onComplete = { aapsLogger.debug("USER ENTRY: $action") } ) } + + fun log(action: Action, s: String = "", values: MutableList) { + 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") } + ) + } } \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt index 4b02f8e21d..a110d68827 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt @@ -1,225 +1,230 @@ package info.nightscout.androidaps.utils.extensions -import com.google.gson.annotations.SerializedName 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) { - UserEntry.Action.BOLUS -> R.string.uel_bolus - UserEntry.Action.BOLUS_WIZARD -> R.string.uel_bolus_wizard - UserEntry.Action.BOLUS_ADVISOR -> R.string.uel_bolus_advisor - UserEntry.Action.BOLUS_RECORD -> R.string.uel_bolus_record - UserEntry.Action.EXTENDED_BOLUS -> R.string.uel_extended_bolus - UserEntry.Action.SUPERBOLUS_TBR -> R.string.uel_superbolus_tbr - UserEntry.Action.CARBS -> R.string.uel_carbs - UserEntry.Action.EXTENDED_CARBS -> R.string.uel_extended_carbs - UserEntry.Action.TEMP_BASAL -> R.string.uel_temp_basal - UserEntry.Action.TT -> R.string.uel_tt - UserEntry.Action.TT_ACTIVITY -> R.string.uel_tt_activity - UserEntry.Action.TT_EATING_SOON -> R.string.uel_tt_eating_soon - UserEntry.Action.TT_HYPO -> R.string.uel_tt_hypo - UserEntry.Action.NEW_PROFILE -> R.string.uel_new_profile - UserEntry.Action.CLONE_PROFILE -> R.string.uel_clone_profile - UserEntry.Action.STORE_PROFILE -> R.string.uel_store_profile - UserEntry.Action.PROFILE_SWITCH -> R.string.uel_profile_switch - UserEntry.Action.PROFILE_SWITCH_CLONED -> R.string.uel_profile_switch_cloned - UserEntry.Action.CLOSED_LOOP_MODE -> R.string.uel_closed_loop_mode - UserEntry.Action.LGS_LOOP_MODE -> R.string.uel_lgs_loop_mode - UserEntry.Action.OPEN_LOOP_MODE -> R.string.uel_open_loop_mode - UserEntry.Action.LOOP_DISABLED -> R.string.uel_loop_disabled - UserEntry.Action.LOOP_ENABLED -> R.string.uel_loop_enabled - UserEntry.Action.RECONNECT -> R.string.uel_reconnect - UserEntry.Action.DISCONNECT_15M -> R.string.uel_disconnect_15m - UserEntry.Action.DISCONNECT_30M -> R.string.uel_disconnect_30m - UserEntry.Action.DISCONNECT_1H -> R.string.uel_disconnect_1h - UserEntry.Action.DISCONNECT_2H -> R.string.uel_disconnect_2h - UserEntry.Action.DISCONNECT_3H -> R.string.uel_disconnect_3h - UserEntry.Action.RESUME -> R.string.uel_resume - UserEntry.Action.SUSPEND_1H -> R.string.uel_suspend_1h - UserEntry.Action.SUSPEND_2H -> R.string.uel_suspend_2h - UserEntry.Action.SUSPEND_3H -> R.string.uel_suspend_3h - UserEntry.Action.SUSPEND_10H -> R.string.uel_suspend_10h - UserEntry.Action.HW_PUMP_ALLOWED -> R.string.uel_hw_pump_allowed - UserEntry.Action.CLEAR_PAIRING_KEYS -> R.string.uel_clear_pairing_keys - UserEntry.Action.ACCEPTS_TEMP_BASAL -> R.string.uel_accepts_temp_basal - UserEntry.Action.CANCEL_TEMP_BASAL -> R.string.uel_cancel_temp_basal - UserEntry.Action.CANCEL_EXTENDED_BOLUS -> R.string.uel_cancel_extended_bolus - UserEntry.Action.CANCEL_TT -> R.string.uel_cancel_tt - UserEntry.Action.CAREPORTAL -> R.string.uel_careportal - UserEntry.Action.CALIBRATION -> R.string.uel_calibration - UserEntry.Action.INSULIN_CHANGE -> R.string.uel_insulin_change - UserEntry.Action.PRIME_BOLUS -> R.string.uel_prime_bolus - UserEntry.Action.SITE_CHANGE -> R.string.uel_site_change - UserEntry.Action.TREATMENT -> R.string.uel_treatment - UserEntry.Action.CAREPORTAL_NS_REFRESH -> R.string.uel_careportal_ns_refresh - UserEntry.Action.PROFILE_SWITCH_NS_REFRESH -> R.string.uel_profile_switch_ns_refresh - UserEntry.Action.TREATMENTS_NS_REFRESH -> R.string.uel_treatments_ns_refresh - UserEntry.Action.TT_NS_REFRESH -> R.string.uel_tt_ns_refresh - UserEntry.Action.AUTOMATION_REMOVED -> R.string.uel_automation_removed - UserEntry.Action.BG_REMOVED -> R.string.uel_bg_removed - UserEntry.Action.CAREPORTAL_REMOVED -> R.string.uel_careportal_removed - UserEntry.Action.EXTENDED_BOLUS_REMOVED -> R.string.uel_extended_bolus_removed - UserEntry.Action.FOOD_REMOVED -> R.string.uel_food_removed - UserEntry.Action.PROFILE_REMOVED -> R.string.uel_profile_removed - UserEntry.Action.PROFILE_SWITCH_REMOVED -> R.string.uel_profile_switch_removed - UserEntry.Action.RESTART_EVENTS_REMOVED -> R.string.uel_restart_events_removed - UserEntry.Action.TREATMENT_REMOVED -> R.string.uel_treatment_removed - UserEntry.Action.TT_REMOVED -> R.string.uel_tt_removed - UserEntry.Action.NS_PAUSED -> R.string.uel_ns_paused - UserEntry.Action.NS_QUEUE_CLEARED -> R.string.uel_ns_queue_cleared - UserEntry.Action.NS_SETTINGS_COPIED -> R.string.uel_ns_settings_copied - UserEntry.Action.ERROR_DIALOG_OK -> R.string.uel_error_dialog_ok - UserEntry.Action.ERROR_DIALOG_MUTE -> R.string.uel_error_dialog_mute - UserEntry.Action.ERROR_DIALOG_MUTE_5MIN -> R.string.uel_error_dialog_mute_5min - UserEntry.Action.OBJECTIVE_STARTED -> R.string.uel_objective_started - UserEntry.Action.OBJECTIVE_UNSTARTED -> R.string.uel_objective_unstarted - UserEntry.Action.OBJECTIVES_SKIPPED -> R.string.uel_objectives_skipped - UserEntry.Action.STAT_RESET -> R.string.uel_stat_reset - UserEntry.Action.DELETE_LOGS -> R.string.uel_delete_logs - UserEntry.Action.DELETE_FUTURE_TREATMENTS -> R.string.uel_delete_future_treatments - UserEntry.Action.EXPORT_SETTINGS -> R.string.uel_export_settings - UserEntry.Action.IMPORT_SETTINGS -> R.string.uel_import_settings - UserEntry.Action.RESET_DATABASES -> R.string.uel_reset_databases - UserEntry.Action.EXPORT_DATABASES -> R.string.uel_export_databases - UserEntry.Action.IMPORT_DATABASES -> R.string.uel_import_databases - UserEntry.Action.OTP_EXPORT -> R.string.uel_otp_export - UserEntry.Action.OTP_RESET -> R.string.uel_otp_reset - UserEntry.Action.SMS_BASAL -> R.string.uel_sms_basal - UserEntry.Action.SMS_BOLUS -> R.string.uel_sms_bolus - UserEntry.Action.SMS_CAL -> R.string.uel_sms_cal - UserEntry.Action.SMS_CARBS -> R.string.uel_sms_carbs - UserEntry.Action.SMS_EXTENDED_BOLUS -> R.string.uel_sms_extended_bolus - UserEntry.Action.SMS_LOOP_DISABLED -> R.string.uel_sms_loop_disabled - UserEntry.Action.SMS_LOOP_ENABLED -> R.string.uel_sms_loop_enabled - UserEntry.Action.SMS_LOOP_RESUME -> R.string.uel_sms_loop_resume - UserEntry.Action.SMS_LOOP_SUSPEND -> R.string.uel_sms_loop_suspend - UserEntry.Action.SMS_PROFILE -> R.string.uel_sms_profile - UserEntry.Action.SMS_PUMP_CONNECT -> R.string.uel_sms_pump_connect - UserEntry.Action.SMS_PUMP_DISCONNECT -> R.string.uel_sms_pump_disconnect - UserEntry.Action.SMS_SMS -> R.string.uel_sms_sms - UserEntry.Action.SMS_TT -> R.string.uel_sms_tt - UserEntry.Action.TT_DELETED_FROM_NS -> R.string.uel_tt_deleted_from_ns - UserEntry.Action.TT_FROM_NS -> R.string.uel_tt_from_ns - UserEntry.Action.TT_CANCELED_FROM_NS -> R.string.uel_tt_canceleted_from_ns - UserEntry.Action.UE_EXPORT_TO_XML -> R.string.ue_export_to_xml + Action.BOLUS -> R.string.uel_bolus + Action.BOLUS_WIZARD -> R.string.uel_bolus_wizard + Action.BOLUS_ADVISOR -> R.string.uel_bolus_advisor + Action.BOLUS_RECORD -> R.string.uel_bolus_record + Action.EXTENDED_BOLUS -> R.string.uel_extended_bolus + Action.SUPERBOLUS_TBR -> R.string.uel_superbolus_tbr + Action.CARBS -> R.string.uel_carbs + Action.EXTENDED_CARBS -> R.string.uel_extended_carbs + Action.TEMP_BASAL -> R.string.uel_temp_basal + Action.TT -> R.string.uel_tt + Action.TT_ACTIVITY -> R.string.uel_tt_activity + Action.TT_EATING_SOON -> R.string.uel_tt_eating_soon + Action.TT_HYPO -> R.string.uel_tt_hypo + Action.NEW_PROFILE -> R.string.uel_new_profile + Action.CLONE_PROFILE -> R.string.uel_clone_profile + Action.STORE_PROFILE -> R.string.uel_store_profile + Action.PROFILE_SWITCH -> R.string.uel_profile_switch + Action.PROFILE_SWITCH_CLONED -> R.string.uel_profile_switch_cloned + Action.CLOSED_LOOP_MODE -> R.string.uel_closed_loop_mode + Action.LGS_LOOP_MODE -> R.string.uel_lgs_loop_mode + Action.OPEN_LOOP_MODE -> R.string.uel_open_loop_mode + Action.LOOP_DISABLED -> R.string.uel_loop_disabled + Action.LOOP_ENABLED -> R.string.uel_loop_enabled + Action.RECONNECT -> R.string.uel_reconnect + Action.DISCONNECT_15M -> R.string.uel_disconnect_15m + Action.DISCONNECT_30M -> R.string.uel_disconnect_30m + Action.DISCONNECT_1H -> R.string.uel_disconnect_1h + Action.DISCONNECT_2H -> R.string.uel_disconnect_2h + Action.DISCONNECT_3H -> R.string.uel_disconnect_3h + Action.RESUME -> R.string.uel_resume + Action.SUSPEND_1H -> R.string.uel_suspend_1h + Action.SUSPEND_2H -> R.string.uel_suspend_2h + Action.SUSPEND_3H -> R.string.uel_suspend_3h + Action.SUSPEND_10H -> R.string.uel_suspend_10h + Action.HW_PUMP_ALLOWED -> R.string.uel_hw_pump_allowed + Action.CLEAR_PAIRING_KEYS -> R.string.uel_clear_pairing_keys + Action.ACCEPTS_TEMP_BASAL -> R.string.uel_accepts_temp_basal + Action.CANCEL_TEMP_BASAL -> R.string.uel_cancel_temp_basal + Action.CANCEL_EXTENDED_BOLUS -> R.string.uel_cancel_extended_bolus + Action.CANCEL_TT -> R.string.uel_cancel_tt + Action.CAREPORTAL -> R.string.uel_careportal + Action.CALIBRATION -> R.string.uel_calibration + Action.INSULIN_CHANGE -> R.string.uel_insulin_change + Action.PRIME_BOLUS -> R.string.uel_prime_bolus + Action.SITE_CHANGE -> R.string.uel_site_change + Action.TREATMENT -> R.string.uel_treatment + Action.CAREPORTAL_NS_REFRESH -> R.string.uel_careportal_ns_refresh + Action.PROFILE_SWITCH_NS_REFRESH -> R.string.uel_profile_switch_ns_refresh + Action.TREATMENTS_NS_REFRESH -> R.string.uel_treatments_ns_refresh + Action.TT_NS_REFRESH -> R.string.uel_tt_ns_refresh + Action.AUTOMATION_REMOVED -> R.string.uel_automation_removed + Action.BG_REMOVED -> R.string.uel_bg_removed + Action.CAREPORTAL_REMOVED -> R.string.uel_careportal_removed + Action.EXTENDED_BOLUS_REMOVED -> R.string.uel_extended_bolus_removed + Action.FOOD_REMOVED -> R.string.uel_food_removed + Action.PROFILE_REMOVED -> R.string.uel_profile_removed + Action.PROFILE_SWITCH_REMOVED -> R.string.uel_profile_switch_removed + Action.RESTART_EVENTS_REMOVED -> R.string.uel_restart_events_removed + Action.TREATMENT_REMOVED -> R.string.uel_treatment_removed + Action.TT_REMOVED -> R.string.uel_tt_removed + Action.NS_PAUSED -> R.string.uel_ns_paused + Action.NS_QUEUE_CLEARED -> R.string.uel_ns_queue_cleared + Action.NS_SETTINGS_COPIED -> R.string.uel_ns_settings_copied + Action.ERROR_DIALOG_OK -> R.string.uel_error_dialog_ok + Action.ERROR_DIALOG_MUTE -> R.string.uel_error_dialog_mute + Action.ERROR_DIALOG_MUTE_5MIN -> R.string.uel_error_dialog_mute_5min + Action.OBJECTIVE_STARTED -> R.string.uel_objective_started + Action.OBJECTIVE_UNSTARTED -> R.string.uel_objective_unstarted + Action.OBJECTIVES_SKIPPED -> R.string.uel_objectives_skipped + Action.STAT_RESET -> R.string.uel_stat_reset + Action.DELETE_LOGS -> R.string.uel_delete_logs + Action.DELETE_FUTURE_TREATMENTS -> R.string.uel_delete_future_treatments + Action.EXPORT_SETTINGS -> R.string.uel_export_settings + Action.IMPORT_SETTINGS -> R.string.uel_import_settings + Action.RESET_DATABASES -> R.string.uel_reset_databases + Action.EXPORT_DATABASES -> R.string.uel_export_databases + Action.IMPORT_DATABASES -> R.string.uel_import_databases + Action.OTP_EXPORT -> R.string.uel_otp_export + Action.OTP_RESET -> R.string.uel_otp_reset + Action.SMS_BASAL -> R.string.uel_sms_basal + Action.SMS_BOLUS -> R.string.uel_sms_bolus + Action.SMS_CAL -> R.string.uel_sms_cal + Action.SMS_CARBS -> R.string.uel_sms_carbs + Action.SMS_EXTENDED_BOLUS -> R.string.uel_sms_extended_bolus + Action.SMS_LOOP_DISABLED -> R.string.uel_sms_loop_disabled + Action.SMS_LOOP_ENABLED -> R.string.uel_sms_loop_enabled + Action.SMS_LOOP_RESUME -> R.string.uel_sms_loop_resume + Action.SMS_LOOP_SUSPEND -> R.string.uel_sms_loop_suspend + Action.SMS_PROFILE -> R.string.uel_sms_profile + Action.SMS_PUMP_CONNECT -> R.string.uel_sms_pump_connect + Action.SMS_PUMP_DISCONNECT -> R.string.uel_sms_pump_disconnect + Action.SMS_SMS -> R.string.uel_sms_sms + Action.SMS_TT -> R.string.uel_sms_tt + Action.TT_DELETED_FROM_NS -> R.string.uel_tt_deleted_from_ns + Action.TT_FROM_NS -> R.string.uel_tt_from_ns + Action.TT_CANCELED_FROM_NS -> R.string.uel_tt_canceleted_from_ns else -> R.string.uel_unknown } } -fun UserEntry.Action.colorId(): Int { +fun Action.colorId(): Int { return when (this) { - UserEntry.Action.BOLUS -> R.color.iob - UserEntry.Action.BOLUS_WIZARD -> R.color.iob - UserEntry.Action.BOLUS_ADVISOR -> R.color.iob - UserEntry.Action.BOLUS_RECORD -> R.color.iob - UserEntry.Action.EXTENDED_BOLUS -> R.color.extendedBolus - UserEntry.Action.SUPERBOLUS_TBR -> R.color.carbs - UserEntry.Action.CARBS -> R.color.carbs - UserEntry.Action.EXTENDED_CARBS -> R.color.carbs - UserEntry.Action.TEMP_BASAL -> R.color.basal - UserEntry.Action.TT -> R.color.tempTargetConfirmation - UserEntry.Action.TT_ACTIVITY -> R.color.tempTargetConfirmation - UserEntry.Action.TT_EATING_SOON -> R.color.tempTargetConfirmation - UserEntry.Action.TT_HYPO -> R.color.tempTargetConfirmation - UserEntry.Action.NEW_PROFILE -> R.color.white - UserEntry.Action.CLONE_PROFILE -> R.color.white - UserEntry.Action.STORE_PROFILE -> R.color.white - UserEntry.Action.PROFILE_SWITCH -> R.color.white - UserEntry.Action.PROFILE_SWITCH_CLONED -> R.color.white - UserEntry.Action.CLOSED_LOOP_MODE -> R.color.loopClosed - UserEntry.Action.LGS_LOOP_MODE -> R.color.loopClosed - UserEntry.Action.OPEN_LOOP_MODE -> R.color.loopOpened - UserEntry.Action.LOOP_DISABLED -> R.color.loopDisabled - UserEntry.Action.LOOP_ENABLED -> R.color.loopClosed - UserEntry.Action.RECONNECT -> R.color.loopDisconnected - UserEntry.Action.DISCONNECT_15M -> R.color.loopDisconnected - UserEntry.Action.DISCONNECT_30M -> R.color.loopDisconnected - UserEntry.Action.DISCONNECT_1H -> R.color.loopDisconnected - UserEntry.Action.DISCONNECT_2H -> R.color.loopDisconnected - UserEntry.Action.DISCONNECT_3H -> R.color.loopDisconnected - UserEntry.Action.RESUME -> R.color.loopClosed - UserEntry.Action.SUSPEND_1H -> R.color.loopSuspended - UserEntry.Action.SUSPEND_2H -> R.color.loopSuspended - UserEntry.Action.SUSPEND_3H -> R.color.loopSuspended - UserEntry.Action.SUSPEND_10H -> R.color.loopSuspended - UserEntry.Action.HW_PUMP_ALLOWED -> R.color.defaulttext - UserEntry.Action.CLEAR_PAIRING_KEYS -> R.color.defaulttext - UserEntry.Action.ACCEPTS_TEMP_BASAL -> R.color.basal - UserEntry.Action.CANCEL_TEMP_BASAL -> R.color.basal - UserEntry.Action.CANCEL_EXTENDED_BOLUS -> R.color.extendedBolus - UserEntry.Action.CANCEL_TT -> R.color.tempTargetConfirmation - UserEntry.Action.CAREPORTAL -> R.color.notificationAnnouncement - UserEntry.Action.CALIBRATION -> R.color.calibration - UserEntry.Action.INSULIN_CHANGE -> R.color.iob - UserEntry.Action.PRIME_BOLUS -> R.color.defaulttext - UserEntry.Action.SITE_CHANGE -> R.color.defaulttext - UserEntry.Action.TREATMENT -> R.color.defaulttext - UserEntry.Action.CAREPORTAL_NS_REFRESH -> R.color.notificationAnnouncement - UserEntry.Action.PROFILE_SWITCH_NS_REFRESH -> R.color.white - UserEntry.Action.TREATMENTS_NS_REFRESH -> R.color.defaulttext - UserEntry.Action.TT_NS_REFRESH -> R.color.tempTargetConfirmation - UserEntry.Action.AUTOMATION_REMOVED -> R.color.defaulttext - UserEntry.Action.BG_REMOVED -> R.color.calibration - UserEntry.Action.CAREPORTAL_REMOVED -> R.color.notificationAnnouncement - UserEntry.Action.EXTENDED_BOLUS_REMOVED -> R.color.extendedBolus - UserEntry.Action.FOOD_REMOVED -> R.color.carbs - UserEntry.Action.PROFILE_REMOVED -> R.color.white - UserEntry.Action.PROFILE_SWITCH_REMOVED -> R.color.white - UserEntry.Action.RESTART_EVENTS_REMOVED -> R.color.defaulttext - UserEntry.Action.TREATMENT_REMOVED -> R.color.defaulttext - UserEntry.Action.TT_REMOVED -> R.color.tempTargetConfirmation - UserEntry.Action.NS_PAUSED -> R.color.defaulttext - UserEntry.Action.NS_QUEUE_CLEARED -> R.color.defaulttext - UserEntry.Action.NS_SETTINGS_COPIED -> R.color.defaulttext - UserEntry.Action.ERROR_DIALOG_OK -> R.color.defaulttext - UserEntry.Action.ERROR_DIALOG_MUTE -> R.color.defaulttext - UserEntry.Action.ERROR_DIALOG_MUTE_5MIN -> R.color.defaulttext - UserEntry.Action.OBJECTIVE_STARTED -> R.color.defaulttext - UserEntry.Action.OBJECTIVE_UNSTARTED -> R.color.defaulttext - UserEntry.Action.OBJECTIVES_SKIPPED -> R.color.defaulttext - UserEntry.Action.STAT_RESET -> R.color.defaulttext - UserEntry.Action.DELETE_LOGS -> R.color.defaulttext - UserEntry.Action.DELETE_FUTURE_TREATMENTS -> R.color.defaulttext - UserEntry.Action.EXPORT_SETTINGS -> R.color.defaulttext - UserEntry.Action.IMPORT_SETTINGS -> R.color.defaulttext - UserEntry.Action.RESET_DATABASES -> R.color.defaulttext - UserEntry.Action.EXPORT_DATABASES -> R.color.defaulttext - UserEntry.Action.IMPORT_DATABASES -> R.color.defaulttext - UserEntry.Action.OTP_EXPORT -> R.color.defaulttext - UserEntry.Action.OTP_RESET -> R.color.defaulttext - UserEntry.Action.SMS_BASAL -> R.color.basal - UserEntry.Action.SMS_BOLUS -> R.color.iob - UserEntry.Action.SMS_CAL -> R.color.calibration - UserEntry.Action.SMS_CARBS -> R.color.carbs - UserEntry.Action.SMS_EXTENDED_BOLUS -> R.color.extendedBolus - UserEntry.Action.SMS_LOOP_DISABLED -> R.color.loopDisabled - UserEntry.Action.SMS_LOOP_ENABLED -> R.color.loopClosed - UserEntry.Action.SMS_LOOP_RESUME -> R.color.loopClosed - UserEntry.Action.SMS_LOOP_SUSPEND -> R.color.loopSuspended - UserEntry.Action.SMS_PROFILE -> R.color.white - UserEntry.Action.SMS_PUMP_CONNECT -> R.color.loopDisconnected - 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 + Action.EXTENDED_CARBS -> R.color.carbs + Action.TEMP_BASAL -> R.color.basal + Action.TT -> R.color.tempTargetConfirmation + Action.TT_ACTIVITY -> R.color.tempTargetConfirmation + Action.TT_EATING_SOON -> R.color.tempTargetConfirmation + Action.TT_HYPO -> R.color.tempTargetConfirmation + Action.NEW_PROFILE -> R.color.white + Action.CLONE_PROFILE -> R.color.white + Action.STORE_PROFILE -> R.color.white + Action.PROFILE_SWITCH -> R.color.white + Action.PROFILE_SWITCH_CLONED -> R.color.white + Action.CLOSED_LOOP_MODE -> R.color.loopClosed + Action.LGS_LOOP_MODE -> R.color.loopClosed + Action.OPEN_LOOP_MODE -> R.color.loopOpened + Action.LOOP_DISABLED -> R.color.loopDisabled + Action.LOOP_ENABLED -> R.color.loopClosed + Action.RECONNECT -> R.color.loopDisconnected + Action.DISCONNECT_15M -> R.color.loopDisconnected + Action.DISCONNECT_30M -> R.color.loopDisconnected + Action.DISCONNECT_1H -> R.color.loopDisconnected + Action.DISCONNECT_2H -> R.color.loopDisconnected + Action.DISCONNECT_3H -> R.color.loopDisconnected + Action.RESUME -> R.color.loopClosed + Action.SUSPEND_1H -> R.color.loopSuspended + Action.SUSPEND_2H -> R.color.loopSuspended + Action.SUSPEND_3H -> R.color.loopSuspended + Action.SUSPEND_10H -> R.color.loopSuspended + Action.HW_PUMP_ALLOWED -> R.color.defaulttext + Action.CLEAR_PAIRING_KEYS -> R.color.defaulttext + Action.ACCEPTS_TEMP_BASAL -> R.color.basal + Action.CANCEL_TEMP_BASAL -> R.color.basal + Action.CANCEL_EXTENDED_BOLUS -> R.color.extendedBolus + Action.CANCEL_TT -> R.color.tempTargetConfirmation + Action.CAREPORTAL -> R.color.notificationAnnouncement + Action.CALIBRATION -> R.color.calibration + Action.INSULIN_CHANGE -> R.color.iob + Action.PRIME_BOLUS -> R.color.defaulttext + Action.SITE_CHANGE -> R.color.defaulttext + Action.TREATMENT -> R.color.defaulttext + Action.CAREPORTAL_NS_REFRESH -> R.color.notificationAnnouncement + Action.PROFILE_SWITCH_NS_REFRESH -> R.color.white + Action.TREATMENTS_NS_REFRESH -> R.color.defaulttext + Action.TT_NS_REFRESH -> R.color.tempTargetConfirmation + Action.AUTOMATION_REMOVED -> R.color.defaulttext + Action.BG_REMOVED -> R.color.calibration + Action.CAREPORTAL_REMOVED -> R.color.notificationAnnouncement + Action.EXTENDED_BOLUS_REMOVED -> R.color.extendedBolus + Action.FOOD_REMOVED -> R.color.carbs + Action.PROFILE_REMOVED -> R.color.white + Action.PROFILE_SWITCH_REMOVED -> R.color.white + Action.RESTART_EVENTS_REMOVED -> R.color.defaulttext + Action.TREATMENT_REMOVED -> R.color.defaulttext + Action.TT_REMOVED -> R.color.tempTargetConfirmation + Action.NS_PAUSED -> R.color.defaulttext + Action.NS_QUEUE_CLEARED -> R.color.defaulttext + Action.NS_SETTINGS_COPIED -> R.color.defaulttext + Action.ERROR_DIALOG_OK -> R.color.defaulttext + Action.ERROR_DIALOG_MUTE -> R.color.defaulttext + Action.ERROR_DIALOG_MUTE_5MIN -> R.color.defaulttext + Action.OBJECTIVE_STARTED -> R.color.defaulttext + Action.OBJECTIVE_UNSTARTED -> R.color.defaulttext + Action.OBJECTIVES_SKIPPED -> R.color.defaulttext + Action.STAT_RESET -> R.color.defaulttext + Action.DELETE_LOGS -> R.color.defaulttext + Action.DELETE_FUTURE_TREATMENTS -> R.color.defaulttext + Action.EXPORT_SETTINGS -> R.color.defaulttext + Action.IMPORT_SETTINGS -> R.color.defaulttext + Action.RESET_DATABASES -> R.color.defaulttext + Action.EXPORT_DATABASES -> R.color.defaulttext + Action.IMPORT_DATABASES -> R.color.defaulttext + Action.OTP_EXPORT -> R.color.defaulttext + Action.OTP_RESET -> R.color.defaulttext + Action.SMS_BASAL -> R.color.basal + Action.SMS_BOLUS -> R.color.iob + Action.SMS_CAL -> R.color.calibration + Action.SMS_CARBS -> R.color.carbs + Action.SMS_EXTENDED_BOLUS -> R.color.extendedBolus + Action.SMS_LOOP_DISABLED -> R.color.loopDisabled + Action.SMS_LOOP_ENABLED -> R.color.loopClosed + Action.SMS_LOOP_RESUME -> R.color.loopClosed + Action.SMS_LOOP_SUSPEND -> R.color.loopSuspended + Action.SMS_PROFILE -> R.color.white + Action.SMS_PUMP_CONNECT -> R.color.loopDisconnected + Action.SMS_PUMP_DISCONNECT -> R.color.loopDisconnected + Action.SMS_SMS -> R.color.defaulttext + Action.SMS_TT -> R.color.tempTargetConfirmation + Action.TT_DELETED_FROM_NS -> R.color.tempTargetConfirmation + Action.TT_FROM_NS -> R.color.tempTargetConfirmation + Action.TT_CANCELED_FROM_NS -> R.color.tempTargetConfirmation + else -> R.color.defaulttext } } -fun UserEntry.Units.stringId(): Int { - return when { - this == UserEntry.Units.Mg_Dl -> R.string.mgdl - this == UserEntry.Units.Mmol_L -> R.string.mmol - this == UserEntry.Units.U -> R.string.insulin_unit_shortname - this == UserEntry.Units.U_H -> R.string.profile_ins_units_per_hour - this == UserEntry.Units.G -> R.string.shortgram - this == UserEntry.Units.M -> R.string.shortminute - this == UserEntry.Units.H -> R.string.shorthour - this == UserEntry.Units.Percent -> R.string.shortpercent - this == UserEntry.Units.R_String -> R.string.formated_string +fun ColorGroup.colorId(): Int { + return when (this) { + ColorGroup.InsulinTreatment -> R.color.basal + ColorGroup.CarbTreatment -> R.color.carbs + ColorGroup.TT -> R.color.tempTargetConfirmation + ColorGroup.Profile -> R.color.white + ColorGroup.Loop -> R.color.loopClosed + ColorGroup.Careportal -> R.color.high + ColorGroup.Pump -> R.color.iob + ColorGroup.Aaps -> R.color.defaulttext + else -> R.color.defaulttext + } +} + +fun 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 } } diff --git a/database/src/main/java/info/nightscout/androidaps/database/entities/UserEntry.kt b/database/src/main/java/info/nightscout/androidaps/database/entities/UserEntry.kt index db47fec809..16e8503f59 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/entities/UserEntry.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/entities/UserEntry.kt @@ -18,109 +18,108 @@ data class UserEntry( var s: String, var values: MutableList ) : DBEntry, DBEntryWithTime { - enum class Action () { - @SerializedName("BOLUS") BOLUS, - @SerializedName("BOLUS_WIZARD") BOLUS_WIZARD, - @SerializedName("BOLUS_ADVISOR") BOLUS_ADVISOR, - @SerializedName("BOLUS_RECORD") BOLUS_RECORD, - @SerializedName("EXTENDED_BOLUS") EXTENDED_BOLUS, - @SerializedName("SUPERBOLUS_TBR") SUPERBOLUS_TBR, - @SerializedName("CARBS") CARBS, - @SerializedName("EXTENDED_CARBS") EXTENDED_CARBS, - @SerializedName("TEMP_BASAL") TEMP_BASAL, - @SerializedName("TT") TT, - @SerializedName("TT_ACTIVITY") TT_ACTIVITY, - @SerializedName("TT_EATING_SOON") TT_EATING_SOON, - @SerializedName("TT_HYPO") TT_HYPO, - @SerializedName("NEW_PROFILE") NEW_PROFILE, - @SerializedName("CLONE_PROFILE") CLONE_PROFILE, - @SerializedName("STORE_PROFILE") STORE_PROFILE, - @SerializedName("PROFILE_SWITCH") PROFILE_SWITCH, - @SerializedName("PROFILE_SWITCH_CLONED") PROFILE_SWITCH_CLONED, - @SerializedName("CLOSED_LOOP_MODE") CLOSED_LOOP_MODE, - @SerializedName("LGS_LOOP_MODE") LGS_LOOP_MODE, - @SerializedName("OPEN_LOOP_MODE") OPEN_LOOP_MODE, - @SerializedName("LOOP_DISABLED") LOOP_DISABLED, - @SerializedName("LOOP_ENABLED") LOOP_ENABLED, - @SerializedName("RECONNECT") RECONNECT, - @SerializedName("DISCONNECT_15M") DISCONNECT_15M, - @SerializedName("DISCONNECT_30M") DISCONNECT_30M, - @SerializedName("DISCONNECT_1H") DISCONNECT_1H, - @SerializedName("DISCONNECT_2H") DISCONNECT_2H, - @SerializedName("DISCONNECT_3H") DISCONNECT_3H, - @SerializedName("RESUME") RESUME, - @SerializedName("SUSPEND_1H") SUSPEND_1H, - @SerializedName("SUSPEND_2H") SUSPEND_2H, - @SerializedName("SUSPEND_3H") SUSPEND_3H, - @SerializedName("SUSPEND_10H") SUSPEND_10H, - @SerializedName("HW_PUMP_ALLOWED") HW_PUMP_ALLOWED, - @SerializedName("CLEAR_PAIRING_KEYS") CLEAR_PAIRING_KEYS, - @SerializedName("ACCEPTS_TEMP_BASAL") ACCEPTS_TEMP_BASAL, - @SerializedName("CANCEL_TEMP_BASAL") CANCEL_TEMP_BASAL, - @SerializedName("CANCEL_EXTENDED_BOLUS") CANCEL_EXTENDED_BOLUS, - @SerializedName("CANCEL_TT") CANCEL_TT, - @SerializedName("CAREPORTAL") CAREPORTAL, - @SerializedName("CALIBRATION") CALIBRATION, - @SerializedName("INSULIN_CHANGE") INSULIN_CHANGE, - @SerializedName("PRIME_BOLUS") PRIME_BOLUS, - @SerializedName("SITE_CHANGE") SITE_CHANGE, - @SerializedName("TREATMENT") TREATMENT, - @SerializedName("CAREPORTAL_NS_REFRESH") CAREPORTAL_NS_REFRESH, - @SerializedName("PROFILE_SWITCH_NS_REFRESH") PROFILE_SWITCH_NS_REFRESH, - @SerializedName("TREATMENTS_NS_REFRESH") TREATMENTS_NS_REFRESH, - @SerializedName("TT_NS_REFRESH") TT_NS_REFRESH, - @SerializedName("AUTOMATION_REMOVED") AUTOMATION_REMOVED, - @SerializedName("BG_REMOVED") BG_REMOVED, - @SerializedName("CAREPORTAL_REMOVED") CAREPORTAL_REMOVED, - @SerializedName("EXTENDED_BOLUS_REMOVED") EXTENDED_BOLUS_REMOVED, - @SerializedName("FOOD_REMOVED") FOOD_REMOVED, - @SerializedName("PROFILE_REMOVED") PROFILE_REMOVED, - @SerializedName("PROFILE_SWITCH_REMOVED") PROFILE_SWITCH_REMOVED, - @SerializedName("RESTART_EVENTS_REMOVED") RESTART_EVENTS_REMOVED, - @SerializedName("TREATMENT_REMOVED") TREATMENT_REMOVED, - @SerializedName("TT_REMOVED") TT_REMOVED, - @SerializedName("NS_PAUSED") NS_PAUSED, - @SerializedName("NS_QUEUE_CLEARED") NS_QUEUE_CLEARED, - @SerializedName("NS_SETTINGS_COPIED") NS_SETTINGS_COPIED, - @SerializedName("ERROR_DIALOG_OK") ERROR_DIALOG_OK, - @SerializedName("ERROR_DIALOG_MUTE") ERROR_DIALOG_MUTE, - @SerializedName("ERROR_DIALOG_MUTE_5MIN") ERROR_DIALOG_MUTE_5MIN, - @SerializedName("OBJECTIVE_STARTED") OBJECTIVE_STARTED, - @SerializedName("OBJECTIVE_UNSTARTED") OBJECTIVE_UNSTARTED, - @SerializedName("OBJECTIVES_SKIPPED") OBJECTIVES_SKIPPED, - @SerializedName("STAT_RESET") STAT_RESET, - @SerializedName("DELETE_LOGS") DELETE_LOGS, - @SerializedName("DELETE_FUTURE_TREATMENTS") DELETE_FUTURE_TREATMENTS, - @SerializedName("EXPORT_SETTINGS") EXPORT_SETTINGS, - @SerializedName("IMPORT_SETTINGS") IMPORT_SETTINGS, - @SerializedName("RESET_DATABASES") RESET_DATABASES, - @SerializedName("EXPORT_DATABASES") EXPORT_DATABASES, - @SerializedName("IMPORT_DATABASES") IMPORT_DATABASES, - @SerializedName("OTP_EXPORT") OTP_EXPORT, - @SerializedName("OTP_RESET") OTP_RESET, - @SerializedName("SMS_BASAL") SMS_BASAL, - @SerializedName("SMS_BOLUS") SMS_BOLUS, - @SerializedName("SMS_CAL") SMS_CAL, - @SerializedName("SMS_CARBS") SMS_CARBS, - @SerializedName("SMS_EXTENDED_BOLUS") SMS_EXTENDED_BOLUS, - @SerializedName("SMS_LOOP_DISABLED") SMS_LOOP_DISABLED, - @SerializedName("SMS_LOOP_ENABLED") SMS_LOOP_ENABLED, - @SerializedName("SMS_LOOP_RESUME") SMS_LOOP_RESUME, - @SerializedName("SMS_LOOP_SUSPEND") SMS_LOOP_SUSPEND, - @SerializedName("SMS_PROFILE") SMS_PROFILE, - @SerializedName("SMS_PUMP_CONNECT") SMS_PUMP_CONNECT, - @SerializedName("SMS_PUMP_DISCONNECT") SMS_PUMP_DISCONNECT, - @SerializedName("SMS_SMS") SMS_SMS, - @SerializedName("SMS_TT") SMS_TT, - @SerializedName("TT_DELETED_FROM_NS") TT_DELETED_FROM_NS, - @SerializedName("TT_FROM_NS") TT_FROM_NS, - @SerializedName("TT_CANCELED_FROM_NS") TT_CANCELED_FROM_NS, - @SerializedName("UE_EXPORT_TO_XML") UE_EXPORT_TO_XML, - @SerializedName("UNKNOWN") UNKNOWN + enum class Action (val colorGroup: ColorGroup) { + @SerializedName("BOLUS") BOLUS (ColorGroup.InsulinTreatment), + @SerializedName("BOLUS_WIZARD") BOLUS_WIZARD (ColorGroup.InsulinTreatment), + @SerializedName("BOLUS_ADVISOR") BOLUS_ADVISOR (ColorGroup.InsulinTreatment), + @SerializedName("BOLUS_RECORD") BOLUS_RECORD (ColorGroup.InsulinTreatment), + @SerializedName("EXTENDED_BOLUS") EXTENDED_BOLUS (ColorGroup.InsulinTreatment), + @SerializedName("SUPERBOLUS_TBR") SUPERBOLUS_TBR (ColorGroup.InsulinTreatment), + @SerializedName("CARBS") CARBS (ColorGroup.CarbTreatment), + @SerializedName("EXTENDED_CARBS") EXTENDED_CARBS (ColorGroup.CarbTreatment), + @SerializedName("TEMP_BASAL") TEMP_BASAL (ColorGroup.TT), + @SerializedName("TT") TT (ColorGroup.TT), + @SerializedName("TT_ACTIVITY") TT_ACTIVITY (ColorGroup.TT), + @SerializedName("TT_EATING_SOON") TT_EATING_SOON (ColorGroup.TT), + @SerializedName("TT_HYPO") TT_HYPO (ColorGroup.TT), + @SerializedName("NEW_PROFILE") NEW_PROFILE (ColorGroup.Profile), + @SerializedName("CLONE_PROFILE") CLONE_PROFILE (ColorGroup.Profile), + @SerializedName("STORE_PROFILE") STORE_PROFILE (ColorGroup.Profile), + @SerializedName("PROFILE_SWITCH") PROFILE_SWITCH (ColorGroup.Profile), + @SerializedName("PROFILE_SWITCH_CLONED") PROFILE_SWITCH_CLONED (ColorGroup.Profile), + @SerializedName("CLOSED_LOOP_MODE") CLOSED_LOOP_MODE (ColorGroup.Loop), + @SerializedName("LGS_LOOP_MODE") LGS_LOOP_MODE (ColorGroup.Loop), + @SerializedName("OPEN_LOOP_MODE") OPEN_LOOP_MODE (ColorGroup.Loop), + @SerializedName("LOOP_DISABLED") LOOP_DISABLED (ColorGroup.Loop), + @SerializedName("LOOP_ENABLED") LOOP_ENABLED (ColorGroup.Loop), + @SerializedName("RECONNECT") RECONNECT (ColorGroup.Pump), + @SerializedName("DISCONNECT_15M") DISCONNECT_15M (ColorGroup.Pump), + @SerializedName("DISCONNECT_30M") DISCONNECT_30M (ColorGroup.Pump), + @SerializedName("DISCONNECT_1H") DISCONNECT_1H (ColorGroup.Pump), + @SerializedName("DISCONNECT_2H") DISCONNECT_2H (ColorGroup.Pump), + @SerializedName("DISCONNECT_3H") DISCONNECT_3H (ColorGroup.Pump), + @SerializedName("RESUME") RESUME (ColorGroup.Loop), + @SerializedName("SUSPEND_1H") SUSPEND_1H (ColorGroup.Loop), + @SerializedName("SUSPEND_2H") SUSPEND_2H (ColorGroup.Loop), + @SerializedName("SUSPEND_3H") SUSPEND_3H (ColorGroup.Loop), + @SerializedName("SUSPEND_10H") SUSPEND_10H (ColorGroup.Loop), + @SerializedName("HW_PUMP_ALLOWED") HW_PUMP_ALLOWED (ColorGroup.Pump), + @SerializedName("CLEAR_PAIRING_KEYS") CLEAR_PAIRING_KEYS (ColorGroup.Pump), + @SerializedName("ACCEPTS_TEMP_BASAL") ACCEPTS_TEMP_BASAL (ColorGroup.InsulinTreatment), + @SerializedName("CANCEL_TEMP_BASAL") CANCEL_TEMP_BASAL (ColorGroup.InsulinTreatment), + @SerializedName("CANCEL_EXTENDED_BOLUS") CANCEL_EXTENDED_BOLUS (ColorGroup.InsulinTreatment), + @SerializedName("CANCEL_TT") CANCEL_TT (ColorGroup.TT), + @SerializedName("CAREPORTAL") CAREPORTAL (ColorGroup.Careportal), + @SerializedName("CALIBRATION") CALIBRATION (ColorGroup.Careportal), + @SerializedName("INSULIN_CHANGE") INSULIN_CHANGE (ColorGroup.InsulinTreatment), + @SerializedName("PRIME_BOLUS") PRIME_BOLUS (ColorGroup.Careportal), + @SerializedName("SITE_CHANGE") SITE_CHANGE (ColorGroup.Careportal), + @SerializedName("TREATMENT") TREATMENT (ColorGroup.InsulinTreatment), + @SerializedName("CAREPORTAL_NS_REFRESH") CAREPORTAL_NS_REFRESH (ColorGroup.Careportal), + @SerializedName("PROFILE_SWITCH_NS_REFRESH") PROFILE_SWITCH_NS_REFRESH (ColorGroup.Profile), + @SerializedName("TREATMENTS_NS_REFRESH") TREATMENTS_NS_REFRESH (ColorGroup.InsulinTreatment), + @SerializedName("TT_NS_REFRESH") TT_NS_REFRESH (ColorGroup.TT), + @SerializedName("AUTOMATION_REMOVED") AUTOMATION_REMOVED (ColorGroup.Aaps), + @SerializedName("BG_REMOVED") BG_REMOVED (ColorGroup.Careportal), + @SerializedName("CAREPORTAL_REMOVED") CAREPORTAL_REMOVED (ColorGroup.Careportal), + @SerializedName("EXTENDED_BOLUS_REMOVED") EXTENDED_BOLUS_REMOVED (ColorGroup.InsulinTreatment), + @SerializedName("FOOD_REMOVED") FOOD_REMOVED (ColorGroup.Careportal), + @SerializedName("PROFILE_REMOVED") PROFILE_REMOVED (ColorGroup.Profile), + @SerializedName("PROFILE_SWITCH_REMOVED") PROFILE_SWITCH_REMOVED (ColorGroup.Profile), + @SerializedName("RESTART_EVENTS_REMOVED") RESTART_EVENTS_REMOVED (ColorGroup.Aaps), + @SerializedName("TREATMENT_REMOVED") TREATMENT_REMOVED (ColorGroup.InsulinTreatment), + @SerializedName("TT_REMOVED") TT_REMOVED (ColorGroup.TT), + @SerializedName("NS_PAUSED") NS_PAUSED (ColorGroup.Aaps), + @SerializedName("NS_QUEUE_CLEARED") NS_QUEUE_CLEARED (ColorGroup.Aaps), + @SerializedName("NS_SETTINGS_COPIED") NS_SETTINGS_COPIED (ColorGroup.Aaps), + @SerializedName("ERROR_DIALOG_OK") ERROR_DIALOG_OK (ColorGroup.Aaps), + @SerializedName("ERROR_DIALOG_MUTE") ERROR_DIALOG_MUTE (ColorGroup.Aaps), + @SerializedName("ERROR_DIALOG_MUTE_5MIN") ERROR_DIALOG_MUTE_5MIN (ColorGroup.Aaps), + @SerializedName("OBJECTIVE_STARTED") OBJECTIVE_STARTED (ColorGroup.Aaps), + @SerializedName("OBJECTIVE_UNSTARTED") OBJECTIVE_UNSTARTED (ColorGroup.Aaps), + @SerializedName("OBJECTIVES_SKIPPED") OBJECTIVES_SKIPPED (ColorGroup.Aaps), + @SerializedName("STAT_RESET") STAT_RESET (ColorGroup.Aaps), + @SerializedName("DELETE_LOGS") DELETE_LOGS (ColorGroup.Aaps), + @SerializedName("DELETE_FUTURE_TREATMENTS") DELETE_FUTURE_TREATMENTS (ColorGroup.Aaps), + @SerializedName("EXPORT_SETTINGS") EXPORT_SETTINGS (ColorGroup.Aaps), + @SerializedName("IMPORT_SETTINGS") IMPORT_SETTINGS (ColorGroup.Aaps), + @SerializedName("RESET_DATABASES") RESET_DATABASES (ColorGroup.Aaps), + @SerializedName("EXPORT_DATABASES") EXPORT_DATABASES (ColorGroup.Aaps), + @SerializedName("IMPORT_DATABASES") IMPORT_DATABASES (ColorGroup.Aaps), + @SerializedName("OTP_EXPORT") OTP_EXPORT (ColorGroup.Aaps), + @SerializedName("OTP_RESET") OTP_RESET (ColorGroup.Aaps), + @SerializedName("SMS_BASAL") SMS_BASAL (ColorGroup.InsulinTreatment), + @SerializedName("SMS_BOLUS") SMS_BOLUS (ColorGroup.InsulinTreatment), + @SerializedName("SMS_CAL") SMS_CAL (ColorGroup.Careportal), + @SerializedName("SMS_CARBS") SMS_CARBS (ColorGroup.CarbTreatment), + @SerializedName("SMS_EXTENDED_BOLUS") SMS_EXTENDED_BOLUS (ColorGroup.InsulinTreatment), + @SerializedName("SMS_LOOP_DISABLED") SMS_LOOP_DISABLED (ColorGroup.Loop), + @SerializedName("SMS_LOOP_ENABLED") SMS_LOOP_ENABLED (ColorGroup.Loop), + @SerializedName("SMS_LOOP_RESUME") SMS_LOOP_RESUME (ColorGroup.Loop), + @SerializedName("SMS_LOOP_SUSPEND") SMS_LOOP_SUSPEND (ColorGroup.Loop), + @SerializedName("SMS_PROFILE") SMS_PROFILE (ColorGroup.Profile), + @SerializedName("SMS_PUMP_CONNECT") SMS_PUMP_CONNECT (ColorGroup.Pump), + @SerializedName("SMS_PUMP_DISCONNECT") SMS_PUMP_DISCONNECT (ColorGroup.Pump), + @SerializedName("SMS_SMS") SMS_SMS (ColorGroup.Aaps), + @SerializedName("SMS_TT") SMS_TT (ColorGroup.TT), + @SerializedName("TT_DELETED_FROM_NS") TT_DELETED_FROM_NS (ColorGroup.TT), + @SerializedName("TT_FROM_NS") TT_FROM_NS (ColorGroup.TT), + @SerializedName("TT_CANCELED_FROM_NS") TT_CANCELED_FROM_NS (ColorGroup.TT), + @SerializedName("UNKNOWN") UNKNOWN (ColorGroup.Aaps) ; 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) { @@ -159,4 +158,15 @@ data class UserEntry( fun fromText(unit: String?) = values().firstOrNull { it.text == unit } ?: None } } + + enum class ColorGroup() { + InsulinTreatment, + CarbTreatment, + TT, + Profile, + Loop, + Careportal, + Pump, + Aaps + } } \ No newline at end of file