From 2bd2510bd8c2e7bf6fefe681861e19904b3c07fd Mon Sep 17 00:00:00 2001 From: Philoul Date: Sat, 27 Mar 2021 16:17:38 +0100 Subject: [PATCH] Add Maintenance source --- .../plugins/general/maintenance/MaintenanceFragment.kt | 10 +++++----- .../androidaps/utils/extensions/UserEntryExt.kt | 1 + .../src/main/res/drawable/ic_maintenance.xml | 0 .../androidaps/database/entities/UserEntry.kt | 1 + 4 files changed, 7 insertions(+), 5 deletions(-) rename {insight => core}/src/main/res/drawable/ic_maintenance.xml (100%) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenanceFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenanceFragment.kt index 32b3001911..48c8c4740b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenanceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/MaintenanceFragment.kt @@ -56,13 +56,12 @@ class MaintenanceFragment : DaggerFragment() { super.onViewCreated(view, savedInstanceState) binding.logSend.setOnClickListener { maintenancePlugin.sendLogs() } binding.logDelete.setOnClickListener { - uel.log(Action.DELETE_LOGS) + uel.log(Action.DELETE_LOGS, ValueWithUnit(Sources.Maintenance)) maintenancePlugin.deleteLogs() } binding.navResetdb.setOnClickListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.maintenance), resourceHelper.gs(R.string.reset_db_confirm), Runnable { - uel.log(Action.RESET_DATABASES) compositeDisposable.add( fromAction { databaseHelper.resetDatabases() @@ -78,18 +77,19 @@ class MaintenanceFragment : DaggerFragment() { onComplete = { rxBus.send(EventNewBG(null)) } ) ) + uel.log(Action.RESET_DATABASES, ValueWithUnit(Sources.Maintenance)) }) } } binding.navExport.setOnClickListener { - uel.log(Action.EXPORT_SETTINGS) + uel.log(Action.EXPORT_SETTINGS, ValueWithUnit(Sources.Maintenance)) // start activity for checking permissions... importExportPrefs.verifyStoragePermissions(this) { importExportPrefs.exportSharedPreferences(this) } } binding.navImport.setOnClickListener { - uel.log(Action.IMPORT_SETTINGS) + uel.log(Action.IMPORT_SETTINGS, ValueWithUnit(Sources.Maintenance)) // start activity for checking permissions... importExportPrefs.verifyStoragePermissions(this) { importExportPrefs.importSharedPreferences(this) @@ -99,7 +99,7 @@ class MaintenanceFragment : DaggerFragment() { binding.exportCsv.setOnClickListener { activity?.let { activity -> OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.ue_export_to_csv) + "?") { - uel.log(Action.EXPORT_CSV) + uel.log(Action.EXPORT_CSV, ValueWithUnit(Sources.Maintenance)) importExportPrefs.exportUserEntriesCsv(activity, repository.getAllUserEntries()) } } diff --git a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt index c1048f1973..99b234abb7 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/extensions/UserEntryExt.kt @@ -38,6 +38,7 @@ fun Sources.iconId(): Int { Sources.Exercise -> R.drawable.ic_cp_exercise Sources.Question -> R.drawable.ic_cp_question Sources.Announcement -> R.drawable.ic_cp_announcement + Sources.Maintenance -> R.drawable.ic_maintenance Sources.Actions -> R.drawable.ic_action Sources.Automation -> R.drawable.ic_automation Sources.Loop -> R.drawable.ic_loop_closed_white diff --git a/insight/src/main/res/drawable/ic_maintenance.xml b/core/src/main/res/drawable/ic_maintenance.xml similarity index 100% rename from insight/src/main/res/drawable/ic_maintenance.xml rename to core/src/main/res/drawable/ic_maintenance.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 ed86b48343..9e08331d87 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 @@ -156,6 +156,7 @@ data class UserEntry( @SerializedName("Actions") Actions ("Actions"), //From Actions plugin @SerializedName("Automation") Automation ("Automation"), //From Automation plugin @SerializedName("Loop") Loop ("Loop"), //From Loop plugin + @SerializedName("Maintenance") Maintenance ("Maintenance"), //From Maintenance plugin @SerializedName("NSClient") NSClient ("NSClient"), //From NSClient plugin @SerializedName("Pump") Pump ("Pump"), //From Pump plugin (for example from pump history) @SerializedName("SMS") SMS ("SMS"), //From SMS plugin