From 6114effb22d489c49f031065156173db7673f64d Mon Sep 17 00:00:00 2001 From: Philoul Date: Thu, 8 Apr 2021 10:06:00 +0200 Subject: [PATCH 1/6] Add BG sources for uel (Calibration and Sensor Change) --- .../plugins/source/BGSourceFragment.kt | 4 +- .../androidaps/plugins/source/DexcomPlugin.kt | 21 ++++++- .../nightscout/androidaps/utils/Translator.kt | 8 +++ .../utils/userEntry/UserEntryMapper.kt | 8 +++ .../userEntry/UserEntryPresentationHelper.kt | 62 +++++++++++-------- .../src/main/res/drawable/ic_eversense.xml | 0 .../src/main/res/drawable/ic_glimp.xml | 0 .../src/main/res/drawable/ic_nsclient_bg.xml | 0 .../src/main/res/drawable/ic_poctech.xml | 0 .../androidaps/database/entities/UserEntry.kt | 8 +++ 10 files changed, 80 insertions(+), 31 deletions(-) rename {app => core}/src/main/res/drawable/ic_eversense.xml (100%) rename {app => core}/src/main/res/drawable/ic_glimp.xml (100%) rename {app => core}/src/main/res/drawable/ic_nsclient_bg.xml (100%) rename {app => core}/src/main/res/drawable/ic_poctech.xml (100%) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt index 03cd4dc816..73c28a7ea7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt @@ -131,8 +131,8 @@ class BGSourceFragment : DaggerFragment() { activity?.let { activity -> val text = dateUtil.dateAndTimeString(glucoseValue.timestamp) + "\n" + glucoseValue.valueToUnitsString(profileFunction.getUnits()) OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable { - //uel.log(Action.BG_REMOVED, XXXValueWithUnit.Timestamp(glucoseValue.timestamp)) - uel.log(Action.BG_REMOVED, Sources.BG, + val source = Sources.BG //Todo Replace Sources.BG by Active BG Source plugin + uel.log(Action.BG_REMOVED, source, ValueWithUnit.Timestamp(glucoseValue.timestamp)) disposable += repository.runTransaction(InvalidateGlucoseValueTransaction(glucoseValue.id)).subscribe() }) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt index 75dde2a6d4..29de0b842c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt @@ -14,6 +14,9 @@ import info.nightscout.androidaps.activities.RequestDexcomPermissionActivity import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.entities.GlucoseValue import info.nightscout.androidaps.database.entities.TherapyEvent +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.database.transactions.CgmSourceTransaction import info.nightscout.androidaps.interfaces.BgSourceInterface import info.nightscout.androidaps.interfaces.PluginBase @@ -21,6 +24,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.receivers.DataWorker import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.T @@ -83,6 +87,7 @@ class DexcomPlugin @Inject constructor( @Inject lateinit var dataWorker: DataWorker @Inject lateinit var broadcastToXDrip: XDripBroadcast @Inject lateinit var repository: AppRepository + @Inject lateinit var uel: UserEntryLogger init { (context.applicationContext as HasAndroidInjector).androidInjector().inject(this) @@ -150,8 +155,20 @@ class DexcomPlugin @Inject constructor( broadcastToXDrip(it) aapsLogger.debug(LTag.DATABASE, "Updated bg $it") } - result.sensorInsertionsInserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted sensor insertion $it") } - result.calibrationsInserted.forEach { aapsLogger.debug(LTag.DATABASE, "Inserted calibration $it") } + result.sensorInsertionsInserted.forEach { + uel.log(Action.CAREPORTAL, + Sources.BG, + ValueWithUnit.Timestamp(it.timestamp), + ValueWithUnit.TherapyEventType(it.type)) + aapsLogger.debug(LTag.DATABASE, "Inserted sensor insertion $it") + } + result.calibrationsInserted.forEach { + uel.log(Action.CAREPORTAL, + Sources.BG, + ValueWithUnit.Timestamp(it.timestamp), + ValueWithUnit.TherapyEventType(it.type)) + aapsLogger.debug(LTag.DATABASE, "Inserted calibration $it") + } } } catch (e: Exception) { aapsLogger.error("Error while processing intent from Dexcom App", e) diff --git a/core/src/main/java/info/nightscout/androidaps/utils/Translator.kt b/core/src/main/java/info/nightscout/androidaps/utils/Translator.kt index 28fe5150f0..37ea3a17b8 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/Translator.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/Translator.kt @@ -233,6 +233,14 @@ class Translator @Inject internal constructor( Sources.Announcement -> TODO() Sources.Actions -> TODO() Sources.BG -> TODO() + Sources.Dexcom -> TODO() + Sources.Eversense -> TODO() + Sources.Glimp -> TODO() + Sources.MM640g -> TODO() + Sources.NSClientSource -> TODO() + Sources.PocTech -> TODO() + Sources.Tomato -> TODO() + Sources.Xdrip -> TODO() Sources.LocalProfile -> TODO() Sources.Maintenance -> TODO() Sources.NSProfile -> TODO() diff --git a/core/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryMapper.kt b/core/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryMapper.kt index bd0a2b723d..ac623c914e 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryMapper.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryMapper.kt @@ -106,6 +106,14 @@ class UserEntryMapper { Actions (UserEntry.Sources.Actions), Automation (UserEntry.Sources.Automation), BG (UserEntry.Sources.BG), + Dexcom (UserEntry.Sources.Dexcom), + Eversense (UserEntry.Sources.Eversense), + Glimp (UserEntry.Sources.Glimp), + MM640g (UserEntry.Sources.MM640g), + NSClientSource (UserEntry.Sources.BG), + PocTech (UserEntry.Sources.PocTech), + Tomato (UserEntry.Sources.Tomato), + Xdrip (UserEntry.Sources.Xdrip), LocalProfile (UserEntry.Sources.LocalProfile), Loop (UserEntry.Sources.Loop), Maintenance (UserEntry.Sources.Maintenance), diff --git a/core/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryPresentationHelper.kt b/core/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryPresentationHelper.kt index 0aeffddb2c..c0f974f51a 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryPresentationHelper.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryPresentationHelper.kt @@ -39,35 +39,43 @@ class UserEntryPresentationHelper @Inject constructor( } fun iconId(source: Sources): Int = when (source) { - Sources.TreatmentDialog -> R.drawable.icon_insulin_carbs - Sources.InsulinDialog -> R.drawable.ic_bolus - Sources.CarbDialog -> R.drawable.ic_cp_bolus_carbs - Sources.WizardDialog -> R.drawable.ic_calculator - Sources.QuickWizard -> R.drawable.ic_quick_wizard + Sources.TreatmentDialog -> R.drawable.icon_insulin_carbs + Sources.InsulinDialog -> R.drawable.ic_bolus + Sources.CarbDialog -> R.drawable.ic_cp_bolus_carbs + Sources.WizardDialog -> R.drawable.ic_calculator + Sources.QuickWizard -> R.drawable.ic_quick_wizard Sources.ExtendedBolusDialog -> R.drawable.ic_actions_startextbolus - Sources.TTDialog -> R.drawable.ic_temptarget_high + Sources.TTDialog -> R.drawable.ic_temptarget_high Sources.ProfileSwitchDialog -> R.drawable.ic_actions_profileswitch - Sources.LoopDialog -> R.drawable.ic_loop_closed - Sources.TempBasalDialog -> R.drawable.ic_actions_starttempbasal - Sources.CalibrationDialog -> R.drawable.ic_calibration - Sources.FillDialog -> R.drawable.ic_cp_pump_canula - Sources.BgCheck -> R.drawable.ic_cp_bgcheck - Sources.SensorInsert -> R.drawable.ic_cp_cgm_insert - Sources.BatteryChange -> R.drawable.ic_cp_pump_battery - Sources.Note -> R.drawable.ic_cp_note - Sources.Exercise -> R.drawable.ic_cp_exercise - Sources.Question -> R.drawable.ic_cp_question - Sources.Announcement -> R.drawable.ic_cp_announcement - Sources.Actions -> R.drawable.ic_action - Sources.Automation -> R.drawable.ic_automation - Sources.BG -> R.drawable.ic_generic_cgm - Sources.LocalProfile -> R.drawable.ic_local_profile - Sources.Loop -> R.drawable.ic_loop_closed_white - Sources.Maintenance -> R.drawable.ic_maintenance - Sources.NSClient -> R.drawable.ic_nightscout_syncs - Sources.NSProfile -> R.drawable.ic_nightscout_profile - Sources.Objectives -> R.drawable.ic_graduation - Sources.Pump -> R.drawable.ic_generic_icon + Sources.LoopDialog -> R.drawable.ic_loop_closed + Sources.TempBasalDialog -> R.drawable.ic_actions_starttempbasal + Sources.CalibrationDialog -> R.drawable.ic_calibration + Sources.FillDialog -> R.drawable.ic_cp_pump_canula + Sources.BgCheck -> R.drawable.ic_cp_bgcheck + Sources.SensorInsert -> R.drawable.ic_cp_cgm_insert + Sources.BatteryChange -> R.drawable.ic_cp_pump_battery + Sources.Note -> R.drawable.ic_cp_note + Sources.Exercise -> R.drawable.ic_cp_exercise + Sources.Question -> R.drawable.ic_cp_question + Sources.Announcement -> R.drawable.ic_cp_announcement + Sources.Actions -> R.drawable.ic_action + Sources.Automation -> R.drawable.ic_automation + Sources.BG -> R.drawable.ic_generic_cgm + Sources.Dexcom -> R.drawable.ic_dexcom_g6 + Sources.Eversense -> R.drawable.ic_eversense + Sources.Glimp -> R.drawable.ic_glimp + Sources.MM640g -> R.drawable.ic_generic_cgm + Sources.NSClientSource -> R.drawable.ic_nsclient_bg + Sources.PocTech -> R.drawable.ic_poctech + Sources.Tomato -> R.drawable.ic_sensor + Sources.Xdrip -> R.drawable.ic_blooddrop_48 + Sources.LocalProfile -> R.drawable.ic_local_profile + Sources.Loop -> R.drawable.ic_loop_closed_white + Sources.Maintenance -> R.drawable.ic_maintenance + Sources.NSClient -> R.drawable.ic_nightscout_syncs + Sources.NSProfile -> R.drawable.ic_nightscout_profile + Sources.Objectives -> R.drawable.ic_graduation + Sources.Pump -> R.drawable.ic_generic_icon Sources.Dana -> R.drawable.ic_danars_128 Sources.DanaR -> R.drawable.ic_danars_128 Sources.DanaRC -> R.drawable.ic_danars_128 diff --git a/app/src/main/res/drawable/ic_eversense.xml b/core/src/main/res/drawable/ic_eversense.xml similarity index 100% rename from app/src/main/res/drawable/ic_eversense.xml rename to core/src/main/res/drawable/ic_eversense.xml diff --git a/app/src/main/res/drawable/ic_glimp.xml b/core/src/main/res/drawable/ic_glimp.xml similarity index 100% rename from app/src/main/res/drawable/ic_glimp.xml rename to core/src/main/res/drawable/ic_glimp.xml diff --git a/app/src/main/res/drawable/ic_nsclient_bg.xml b/core/src/main/res/drawable/ic_nsclient_bg.xml similarity index 100% rename from app/src/main/res/drawable/ic_nsclient_bg.xml rename to core/src/main/res/drawable/ic_nsclient_bg.xml diff --git a/app/src/main/res/drawable/ic_poctech.xml b/core/src/main/res/drawable/ic_poctech.xml similarity index 100% rename from app/src/main/res/drawable/ic_poctech.xml rename to core/src/main/res/drawable/ic_poctech.xml 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 390c92aca5..759413381e 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 @@ -125,6 +125,14 @@ data class UserEntry( Actions, //From Actions plugin Automation, //From Automation plugin BG, //From BG plugin => Add One Source per BG Source for Calibration or Sensor Change + Dexcom, + Eversense, + Glimp, + MM640g, + NSClientSource, + PocTech, + Tomato, + Xdrip, LocalProfile, //From LocalProfile plugin Loop, //From Loop plugin Maintenance, //From Maintenance plugin From ff0e6e9c87f79dd78923e65fc7acc5d8c05e05af Mon Sep 17 00:00:00 2001 From: Philoul Date: Thu, 8 Apr 2021 18:47:00 +0200 Subject: [PATCH 2/6] Use icon of activeBgSource for uel Log --- .../androidaps/plugins/source/BGSourceFragment.kt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt index 73c28a7ea7..6ec4d20525 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt @@ -29,6 +29,8 @@ import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.extensions.directionToIcon import info.nightscout.androidaps.extensions.toVisibility import info.nightscout.androidaps.extensions.valueToUnitsString +import info.nightscout.androidaps.interfaces.ActivePluginProvider +import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.rx.AapsSchedulers import io.reactivex.disposables.CompositeDisposable @@ -47,6 +49,7 @@ class BGSourceFragment : DaggerFragment() { @Inject lateinit var repository: AppRepository @Inject lateinit var aapsSchedulers: AapsSchedulers @Inject lateinit var uel: UserEntryLogger + @Inject lateinit var activePlugin: ActivePluginProvider private val disposable = CompositeDisposable() private val millsToThePast = T.hours(12).msecs() @@ -131,7 +134,17 @@ class BGSourceFragment : DaggerFragment() { activity?.let { activity -> val text = dateUtil.dateAndTimeString(glucoseValue.timestamp) + "\n" + glucoseValue.valueToUnitsString(profileFunction.getUnits()) OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable { - val source = Sources.BG //Todo Replace Sources.BG by Active BG Source plugin + val source = when((activePlugin.activeBgSource as PluginBase).pluginDescription.pluginName) { + R.string.dexcom_app_patched -> Sources.Dexcom + R.string.eversense -> Sources.Eversense + R.string.Glimp -> Sources.Glimp + R.string.MM640g -> Sources.MM640g + R.string.nsclientbg -> Sources.NSClientSource + R.string.poctech -> Sources.PocTech + R.string.tomato -> Sources.Tomato + R.string.xdrip -> Sources.Xdrip + else -> Sources.Unknown + } uel.log(Action.BG_REMOVED, source, ValueWithUnit.Timestamp(glucoseValue.timestamp)) disposable += repository.runTransaction(InvalidateGlucoseValueTransaction(glucoseValue.id)).subscribe() From 50232256507b6c660ba2fa994f055f6bc4d0216c Mon Sep 17 00:00:00 2001 From: Philoul Date: Fri, 9 Apr 2021 12:00:33 +0200 Subject: [PATCH 3/6] Add uel.log for Alert Carbs required --- .../info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt index 3382500de6..23c08ffef6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.kt @@ -378,6 +378,8 @@ open class LoopPlugin @Inject constructor( // mId allows you to update the notification later on. mNotificationManager.notify(Constants.notificationID, builder.build()) + uel.log(Action.CAREPORTAL, Sources.Loop, + ValueWithUnit.StringResource(info.nightscout.androidaps.core.R.string.carbsreq, listOf(ValueWithUnit.Gram(resultAfterConstraints.carbsReq), ValueWithUnit.Minute(resultAfterConstraints.carbsReqWithin)))) rxBus.send(EventNewOpenLoopNotification()) //only send to wear if Native notifications are turned off From c728f8689b7a9b1a3683b5fc741ed4b943c28009 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sat, 10 Apr 2021 11:35:38 +0200 Subject: [PATCH 4/6] uel.log for Start and Exit AAPS --- .../nightscout/androidaps/MainActivity.kt | 5 +++ .../info/nightscout/androidaps/MainApp.kt | 4 +++ .../nightscout/androidaps/utils/Translator.kt | 3 ++ .../utils/userEntry/UserEntryMapper.kt | 3 ++ .../userEntry/UserEntryPresentationHelper.kt | 31 ++++++++++--------- .../src/main/res/drawable/ic_cogs.xml | 0 core/src/main/res/values/strings.xml | 2 ++ .../androidaps/database/entities/UserEntry.kt | 3 ++ 8 files changed, 36 insertions(+), 15 deletions(-) rename {app => core}/src/main/res/drawable/ic_cogs.xml (100%) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt index bccdbbcb1a..da9b179cb1 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt @@ -32,6 +32,8 @@ import info.nightscout.androidaps.activities.PreferencesActivity import info.nightscout.androidaps.activities.ProfileHelperActivity import info.nightscout.androidaps.activities.SingleFragmentActivity import info.nightscout.androidaps.activities.StatsActivity +import info.nightscout.androidaps.database.entities.UserEntry.Action +import info.nightscout.androidaps.database.entities.UserEntry.Sources import info.nightscout.androidaps.databinding.ActivityMainBinding import info.nightscout.androidaps.events.EventAppExit import info.nightscout.androidaps.events.EventPreferenceChange @@ -41,6 +43,7 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker @@ -87,6 +90,7 @@ class MainActivity : NoSplashAppCompatActivity() { @Inject lateinit var constraintChecker: ConstraintChecker @Inject lateinit var signatureVerifierPlugin: SignatureVerifierPlugin @Inject lateinit var config: Config + @Inject lateinit var uel: UserEntryLogger private lateinit var actionBarDrawerToggle: ActionBarDrawerToggle private var pluginPreferencesMenuItem: MenuItem? = null @@ -316,6 +320,7 @@ class MainActivity : NoSplashAppCompatActivity() { R.id.nav_exit -> { aapsLogger.debug(LTag.CORE, "Exiting") + uel.log(Action.EXIT_AAPS, Sources.Aaps) rxBus.send(EventAppExit()) finish() System.runFinalization() diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.kt b/app/src/main/java/info/nightscout/androidaps/MainApp.kt index db3e97d199..fa7c8c5ae0 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.kt @@ -11,6 +11,7 @@ import dagger.android.AndroidInjector import dagger.android.DaggerApplication import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.entities.TherapyEvent +import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.database.transactions.InsertIfNewByTimestampTherapyEventTransaction import info.nightscout.androidaps.database.transactions.VersionChangeTransaction import info.nightscout.androidaps.db.CompatDBHelper @@ -20,6 +21,7 @@ import info.nightscout.androidaps.dependencyInjection.DaggerAppComponent import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag +import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin import info.nightscout.androidaps.plugins.configBuilder.PluginStore import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtils @@ -54,6 +56,7 @@ class MainApp : DaggerApplication() { @Inject lateinit var repository: AppRepository @Inject lateinit var dateUtil: DateUtil @Inject lateinit var staticInjector: StaticInjector// TODO avoid , here fake only to initialize + @Inject lateinit var uel: UserEntryLogger override fun onCreate() { super.onCreate() @@ -85,6 +88,7 @@ class MainApp : DaggerApplication() { configBuilderPlugin.initialize() keepAliveManager.setAlarm(this) doMigrations() + uel.log(UserEntry.Action.START_AAPS, UserEntry.Sources.Aaps) } private fun doMigrations() { diff --git a/core/src/main/java/info/nightscout/androidaps/utils/Translator.kt b/core/src/main/java/info/nightscout/androidaps/utils/Translator.kt index 37ea3a17b8..b740f01308 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/Translator.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/Translator.kt @@ -94,6 +94,8 @@ class Translator @Inject internal constructor( Action.OTP_RESET -> resourceHelper.gs(R.string.uel_otp_reset) Action.EXPORT_CSV -> resourceHelper.gs(R.string.uel_export_csv) 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.UNKNOWN -> resourceHelper.gs(R.string.unknown) } @@ -263,6 +265,7 @@ class Translator @Inject internal constructor( Sources.ConfigBuilder -> TODO() Sources.Overview -> TODO() Sources.Stats -> TODO() + Sources.Aaps -> TODO() */ Sources.Automation -> resourceHelper.gs(R.string.automation) Sources.Loop -> resourceHelper.gs(R.string.loop) diff --git a/core/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryMapper.kt b/core/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryMapper.kt index ac623c914e..9bcd0ab632 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryMapper.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryMapper.kt @@ -79,6 +79,8 @@ class UserEntryMapper { STOP_SMS (UserEntry.Action.STOP_SMS), FOOD (UserEntry.Action.FOOD), EXPORT_CSV (UserEntry.Action.EXPORT_CSV), + START_AAPS (UserEntry.Action.START_AAPS), + EXIT_AAPS (UserEntry.Action.EXIT_AAPS), UNKNOWN (UserEntry.Action.UNKNOWN) ; } @@ -141,6 +143,7 @@ class UserEntryMapper { ConfigBuilder (UserEntry.Sources.ConfigBuilder), Overview (UserEntry.Sources.Overview), Stats (UserEntry.Sources.Stats), + Aaps (UserEntry.Sources.Aaps), Unknown(UserEntry.Sources.Unknown) ; } diff --git a/core/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryPresentationHelper.kt b/core/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryPresentationHelper.kt index c0f974f51a..ee0f352413 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryPresentationHelper.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/userEntry/UserEntryPresentationHelper.kt @@ -28,13 +28,13 @@ class UserEntryPresentationHelper @Inject constructor( fun colorId(colorGroup: ColorGroup): Int = when (colorGroup) { ColorGroup.InsulinTreatment -> R.color.iob ColorGroup.BasalTreatment -> 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.loopDisconnected - ColorGroup.Aaps -> R.color.defaulttext + 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.loopDisconnected + ColorGroup.Aaps -> R.color.defaulttext else -> R.color.defaulttext } @@ -89,14 +89,15 @@ class UserEntryPresentationHelper @Inject constructor( Sources.OmnipodDash -> R.drawable.ic_pod_128 Sources.MDI -> R.drawable.ic_ict Sources.VirtualPump -> R.drawable.ic_virtual_pump - Sources.SMS -> R.drawable.ic_sms - Sources.Treatments -> R.drawable.ic_treatments - Sources.Wear -> R.drawable.ic_watch - Sources.Food -> R.drawable.ic_food - Sources.Stats -> R.drawable.ic_cp_stats - Sources.ConfigBuilder -> R.drawable.ic_generic_icon - Sources.Overview -> R.drawable.ic_generic_icon - Sources.Unknown -> R.drawable.ic_generic_icon + Sources.SMS -> R.drawable.ic_sms + Sources.Treatments -> R.drawable.ic_treatments + Sources.Wear -> R.drawable.ic_watch + Sources.Food -> R.drawable.ic_food + Sources.Stats -> R.drawable.ic_cp_stats + Sources.ConfigBuilder -> R.drawable.ic_cogs + Sources.Overview -> R.drawable.ic_notif_aaps + Sources.Aaps -> R.drawable.ic_notif_aaps + Sources.Unknown -> R.drawable.ic_generic_icon } fun actionToColoredString(action: Action): Spanned = when (action) { diff --git a/app/src/main/res/drawable/ic_cogs.xml b/core/src/main/res/drawable/ic_cogs.xml similarity index 100% rename from app/src/main/res/drawable/ic_cogs.xml rename to core/src/main/res/drawable/ic_cogs.xml diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index c627510416..d18775e7b3 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -477,6 +477,8 @@ OTP RESET STOP SMS EXPORT USER ENTRIES + START AAPS + EXIT AAPS UNKNOWN Formated string Source 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 759413381e..1363fb00dd 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 @@ -94,6 +94,8 @@ data class UserEntry( STOP_SMS (ColorGroup.Aaps), FOOD (ColorGroup.CarbTreatment), EXPORT_CSV (ColorGroup.Aaps), + START_AAPS (ColorGroup.Aaps), + EXIT_AAPS (ColorGroup.Aaps), UNKNOWN (ColorGroup.Aaps) ; @@ -160,6 +162,7 @@ data class UserEntry( ConfigBuilder, //From ConfigBuilder Plugin Overview, //From OverViewPlugin Stats, //From Stat Activity + Aaps, // MainApp Unknown //if necessary ; From baa37c4e3a619a732acdf44414542697f013134a Mon Sep 17 00:00:00 2001 From: Philoul Date: Sat, 10 Apr 2021 19:55:24 +0200 Subject: [PATCH 5/6] uel.log for plugin enabled / disabled --- .../plugins/configBuilder/ConfigBuilderPlugin.kt | 12 +++++++++++- .../info/nightscout/androidaps/utils/Translator.kt | 2 ++ core/src/main/res/values/strings.xml | 2 ++ .../androidaps/database/entities/UserEntry.kt | 2 ++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt index 37647464e4..87cd0b8428 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt @@ -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 @@ -144,7 +145,8 @@ class ConfigBuilderPlugin @Inject constructor( OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.allow_hardware_pump_text), Runnable { performPluginSwitch(changedPlugin, newState, type) 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!") }, Runnable { rxBus.send(EventConfigBuilderUpdateGui()) @@ -154,6 +156,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) diff --git a/core/src/main/java/info/nightscout/androidaps/utils/Translator.kt b/core/src/main/java/info/nightscout/androidaps/utils/Translator.kt index b740f01308..b95247ddf6 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/Translator.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/Translator.kt @@ -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) } diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index d18775e7b3..fbae23f8df 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -479,6 +479,8 @@ EXPORT USER ENTRIES START AAPS EXIT AAPS + PLUGIN ENABLED + PLUGIN DISABLED UNKNOWN Formated string Source 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 1363fb00dd..d4347542c2 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 @@ -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) ; From 4d1f330064bca59bf5e9afbcbceaeb8cbd31f9e3 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sat, 10 Apr 2021 19:56:28 +0200 Subject: [PATCH 6/6] Fix double userEntry with VirtualPump if we enter Carbs + Insulin --- .../nightscout/androidaps/dialogs/TreatmentDialog.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt index 4aaa063ec9..4490d433cf 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt @@ -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 }) }