Merge pull request #468 from Philoul/meallink_VWU_v2

Fix double Entries in Treatment Dialog (+ add new uel.log for plugin enabled/disabled
This commit is contained in:
Milos Kozak 2021-04-11 08:39:43 +02:00 committed by GitHub
commit b0a12dab1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 7 deletions

View file

@ -167,18 +167,18 @@ class TreatmentDialog : DialogFragmentWithDate() {
{ aapsLogger.error(LTag.DATABASE, "Error while saving carbs", it) }
)
} else {
if (detailedBolusInfo.insulin > 0)
if (detailedBolusInfo.insulin > 0) {
uel.log(action, Sources.TreatmentDialog,
ValueWithUnit.Insulin(insulinAfterConstraints),
ValueWithUnit.Gram(carbsAfterConstraints).takeIf { carbsAfterConstraints != 0 })
commandQueue.bolus(detailedBolusInfo, object : Callback() {
override fun run() {
if (!result.success) {
ErrorHelperActivity.runAlarm(ctx, result.comment, resourceHelper.gs(R.string.treatmentdeliveryerror), info.nightscout.androidaps.dana.R.raw.boluserror)
} else
uel.log(action, Sources.TreatmentDialog,
ValueWithUnit.Insulin(insulinAfterConstraints),
ValueWithUnit.Gram(carbsAfterConstraints).takeIf { carbsAfterConstraints != 0 })
}
}
})
else
} else
uel.log(action, Sources.TreatmentDialog,
ValueWithUnit.Gram(carbsAfterConstraints).takeIf { carbs != 0 })
}

View file

@ -5,6 +5,7 @@ import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.database.entities.UserEntry.Action
import info.nightscout.androidaps.database.entities.UserEntry.Sources
import info.nightscout.androidaps.database.entities.ValueWithUnit
import info.nightscout.androidaps.events.EventAppInitialized
import info.nightscout.androidaps.events.EventConfigBuilderChange
import info.nightscout.androidaps.events.EventRebuildTabs
@ -147,7 +148,8 @@ class ConfigBuilderPlugin @Inject constructor(
performPluginSwitch(changedPlugin, newState, type)
pumpSync.connectNewPump()
sp.putBoolean("allow_hardware_pump", true)
uel.log(Action.HW_PUMP_ALLOWED, Sources.ConfigBuilder)
uel.log(Action.HW_PUMP_ALLOWED, Sources.ConfigBuilder,
ValueWithUnit.StringResource(changedPlugin.pluginDescription.pluginName))
aapsLogger.debug(LTag.PUMP, "First time HW pump allowed!")
}, {
rxBus.send(EventConfigBuilderUpdateGui())
@ -157,6 +159,14 @@ class ConfigBuilderPlugin @Inject constructor(
}
override fun performPluginSwitch(changedPlugin: PluginBase, enabled: Boolean, type: PluginType) {
if(enabled && !changedPlugin.isEnabled()) {
uel.log(Action.PLUGIN_ENABLED, Sources.ConfigBuilder,
ValueWithUnit.StringResource(changedPlugin.pluginDescription.pluginName))
}
else if(!enabled) {
uel.log(Action.PLUGIN_DISABLED, Sources.ConfigBuilder,
ValueWithUnit.StringResource(changedPlugin.pluginDescription.pluginName))
}
changedPlugin.setPluginEnabled(type, enabled)
changedPlugin.setFragmentVisible(type, enabled)
processOnEnabledCategoryChanged(changedPlugin, type)

View file

@ -96,6 +96,8 @@ class Translator @Inject internal constructor(
Action.STOP_SMS -> resourceHelper.gs(R.string.uel_stop_sms)
Action.START_AAPS -> resourceHelper.gs(R.string.uel_start_aaps)
Action.EXIT_AAPS -> resourceHelper.gs(R.string.uel_exit_aaps)
Action.PLUGIN_ENABLED -> resourceHelper.gs(R.string.uel_plugin_enabled)
Action.PLUGIN_DISABLED -> resourceHelper.gs(R.string.uel_plugin_disabled)
Action.UNKNOWN -> resourceHelper.gs(R.string.unknown)
}

View file

@ -483,6 +483,8 @@
<string name="uel_export_csv">EXPORT USER ENTRIES</string>
<string name="uel_start_aaps">START AAPS</string>
<string name="uel_exit_aaps">EXIT AAPS</string>
<string name="uel_plugin_enabled">PLUGIN ENABLED</string>
<string name="uel_plugin_disabled">PLUGIN DISABLED</string>
<string name="uel_unknown">UNKNOWN</string>
<string name="ue_formated_string">Formated string</string>
<string name="ue_source">Source</string>

View file

@ -96,6 +96,8 @@ data class UserEntry(
EXPORT_CSV (ColorGroup.Aaps),
START_AAPS (ColorGroup.Aaps),
EXIT_AAPS (ColorGroup.Aaps),
PLUGIN_ENABLED (ColorGroup.Aaps),
PLUGIN_DISABLED (ColorGroup.Aaps),
UNKNOWN (ColorGroup.Aaps)
;