From c728f8689b7a9b1a3683b5fc741ed4b943c28009 Mon Sep 17 00:00:00 2001 From: Philoul Date: Sat, 10 Apr 2021 11:35:38 +0200 Subject: [PATCH] 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 ;