UserEntry refactor to include XXXValueWithUnit (Loop Dialog and ProfileSwitchDialog only)

This commit is contained in:
Philoul 2021-04-01 19:27:13 +02:00
parent a07b685e8d
commit 83f4d25527
5 changed files with 2967 additions and 32 deletions

View file

@ -243,28 +243,28 @@ class LoopDialog : DaggerDialogFragment() {
val profile = profileFunction.getProfile() ?: return true val profile = profileFunction.getProfile() ?: return true
when (v.id) { when (v.id) {
R.id.overview_closeloop -> { R.id.overview_closeloop -> {
uel.log(Action.CLOSED_LOOP_MODE, ValueWithUnit(Sources.LoopDialog)) uel.log(Action.CLOSED_LOOP_MODE, Sources.LoopDialog)
sp.putString(R.string.key_aps_mode, "closed") sp.putString(R.string.key_aps_mode, "closed")
rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.closedloop))) rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.closedloop)))
return true return true
} }
R.id.overview_lgsloop -> { R.id.overview_lgsloop -> {
uel.log(Action.LGS_LOOP_MODE, ValueWithUnit(Sources.LoopDialog)) uel.log(Action.LGS_LOOP_MODE, Sources.LoopDialog)
sp.putString(R.string.key_aps_mode, "lgs") sp.putString(R.string.key_aps_mode, "lgs")
rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend))) rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend)))
return true return true
} }
R.id.overview_openloop -> { R.id.overview_openloop -> {
uel.log(Action.OPEN_LOOP_MODE, ValueWithUnit(Sources.LoopDialog)) uel.log(Action.OPEN_LOOP_MODE, Sources.LoopDialog)
sp.putString(R.string.key_aps_mode, "open") sp.putString(R.string.key_aps_mode, "open")
rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend))) rxBus.send(EventPreferenceChange(resourceHelper.gs(R.string.lowglucosesuspend)))
return true return true
} }
R.id.overview_disable -> { R.id.overview_disable -> {
uel.log(Action.LOOP_DISABLED, ValueWithUnit(Sources.LoopDialog)) uel.log(Action.LOOP_DISABLED, Sources.LoopDialog)
loopPlugin.setPluginEnabled(PluginType.LOOP, false) loopPlugin.setPluginEnabled(PluginType.LOOP, false)
loopPlugin.setFragmentVisible(PluginType.LOOP, false) loopPlugin.setFragmentVisible(PluginType.LOOP, false)
configBuilderPlugin.storeSettings("DisablingLoop") configBuilderPlugin.storeSettings("DisablingLoop")
@ -281,7 +281,7 @@ class LoopDialog : DaggerDialogFragment() {
} }
R.id.overview_enable -> { R.id.overview_enable -> {
uel.log(Action.LOOP_ENABLED, ValueWithUnit(Sources.LoopDialog)) uel.log(Action.LOOP_ENABLED, Sources.LoopDialog)
loopPlugin.setPluginEnabled(PluginType.LOOP, true) loopPlugin.setPluginEnabled(PluginType.LOOP, true)
loopPlugin.setFragmentVisible(PluginType.LOOP, true) loopPlugin.setFragmentVisible(PluginType.LOOP, true)
configBuilderPlugin.storeSettings("EnablingLoop") configBuilderPlugin.storeSettings("EnablingLoop")
@ -291,8 +291,7 @@ class LoopDialog : DaggerDialogFragment() {
} }
R.id.overview_resume, R.id.overview_reconnect -> { R.id.overview_resume, R.id.overview_reconnect -> {
//uel.log(if (v.id == R.id.overview_resume) Action.RESUME else Action.RECONNECT ) uel.log(if (v.id==R.id.overview_resume) Action.RESUME else Action.RECONNECT, Sources.LoopDialog)
uel.log(if (v.id==R.id.overview_resume) Action.RESUME else Action.RECONNECT, ValueWithUnit(Sources.LoopDialog))
loopPlugin.suspendTo(0L) loopPlugin.suspendTo(0L)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
commandQueue.cancelTempBasal(true, object : Callback() { commandQueue.cancelTempBasal(true, object : Callback() {
@ -308,56 +307,49 @@ class LoopDialog : DaggerDialogFragment() {
} }
R.id.overview_suspend_1h -> { R.id.overview_suspend_1h -> {
//uel.log(Action.SUSPEND, XXXValueWithUnit.Hour(1)) uel.log(Action.SUSPEND, Sources.LoopDialog, XXXValueWithUnit.Hour(1))
uel.log(Action.SUSPEND, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(1, Units.H))
loopPlugin.suspendLoop(60) loopPlugin.suspendLoop(60)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
return true return true
} }
R.id.overview_suspend_2h -> { R.id.overview_suspend_2h -> {
//uel.log(Action.SUSPEND, XXXValueWithUnit.Hour(2)) uel.log(Action.SUSPEND, Sources.LoopDialog, XXXValueWithUnit.Hour(2))
uel.log(Action.SUSPEND, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(2, Units.H))
loopPlugin.suspendLoop(120) loopPlugin.suspendLoop(120)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
return true return true
} }
R.id.overview_suspend_3h -> { R.id.overview_suspend_3h -> {
//uel.log(Action.SUSPEND, XXXValueWithUnit.Hour(3)) uel.log(Action.SUSPEND, Sources.LoopDialog, XXXValueWithUnit.Hour(3))
uel.log(Action.SUSPEND, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(3, Units.H))
loopPlugin.suspendLoop(180) loopPlugin.suspendLoop(180)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
return true return true
} }
R.id.overview_suspend_10h -> { R.id.overview_suspend_10h -> {
//uel.log(Action.SUSPEND, XXXValueWithUnit.Hour(10)) uel.log(Action.SUSPEND, Sources.LoopDialog, XXXValueWithUnit.Hour(10))
uel.log(Action.SUSPEND, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(10, Units.H))
loopPlugin.suspendLoop(600) loopPlugin.suspendLoop(600)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
return true return true
} }
R.id.overview_disconnect_15m -> { R.id.overview_disconnect_15m -> {
//Muel.log(Action.DISCONNECT, XXXValueWithUnit.Minute(15)) uel.log(Action.DISCONNECT, Sources.LoopDialog, XXXValueWithUnit.Minute(15))
uel.log(Action.DISCONNECT, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(15, Units.M))
loopPlugin.disconnectPump(15, profile) loopPlugin.disconnectPump(15, profile)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
return true return true
} }
R.id.overview_disconnect_30m -> { R.id.overview_disconnect_30m -> {
//uel.log(Action.DISCONNECT, XXXValueWithUnit.Minute(30)) uel.log(Action.DISCONNECT, Sources.LoopDialog, XXXValueWithUnit.Minute(30))
uel.log(Action.DISCONNECT, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(30, Units.M))
loopPlugin.disconnectPump(30, profile) loopPlugin.disconnectPump(30, profile)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
return true return true
} }
R.id.overview_disconnect_1h -> { R.id.overview_disconnect_1h -> {
//uel.log(Action.DISCONNECT, XXXValueWithUnit.Hour(1)) uel.log(Action.DISCONNECT, Sources.LoopDialog, XXXValueWithUnit.Hour(1))
uel.log(Action.DISCONNECT, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(1, Units.H))
loopPlugin.disconnectPump(60, profile) loopPlugin.disconnectPump(60, profile)
sp.putBoolean(R.string.key_objectiveusedisconnect, true) sp.putBoolean(R.string.key_objectiveusedisconnect, true)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
@ -365,16 +357,14 @@ class LoopDialog : DaggerDialogFragment() {
} }
R.id.overview_disconnect_2h -> { R.id.overview_disconnect_2h -> {
//uel.log(Action.DISCONNECT, XXXValueWithUnit.Hour(2)) uel.log(Action.DISCONNECT, Sources.LoopDialog, XXXValueWithUnit.Hour(2))
uel.log(Action.DISCONNECT, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(2, Units.H))
loopPlugin.disconnectPump(120, profile) loopPlugin.disconnectPump(120, profile)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
return true return true
} }
R.id.overview_disconnect_3h -> { R.id.overview_disconnect_3h -> {
//uel.log(Action.DISCONNECT, XXXValueWithUnit.Hour(3)) uel.log(Action.DISCONNECT, Sources.LoopDialog, XXXValueWithUnit.Hour(3))
uel.log(Action.DISCONNECT, ValueWithUnit(Sources.LoopDialog), ValueWithUnit(3, Units.H))
loopPlugin.disconnectPump(180, profile) loopPlugin.disconnectPump(180, profile)
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
return true return true

View file

@ -115,7 +115,7 @@ class ClassicPrefsFormat @Inject constructor(
var action = csvString(entry.action) var action = csvString(entry.action)
var therapyEvent = "" var therapyEvent = ""
var source = "" var source = ""
var note = csvString(entry.s) var note = csvString(entry.note)
var formatedString = "" var formatedString = ""
var timestamp = "" var timestamp = ""
var bg = "" var bg = ""
@ -126,7 +126,7 @@ class ClassicPrefsFormat @Inject constructor(
var h = "" var h = ""
var m = "" var m = ""
var other = "" var other = ""
/*
for (v in entry.values) { for (v in entry.values) {
when (v.unit) { when (v.unit) {
Units.Timestamp -> timestamp = dateUtil.dateAndTimeAndSecondsString(v.lValue) Units.Timestamp -> timestamp = dateUtil.dateAndTimeAndSecondsString(v.lValue)
@ -154,6 +154,7 @@ class ClassicPrefsFormat @Inject constructor(
else -> other = if (other == "") v.value().toString() else other + " / " + v.value().toString() else -> other = if (other == "") v.value().toString() else other + " / " + v.value().toString()
} }
} }
*/
therapyEvent = csvString(therapyEvent) therapyEvent = csvString(therapyEvent)
formatedString = csvString(formatedString) formatedString = csvString(formatedString)
other = csvString(other) other = csvString(other)

View file

@ -82,10 +82,10 @@ class UserEntryPresentationHelper @Inject constructor(
list.joinToString(separator = " ", transform = this::toPresentationString) list.joinToString(separator = " ", transform = this::toPresentationString)
private fun toPresentationString(valueWithUnit: XXXValueWithUnit?): String = when (valueWithUnit) { private fun toPresentationString(valueWithUnit: XXXValueWithUnit?): String = when (valueWithUnit) {
is XXXValueWithUnit.Gram -> "${valueWithUnit.value} ${translator.translate(Units.G)}" is XXXValueWithUnit.Gram -> "${valueWithUnit.value}${translator.translate(Units.G)}"
is XXXValueWithUnit.Hour -> "${valueWithUnit.value} ${translator.translate(Units.H)}" is XXXValueWithUnit.Hour -> "${valueWithUnit.value}${translator.translate(Units.H)}"
is XXXValueWithUnit.Minute -> "${valueWithUnit.value} ${translator.translate(Units.G)}" is XXXValueWithUnit.Minute -> "${valueWithUnit.value}${translator.translate(Units.M)}"
is XXXValueWithUnit.Percent -> "${valueWithUnit.value} ${translator.translate(Units.Percent)}" is XXXValueWithUnit.Percent -> "${valueWithUnit.value}${translator.translate(Units.Percent)}"
is XXXValueWithUnit.Insulin -> DecimalFormatter.to2Decimal(valueWithUnit.value) + translator.translate(UserEntry.Units.U) is XXXValueWithUnit.Insulin -> DecimalFormatter.to2Decimal(valueWithUnit.value) + translator.translate(UserEntry.Units.U)
is XXXValueWithUnit.UnitPerHour -> DecimalFormatter.to2Decimal(valueWithUnit.value) + translator.translate(UserEntry.Units.U_H) is XXXValueWithUnit.UnitPerHour -> DecimalFormatter.to2Decimal(valueWithUnit.value) + translator.translate(UserEntry.Units.U_H)
is XXXValueWithUnit.SimpleInt -> valueWithUnit.value.toString() is XXXValueWithUnit.SimpleInt -> valueWithUnit.value.toString()

File diff suppressed because it is too large Load diff

View file

@ -62,4 +62,11 @@ open class DatabaseModule {
database.execSQL("CREATE INDEX IF NOT EXISTS `index_mealLinks_noteId` ON mealLinks (`noteId`)") database.execSQL("CREATE INDEX IF NOT EXISTS `index_mealLinks_noteId` ON mealLinks (`noteId`)")
} }
} }
private val migration10to11 = object : Migration(10,11) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("DROP TABLE IF EXISTS userEntry")
database.execSQL("CREATE TABLE IF NOT EXISTS userEntry (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `action` TEXT NOT NULL, `source` TEXT NOT NULL, `note` TEXT NOT NULL, `values` TEXT NOT NULL)")
}
}
} }