From d42e8fbe929fb5bc30381858e3ce7581c71f7470 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sun, 28 Feb 2021 19:48:33 +0100 Subject: [PATCH 01/16] call confirm wear event --- .../androidaps/plugins/aps/loop/LoopPlugin.kt | 9 +++++---- .../plugins/general/overview/OverviewFragment.kt | 4 ++-- .../plugins/general/wear/ActionStringHandler.kt | 10 ++++++++-- ...{EventWearDoAction.kt => EventWearConfirmAction.kt} | 2 +- .../general/wear/events/EventWearInitiateAction.kt | 5 +++++ .../wear/wearintegration/WatchUpdaterService.java | 6 +++--- 6 files changed, 24 insertions(+), 12 deletions(-) rename app/src/main/java/info/nightscout/androidaps/plugins/general/wear/events/{EventWearDoAction.kt => EventWearConfirmAction.kt} (65%) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/general/wear/events/EventWearInitiateAction.kt 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 e02d1f5935..897cc5e860 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 @@ -33,9 +33,10 @@ import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification import info.nightscout.androidaps.plugins.general.overview.notifications.Notification -import info.nightscout.androidaps.plugins.general.wear.events.EventWearDoAction +import info.nightscout.androidaps.plugins.general.wear.events.EventWearInitiateAction import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.events.EventAutosensCalculationFinished +import info.nightscout.androidaps.plugins.general.wear.events.EventWearConfirmAction import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.queue.Callback @@ -368,7 +369,7 @@ open class LoopPlugin @Inject constructor( //only send to wear if Native notifications are turned off if (!sp.getBoolean(R.string.key_raise_notifications_as_android_notifications, true)) { // Send to Wear - rxBus.send(EventWearDoAction("changeRequest")) + rxBus.send(EventWearInitiateAction("changeRequest")) } } } else { @@ -472,14 +473,14 @@ open class LoopPlugin @Inject constructor( rxBus.send(EventNewOpenLoopNotification()) // Send to Wear - rxBus.send(EventWearDoAction("changeRequest")) + rxBus.send(EventWearInitiateAction("changeRequest")) } private fun dismissSuggestion() { // dismiss notifications val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager notificationManager.cancel(Constants.notificationID) - rxBus.send(EventWearDoAction("cancelChangeRequest")) + rxBus.send(EventWearConfirmAction("cancelChangeRequest")) } fun acceptChangeRequest() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt index e254c4f025..66c321ea8a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt @@ -43,7 +43,7 @@ import info.nightscout.androidaps.plugins.general.nsclient.data.NSDeviceStatus import info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationStore -import info.nightscout.androidaps.plugins.general.wear.events.EventWearDoAction +import info.nightscout.androidaps.plugins.general.wear.events.EventWearInitiateAction import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.events.EventAutosensCalculationFinished @@ -345,7 +345,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList uel.log("ACCEPT TEMP BASAL") binding.buttonsLayout.acceptTempButton.visibility = View.GONE (context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager).cancel(Constants.notificationID) - rxBus.send(EventWearDoAction("cancelChangeRequest")) + rxBus.send(EventWearInitiateAction("cancelChangeRequest")) loopPlugin.acceptChangeRequest() }) }) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt index 51846f1270..847dd51d6d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/ActionStringHandler.kt @@ -27,7 +27,8 @@ import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification -import info.nightscout.androidaps.plugins.general.wear.events.EventWearDoAction +import info.nightscout.androidaps.plugins.general.wear.events.EventWearConfirmAction +import info.nightscout.androidaps.plugins.general.wear.events.EventWearInitiateAction import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin import info.nightscout.androidaps.plugins.treatments.CarbsGenerator @@ -83,9 +84,14 @@ class ActionStringHandler @Inject constructor( init { disposable += rxBus - .toObservable(EventWearDoAction::class.java) + .toObservable(EventWearInitiateAction::class.java) .observeOn(aapsSchedulers.main) .subscribe({ handleInitiate(it.action) }, fabricPrivacy::logException) + + disposable += rxBus + .toObservable(EventWearConfirmAction::class.java) + .observeOn(aapsSchedulers.main) + .subscribe({ handleConfirmation(it.action) }, fabricPrivacy::logException) } @Synchronized diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/events/EventWearDoAction.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/events/EventWearConfirmAction.kt similarity index 65% rename from app/src/main/java/info/nightscout/androidaps/plugins/general/wear/events/EventWearDoAction.kt rename to app/src/main/java/info/nightscout/androidaps/plugins/general/wear/events/EventWearConfirmAction.kt index 7d8bb75403..211836d27d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/events/EventWearDoAction.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/events/EventWearConfirmAction.kt @@ -2,4 +2,4 @@ package info.nightscout.androidaps.plugins.general.wear.events import info.nightscout.androidaps.events.Event -class EventWearDoAction (val action: String) : Event() \ No newline at end of file +class EventWearConfirmAction(val action: String) : Event() \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/events/EventWearInitiateAction.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/events/EventWearInitiateAction.kt new file mode 100644 index 0000000000..9661c4af38 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/events/EventWearInitiateAction.kt @@ -0,0 +1,5 @@ +package info.nightscout.androidaps.plugins.general.wear.events + +import info.nightscout.androidaps.events.Event + +class EventWearInitiateAction(val action: String) : Event() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java index 9f0c38d1a6..d7795b6784 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java @@ -48,7 +48,7 @@ import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.general.nsclient.data.NSDeviceStatus; import info.nightscout.androidaps.plugins.general.wear.WearPlugin; -import info.nightscout.androidaps.plugins.general.wear.events.EventWearDoAction; +import info.nightscout.androidaps.plugins.general.wear.events.EventWearInitiateAction; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; @@ -261,13 +261,13 @@ public class WatchUpdaterService extends WearableListenerService implements Goog if (event != null && event.getPath().equals(WEARABLE_INITIATE_ACTIONSTRING_PATH)) { String actionstring = new String(event.getData()); aapsLogger.debug(LTag.WEAR, "Wear: " + actionstring); - rxBus.send(new EventWearDoAction(actionstring)); + rxBus.send(new EventWearInitiateAction(actionstring)); } if (event != null && event.getPath().equals(WEARABLE_CONFIRM_ACTIONSTRING_PATH)) { String actionstring = new String(event.getData()); aapsLogger.debug(LTag.WEAR, "Wear Confirm: " + actionstring); - rxBus.send(new EventWearDoAction(actionstring)); + rxBus.send(new EventWearConfirmAction(actionstring)); } } } From d098f812412271667e54bae34adaf829a689bb5c Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sun, 28 Feb 2021 20:02:36 +0100 Subject: [PATCH 02/16] missing import --- .../general/wear/wearintegration/WatchUpdaterService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java index d7795b6784..5640a78d92 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/WatchUpdaterService.java @@ -48,6 +48,7 @@ import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.general.nsclient.data.NSDeviceStatus; import info.nightscout.androidaps.plugins.general.wear.WearPlugin; +import info.nightscout.androidaps.plugins.general.wear.events.EventWearConfirmAction; import info.nightscout.androidaps.plugins.general.wear.events.EventWearInitiateAction; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin; From 3b5b945fea6573b32941b828c74e39a13d4d63ba Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 1 Mar 2021 12:42:42 +0100 Subject: [PATCH 03/16] TemporaryTarget -> room database --- .idea/codeStyles/Project.xml | 16 -- .../androidaps/db/DatabaseHelper.java | 228 +----------------- .../androidaps/dialogs/CarbsDialog.kt | 73 ++++-- .../androidaps/dialogs/CareDialog.kt | 6 +- .../androidaps/dialogs/InsulinDialog.kt | 32 ++- .../androidaps/dialogs/TempTargetDialog.kt | 66 +++-- .../androidaps/dialogs/WizardDialog.kt | 23 +- .../historyBrowser/TreatmentsPluginHistory.kt | 6 +- .../androidaps/plugins/aps/loop/LoopPlugin.kt | 2 +- .../aps/openAPSAMA/OpenAPSAMAPlugin.kt | 18 +- .../aps/openAPSSMB/OpenAPSSMBPlugin.kt | 16 +- .../constraints/safety/SafetyPlugin.kt | 2 +- .../general/actions/ActionsFragment.kt | 2 +- .../general/nsclient/NSClientPlugin.java | 45 +++- .../general/openhumans/OpenHumansUploader.kt | 18 +- .../general/overview/OverviewFragment.kt | 38 +-- .../general/overview/graphData/GraphData.kt | 28 ++- .../smsCommunicator/SmsCommunicatorPlugin.kt | 115 +++++---- .../general/wear/ActionStringHandler.kt | 60 +++-- .../iob/iobCobCalculator/IobCobOref1Thread.kt | 10 +- .../plugins/pump/virtual/VirtualPumpPlugin.kt | 2 +- .../plugins/source/EversensePlugin.kt | 2 +- .../plugins/treatments/TreatmentsPlugin.java | 62 +---- .../events/EventTreatmentUpdateGui.kt | 5 + .../fragments/TreatmentsTempTargetFragment.kt | 143 ++++++----- .../androidaps/utils/stats/TddCalculator.kt | 11 +- .../androidaps/utils/wizard/BolusWizard.kt | 10 +- .../utils/wizard/QuickWizardEntry.kt | 10 +- .../layout/treatments_temptarget_fragment.xml | 39 ++- .../res/layout/treatments_temptarget_item.xml | 22 +- .../data/OverlappingIntervalsTest.kt | 23 +- .../androidaps/data/TempTargetTest.kt | 83 +++++++ .../interfaces/ConstraintsCheckerTest.kt | 6 +- .../SmsCommunicatorPluginTest.kt | 12 +- .../treatments/TreatmentsPluginTest.kt | 8 +- .../actions/ActionStartTempTarget.kt | 41 +++- .../actions/ActionStopTempTarget.kt | 26 +- .../automation/triggers/TriggerTempTarget.kt | 9 +- .../actions/ActionStartTempTargetTest.kt | 5 +- .../actions/ActionStopTempTargetTest.kt | 5 +- .../automation/actions/ActionsTestBase.kt | 6 +- .../triggers/TriggerTempTargetTest.kt | 10 +- .../automation/triggers/TriggerTestBase.kt | 5 +- .../nightscout/androidaps/db/DbRequest.java | 15 +- .../nightscout/androidaps/db/TempTarget.java | 199 --------------- .../dialogs/DialogFragmentWithDate.kt | 4 +- .../interfaces/TreatmentsInterface.java | 12 +- .../plugins/general/nsclient/NSUpload.java | 106 ++++---- .../nightscout/androidaps/utils/DateUtil.java | 8 +- .../androidaps/utils/FabricPrivacy.kt | 3 +- .../nightscout/androidaps/utils/JsonHelper.kt | 16 +- .../extensions/TemporaryTargetExtension.kt | 84 +++++++ .../androidaps/utils/DateUtilTest.kt | 4 +- .../danaRKorean/DanaRKoreanPlugin.java | 23 +- .../androidaps/danar/DanaRPlugin.java | 28 +-- .../androidaps/database/AppRepository.kt | 31 ++- .../database/daos/TemporaryTargetDao.kt | 15 +- .../database/entities/TemporaryTarget.kt | 6 +- ...lCurrentTemporaryTargetIfAnyTransaction.kt | 15 +- ...poraryTargetAndCancelCurrentTransaction.kt | 15 +- .../SyncTemporaryTargetTransaction.kt | 71 ++++++ .../pump/insight/LocalInsightPlugin.java | 16 +- .../medtronic/data/MedtronicHistoryData.java | 2 +- .../eros/manager/AapsOmnipodErosManager.java | 2 +- 64 files changed, 1051 insertions(+), 973 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/treatments/events/EventTreatmentUpdateGui.kt create mode 100644 app/src/test/java/info/nightscout/androidaps/data/TempTargetTest.kt delete mode 100644 core/src/main/java/info/nightscout/androidaps/db/TempTarget.java create mode 100644 core/src/main/java/info/nightscout/androidaps/utils/extensions/TemporaryTargetExtension.kt create mode 100644 database/src/main/java/info/nightscout/androidaps/database/transactions/SyncTemporaryTargetTransaction.kt diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 3542887fac..ff53f4004f 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -2,22 +2,6 @@