Remove SerializedName (all) and Text (Sources)

This commit is contained in:
Philoul 2021-03-28 21:45:40 +02:00
parent 9d4a1d5944
commit 74b911d875
2 changed files with 120 additions and 120 deletions

View file

@ -161,7 +161,7 @@ class TreatmentsUserEntryFragment : DaggerFragment() {
-> valuesWithUnitString += DecimalFormatter.to2Decimal(v.dValue) + translator.translate(v.unit) + separator -> valuesWithUnitString += DecimalFormatter.to2Decimal(v.dValue) + translator.translate(v.unit) + separator
Units.G, Units.M, Units.H, Units.Percent Units.G, Units.M, Units.H, Units.Percent
-> valuesWithUnitString += v.iValue.toString() + translator.translate(v.unit) + separator -> valuesWithUnitString += v.iValue.toString() + translator.translate(v.unit) + separator
Units.Source -> source = Sources.fromText(v.sValue) // = separator + translator.translate(v.sValue) Units.Source -> source = Sources.fromString(v.sValue) // = separator + translator.translate(v.sValue)
else -> valuesWithUnitString += if (v.iValue != 0 || v.sValue != "") { v.value().toString() + separator } else "" else -> valuesWithUnitString += if (v.iValue != 0 || v.sValue != "") { v.value().toString() + separator } else ""
} }
} }

View file

@ -20,77 +20,77 @@ data class UserEntry(
var values: MutableList<ValueWithUnit> var values: MutableList<ValueWithUnit>
) : DBEntry, DBEntryWithTime { ) : DBEntry, DBEntryWithTime {
enum class Action (val colorGroup: ColorGroup) { enum class Action (val colorGroup: ColorGroup) {
@SerializedName("BOLUS") BOLUS (ColorGroup.InsulinTreatment), BOLUS (ColorGroup.InsulinTreatment),
@SerializedName("SMB") SMB (ColorGroup.InsulinTreatment), SMB (ColorGroup.InsulinTreatment),
@SerializedName("BOLUS_ADVISOR") BOLUS_ADVISOR (ColorGroup.InsulinTreatment), BOLUS_ADVISOR (ColorGroup.InsulinTreatment),
@SerializedName("EXTENDED_BOLUS") EXTENDED_BOLUS (ColorGroup.InsulinTreatment), EXTENDED_BOLUS (ColorGroup.InsulinTreatment),
@SerializedName("SUPERBOLUS_TBR") SUPERBOLUS_TBR (ColorGroup.InsulinTreatment), SUPERBOLUS_TBR (ColorGroup.InsulinTreatment),
@SerializedName("CARBS") CARBS (ColorGroup.CarbTreatment), CARBS (ColorGroup.CarbTreatment),
@SerializedName("EXTENDED_CARBS") EXTENDED_CARBS (ColorGroup.CarbTreatment), EXTENDED_CARBS (ColorGroup.CarbTreatment),
@SerializedName("TEMP_BASAL") TEMP_BASAL (ColorGroup.InsulinTreatment), TEMP_BASAL (ColorGroup.InsulinTreatment),
@SerializedName("TT") TT (ColorGroup.TT), TT (ColorGroup.TT),
@SerializedName("NEW_PROFILE") NEW_PROFILE (ColorGroup.Profile), NEW_PROFILE (ColorGroup.Profile),
@SerializedName("CLONE_PROFILE") CLONE_PROFILE (ColorGroup.Profile), CLONE_PROFILE (ColorGroup.Profile),
@SerializedName("STORE_PROFILE") STORE_PROFILE (ColorGroup.Profile), STORE_PROFILE (ColorGroup.Profile),
@SerializedName("PROFILE_SWITCH") PROFILE_SWITCH (ColorGroup.Profile), PROFILE_SWITCH (ColorGroup.Profile),
@SerializedName("PROFILE_SWITCH_CLONED") PROFILE_SWITCH_CLONED (ColorGroup.Profile), PROFILE_SWITCH_CLONED (ColorGroup.Profile),
@SerializedName("CLOSED_LOOP_MODE") CLOSED_LOOP_MODE (ColorGroup.Loop), CLOSED_LOOP_MODE (ColorGroup.Loop),
@SerializedName("LGS_LOOP_MODE") LGS_LOOP_MODE (ColorGroup.Loop), LGS_LOOP_MODE (ColorGroup.Loop),
@SerializedName("OPEN_LOOP_MODE") OPEN_LOOP_MODE (ColorGroup.Loop), OPEN_LOOP_MODE (ColorGroup.Loop),
@SerializedName("LOOP_DISABLED") LOOP_DISABLED (ColorGroup.Loop), LOOP_DISABLED (ColorGroup.Loop),
@SerializedName("LOOP_ENABLED") LOOP_ENABLED (ColorGroup.Loop), LOOP_ENABLED (ColorGroup.Loop),
@SerializedName("RECONNECT") RECONNECT (ColorGroup.Pump), RECONNECT (ColorGroup.Pump),
@SerializedName("DISCONNECT") DISCONNECT (ColorGroup.Pump), DISCONNECT (ColorGroup.Pump),
@SerializedName("RESUME") RESUME (ColorGroup.Loop), RESUME (ColorGroup.Loop),
@SerializedName("SUSPEND") SUSPEND (ColorGroup.Loop), SUSPEND (ColorGroup.Loop),
@SerializedName("HW_PUMP_ALLOWED") HW_PUMP_ALLOWED (ColorGroup.Pump), HW_PUMP_ALLOWED (ColorGroup.Pump),
@SerializedName("CLEAR_PAIRING_KEYS") CLEAR_PAIRING_KEYS (ColorGroup.Pump), CLEAR_PAIRING_KEYS (ColorGroup.Pump),
@SerializedName("ACCEPTS_TEMP_BASAL") ACCEPTS_TEMP_BASAL (ColorGroup.InsulinTreatment), ACCEPTS_TEMP_BASAL (ColorGroup.InsulinTreatment),
@SerializedName("CANCEL_TEMP_BASAL") CANCEL_TEMP_BASAL (ColorGroup.InsulinTreatment), CANCEL_TEMP_BASAL (ColorGroup.InsulinTreatment),
@SerializedName("CANCEL_EXTENDED_BOLUS") CANCEL_EXTENDED_BOLUS (ColorGroup.InsulinTreatment), CANCEL_EXTENDED_BOLUS (ColorGroup.InsulinTreatment),
@SerializedName("CANCEL_TT") CANCEL_TT (ColorGroup.TT), CANCEL_TT (ColorGroup.TT),
@SerializedName("CAREPORTAL") CAREPORTAL (ColorGroup.Careportal), CAREPORTAL (ColorGroup.Careportal),
@SerializedName("CALIBRATION") CALIBRATION (ColorGroup.Careportal), CALIBRATION (ColorGroup.Careportal),
@SerializedName("PRIME_BOLUS") PRIME_BOLUS (ColorGroup.Careportal), PRIME_BOLUS (ColorGroup.Careportal),
@SerializedName("TREATMENT") TREATMENT (ColorGroup.InsulinTreatment), TREATMENT (ColorGroup.InsulinTreatment),
@SerializedName("CAREPORTAL_NS_REFRESH") CAREPORTAL_NS_REFRESH (ColorGroup.Aaps), CAREPORTAL_NS_REFRESH (ColorGroup.Aaps),
@SerializedName("PROFILE_SWITCH_NS_REFRESH") PROFILE_SWITCH_NS_REFRESH (ColorGroup.Aaps), PROFILE_SWITCH_NS_REFRESH (ColorGroup.Aaps),
@SerializedName("TREATMENTS_NS_REFRESH") TREATMENTS_NS_REFRESH (ColorGroup.Aaps), TREATMENTS_NS_REFRESH (ColorGroup.Aaps),
@SerializedName("TT_NS_REFRESH") TT_NS_REFRESH (ColorGroup.Aaps), TT_NS_REFRESH (ColorGroup.Aaps),
@SerializedName("AUTOMATION_REMOVED") AUTOMATION_REMOVED (ColorGroup.Aaps), AUTOMATION_REMOVED (ColorGroup.Aaps),
@SerializedName("BG_REMOVED") BG_REMOVED (ColorGroup.Careportal), BG_REMOVED (ColorGroup.Careportal),
@SerializedName("CAREPORTAL_REMOVED") CAREPORTAL_REMOVED (ColorGroup.Careportal), CAREPORTAL_REMOVED (ColorGroup.Careportal),
@SerializedName("EXTENDED_BOLUS_REMOVED") EXTENDED_BOLUS_REMOVED (ColorGroup.InsulinTreatment), EXTENDED_BOLUS_REMOVED (ColorGroup.InsulinTreatment),
@SerializedName("FOOD_REMOVED") FOOD_REMOVED (ColorGroup.Careportal), FOOD_REMOVED (ColorGroup.Careportal),
@SerializedName("PROFILE_REMOVED") PROFILE_REMOVED (ColorGroup.Profile), PROFILE_REMOVED (ColorGroup.Profile),
@SerializedName("PROFILE_SWITCH_REMOVED") PROFILE_SWITCH_REMOVED (ColorGroup.Profile), PROFILE_SWITCH_REMOVED (ColorGroup.Profile),
@SerializedName("RESTART_EVENTS_REMOVED") RESTART_EVENTS_REMOVED (ColorGroup.Aaps), RESTART_EVENTS_REMOVED (ColorGroup.Aaps),
@SerializedName("TREATMENT_REMOVED") TREATMENT_REMOVED (ColorGroup.InsulinTreatment), TREATMENT_REMOVED (ColorGroup.InsulinTreatment),
@SerializedName("TT_REMOVED") TT_REMOVED (ColorGroup.TT), TT_REMOVED (ColorGroup.TT),
@SerializedName("NS_PAUSED") NS_PAUSED (ColorGroup.Aaps), NS_PAUSED (ColorGroup.Aaps),
@SerializedName("NS_RESUME") NS_RESUME (ColorGroup.Aaps), NS_RESUME (ColorGroup.Aaps),
@SerializedName("NS_QUEUE_CLEARED") NS_QUEUE_CLEARED (ColorGroup.Aaps), NS_QUEUE_CLEARED (ColorGroup.Aaps),
@SerializedName("NS_SETTINGS_COPIED") NS_SETTINGS_COPIED (ColorGroup.Aaps), NS_SETTINGS_COPIED (ColorGroup.Aaps),
@SerializedName("ERROR_DIALOG_OK") ERROR_DIALOG_OK (ColorGroup.Aaps), ERROR_DIALOG_OK (ColorGroup.Aaps),
@SerializedName("ERROR_DIALOG_MUTE") ERROR_DIALOG_MUTE (ColorGroup.Aaps), ERROR_DIALOG_MUTE (ColorGroup.Aaps),
@SerializedName("ERROR_DIALOG_MUTE_5MIN") ERROR_DIALOG_MUTE_5MIN (ColorGroup.Aaps), ERROR_DIALOG_MUTE_5MIN (ColorGroup.Aaps),
@SerializedName("OBJECTIVE_STARTED") OBJECTIVE_STARTED (ColorGroup.Aaps), OBJECTIVE_STARTED (ColorGroup.Aaps),
@SerializedName("OBJECTIVE_UNSTARTED") OBJECTIVE_UNSTARTED (ColorGroup.Aaps), OBJECTIVE_UNSTARTED (ColorGroup.Aaps),
@SerializedName("OBJECTIVES_SKIPPED") OBJECTIVES_SKIPPED (ColorGroup.Aaps), OBJECTIVES_SKIPPED (ColorGroup.Aaps),
@SerializedName("STAT_RESET") STAT_RESET (ColorGroup.Aaps), STAT_RESET (ColorGroup.Aaps),
@SerializedName("DELETE_LOGS") DELETE_LOGS (ColorGroup.Aaps), DELETE_LOGS (ColorGroup.Aaps),
@SerializedName("DELETE_FUTURE_TREATMENTS") DELETE_FUTURE_TREATMENTS (ColorGroup.Aaps), DELETE_FUTURE_TREATMENTS (ColorGroup.Aaps),
@SerializedName("EXPORT_SETTINGS") EXPORT_SETTINGS (ColorGroup.Aaps), EXPORT_SETTINGS (ColorGroup.Aaps),
@SerializedName("IMPORT_SETTINGS") IMPORT_SETTINGS (ColorGroup.Aaps), IMPORT_SETTINGS (ColorGroup.Aaps),
@SerializedName("RESET_DATABASES") RESET_DATABASES (ColorGroup.Aaps), RESET_DATABASES (ColorGroup.Aaps),
@SerializedName("EXPORT_DATABASES") EXPORT_DATABASES (ColorGroup.Aaps), EXPORT_DATABASES (ColorGroup.Aaps),
@SerializedName("IMPORT_DATABASES") IMPORT_DATABASES (ColorGroup.Aaps), IMPORT_DATABASES (ColorGroup.Aaps),
@SerializedName("OTP_EXPORT") OTP_EXPORT (ColorGroup.Aaps), OTP_EXPORT (ColorGroup.Aaps),
@SerializedName("OTP_RESET") OTP_RESET (ColorGroup.Aaps), OTP_RESET (ColorGroup.Aaps),
@SerializedName("STOP_SMS") STOP_SMS (ColorGroup.Aaps), STOP_SMS (ColorGroup.Aaps),
@SerializedName("FOOD") FOOD (ColorGroup.Careportal), FOOD (ColorGroup.Careportal),
@SerializedName("EXPORT_CSV") EXPORT_CSV (ColorGroup.Aaps), EXPORT_CSV (ColorGroup.Aaps),
@SerializedName("UNKNOWN") UNKNOWN (ColorGroup.Aaps) UNKNOWN (ColorGroup.Aaps)
; ;
companion object { companion object {
@ -102,7 +102,7 @@ data class UserEntry(
constructor(ivalue: Int, unit: Units, condition:Boolean = true) : this(0.0, ivalue, 0, "", unit, condition) constructor(ivalue: Int, unit: Units, condition:Boolean = true) : this(0.0, ivalue, 0, "", unit, condition)
constructor(lvalue: Long, unit: Units, condition:Boolean = true) : this(0.0,0, lvalue, "", unit, condition) constructor(lvalue: Long, unit: Units, condition:Boolean = true) : this(0.0,0, lvalue, "", unit, condition)
constructor(svalue: String, unit:Units) : this(0.0,0, 0, svalue, unit, svalue != "") constructor(svalue: String, unit:Units) : this(0.0,0, 0, svalue, unit, svalue != "")
constructor(source: Sources) : this(0.0,0, 0, source.text, Units.Source, true) constructor(source: Sources) : this(0.0,0, 0, source.name, Units.Source, true)
constructor(dvalue: Double, unit:String, condition:Boolean = true) : this(dvalue,0, 0, "", Units.fromText(unit), condition) constructor(dvalue: Double, unit:String, condition:Boolean = true) : this(dvalue,0, 0, "", Units.fromText(unit), condition)
constructor(rStringRef: Int, nbParam: Long) : this(0.0, rStringRef, nbParam, "", Units.R_String, !rStringRef.equals(0)) // additionnal constructors for formated strings with additional values as parameters (define number of parameters as long constructor(rStringRef: Int, nbParam: Long) : this(0.0, rStringRef, nbParam, "", Units.R_String, !rStringRef.equals(0)) // additionnal constructors for formated strings with additional values as parameters (define number of parameters as long
@ -114,19 +114,20 @@ data class UserEntry(
} }
} }
enum class Units(val text: String) { enum class Units(val text: String) {
@SerializedName("None") None (""), //Int or String None (""), //Int or String
@SerializedName("Mg_Dl") Mg_Dl ("mg/dl"), //Double Mg_Dl ("mg/dl"), //Double
@SerializedName("Mmol_L") Mmol_L ("mmol"), //Double Mmol_L ("mmol"), //Double
@SerializedName("Timestamp") Timestamp("Timestamp"), //long Timestamp("Timestamp"), //long
@SerializedName("U") U ("U"), //Double U ("U"), //Double
@SerializedName("U_H") U_H ("U/h"), //Double U_H ("U/h"), //Double
@SerializedName("G") G ("g"), //Int G ("g"), //Int
@SerializedName("M") M ("m"), //Int M ("m"), //Int
@SerializedName("H") H ("h"), //Int H ("h"), //Int
@SerializedName("Percent") Percent ("%"), //Int Percent ("%"), //Int
@SerializedName("TherapyEvent") TherapyEvent ("TherapyEvent"), //String (All enum key translated by Translator function, mainly TherapyEvent) TherapyEvent ("TherapyEvent"), //String (All enum key translated by Translator function, mainly The
@SerializedName("R_String") R_String ("R.string"), //Int R_String ("R.string"), //Int
@SerializedName("Source") Source ("Source") //String Source ("Source") //String
; ;
companion object { companion object {
@ -134,43 +135,42 @@ data class UserEntry(
fun fromText(unit: String?) = values().firstOrNull { it.text == unit } ?: None fun fromText(unit: String?) = values().firstOrNull { it.text == unit } ?: None
} }
} }
enum class Sources(val text: String) { enum class Sources() {
@SerializedName("TreatmentDialog") TreatmentDialog ("TreatmentDialog"), TreatmentDialog,
@SerializedName("InsulinDialog") InsulinDialog ("InsulinDialog"), InsulinDialog,
@SerializedName("CarbDialog") CarbDialog ("CarbDialog"), CarbDialog,
@SerializedName("WizardDialog") WizardDialog ("WizardDialog"), WizardDialog,
@SerializedName("QuickWizard") QuickWizard ("QuickWizard"), QuickWizard,
@SerializedName("ExtendedBolusDialog") ExtendedBolusDialog ("ExtendedBolusDialog"), ExtendedBolusDialog,
@SerializedName("TTDialog") TTDialog ("TTDialog"), TTDialog,
@SerializedName("ProfileSwitchDialog") ProfileSwitchDialog ("ProfileSwitchDialog"), ProfileSwitchDialog,
@SerializedName("LoopDialog") LoopDialog ("LoopDialog"), LoopDialog,
@SerializedName("TempBasalDialog") TempBasalDialog ("TempBasalDialog"), TempBasalDialog,
@SerializedName("CalibrationDialog") CalibrationDialog ("CalibrationDialog"), CalibrationDialog,
@SerializedName("FillDialog") FillDialog ("FillDialog"), FillDialog,
@SerializedName("BgCheck") BgCheck ("BgCheck"), BgCheck,
@SerializedName("SensorInsert") SensorInsert ("SensorInsert"), SensorInsert,
@SerializedName("BatteryChange") BatteryChange ("BatteryChange"), BatteryChange,
@SerializedName("Note") Note ("Note"), Note,
@SerializedName("Exercise") Exercise ("Exercise"), Exercise,
@SerializedName("Question") Question ("Question"), Question,
@SerializedName("Announcement") Announcement ("Announcement"), Announcement,
@SerializedName("Actions") Actions ("Actions"), //From Actions plugin Actions, //From Actions plugin
@SerializedName("Automation") Automation ("Automation"), //From Automation plugin Automation, //From Automation plugin
@SerializedName("LocalProfile") LocalProfile ("LocalProfile"), //From LocalProfile plugin LocalProfile, //From LocalProfile plugin
@SerializedName("Loop") Loop ("Loop"), //From Loop plugin Loop, //From Loop plugin
@SerializedName("Maintenance") Maintenance ("Maintenance"), //From Maintenance plugin Maintenance, //From Maintenance plugin
@SerializedName("NSClient") NSClient ("NSClient"), //From NSClient plugin NSClient, //From NSClient plugin
@SerializedName("Pump") Pump ("Pump"), //From Pump plugin (for example from pump history) Pump, //From Pump plugin
@SerializedName("SMS") SMS ("SMS"), //From SMS plugin SMS, //From SMS plugin
@SerializedName("Treatments") Treatments ("Treatments"), //From Treatments plugin Treatments, //From Treatments plugin
@SerializedName("Wear") Wear ("Wear"), //From Wear plugin Wear, //From Wear plugin
@SerializedName("Food") Food ("Food"), //From Food plugin Food, //From Food plugin
@SerializedName("Unknown") Unknown ("Unknown") //if necessary Unknown //if necessary
; ;
companion object { companion object {
fun fromString(source: String?) = values().firstOrNull { it.name == source } ?: Unknown fun fromString(source: String?) = values().firstOrNull { it.name == source } ?: Unknown
fun fromText(source: String?) = values().firstOrNull { it.text == source } ?: Unknown
} }
} }
@ -188,7 +188,7 @@ data class UserEntry(
fun isLoop(): Boolean { fun isLoop(): Boolean {
var result = false var result = false
for (v in values) { for (v in values) {
if (v.unit == Units.Source && Sources.fromText(v.sValue).equals(Sources.Loop)) result = true if (v.unit == Units.Source && Sources.fromString(v.sValue).equals(Sources.Loop)) result = true
} }
return result return result
} }